LIST1901.php
14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<?PHP
//*****************************************************************************
//*
//* プログラム名:め〜るNiポン!V2
//* プログラムID:LIST1901.php
//* 機能 :CSVファイルにデータを吐き出す
//*
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
//***************************
//* インクルードファイル
//***************************
include("./include/jcode.phps");
include("./include/session_start.inc");
include("./include/SessionChk.inc");
include("./include/dbcon.inc");
//********** 表示項目 ************//
$strSQL = "SELECT Disp_id,Disp_name FROM Mst_disp ORDER BY Disp_id ASC";
$objRecSet1 = pg_exec($strSQL);
if($objRecSet1==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$strKenmei = pg_result($objRecSet1,2,"Disp_name");
//********** 回答文言 ************//
$strSQL = "SELECT * FROM answer_data WHERE mail_id = " . $_POST["mail_id"];
$objRecSet2 = pg_exec($strSQL);
if($objRecSet2==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
if(pg_numrows($objRecSet2)!=0){
$objData = pg_fetch_object($objRecSet2,0);
$select_cnt=$objData->select_nm;
$SYORI_MODE = $objData->name50_nm;
for($intIdx = 1; $intIdx <= $objData->select_nm; $intIdx++){
$name_id[$intIdx]=pg_result($objRecSet2, 0, "name" . $intIdx . "_id");
$name_nm[$intIdx]=pg_result($objRecSet2, 0, "name" . $intIdx . "_nm");
}
}else{
$select_cnt=0;
}
//********** 配信情報 ************//
$strSQL = "SELECT Message_date, Message_time, Subject_name, Contents, Admin_cd, send_date, send_alarm, send_type, " .
"reserva_flg, reserva_date, reserva_time FROM Mail_data WHERE Mail_id = " . (int)$_POST["mail_id"];
$objRecSet3 = pg_exec($strSQL);
if($objRecSet3==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intDataCount = pg_numrows($objRecSet3);
$Mail_date = pg_result($objRecSet3,0,"Message_date");
$Mail_time = pg_result($objRecSet3,0,"Message_time");
$Subject_name = pg_result($objRecSet3,0,"Subject_name");
$Contents = pg_result($objRecSet3,0,"Contents");
$Admin_cd = pg_result($objRecSet3,0,"Admin_cd");
$send_date = pg_result($objRecSet3,0,"send_date");
$Send_alarm = pg_result($objRecSet3,0,"send_alarm");
$send_type = pg_result($objRecSet3,0,"send_type");
$reserva_flg = pg_result($objRecSet3,0,"reserva_flg");
$reserva_date = pg_result($objRecSet3,0,"reserva_date");
$reserva_time = pg_result($objRecSet3,0,"reserva_time");
//********** 既読・未読自動再送情報 ************//
$Auto_Name="";
$strSQL = "SELECT * FROM kidok_data WHERE mail_id = " . (int)$_POST["mail_id"] . " ORDER BY kidok_data.check_id";
$objRecSet4 = pg_exec($strSQL);
if($objRecSet4==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intKidokCount = pg_numrows($objRecSet4);
if($intKidokCount!=0){
$Kidok_date = pg_result($objRecSet4,0,"Message_date");
$Kidok_time = pg_result($objRecSet4,0,"Message_time");
$Send_flg = pg_result($objRecSet4,0,"send_flg");
}
//********** グループ情報 ************//
$strSQL = "SELECT group_info.syain_cd,group_info.group_id,mst_group.group_name FROM group_info,mst_group " .
"WHERE group_info.group_id = mst_group.group_id ORDER BY group_info.syain_cd";
$objRecSet5 = pg_exec($strSQL);
if($objRecSet5==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intInfo_Count = pg_numrows($objRecSet5);
for($intIdx = 0; $intIdx < $intInfo_Count ; $intIdx++) {
$objData = pg_fetch_object($objRecSet5, $intIdx);
$intInfo_Cd[$intIdx] = $objData->syain_cd;
$strGroup_Name[$intIdx] = JcodeConvert($objData->group_name, 1, 1);
}
//********** ユーザ情報 ************//
$strSQL = "SELECT Name_kj_sei, Name_kj_mei FROM Syain_tbl WHERE Syain_cd = " . $Admin_cd . " ORDER BY Syain_id ASC";
$objRecSet6 = pg_exec($strSQL);
if($objRecSet6==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intDataCount = pg_numrows($objRecSet6);
$Admin_sei = pg_result($objRecSet6,0,"Name_kj_sei");
$Admin_mei = pg_result($objRecSet6,0,"Name_kj_mei");
//********** 個人別回答内容 ************//
$Mcnt=0;
$Kcnt=0;
$Ncnt=0;
$Scnt=0;
$strSQL = "SELECT Mail_info.Check_flg, Mail_info.Kousin, Mail_info.comment, Syain_tbl.Syain_id, Syain_tbl.Syain_cd, Syain_tbl.Name_kj_sei, Syain_tbl.Name_kj_mei, " .
"Syain_tbl.mail_addr, Syain_tbl.pc_mail_addr, mail_send_tbl.send_flg FROM (Mail_info left join Syain_tbl on Mail_info.Syain_cd = Syain_tbl.Syain_cd) " .
"left join mail_send_tbl on Mail_info.Mail_id = mail_send_tbl.Mail_id and Mail_info.Syain_cd = mail_send_tbl.Syain_cd ".
"WHERE Mail_info.Mail_id = " . (int)$_POST["mail_id"] . " ORDER BY Mail_info.check_flg , Syain_tbl.name_kn_sei, Syain_tbl.name_kn_mei, Syain_tbl.Syain_cd ASC";
$objRecSet7 = pg_exec($strSQL);
if($objRecSet7==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intDataCount7 = pg_numrows($objRecSet7);
for($intIdx = 1; $intIdx <= $select_cnt; $intIdx++){
$Cnt[$intIdx]=0;
}
for ($intCount = 0; $intCount < $intDataCount7; $intCount++) {
$Syain_id[$intCount] = pg_result($objRecSet7,$intCount,"Syain_id");
$Syain_cd[$intCount] = pg_result($objRecSet7,$intCount,"Syain_cd");
$Name_kj_sei[$intCount] = pg_result($objRecSet7,$intCount,"Name_kj_sei");
$Name_kj_mei[$intCount] = pg_result($objRecSet7,$intCount,"Name_kj_mei");
$mail_addr[$intCount] = pg_result($objRecSet7,$intCount,"mail_addr");
$pc_mail_addr[$intCount] = pg_result($objRecSet7,$intCount,"pc_mail_addr");
$Check_flg[$intCount] = pg_result($objRecSet7,$intCount,"Check_flg");
$Send_flg[$intCount] = pg_result($objRecSet7,$intCount,"send_flg");
//件数カウント
if(pg_result($objRecSet7,$intCount,"Check_flg")==0){
$Mcnt=$Mcnt + 1;
}elseif(pg_result($objRecSet7,$intCount,"Check_flg")==98){
$Scnt=$Scnt + 1;
}elseif(pg_result($objRecSet7,$intCount,"Check_flg")==99){
$Kcnt=$Kcnt + 1;
}elseif(pg_result($objRecSet7,$intCount,"Check_flg")==100){
$Ncnt=$Ncnt + 1;
}else{
for($intIdx = 1; $intIdx <= $select_cnt; $intIdx++){
if($name_id[$intIdx]==pg_result($objRecSet7,$intCount,"Check_flg")){
$Cnt[$intIdx]=$Cnt[$intIdx] + 1;
break;
}
}
}
$Kousin[$intCount] = pg_result($objRecSet7,$intCount,"Kousin");
$Comment[$intCount] = pg_result($objRecSet7,$intCount,"comment");
}
//********** 回答期限 ************//
$strSQL="SELECT * FROM res_time_tbl WHERE mail_id = " . (int)$_POST["mail_id"] . " ORDER BY mail_id";
$objRecSet8 = pg_exec($strSQL);
if($objRecSet8==false){
echo("SQL実行に失敗しました(UPDATE)");
exit;
}
if(pg_numrows($objRecSet8)!=0){
$objData = pg_fetch_object($objRecSet8, 0);
$d1 = mktime (substr($objData->date,8,2), substr($objData->date,10,2) , 0 , substr($objData->date,4,2), substr($objData->date,6,2), substr($objData->date,0,4));
$strlimit_date=date("Y年m月d日 H時i分",$d1)."まで";
$limit_date = $objData->date;
$NowDate = date("YmdHi",mktime(date("H"),date("i"),0,(date("m")),date("d"),date("Y")));
}else{
$limit_date = "1";
$strlimit_date="設定なし";
$NowDate = "0";
}
//********** ファイル作成 ************//
$strWk = str_replace("/","",$Subject_name);
$strWk = str_replace("|","",$strWk);
$strWk = str_replace("<","",$strWk);
$strWk = str_replace(">","",$strWk);
$strWk = str_replace("?","",$strWk);
$strWk = str_replace(":","",$strWk);
$strWk = str_replace(";","",$strWk);
$strWk = str_replace("*","",$strWk);
$strWk = str_replace("$","",$strWk);
$strWk = str_replace("&","",$strWk);
$strWk = str_replace("%","",$strWk);
$strWk = str_replace("_","",$strWk);
$strWk = str_replace(chr(92),"",$strWk);
$strWk = str_replace(chr(34),"",$strWk);
$filename = str_replace(chr(35),"",$strWk);
$filename = "め〜るNiポン!(".$strWk.").csv";
//ブラウザ判定
$Agent = getenv( "HTTP_USER_AGENT" );
if( ereg( "MSIE", $Agent ) ){
$filename = JcodeConvert($filename, 1, 2);
} elseif( ereg( "Firefox", $Agent ) ) {
} elseif( ereg( "Safari", $Agent ) ) {
} else {
$filename = JcodeConvert($filename, 1, 2);
}
Header("Content-Disposition: attachment; filename=\"$filename\"");
Header("Content-Type: text/csv");
session_start();
//********** 配信情報 ************//
//ヘッダー行出力
$strWk="【配信情報】";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
//自動再配信日
$strWk="自動再配信";
echo JcodeConvert($strWk, 1, 2);
echo ",";
if($intKidokCount>0){
$strWk=substr($Kidok_date,0,4)."年".substr($Kidok_date,4,2)."月".substr($Kidok_date,6,2)."日 ".substr($Kidok_time,0,2)."時".substr($Kidok_time,2,2)."分";
echo JcodeConvert($strWk, 1, 2);
if($Send_flg==1){
$strWk=" 送信済み";
echo JcodeConvert($strWk, 1, 2);
}else{
$strWk=" 設定済み";
echo JcodeConvert($strWk, 1, 2);
}
}else{
$strWk="未設定";
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
//配信日時
$strWk="配信日時";
echo JcodeConvert($strWk, 1, 2);
echo ",";
if($reserva_date!=""){
$strWk=substr($reserva_date,0,4)."年".substr($reserva_date,4,2)."月".substr($reserva_date,6,2)."日 ".substr($reserva_time,0,2)."時".substr($reserva_time,2,2)."分";
echo JcodeConvert($strWk, 1, 2);
}else{
if($reserva_flg!=1){
$strWk=substr($send_date,0,4)."年".substr($send_date,4,2)."月".substr($send_date,6,2)."日 ".substr($send_date,8,2)."時".substr($send_date,10,2)."分";
echo JcodeConvert($strWk, 1, 2);
}
}
if($reserva_flg!=1){
$strWk=" 配信済み";
echo JcodeConvert($strWk, 1, 2);
}else{
$strWk=" 配信予定";
echo JcodeConvert($strWk, 1, 2);
if($reserva_date==""){
$strWk=" なし";
echo JcodeConvert($strWk, 1, 2);
}
}
echo "\n";
//作成者
$strWk="作成者";
echo JcodeConvert($strWk, 1, 2);
echo ",";
$strWk=$Admin_sei." ".$Admin_mei;
echo JcodeConvert($strWk, 1, 2);
echo "\n";
//開催日時
$strWk="開催日時";
echo JcodeConvert($strWk, 1, 2);
echo ",";
if(intval(substr($Mail_date,4,2))!=0 && intval(substr($Mail_date,6,2))!=0){
//日付
$strWk=substr($Mail_date,0,4)."年".substr($Mail_date,4,2)."月".substr($Mail_date,6,2)."日 ";
echo JcodeConvert($strWk, 1, 2);
}
if(mb_strlen($Mail_time)>0){
//時
$strWk=substr($Mail_time,0,2);
echo JcodeConvert($strWk, 1, 2);
$strWk="時";
echo JcodeConvert($strWk, 1, 2);
}
if(mb_strlen($Mail_time)>2){
//分
$strWk=substr($Mail_time,2,2);
echo JcodeConvert($strWk, 1, 2);
$strWk="分";
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
//送信先種類
$strWk="送信先種類";
echo JcodeConvert($strWk, 1, 2);
echo ",";
if($send_type==0){
$strWk="携帯/PC";
echo JcodeConvert($strWk, 1, 2);
}elseif($send_type==1){
$strWk="携帯";
echo JcodeConvert($strWk, 1, 2);
}elseif($send_type==2){
$strWk="PC";
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
//回答期限
$strWk="回答期限";
echo JcodeConvert($strWk, 1, 2);
echo ",";
echo JcodeConvert($strlimit_date, 1, 2);
echo "\n";
//件名
echo JcodeConvert($strKenmei, 1, 2);
echo ",";
if($Subject_name != ""){
$strWk = str_replace(",",",",$Subject_name);
$strWk = str_replace(chr(34)," ",$strWk);
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
//内容
$strWk="内容";
echo JcodeConvert($strWk, 1, 2);
echo ",";
if($Contents != ""){
$strWk = str_replace(chr(34),"”",$Contents);
$strWk = chr(34) .$strWk. chr(34) ;
$strWk = str_replace(",",",",$strWk);
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
echo "\n";
//********** 閲覧状況 ************//
//タイトル
$strWk="【閲覧状況】";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
//件数
$strWk="アドレス未設定";
echo JcodeConvert($strWk, 1, 2);
echo ",";
echo JcodeConvert($Ncnt, 1, 2);
$strWk="件";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
if($SYORI_MODE =="DM"){
$strWk="送信済み";
echo JcodeConvert($strWk, 1, 2);
echo ",";
echo JcodeConvert($Scnt, 1, 2);
$strWk="件";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
}else{
$strWk="未読";
echo JcodeConvert($strWk, 1, 2);
echo ",";
echo JcodeConvert($Mcnt, 1, 2);
$strWk="件";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
$strWk="既読";
echo JcodeConvert($strWk, 1, 2);
echo ",";
echo JcodeConvert($Kcnt, 1, 2);
$strWk="件";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
for($intIdx = 1; $intIdx <= $select_cnt; $intIdx++){
echo JcodeConvert($name_nm[$intIdx], 1, 2);
echo ",";
echo JcodeConvert($Cnt[$intIdx], 1, 2);
$strWk="件";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
}
}
echo "\n";
echo "\n";
//********** 個人回答状況 ************//
//タイトル
$strWk="【個人回答状況】";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
//項目
$strWk="氏名,グループ,閲覧,確認日付,確認時間,コメント,送信先";
echo JcodeConvert($strWk, 1, 2);
echo "\n";
//詳細データ出力
for ($i = 0; $i < $intDataCount7; $i++){
//社員名
$strWk=$Name_kj_sei[$i]." ".$Name_kj_mei[$i];
echo JcodeConvert($strWk, 1, 2);
echo ",";
//グループ名
$strGname="";
for($intCount1 = 0; $intCount1 < $intInfo_Count; $intCount1++){
if ($Syain_cd[$i] == $intInfo_Cd[$intCount1]){
if ($strGname==""){
$strGname = $strGroup_Name[$intCount1];
}else{
$strGname = $strGname . "\r\n" . $strGroup_Name[$intCount1];
}
}
}
$strGname = chr(34) . $strGname . chr(34);
echo JcodeConvert($strGname, 1, 2);
echo ",";
//閲覧状況
if($Check_flg[$i] == 0){
$strWk="未読";
echo JcodeConvert($strWk, 1, 2);
}else if($Check_flg[$i] == 98){
$strWk="送信済み";
echo JcodeConvert($strWk, 1, 2);
}else if($Check_flg[$i] == 99){
$strWk="既読";
echo JcodeConvert($strWk, 1, 2);
}else if($Check_flg[$i] == 100){
if($send_type == 0){
if($mail_addr[$i]!="" || $pc_mail_addr[$i]!=""){
$strWk="未送信";
echo JcodeConvert($strWk, 1, 2);
}else{
$strWk="アドレス無";
echo JcodeConvert($strWk, 1, 2);
}
}elseif($send_type == 1){
if($mail_addr[$i]!=""){
$strWk="未送信";
echo JcodeConvert($strWk, 1, 2);
}else{
$strWk="アドレス無";
echo JcodeConvert($strWk, 1, 2);
}
}elseif($send_type == 2){
if($pc_mail_addr[$i]!=""){
$strWk="未送信";
echo JcodeConvert($strWk, 1, 2);
}else{
$strWk="アドレス無";
echo JcodeConvert($strWk, 1, 2);
}
}else{
$strWk="アドレス無";
echo JcodeConvert($strWk, 1, 2);
}
}else{
for ($j = 0; $j <= $select_cnt; $j++){
if($name_id[$j] == $Check_flg[$i]){
echo JcodeConvert($name_nm[$j], 1, 2);
}
}
}
echo ",";
//更新日時
if($Kousin[$i] != ""){
//日付
$strWk=chr(34) .substr($Kousin[$i],0,4) . "/". substr($Kousin[$i],4,2) . "/" . substr($Kousin[$i],6,2) . chr(34);
echo JcodeConvert($strWk, 1, 2);
echo ",";
//時間
$strWk=chr(34) .substr($Kousin[$i],8,2) .":" . substr($Kousin[$i],10,2) .chr(34);
echo JcodeConvert($strWk, 1, 2);
}else{
echo ",";
}
echo ",";
//コメント
if($Comment[$i] != ""){
$strWk = str_replace(chr(34),"”",$Comment[$i]);
$strWk = chr(34) .$strWk. chr(34) ;
$strWk = str_replace(",",",",$strWk);
echo JcodeConvert($strWk, 1, 2);
}
echo ",";
//送信先
if($send_type==0){
$strWk="携帯/PC";
echo JcodeConvert($strWk, 1, 2);
}elseif($send_type==1){
$strWk="携帯";
echo JcodeConvert($strWk, 1, 2);
}elseif($send_type==2){
$strWk="PC";
echo JcodeConvert($strWk, 1, 2);
}
echo "\n";
}
?>