CIR008.php
7.18 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
<?php
//*****************************************************************************
//*
//* プログラム名:回覧板CSVファイル吐き出し
//* プログラムID:CIR008.php
//* 機能 :CSVファイルにデータを吐き出す
//* 作成者 :
//*
//* Copyright (C) 2004 Media Tech Inc. All rights reserved.
//*****************************************************************************
//***************************
//* インクルードファイル
//***************************
include("include/session_start.inc");
include("include/SessionChk.inc");
include("include/jcode.phps");
$strDBinc="include/dbcon.inc";
include($strDBinc);
//一覧取得
$strSQL="SELECT pkairan_tbl.seq,kairan_tbl.date,kairan_tbl.time,kairan_tbl.syain_cd,kairan_tbl.title,kairan_tbl.memo,kairan_tbl.filename,kairan_tbl.filename_jp,kairan_tbl.filename2,kairan_tbl.filename_jp2,kairan_tbl.filename3,kairan_tbl.filename_jp3,pkairan_tbl.read_flg,name_kj_sei,name_kj_mei,kairan_tbl.date_kigen,kairan_tbl.time_kigen " .
" FROM kairan_tbl,pkairan_tbl,syain_tbl ".
" Where pkairan_tbl.syain_cd='$PHP_SYAIN_CD' and kairan_tbl.syain_cd=syain_tbl.syain_cd and pkairan_tbl.seq=kairan_tbl.seq".
" and pkairan_tbl.del_flg=0 ".
//" Order by pkairan_tbl.read_flg,seq DESC";
" Order by ";
// ソート情報
switch ($Sort_Mode) {
case "1":
//送信日
$strSQL .= " pkairan_tbl.read_flg,seq ";
break;
case "2":
//タイトル
$strSQL .= "kairan_tbl.title ";
break;
case "3":
//送信者氏名
$strSQL .= "kairan_tbl.syain_cd ";
break;
case "4":
//回覧期限
if($Sort_Ptn=="1"){
$strSQL .= "kairan_tbl.date_kigen ASC,kairan_tbl.time_kigen ASC";
}else{
$strSQL .= "kairan_tbl.date_kigen DESC,kairan_tbl.time_kigen DESC";
}
break;
default:
$Sort_Mode = 1;
$strSQL .= " pkairan_tbl.read_flg,seq ";
}
if($Sort_Mode != "4"){
switch ($Sort_Ptn) {
case "1":
$strSQL .= "ASC ";
break;
case "2":
$strSQL .= "DESC ";
break;
default:
//受信日付
$Sort_Ptn = "2";
$strSQL .= "DESC ";
}
}
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$intCount = pg_numrows($objRec);
$filename = "回覧板".date("Y").date("m").date("d").".csv";
//20091015 ブラウザ判定
$Agent = getenv( "HTTP_USER_AGENT" );
/*201310対応
if( ereg( "MSIE", $Agent ) ){
$filename = JcodeConvert($filename, 1, 2);
} elseif( ereg( "Firefox", $Agent ) ) {
} elseif( ereg( "Safari", $Agent ) ) {
} else {
$filename = JcodeConvert($filename, 1, 2);
}
*/
if( preg_match( "/MSIE/", $Agent ) ){
$filename = JcodeConvert($filename, 1, 2);
} elseif( preg_match( "/Chrome/", $Agent ) ) {
$filename = JcodeConvert($filename, 1, 2);
} elseif( preg_match( "/Firefox/", $Agent ) ) {
} elseif( preg_match( "/Safari/", $Agent ) ) {
} else {
$filename = JcodeConvert($filename, 1, 2);
}
Header("Content-Disposition: attachment; filename=\"$filename\"");
Header("Content-Type: text/csv");
//ヘッダー行出力
$strWk="送信日時,タイトル,送信者氏名,添付ファイル1,添付ファイル2,添付ファイル3,回覧期限,既読情報,回覧内容,回答者,回答日時,コメント\n";
echo JcodeConvert($strWk, 1, 2);
//明細データ出力
for ($i = 0; $i < $intCount; $i++){
$objData = pg_fetch_object($objRec, $intCnt);
//送信日
$strWk = str_replace("\r\n"," ",$objData->date);
$strWk = str_replace(",",",",$strWk);
echo JcodeConvert($strWk, 1, 2);
//送信時間
$strWk = str_replace("\r\n"," ",$objData->time);
$strWk = str_replace(",",",",$strWk);
echo " ".JcodeConvert($strWk, 1, 2);
//タイトル
$strWk = str_replace("\r\n"," ",$objData->title);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
//送信者氏名取得
$strSyain="SELECT name_kj_sei,name_kj_mei FROM syain_tbl ".
"Where syain_cd=" . "'" .$objData->syain_cd ."'";
$objRecSyain = pg_exec($strSyain);
if($objRecSyain==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$objSyain = pg_fetch_object($objRecSyain, 0);
$strData = $objSyain->name_kj_sei.$objSyain->name_kj_mei;
echo ",".JcodeConvert($strData, 1, 2);
//添付ファイル1
$strWk = str_replace("\r\n"," ",$objData->filename_jp);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
//添付ファイル2
$strWk = str_replace("\r\n"," ",$objData->filename_jp2);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
//添付ファイル3
$strWk = str_replace("\r\n"," ",$objData->filename_jp3);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
//回覧期限:日
$strWk = str_replace("\r\n"," ",$objData->date_kigen);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
//回覧期限:時
$strWk = str_replace("\r\n"," ",$objData->time_kigen);
$strWk = str_replace(",",",",$strWk);
echo " ".JcodeConvert($strWk, 1, 2);
//既読情報
if ($objData->read_flg==0){
$strWk = "未読";
}else{
$strWk = "既読";
}
echo ",".JcodeConvert($strWk, 1, 2);
//回覧内容
$strWk = str_replace("\r\n"," ",$objData->memo);
$strWk = str_replace(",",",",$strWk);
echo ",".JcodeConvert($strWk, 1, 2);
$seq=$objData->seq;
//回覧板マスタ情報取得
$strSQLmstwww="SELECT date,time,title,memo,name_kj_sei,name_kj_mei,kairan_tbl.syain_cd,filename,filename_jp,filename2,filename_jp2,filename3,filename_jp3,date_kigen,time_kigen,readonly_list,open_flg from kairan_tbl,syain_tbl " .
"Where seq=$seq and syain_tbl.syain_cd=kairan_tbl.syain_cd";
$objRecmstwww = pg_exec($strSQLmstwww);
if($objRecmstwww==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$objmstwww = pg_fetch_object($objRecmstwww,0);
//回答の公開設定
$open_flg=$objmstwww->open_flg;
//回覧板詳細取得
$strSQLwww="SELECT pkairan_tbl.seq,pkairan_tbl.syain_cd,pkairan_tbl.date,pkairan_tbl.time,pkairan_tbl.memo,pkairan_tbl.read_flg,name_kj_sei,name_kj_mei,kairan_tbl.title FROM pkairan_tbl,syain_tbl,kairan_tbl ".
"Where syain_tbl.syain_cd =pkairan_tbl.syain_cd and kairan_tbl.seq=pkairan_tbl.seq and pkairan_tbl.seq ='$seq'" .
"Order by disp_rank";
$objRecwww = pg_exec($strSQLwww);
if($objRecwww==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
//回覧先
for ($intpCnt = 0; $intpCnt < pg_numrows($objRecwww) ; $intpCnt++) {
$objpData = pg_fetch_object($objRecwww, $intpCnt);
$strComent = str_replace ("\r\n"," ",$objpData->memo);
$strComent = str_replace(",",",",$strComent);
//回覧内容
$PhpEtcName_kj_sei[$intpCnt] = $objpData->name_kj_sei;
$PhpEtcName_kj_mei[$intpCnt] = $objpData->name_kj_mei;
$strWk =$PhpEtcName_kj_sei[$intpCnt].$PhpEtcName_kj_mei[$intpCnt];
echo ",".JcodeConvert($strWk, 1, 2);
$PhpEtcDate[$intpCnt] = $objpData->date;
$PhpEtcTime[$intpCnt] = $objpData->time;
$strWk =$PhpEtcDate[$intpCnt].$PhpEtcTime[$intpCnt];
echo ",".JcodeConvert($strWk, 1, 2);
if ($open_flg==1){
if (($objdata->syain_cd==$PHP_SYAIN_CD) ){
$PhpEtcComent[$intpCnt] = $strComent;
$strWk =$PhpEtcComent[$intpCnt];
echo ",".JcodeConvert($strWk, 1, 2);
}else{
$PhpEtcComent[$intpCnt] = "回答は非公開になっています";
$strWk =$PhpEtcComent[$intpCnt];
echo ",".JcodeConvert($strWk, 1, 2);
}
}else{
$PhpEtcComent[$intpCnt] = $strComent;
$strWk =$PhpEtcComent[$intpCnt];
echo ",".JcodeConvert($strWk, 1, 2);
}
}
echo "\n";
}
?>