| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * CSV 関連 のヘルパークラス. |
|---|
| 10 | * |
|---|
| 11 | * @package Page |
|---|
| 12 | * @author LOCKON CO.,LTD. |
|---|
| 13 | * @version $Id$ |
|---|
| 14 | */ |
|---|
| 15 | class SC_Helper_CSV { |
|---|
| 16 | |
|---|
| 17 | // {{{ properties |
|---|
| 18 | |
|---|
| 19 | /** 項目英名 */ |
|---|
| 20 | var $arrSubnavi; |
|---|
| 21 | |
|---|
| 22 | /** 項目名 */ |
|---|
| 23 | var $arrSubnaviName; |
|---|
| 24 | |
|---|
| 25 | /** レビュー管理項目 */ |
|---|
| 26 | var $arrREVIEW_CVSCOL; |
|---|
| 27 | |
|---|
| 28 | /** レビュータイトル */ |
|---|
| 29 | var $arrREVIEW_CVSTITLE; |
|---|
| 30 | |
|---|
| 31 | /** トラックバック項目 */ |
|---|
| 32 | var $arrTRACKBACK_CVSCOL; |
|---|
| 33 | |
|---|
| 34 | /** トラックバックタイトル */ |
|---|
| 35 | var $arrTRACKBACK_CVSTITLE; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | // }}} |
|---|
| 39 | // {{{ constructor |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | * デフォルトコンストラクタ. |
|---|
| 43 | */ |
|---|
| 44 | function SC_Helper_CSV() { |
|---|
| 45 | $this->init(); |
|---|
| 46 | |
|---|
| 47 | $masterData = new SC_DB_MasterData_Ex(); |
|---|
| 48 | $this->arrPref = $masterData->getMasterData("mtb_pref", |
|---|
| 49 | array("pref_id", "pref_name", "rank")); |
|---|
| 50 | $this->arrSex = $masterData->getMasterData("mtb_sex"); |
|---|
| 51 | $this->arrDISP = $masterData->getMasterData("mtb_disp"); |
|---|
| 52 | $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend"); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | // }}} |
|---|
| 56 | // {{{ functions |
|---|
| 57 | |
|---|
| 58 | /** |
|---|
| 59 | * CSV 項目を出力する. |
|---|
| 60 | * |
|---|
| 61 | * @param integer $csv_id CSV ID |
|---|
| 62 | * @param string $where SQL の WHERE 句 |
|---|
| 63 | * @param array $arrVal WHERE 句の要素 |
|---|
| 64 | * @return array CSV 項目の配列 |
|---|
| 65 | */ |
|---|
| 66 | function sfgetCsvOutput($csv_id = "", $where = "", $arrVal = array()){ |
|---|
| 67 | $objQuery = new SC_Query(); |
|---|
| 68 | $ret = array(); |
|---|
| 69 | |
|---|
| 70 | $sql = <<< __EOS__ |
|---|
| 71 | SELECT |
|---|
| 72 | no, |
|---|
| 73 | csv_id, |
|---|
| 74 | col, |
|---|
| 75 | disp_name, |
|---|
| 76 | rank, |
|---|
| 77 | status, |
|---|
| 78 | create_date, |
|---|
| 79 | update_date, |
|---|
| 80 | mb_convert_kana_option |
|---|
| 81 | FROM |
|---|
| 82 | dtb_csv |
|---|
| 83 | __EOS__; |
|---|
| 84 | |
|---|
| 85 | if (strlen($csv_id) >= 1) { |
|---|
| 86 | $where = "($where) AND csv_id = ?"; |
|---|
| 87 | $arrVal[] = $csv_id; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | if (strlen($where) >= 1) { |
|---|
| 91 | $sql .= " WHERE $where"; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | $sql .= " ORDER BY "; |
|---|
| 95 | $sql .= " rank , no"; |
|---|
| 96 | $sql .= " "; |
|---|
| 97 | |
|---|
| 98 | $ret = $objQuery->getAll($sql, $arrVal); |
|---|
| 99 | |
|---|
| 100 | return $ret; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | // CSVを送信する。(共通。現状は受注のみ利用。) |
|---|
| 104 | function sfDownloadCsv($csv_id, $where, $arrval, $order) { |
|---|
| 105 | switch ($csv_id) { |
|---|
| 106 | case 3: // 受注 |
|---|
| 107 | $from = 'dtb_order'; |
|---|
| 108 | break; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | // CSV出力タイトル行の作成 |
|---|
| 112 | $arrCsvOutput = SC_Utils_Ex::sfSwapArray($this->sfgetCsvOutput($csv_id, 'status = 1')); |
|---|
| 113 | |
|---|
| 114 | if (count($arrCsvOutput) <= 0) break; |
|---|
| 115 | |
|---|
| 116 | $arrCsvOutputCols = $arrCsvOutput['col']; |
|---|
| 117 | $arrCsvOutputConvs = $arrCsvOutput['conv']; |
|---|
| 118 | $arrCsvOutputTitle = $arrCsvOutput['disp_name']; |
|---|
| 119 | $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle); |
|---|
| 120 | $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols, $arrCsvOutputConvs); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | // CSVを送信する。(商品) |
|---|
| 124 | function sfDownloadProductsCsv($where, $arrval, $order) { |
|---|
| 125 | |
|---|
| 126 | // CSV出力タイトル行の作成 |
|---|
| 127 | $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfgetCsvOutput(1, 'status = 1')); |
|---|
| 128 | if (count($arrOutput) <= 0) return false; // 失敗終了 |
|---|
| 129 | $arrOutputCols = $arrOutput['col']; |
|---|
| 130 | |
|---|
| 131 | $objQuery = new SC_Query(); |
|---|
| 132 | $objQuery->setOrder($order); |
|---|
| 133 | |
|---|
| 134 | /* |
|---|
| 135 | * FIXME |
|---|
| 136 | * パフォーマンスが出ないため, |
|---|
| 137 | * SC_Product::getProductsClassByProductIds() を使用した実装に変更 |
|---|
| 138 | */ |
|---|
| 139 | $dataRows = $objQuery->select( |
|---|
| 140 | SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id')) |
|---|
| 141 | ,'vw_product_class AS prdcls' |
|---|
| 142 | ,$where |
|---|
| 143 | ,$arrval |
|---|
| 144 | ); |
|---|
| 145 | |
|---|
| 146 | // 規格分類名一覧 |
|---|
| 147 | if (in_array('classcategory_id1', $arrOutputCols) || in_array('classcategory_id2', $arrOutputCols)) { |
|---|
| 148 | $objDb = new SC_Helper_DB_Ex(); |
|---|
| 149 | $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | $outputArray = array(); |
|---|
| 153 | |
|---|
| 154 | // ヘッダ行 |
|---|
| 155 | $outputArray[] = $arrOutput['disp_name']; |
|---|
| 156 | |
|---|
| 157 | $objQuery = new SC_Query(); |
|---|
| 158 | // データ行 |
|---|
| 159 | foreach ($dataRows as $row) { |
|---|
| 160 | // 規格名1 |
|---|
| 161 | if (in_array('classcategory_id1', $arrOutputCols)) { |
|---|
| 162 | $row['classcategory_id1'] = $arrClassCatName[$row['classcategory_id1']]; |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | // 規格名2 |
|---|
| 166 | if (in_array('classcategory_id2', $arrOutputCols)) { |
|---|
| 167 | $row['classcategory_id2'] = $arrClassCatName[$row['classcategory_id2']]; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | // カテゴリID |
|---|
| 171 | if (in_array('category_id', $arrOutputCols)) { |
|---|
| 172 | $row['category_id'] = $objQuery->getCol("dtb_product_categories", |
|---|
| 173 | "category_id", |
|---|
| 174 | "product_id = ?", |
|---|
| 175 | array($row['product_id'])); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | $outputArray[] = $row; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | // CSVを送信する。 |
|---|
| 182 | $this->lfDownloadCsv($outputArray); |
|---|
| 183 | |
|---|
| 184 | // 成功終了 |
|---|
| 185 | return true; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | // CSV出力データを作成する。(レビュー) |
|---|
| 189 | function lfGetReviewCSV($where, $option, $arrval) { |
|---|
| 190 | |
|---|
| 191 | $from = "dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id "; |
|---|
| 192 | $cols = SC_Utils_Ex::sfGetCommaList($this->arrREVIEW_CVSCOL); |
|---|
| 193 | |
|---|
| 194 | $objQuery = new SC_Query(); |
|---|
| 195 | $objQuery->setOption($option); |
|---|
| 196 | |
|---|
| 197 | $list_data = $objQuery->select($cols, $from, $where, $arrval); |
|---|
| 198 | |
|---|
| 199 | $max = count($list_data); |
|---|
| 200 | if (!isset($data)) $data = ""; |
|---|
| 201 | for($i = 0; $i < $max; $i++) { |
|---|
| 202 | // 各項目をCSV出力用に変換する。 |
|---|
| 203 | $data .= $this->lfMakeReviewCSV($list_data[$i]); |
|---|
| 204 | } |
|---|
| 205 | return $data; |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | // CSV出力データを作成する。(トラックバック) |
|---|
| 209 | function lfGetTrackbackCSV($where, $option, $arrval) { |
|---|
| 210 | $from = "dtb_trackback AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id "; |
|---|
| 211 | $cols = SC_Utils_Ex::sfGetCommaList($this->arrTRACKBACK_CVSCOL); |
|---|
| 212 | |
|---|
| 213 | $objQuery = new SC_Query(); |
|---|
| 214 | $objQuery->setOption($option); |
|---|
| 215 | |
|---|
| 216 | $list_data = $objQuery->select($cols, $from, $where, $arrval); |
|---|
| 217 | |
|---|
| 218 | $max = count($list_data); |
|---|
| 219 | if (!isset($data)) $data = ""; |
|---|
| 220 | for($i = 0; $i < $max; $i++) { |
|---|
| 221 | // 各項目をCSV出力用に変換する。 |
|---|
| 222 | $data .= $this->lfMakeTrackbackCSV($list_data[$i]); |
|---|
| 223 | } |
|---|
| 224 | return $data; |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | // CSVを送信する。(カテゴリ) |
|---|
| 228 | function sfDownloadCategoryCsv() { |
|---|
| 229 | |
|---|
| 230 | // CSV出力タイトル行の作成 |
|---|
| 231 | $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfgetCsvOutput(5, 'status = 1')); |
|---|
| 232 | if (count($arrOutput) <= 0) return false; // 失敗終了 |
|---|
| 233 | $arrOutputCols = $arrOutput['col']; |
|---|
| 234 | |
|---|
| 235 | $objQuery = new SC_Query(); |
|---|
| 236 | $objQuery->setOrder('rank DESC'); |
|---|
| 237 | |
|---|
| 238 | $dataRows = $objQuery->select( |
|---|
| 239 | SC_Utils_Ex::sfGetCommaList($arrOutputCols) |
|---|
| 240 | ,'dtb_category' |
|---|
| 241 | ,'del_flg = 0' |
|---|
| 242 | ); |
|---|
| 243 | |
|---|
| 244 | $outputArray = array(); |
|---|
| 245 | |
|---|
| 246 | // ヘッダ行 |
|---|
| 247 | $outputArray[] = $arrOutput['disp_name']; |
|---|
| 248 | |
|---|
| 249 | // データ行 |
|---|
| 250 | foreach ($dataRows as $row) { |
|---|
| 251 | $outputArray[] = $row; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | // CSVを送信する。 |
|---|
| 255 | $this->lfDownloadCsv($outputArray, 'category'); |
|---|
| 256 | |
|---|
| 257 | // 成功終了 |
|---|
| 258 | return true; |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | // CSV出力データを作成する。 |
|---|
| 262 | function lfGetCSV($from, $where, $option, $arrval, $arrCsvOutputCols = "", $arrCsvOutputConverts = array()) { |
|---|
| 263 | |
|---|
| 264 | $cols = SC_Utils_Ex::sfGetCommaList($arrCsvOutputCols); |
|---|
| 265 | |
|---|
| 266 | $objQuery = new SC_Query(); |
|---|
| 267 | $objQuery->setOption($option); |
|---|
| 268 | |
|---|
| 269 | $list_data = $objQuery->select($cols, $from, $where, $arrval, MDB2_FETCHMODE_ORDERED); |
|---|
| 270 | |
|---|
| 271 | $csv = ''; |
|---|
| 272 | foreach ($list_data as $row) { |
|---|
| 273 | $row = SC_Utils_Ex::mbConvertKanaWithArray($row, $arrCsvOutputConverts); |
|---|
| 274 | // 各項目をCSV出力用に変換する。 |
|---|
| 275 | $line = $this->sfArrayToCsv($row); |
|---|
| 276 | $csv .= "$line\r\n"; |
|---|
| 277 | } |
|---|
| 278 | return $csv; |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | // 各項目をCSV出力用に変換する。 |
|---|
| 282 | function lfMakeCSV($list) { |
|---|
| 283 | $line = ""; |
|---|
| 284 | |
|---|
| 285 | foreach($list as $key => $val) { |
|---|
| 286 | $tmp = ""; |
|---|
| 287 | switch($key) { |
|---|
| 288 | case 'order_pref': |
|---|
| 289 | case 'deliv_pref': |
|---|
| 290 | $tmp = $this->arrPref[$val]; |
|---|
| 291 | break; |
|---|
| 292 | default: |
|---|
| 293 | $tmp = $val; |
|---|
| 294 | break; |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | $tmp = preg_replace('/[",]/', " ", $tmp); |
|---|
| 298 | $line .= "\"".$tmp."\","; |
|---|
| 299 | } |
|---|
| 300 | // 文末の","を変換 |
|---|
| 301 | $line = $this->replaceLineSuffix($line); |
|---|
| 302 | return $line; |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | // 各項目をCSV出力用に変換する。(レビュー) |
|---|
| 306 | function lfMakeReviewCSV($list) { |
|---|
| 307 | $line = ""; |
|---|
| 308 | |
|---|
| 309 | foreach($list as $key => $val) { |
|---|
| 310 | $tmp = ""; |
|---|
| 311 | switch($key) { |
|---|
| 312 | case 'sex': |
|---|
| 313 | $tmp = isset($this->arrSex[$val]) ? $this->arrSex[$val] : ""; |
|---|
| 314 | break; |
|---|
| 315 | case 'recommend_level': |
|---|
| 316 | $tmp = isset($this->arrRECOMMEND[$val]) ? $this->arrRECOMMEND[$val] |
|---|
| 317 | : ""; |
|---|
| 318 | break; |
|---|
| 319 | case 'status': |
|---|
| 320 | $tmp = isset($this->arrDISP[$val]) ? $this->arrDISP[$val] : ""; |
|---|
| 321 | break; |
|---|
| 322 | default: |
|---|
| 323 | $tmp = $val; |
|---|
| 324 | break; |
|---|
| 325 | } |
|---|
| 326 | |
|---|
| 327 | $tmp = preg_replace('/[",]/', " ", $tmp); |
|---|
| 328 | $line .= "\"".$tmp."\","; |
|---|
| 329 | } |
|---|
| 330 | // 文末の","を変換 |
|---|
| 331 | $line = $this->replaceLineSuffix($line); |
|---|
| 332 | return $line; |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | // 各項目をCSV出力用に変換する。(トラックバック) |
|---|
| 336 | function lfMakeTrackbackCSV($list) { |
|---|
| 337 | |
|---|
| 338 | $line = ""; |
|---|
| 339 | |
|---|
| 340 | foreach($list as $key => $val) { |
|---|
| 341 | $tmp = ""; |
|---|
| 342 | switch($key) { |
|---|
| 343 | case 'status': |
|---|
| 344 | $tmp = $this->arrTrackBackStatus[$val]; |
|---|
| 345 | break; |
|---|
| 346 | default: |
|---|
| 347 | $tmp = $val; |
|---|
| 348 | break; |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | $tmp = preg_replace('/[",]/', " ", $tmp); |
|---|
| 352 | $line .= "\"".$tmp."\","; |
|---|
| 353 | } |
|---|
| 354 | // 文末の","を変換 |
|---|
| 355 | $line = $this->replaceLineSuffix($line); |
|---|
| 356 | return $line; |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | /** |
|---|
| 360 | * 行末の ',' を CRLF へ変換する. |
|---|
| 361 | * |
|---|
| 362 | * @access private |
|---|
| 363 | * @param string $line CSV出力用の1行分の文字列 |
|---|
| 364 | * @return string 行末の ',' を CRLF に変換した文字列 |
|---|
| 365 | */ |
|---|
| 366 | function replaceLineSuffix($line) { |
|---|
| 367 | // return mb_ereg_replace(",$", "\r\n", $line); |
|---|
| 368 | return preg_replace('/,$/',"\r\n",$line); |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | /** |
|---|
| 372 | * 項目情報を初期化する. |
|---|
| 373 | * |
|---|
| 374 | * @access private |
|---|
| 375 | * @return void |
|---|
| 376 | */ |
|---|
| 377 | function init() { |
|---|
| 378 | $this->arrSubnavi = array( |
|---|
| 379 | 1 => 'product', |
|---|
| 380 | 2 => 'customer', |
|---|
| 381 | 3 => 'order', |
|---|
| 382 | 4 => 'campaign', |
|---|
| 383 | 5 => 'category' |
|---|
| 384 | ); |
|---|
| 385 | |
|---|
| 386 | $this->arrSubnaviName = array( |
|---|
| 387 | 1 => '商品管理', |
|---|
| 388 | 2 => '顧客管理', |
|---|
| 389 | 3 => '受注管理', |
|---|
| 390 | 4 => 'キャンペーン', |
|---|
| 391 | 5 => 'カテゴリ' |
|---|
| 392 | ); |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | $this->arrREVIEW_CVSCOL = array( |
|---|
| 396 | 'B.name', |
|---|
| 397 | 'A.status', |
|---|
| 398 | 'A.create_date', |
|---|
| 399 | 'A.reviewer_name', |
|---|
| 400 | 'A.sex', |
|---|
| 401 | 'A.recommend_level', |
|---|
| 402 | 'A.title', |
|---|
| 403 | 'A.comment' |
|---|
| 404 | ); |
|---|
| 405 | |
|---|
| 406 | $this->arrREVIEW_CVSTITLE = array( |
|---|
| 407 | '商品名', |
|---|
| 408 | 'レビュー表示', |
|---|
| 409 | '投稿日', |
|---|
| 410 | '投稿者名', |
|---|
| 411 | '性別', |
|---|
| 412 | 'おすすめレベル', |
|---|
| 413 | 'タイトル', |
|---|
| 414 | 'コメント' |
|---|
| 415 | ); |
|---|
| 416 | |
|---|
| 417 | $this->arrTRACKBACK_CVSTITLE = array( |
|---|
| 418 | '商品名', |
|---|
| 419 | 'ブログ名', |
|---|
| 420 | 'ブログ記事タイトル', |
|---|
| 421 | 'ブログ記事内容', |
|---|
| 422 | '状態', |
|---|
| 423 | '投稿日' |
|---|
| 424 | ); |
|---|
| 425 | |
|---|
| 426 | $this->arrTRACKBACK_CVSCOL = array( |
|---|
| 427 | 'B.name', |
|---|
| 428 | 'A.blog_name', |
|---|
| 429 | 'A.title', |
|---|
| 430 | 'A.excerpt', |
|---|
| 431 | 'A.status', |
|---|
| 432 | 'A.create_date' |
|---|
| 433 | ); |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | /** |
|---|
| 437 | * 1次元配列を1行のCSVとして返す |
|---|
| 438 | * 参考: http://jp.php.net/fputcsv |
|---|
| 439 | */ |
|---|
| 440 | function sfArrayToCsv($fields, $delimiter = ',', $enclosure = '"', $arrayDelimiter = '|') { |
|---|
| 441 | |
|---|
| 442 | if( strlen($delimiter) != 1 ) { |
|---|
| 443 | trigger_error('delimiter must be a single character', E_USER_WARNING); |
|---|
| 444 | return ""; |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | if( strlen($enclosure) < 1 ) { |
|---|
| 448 | trigger_error('enclosure must be a single character', E_USER_WARNING); |
|---|
| 449 | return ""; |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | foreach (array_keys($fields) as $key) { |
|---|
| 453 | $field =& $fields[$key]; |
|---|
| 454 | |
|---|
| 455 | // 配列を「|」区切りの文字列に変換する |
|---|
| 456 | if (is_array($field)) { |
|---|
| 457 | $field = implode($arrayDelimiter, $field); |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | /* enclose a field that contains a delimiter, an enclosure character, or a newline */ |
|---|
| 461 | if ( |
|---|
| 462 | is_string($field) |
|---|
| 463 | && preg_match('/[' . preg_quote($delimiter) . preg_quote($enclosure) . '\\s]/', $field) |
|---|
| 464 | ) { |
|---|
| 465 | $field = $enclosure . preg_replace('/' . preg_quote($enclosure) . '/', $enclosure . $enclosure, $field) . $enclosure; |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | return implode($delimiter, $fields); |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | /** |
|---|
| 473 | * CSVを送信する。 |
|---|
| 474 | */ |
|---|
| 475 | function lfDownloadCsv($arrayData, $prefix = ""){ |
|---|
| 476 | |
|---|
| 477 | if($prefix == "") { |
|---|
| 478 | $dir_name = SC_Utils::sfUpDirName(); |
|---|
| 479 | $file_name = $dir_name . date("ymdHis") .".csv"; |
|---|
| 480 | } else { |
|---|
| 481 | $file_name = $prefix . date("ymdHis") .".csv"; |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | /* HTTPヘッダの出力 */ |
|---|
| 485 | Header("Content-disposition: attachment; filename=${file_name}"); |
|---|
| 486 | Header("Content-type: application/octet-stream; name=${file_name}"); |
|---|
| 487 | Header("Cache-Control: "); |
|---|
| 488 | Header("Pragma: "); |
|---|
| 489 | |
|---|
| 490 | /* データを出力 */ |
|---|
| 491 | foreach ($arrayData as $lineArray) { |
|---|
| 492 | $lineString = $this->sfArrayToCsv($lineArray); |
|---|
| 493 | $lineString = mb_convert_encoding($lineString, 'SJIS-Win'); |
|---|
| 494 | echo $lineString . "\r\n"; |
|---|
| 495 | } |
|---|
| 496 | } |
|---|
| 497 | } |
|---|
| 498 | ?> |
|---|