Ignore:
Timestamp:
2010/02/12 18:46:50 (16 years ago)
Author:
kajiwara
Message:

EC-CUBE Ver2.4.3 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=210

Location:
trunk/data/class/pages/admin/products
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/class/pages/admin/products/LC_Page_Admin_Products.php

    r17834 r18562  
    164164 
    165165                    switch ($key) { 
    166                         case 'search_product_id':   // 商品ID 
     166                        case 'search_product_id': // 商品ID 
    167167                            $where .= " AND product_id = ?"; 
    168168                            $view_where .= " AND product_id = ?"; 
     
    179179                            $view_where = $where; 
    180180                            break; 
    181                         case 'search_name':         // 商品名 
     181                        case 'search_name': // 商品名 
    182182                            $where .= " AND name ILIKE ?"; 
    183183                            $view_where .= " AND name ILIKE ?"; 
    184184                            $arrval[] = "%$val%"; 
    185185                            break; 
    186                         case 'search_category_id':  // カテゴリー 
     186                        case 'search_category_id': // カテゴリー 
    187187                            list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); 
    188188                            if($tmp_where != "") { 
     
    192192                            } 
    193193                            break; 
    194                         case 'search_product_code': // 商品コード 
     194                        case 'search_product_code': // 商品コード 
    195195                            $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)"; 
    196196                            $view_where .= " AND EXISTS (SELECT product_id FROM dtb_products_class as cls WHERE cls.product_code ILIKE ? AND dtb_products.product_id = cls.product_id GROUP BY cls.product_id )"; 
    197197                            $arrval[] = "%$val%"; 
    198198                            break; 
    199                         case 'search_startyear':    // 登録更新日(FROM) 
     199                        case 'search_startyear': // 登録更新日(FROM) 
    200200                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']); 
    201201                            $where.= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth']. "/" .$_POST['search_startday'] . "'"; 
    202202                            $view_where.= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth']. "/" .$_POST['search_startday'] . "'"; 
    203203                            break; 
    204                         case 'search_endyear':      // 登録更新日(TO) 
     204                        case 'search_endyear': // 登録更新日(TO) 
    205205                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']); 
    206206                            $date = date('Y/m/d', strtotime($date) + 86400); 
     
    208208                            $view_where.= " AND update_date < date('" . $date . "')"; 
    209209                            break; 
    210                         case 'search_product_flag': //種別 
     210                        case 'search_product_flag': //種別 
    211211                            global $arrSTATUS; 
    212212                            $search_product_flag = SC_Utils_Ex::sfSearchCheckBoxes($val); 
     
    217217                            } 
    218218                            break; 
    219                         case 'search_status':       // ステータス 
     219                        case 'search_status': // ステータス 
    220220                            $tmp_where = ""; 
    221221                            foreach ($val as $element){ 
     
    244244 
    245245                switch($_POST['mode']) { 
    246                 case 'csv': 
    247  
    248                     require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php"); 
    249  
    250                     $objCSV = new SC_Helper_CSV_Ex(); 
    251                     // オプションの指定 
    252                     $option = "ORDER BY $order"; 
    253                     // CSV出力タイトル行の作成 
    254                     $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(1, " WHERE csv_id = 1 AND status = 1")); 
    255  
    256                     if (count($arrOutput) <= 0) break; 
    257  
    258                     $arrOutputCols = $arrOutput['col']; 
    259                     $arrOutputTitle = $arrOutput['disp_name']; 
    260  
    261                     $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle); 
    262  
    263                     $data = $objCSV->lfGetProductsCSV($where, $option, $arrval, $arrOutputCols); 
    264  
    265                     // CSVを送信する。 
    266                     SC_Utils_Ex::sfCSVDownload($head.$data); 
    267                     exit; 
    268                     break; 
    269                 case 'delete_all': 
    270                     // 検索結果の取得 
    271                     $col = "product_id"; 
    272                     $from = "vw_products_nonclass AS noncls "; 
    273                     $arrProducts = $objQuery->select($col, $from, $where, $arrval); 
    274                     // 検索結果をすべて削除 
    275                     $sqlval['del_flg'] = 1; 
    276                     $where = "product_id = ?"; 
    277                     if (count($arrProducts) > 0) { 
    278                         foreach ($arrProducts as $key => $val) { 
    279                             $objQuery->update("dtb_products", $sqlval, $where, array($arrProducts[$key]["product_id"])); 
     246                    case 'csv': 
     247                        require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php"); 
     248 
     249                        $objCSV = new SC_Helper_CSV_Ex(); 
     250 
     251                        // CSVを送信する。正常終了の場合、終了。 
     252                        $objCSV->sfDownloadProductsCsv($where, $arrval, $order) && exit; 
     253 
     254                        break; 
     255                    case 'delete_all': 
     256                        // 検索結果をすべて削除 
     257                        $where = "product_id IN (SELECT product_id FROM vw_products_allclass_detail AS alldtl WHERE $where)"; 
     258                        $sqlval['del_flg'] = 1; 
     259                        $objQuery->update("dtb_products", $sqlval, $where, $arrval); 
     260                        $objQuery->delete("dtb_customer_favorite_products", $where, $arrval); 
     261                        break; 
     262                    default: 
     263                        // 読み込む列とテーブルの指定 
     264                        $col = "product_id, name, main_list_image, status, product_code_min, product_code_max, price02_min, price02_max, stock_min, stock_max, stock_unlimited_min, stock_unlimited_max, update_date"; 
     265                        $from = "vw_products_allclass_detail AS alldtl "; 
     266 
     267                        // 行数の取得 
     268                        $linemax = $objQuery->count("dtb_products", $view_where, $arrval); 
     269                        $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 
     270 
     271                        // ページ送りの処理 
     272                        if(is_numeric($_POST['search_page_max'])) { 
     273                            $page_max = $_POST['search_page_max']; 
     274                        } else { 
     275                            $page_max = SEARCH_PMAX; 
    280276                        } 
    281                     } 
    282                     break; 
    283                 default: 
    284                     // 読み込む列とテーブルの指定 
    285                     $col = "product_id, name, category_id, main_list_image, status, product_code, price01, price02, stock, stock_unlimited"; 
    286                     $from = "vw_products_nonclass AS noncls "; 
    287  
    288                     // 行数の取得 
    289                     $linemax = $objQuery->count("dtb_products", $view_where, $arrval); 
    290                     $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用 
    291  
    292                     // ページ送りの処理 
    293                     if(is_numeric($_POST['search_page_max'])) { 
    294                         $page_max = $_POST['search_page_max']; 
    295                     } else { 
    296                         $page_max = SEARCH_PMAX; 
    297                     } 
    298  
    299                     // ページ送りの取得 
    300                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX); 
    301                     $startno = $objNavi->start_row; 
    302                     $this->arrPagenavi = $objNavi->arrPagenavi; 
    303  
    304                     //キャンペーン商品検索時は、全結果の商品IDを変数に格納する 
    305                     if(isset($_POST['search_mode']) && $_POST['search_mode'] == 'campaign') { 
    306                         $arrRet = $objQuery->select($col, $from, $where, $arrval); 
    307                         if(count($arrRet) > 0) { 
    308                             $arrRet = sfSwapArray($arrRet); 
    309                             $pid = implode("-", $arrRet['product_id']); 
    310                             $this->arrHidden['campaign_product_id'] = $pid; 
     277 
     278                        // ページ送りの取得 
     279                        $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX); 
     280                        $startno = $objNavi->start_row; 
     281                        $this->arrPagenavi = $objNavi->arrPagenavi; 
     282 
     283                        //キャンペーン商品検索時は、全結果の商品IDを変数に格納する 
     284                        if(isset($_POST['search_mode']) && $_POST['search_mode'] == 'campaign') { 
     285                            $arrRet = $objQuery->select($col, $from, $where, $arrval); 
     286                            if(count($arrRet) > 0) { 
     287                                $arrRet = sfSwapArray($arrRet); 
     288                                $pid = implode("-", $arrRet['product_id']); 
     289                                $this->arrHidden['campaign_product_id'] = $pid; 
     290                            } 
    311291                        } 
    312                     } 
    313  
    314                     // 取得範囲の指定(開始行番号、行数のセット) 
    315                     //                    if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno); 
    316                     $objQuery->setlimitoffset($page_max, $startno); 
    317                     // 表示順序 
    318                     $objQuery->setorder($order); 
    319  
    320                     // 検索結果の取得 
    321                     $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); 
    322  
    323                     // 各商品ごとのカテゴリIDを取得 
    324                     if (count($this->arrProducts) > 0) { 
    325                         foreach ($this->arrProducts as $key => $val) { 
    326                             $this->arrProducts[$key]["categories"] = $objDb->sfGetCategoryId($val["product_id"]); 
    327                             $objDb->g_category_on = false; 
     292 
     293                        // 取得範囲の指定(開始行番号、行数のセット) 
     294                        //                    if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno); 
     295                        $objQuery->setlimitoffset($page_max, $startno); 
     296                        // 表示順序 
     297                        $objQuery->setorder($order); 
     298 
     299                        // 検索結果の取得 
     300                        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); 
     301 
     302                        // 各商品ごとのカテゴリIDを取得 
     303                        if (count($this->arrProducts) > 0) { 
     304                            foreach ($this->arrProducts as $key => $val) { 
     305                                $this->arrProducts[$key]["categories"] = $objDb->sfGetCategoryId($val["product_id"]); 
     306                                $objDb->g_category_on = false; 
     307                            } 
    328308                        } 
    329                     } 
    330309                } 
    331310            } 
     
    354333        global $objPage; 
    355334        /* 
    356          *  文字列の変換 
    357          *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換 
    358          *  C :  「全角ひら仮名」を「全角かた仮名」に変換 
    359          *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します 
    360          *  n :  「全角」数字を「半角(ハンカク)」に変換 
     335         * 文字列の変換 
     336         * K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換 
     337         * C :  「全角ひら仮名」を「全角かた仮名」に変換 
     338         * V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します 
     339         * n :  「全角」数字を「半角(ハンカク)」に変換 
    361340         */ 
    362341        $arrConvList['search_name'] = "KVa"; 
  • trunk/data/class/pages/admin/products/LC_Page_Admin_Products_Category.php

    r18432 r18562  
    180180 
    181181            $objCSV = new SC_Helper_CSV_Ex(); 
    182             // オプションの指定 
    183             $option = "ORDER BY rank DESC"; 
    184             // CSV出力タイトル行の作成 
    185             $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(5, " WHERE csv_id = 5 AND status = 1")); 
    186  
    187             if (count($arrOutput) <= 0) break; 
    188  
    189             $arrOutputCols = $arrOutput['col']; 
    190             $arrOutputTitle = $arrOutput['disp_name']; 
    191  
    192             $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle); 
    193  
    194             $where = "del_flg = 0"; 
    195             $arrval = array(); 
    196             $data = $objCSV->lfGetCategoryCSV($where, $option, $arrval, $arrOutputCols); 
    197  
    198             // CSVを送信する。 
    199             SC_Utils_Ex::sfCSVDownload($head.$data, 'category'); 
    200             exit; 
     182 
     183            // CSVを送信する。正常終了の場合、終了。 
     184            $objCSV->sfDownloadCategoryCsv() && exit; 
     185 
    201186            break; 
    202187        default: 
  • trunk/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSV.php

    r18007 r18562  
    9090            $arrErr['csv_file'] = $this->objUpFile->makeTempFile('csv_file'); 
    9191 
    92             if($arrErr['css_file'] == "") { 
     92            if($arrErr['csv_file'] == "") { 
    9393                $arrErr = $this->objUpFile->checkEXISTS(); 
    9494            } 
     
    109109                $enc_filepath = SC_Utils_Ex::sfEncodeFile($filepath, 
    110110                                                          CHAR_CODE, CSV_TEMP_DIR); 
     111                $fp = fopen($enc_filepath, "r"); 
     112 
     113                // 無効なファイルポインタが渡された場合はエラー表示 
     114                if ($fp === false) { 
     115                    SC_Utils_Ex::sfDispError(""); 
     116                } 
    111117 
    112118                // レコード数を得る 
    113                 $rec_count = $this->lfCSVRecordCount($enc_filepath); 
    114  
    115                 $fp = fopen($enc_filepath, "r"); 
     119                $rec_count = $this->lfCSVRecordCount($fp); 
     120 
    116121                $line = 0;      // 行数 
    117122                $regist = 0;    // 登録数 
     
    490495     * CSVのカウント数を得る. 
    491496     * 
    492      * @param string $file_name ファイルパス 
     497     * @param resource $fp fopenを使用して作成したファイルポインタ 
    493498     * @return integer CSV のカウント数 
    494499     */ 
    495     function lfCSVRecordCount($file_name) { 
     500    function lfCSVRecordCount($fp) { 
    496501 
    497502        $count = 0; 
    498         $fp = fopen($file_name, "r"); 
    499503        while(!feof($fp)) { 
    500504            $arrCSV = fgetcsv($fp, CSV_LINE_MAX); 
    501505            $count++; 
    502506        } 
    503  
    504         return $count-1; 
     507        // ファイルポインタを戻す 
     508        if (rewind($fp)) { 
     509            return $count-1; 
     510        } else { 
     511            SC_Utils_Ex::sfDispError(""); 
     512        } 
    505513    } 
    506514 
  • trunk/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSVCategory.php

    r18432 r18562  
    106106                    CHAR_CODE, CSV_TEMP_DIR); 
    107107 
     108                    $fp = fopen($enc_filepath, "r"); 
     109 
     110                    // 無効なファイルポインタが渡された場合はエラー表示 
     111                    if ($fp === false) { 
     112                        SC_Utils_Ex::sfDispError(""); 
     113                    } 
     114 
    108115                    // レコード数を得る 
    109                     $rec_count = $this->lfCSVRecordCount($enc_filepath); 
    110                     if ($rec_count === false) { 
    111                         $err = false; 
    112                         $arrErr['bad_file_pointer'] = "※ 不正なファイルポインタが検出されました"; 
    113                     } 
    114  
    115                     $fp = fopen($enc_filepath, "r"); 
     116                    $rec_count = $this->lfCSVRecordCount($fp); 
     117 
    116118                    $line = 0;      // 行数 
    117119                    $regist = 0;    // 登録数 
     
    121123 
    122124                    echo "■ CSV登録進捗状況 <br/><br/>\n"; 
    123  
    124125                    while (!feof($fp) && !$err) { 
    125126                        $arrCSV = fgetcsv($fp, CSV_LINE_MAX); 
     
    192193                exit; 
    193194                break; 
    194             default: 
    195                 break; 
     195        default: 
     196            break; 
    196197        } 
    197198 
     
    342343     * CSVのカウント数を得る. 
    343344     * 
    344      * @param string $file_name ファイルパス 
    345      * @return mixed CSV のカウント数; $file_name が無効な場合は false 
    346      */ 
    347     function lfCSVRecordCount($file_name) { 
     345     * @param resource $fp fopenを使用して作成したファイルポインタ 
     346     * @return integer CSV のカウント数 
     347     */ 
     348    function lfCSVRecordCount($fp) { 
    348349        $count = 0; 
    349         $fp = fopen($file_name, "r"); 
    350         if ($fp !== false) { 
    351             while(!feof($fp)) { 
    352                 $arrCSV = fgetcsv($fp, CSV_LINE_MAX); 
    353                 $count++; 
    354             } 
    355         } else { 
    356             return false; 
    357         } 
    358         return $count-1; 
     350        while(!feof($fp)) { 
     351            $arrCSV = fgetcsv($fp, CSV_LINE_MAX); 
     352            $count++; 
     353        } 
     354        // ファイルポインタを戻す 
     355        if (rewind($fp)) { 
     356            return $count-1; 
     357        } else { 
     358            SC_Utils_Ex::sfDispError(""); 
     359        } 
    359360    } 
    360361 
Note: See TracChangeset for help on using the changeset viewer.