Changeset 20207


Ignore:
Timestamp:
2011/02/19 20:24:28 (10 years ago)
Author:
ume
Message:

#973 [管理画面]商品管理 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

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

    r20202 r20207  
    139139                // CSVを送信する。 
    140140                case 'csv': 
    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); 
     141                    list($file_name, $data) = $this->getCSV($where, $arrval, $order, $objProduct); 
     142                    $this->sendResponseCSV($file_name, $data); 
    150143                    exit; 
     144                     
    151145                // 全件削除(ADMIN_MODE) 
    152146                case 'delete_all': 
     
    358352 
    359353    /** 
     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    /** 
    360390     * 検索結果の行数を取得する. 
    361391     * 
  • branches/version-2_5-dev/html/install/sql/insert_data.sql

    r20184 r20207  
    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 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'); 
    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 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'); 
    219 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 (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'); 
    220 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 (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'); 
     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 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'); 
     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 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'); 
    221219INSERT 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);                                    
    222220INSERT 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.