Changeset 20276


Ignore:
Timestamp:
2011/02/21 01:11:35 (10 years ago)
Author:
AMUAMU
Message:

r20207 の取り消し。CSV関連がでぐれってるのと、支払い方法を出力しないようになっているため(仕様変更に伴うエラーは別途解決します)。

Location:
branches/version-2_5-dev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/helper/SC_Helper_CSV.php

    r20270 r20276  
    164164        fwrite($this->fpOutput, $line); 
    165165        return true; 
     166    } 
     167 
     168    // CSVを送信する。(商品) 
     169    function sfDownloadProductsCsv($where, $arrval, $order, $is_download = false) { 
     170        // 実行時間を制限しない 
     171        @set_time_limit(0); 
     172 
     173        // CSV出力タイトル行の作成 
     174        $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput(1, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE)); 
     175        if (count($arrOutput) <= 0) return false; // 失敗終了 
     176        $arrOutputCols = $arrOutput['col']; 
     177 
     178        $objQuery =& SC_Query::getSingletonInstance(); 
     179        $objQuery->setOrder($order); 
     180         
     181        $objProduct = new SC_Product(); 
     182        $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true); 
     183        // このWhereを足さないと無効な規格も出力される。現行仕様と合わせる為追加。 
     184        $inner_where = 'dtb_products_class.del_flg = 0'; 
     185        $sql = $objQuery->getSql($cols, $objProduct->prdclsSQL($inner_where),$where); 
     186        $header = $this->sfArrayToCSV($arrOutput['disp_name']); 
     187        $header = mb_convert_encoding($header, 'SJIS-Win'); 
     188        $header .= "\r\n"; 
     189         
     190        //テンポラリファイル作成 
     191        // TODO: パフォーマンス向上には、ストリームを使うようにすると良い 
     192        //  環境要件がバージョン5.1以上になったら使うように変えても良いかと 
     193        //  fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+'); 
     194        $tmp_filename = tempnam(CSV_TEMP_REALDIR, 'product_csv'); 
     195        $this->fpOutput = fopen($tmp_filename, "w+"); 
     196 
     197        fwrite($this->fpOutput, $header); 
     198 
     199        $objQuery->doCallbackAll(array(&$this, 'cbOutputProductCSV'), $sql, $arrval); 
     200 
     201        fclose($this->fpOutput); 
     202 
     203        if($is_download) { 
     204            // CSVを送信する。 
     205            $this->lfDownloadCSVFile($tmp_filename,"product_"); 
     206            $res = true; 
     207        }else{ 
     208            $res = SC_Utils_Ex::sfReadFile($tmp_filename); 
     209        } 
     210         
     211        //テンポラリファイル削除 
     212        unlink($tmp_filename); 
     213        return $res; 
    166214    } 
    167215 
  • branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php

    r20207 r20276  
    139139                // CSVを送信する。 
    140140                case 'csv': 
    141                     list($file_name, $data) = $this->getCSV($where, $arrval, $order, $objProduct); 
    142                     $this->sendResponseCSV($file_name, $data); 
     141                    require_once(CLASS_EX_REALDIR . "helper_extends/SC_Helper_CSV_Ex.php"); 
     142 
     143                    $objCSV = new SC_Helper_CSV_Ex(); 
     144 
     145                    // CSVを送信する。正常終了の場合、終了。 
     146                    $objCSV->sfDownloadProductsCsv($where, $arrval, $order, true); 
     147                    // FIXME: sendResponseに渡した方が良いのか? 
     148//                        $data = $objCSV->sfDownloadProductsCsv($where, $arrval, $order); 
     149//                        $this->sendResponseCSV($fime_name, $data); 
    143150                    exit; 
    144                      
    145151                // 全件削除(ADMIN_MODE) 
    146152                case 'delete_all': 
     
    352358 
    353359    /** 
    354      * CSV データを構築して取得する. 
    355      * 
    356      * 構築に成功した場合は, ファイル名と出力内容を配列で返す. 
    357      * 構築に失敗した場合は, false を返す. 
    358      * 
    359      * @param string $where 検索条件の WHERE 句 
    360      * @param array $arrValues 検索条件のパラメータ 
    361      * @param string $order 検索結果の並び順 
    362      * @param SC_Product $objProduct SC_Product インスタンス 
    363      * @return array|boolean 構築に成功した場合, ファイルと出力内容の配列; 
    364      *                       失敗した場合 false 
    365      */ 
    366     function getCSV($where, $arrValues, $order, &$objProduct) { 
    367         require_once(CLASS_EX_REALDIR . "helper_extends/SC_Helper_CSV_Ex.php"); 
    368         $objCSV = new SC_Helper_CSV_Ex(); 
    369  
    370         $option = "ORDER BY $order"; 
    371  
    372         // CSV出力タイトル行の作成 
    373         $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfGetCsvOutput(1, 'status = 1')); 
    374  
    375         if (count($arrCsvOutput) <= 0) { 
    376             return false; 
    377         } 
    378  
    379         $arrCsvOutputCols = $arrCsvOutput['col']; 
    380         $arrCsvOutputConvs = $arrCsvOutput['conv']; 
    381         $arrCsvOutputTitle = $arrCsvOutput['disp_name']; 
    382         $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle); 
    383         $from = $objProduct->prdclsSQL(); 
    384         $data = $objCSV->lfGetCSV($from, $where, $option, $arrValues, 
    385                                   $arrCsvOutputCols, $arrCsvOutputConvs); 
    386         return SC_Utils_Ex::sfGetCSVData($head . $data); 
    387     } 
    388  
    389     /** 
    390360     * 検索結果の行数を取得する. 
    391361     * 
  • branches/version-2_5-dev/html/install/sql/insert_data.sql

    r20246 r20276  
    215215INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (70, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT product_status_id FROM dtb_product_status WHERE dtb_product_status.product_id = prdcls.product_id and del_flg = 0 ORDER BY dtb_product_status.product_status_id), '','')) as product_statuses', '商品ステータス', 70, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'STEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
    216216INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (71, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT name FROM dtb_product_status LEFT JOIN mtb_status ON  dtb_product_status.product_status_id = mtb_status.id  WHERE dtb_product_status.product_id = prdcls.product_id and del_flg = 0 ORDER BY dtb_product_status.product_status_id), '','')) as product_status_names', '商品ステータス名', 71, 2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'LTEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
    217 INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (72, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT category_id FROM dtb_product_categories WHERE dtb_product_categories.product_id = prdcls.product_id ORDER BY dtb_product_categories.rank), '','')) as category_ids', 'カテゴリID', 72, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'STEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
    218 INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (73, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT category_name FROM dtb_product_categories LEFT JOIN dtb_category ON dtb_product_categories.category_id = dtb_category.category_id WHERE dtb_product_categories.product_id = prdcls.product_id ORDER BY dtb_product_categories.rank), '','')) as category_names', 'カテゴリ名', 73, 2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'LTEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
     217INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (72, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT payment_id FROM dtb_payment_options WHERE dtb_payment_options.product_class_id = prdcls.product_class_id ORDER BY dtb_payment_options.rank), '','')) as product_payment_ids', '支払い方法フラグ', 72, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'STEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
     218INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (73, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT payment_method FROM dtb_payment_options LEFT JOIN dtb_payment ON dtb_payment_options.payment_id = dtb_payment.payment_id WHERE dtb_payment_options.product_class_id = prdcls.product_class_id ORDER BY dtb_payment_options.rank), '','')) as product_payment_names', '支払い方法名', 73, 2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'LTEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
     219INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (74, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT category_id FROM dtb_product_categories WHERE dtb_product_categories.product_id = prdcls.product_id ORDER BY dtb_product_categories.rank), '','')) as category_ids', 'カテゴリID', 74, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'STEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
     220INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, rw_flg, status, create_date, update_date, mb_convert_kana_option, size_const_type, error_check_types) VALUES (75, 1, '(SELECT ARRAY_TO_STRING(ARRAY(SELECT category_name FROM dtb_product_categories LEFT JOIN dtb_category ON dtb_product_categories.category_id = dtb_category.category_id WHERE dtb_product_categories.product_id = prdcls.product_id ORDER BY dtb_product_categories.rank), '','')) as category_names', 'カテゴリ名', 75, 2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'KVa', 'LTEXT_LEN', 'SPTAB_CHECK,MAX_LENGTH_CHECK'); 
    219221INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, status, create_date, update_date) VALUES (76, 2, 'customer_id', '顧客ID', 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);                                    
    220222INSERT INTO dtb_csv (no, csv_id, col, disp_name, rank, status, create_date, update_date) VALUES (77, 2, 'name01', 'お名前(姓)', 2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);                                     
Note: See TracChangeset for help on using the changeset viewer.