Warning: Can't use blame annotator:
svn blame failed on branches/comu-ver2/data/class/pages/products/LC_Page_Products_List.php: バイナリファイル 'file:///home/svn/open/branches/comu-ver2/data/class/pages/products/LC_Page_Products_List.php' に対しては blame で各行の最終変更者を計算できません 195004

source: branches/comu-ver2/data/class/pages/products/LC_Page_Products_List.php @ 17938

Revision 17938, 27.8 KB checked in by Seasoft, 15 years ago (diff)

カテゴリを指定せずにキーワード検索するとPHPワーニングが発生する問題を修正。r17853 で変数初期化漏れがあった。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
RevLine 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26
27/**
28 * 商品一覧 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Products_List.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Products_List extends LC_Page {
35
36    // {{{ properties
37
38    /** テンプレートクラス名1 */
39    var $tpl_class_name1;
40
41    /** テンプレートクラス名2 */
42    var $tpl_class_name2;
43
44    /** JavaScript テンプレート */
45    var $tpl_javascript;
46
47    // }}}
48    // {{{ functions
49
50    /**
51     * Page を初期化する.
52     *
53     * @return void
54     */
55    function init() {
56        parent::init();
57
58        $masterData = new SC_DB_MasterData_Ex();
59        $this->arrSTATUS = $masterData->getMasterData("mtb_status");
60        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");
61        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");
62        $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max");
63
64        $this->tpl_class_name1 = array();
65        $this->tpl_class_name2 = array();
66        $this->allowClientCache();
67    }
68
69    /**
70     * Page のプロセス.
71     *
72     * @return void
73     */
74    function process() {
75        $objView = new SC_SiteView();
76        $conn = new SC_DBConn();
77        $objDb = new SC_Helper_DB_Ex();
78
79        // レイアウトデザインを取得
80        $helper = new SC_Helper_PageLayout_Ex();
81        $helper->sfGetPageLayout($this, false, DEF_LAYOUT);
82
83        //表示件数の選択
84        if(isset($_POST['disp_number'])
85           && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) {
86            $this->disp_number = $_POST['disp_number'];
87        } else {
88            //最小表示件数を選択
89            $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
90        }
91
92        //表示順序の保存
93        $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : "";
94
95        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
96        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
97
98        if (!isset($_GET['mode'])) $_GET['mode'] = "";
99        if (!isset($_GET['name'])) $_GET['name'] = "";
100        if (!isset($_POST['orderby'])) $_POST['orderby'] = "";
101        if (empty($arrCategory_id)) $arrCategory_id = array("0");
102
103        // タイトル編集
104        $tpl_subtitle = "";
105        if ($_GET['mode'] == 'search') {
106            $tpl_subtitle = "検索結果";
107        } elseif (empty($arrCategory_id[0])) {
108            $tpl_subtitle = "全商品";
109        } else {
110            $arrCat = $objDb->sfGetCat($arrCategory_id[0]);
111            $tpl_subtitle = $arrCat['name'];
112        }
113
114        $objQuery = new SC_Query();
115        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
116
117        // 以下の条件でBEST商品を表示する
118        // ・BEST最大数の商品が登録されている。
119        // ・カテゴリIDがルートIDである。
120        // ・検索モードでない。
121        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) {
122            // 商品TOPの表示処理
123            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
124            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
125        } else {
126            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
127                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
128                $arrCategory_id = array(0);
129            }
130
131            // 商品一覧の表示処理
132            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $_GET['maker_id'], $this->disp_number, $_POST['orderby']);
133
134            // 検索条件を画面に表示
135            // カテゴリー検索条件
136            if (strlen($_GET['category_id']) == 0) {
137                $arrSearch['category'] = "指定なし";
138            }else{
139                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id);
140                $arrSearch['category'] = $arrCat;
141            }
142
143            // メーカー検索条件
144            if (strlen($_GET['maker_id']) == 0) {
145                $arrSearch['maker'] = "指定なし";
146            }else{
147                $arrSearch['maker'] = $name = $conn->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", $_GET['maker_id']);
148            }
149
150            // 商品名検索条件
151            if ($_GET['name'] === "") {
152                $arrSearch['name'] = "指定なし";
153            }else{
154                $arrSearch['name'] = $_GET['name'];
155            }
156        }
157
158        // レイアウトデザインを取得
159        $layout = new SC_Helper_PageLayout_Ex();
160        $layout->sfGetPageLayout($this, false, "products/list.php");
161
162        if(isset($_POST['mode']) && $_POST['mode'] == "cart"
163           && $_POST['product_id'] != "") {
164
165            // 値の正当性チェック
166            if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
167                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
168            } else {
169                // 入力値の変換
170                $this->arrErr = $this->lfCheckError($_POST['product_id']);
171                if(count($this->arrErr) == 0) {
172                    $objCartSess = new SC_CartSession();
173                    $classcategory_id = "classcategory_id". $_POST['product_id'];
174                    $classcategory_id1 = $_POST[$classcategory_id. '_1'];
175                    $classcategory_id2 = $_POST[$classcategory_id. '_2'];
176                    $quantity = "quantity". $_POST['product_id'];
177                    // 規格1が設定されていない場合
178                    if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
179                        $classcategory_id1 = '0';
180                    }
181                    // 規格2が設定されていない場合
182                    if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
183                        $classcategory_id2 = '0';
184                    }
185                    $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
186                    $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
187                    $this->sendRedirect($this->getLocation(URL_CART_TOP));
188                    exit;
189                }
190            }
191        }
192
193        $this->tpl_subtitle = $tpl_subtitle;
194
195        // 支払方法の取得
196        $this->arrPayment = $this->lfGetPayment();
197        // 入力情報を渡す
198        $this->arrForm = $_POST;
199
200        $this->lfConvertParam();
201
202        $this->category_id = $arrCategory_id[0];
203        $this->arrSearch = $arrSearch;
204
205        $objView->assignobj($this);
206        $objView->display(SITE_FRAME);
207    }
208
209    /**
210     * モバイルページを初期化する.
211     *
212     * @return void
213     */
214    function mobileInit() {
215        $this->init();
216    }
217
218    /**
219     * Page のプロセス(モバイル).
220     *
221     * FIXME スパゲッティ...
222     *
223     * @return void
224     */
225    function mobileProcess() {
226        $objView = new SC_MobileView();
227        $conn = new SC_DBConn();
228        $objDb = new SC_Helper_DB_Ex();
229
230        //表示件数の選択
231        if(isset($_REQUEST['disp_number'])
232           && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {
233            $this->disp_number = $_REQUEST['disp_number'];
234        } else {
235            //最小表示件数を選択
236            $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
237        }
238
239        //表示順序の保存
240        $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";
241
242        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
243        $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
244
245
246        // タイトル編集
247        $tpl_subtitle = "";
248        $tpl_search_mode = false;
249
250        if (!isset($_GET['mode'])) $_GET['mode'] = "";
251        if (!isset($_POST['mode'])) $_POST['mode'] = "";
252        if (!isset($_GET['name'])) $_GET['name'] = "";
253        if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = "";
254        if (empty($arrCategory_id)) $arrCategory_id = array("0");
255
256        if($_GET['mode'] == 'search'){
257            $tpl_subtitle = "検索結果";
258            $tpl_search_mode = true;
259        }elseif (empty($arrCategory_id)) {
260            $tpl_subtitle = "全商品";
261        }else{
262            $arrCat = $objDb->sfGetCat($arrCategory_id[0]);
263            $tpl_subtitle = $arrCat['name'];
264        }
265
266        $objQuery = new SC_Query();
267        $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
268
269        // 以下の条件でBEST商品を表示する
270        // ・BEST最大数の商品が登録されている。
271        // ・カテゴリIDがルートIDである。
272        // ・検索モードでない。
273        if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) {
274            // 商品TOPの表示処理
275
276            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
277            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
278        } else {
279            if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
280                // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
281                $arrCategory_id = array("");
282            }
283
284            // 商品一覧の表示処理
285            $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $_GET['maker_id'], $this->disp_number, $_REQUEST['orderby']);
286
287            // 検索条件を画面に表示
288            // カテゴリー検索条件
289            if (strlen($_GET['category_id']) == 0) {
290                $arrSearch['category'] = "指定なし";
291            }else{
292                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id));
293                $arrSearch['category'] = $arrCat;
294            }
295
296            // 商品名検索条件
297            if ($_GET['name'] === "") {
298                $arrSearch['name'] = "指定なし";
299            }else{
300                $arrSearch['name'] = $_GET['name'];
301            }
302        }
303
304        if($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
305            // 値の正当性チェック
306            if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
307                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
308            } else {
309                // 入力値の変換
310                $this->arrErr = $this->lfCheckError($_POST['product_id']);
311                if(count($this->arrErr) == 0) {
312                    $objCartSess = new SC_CartSession();
313                    $classcategory_id = "classcategory_id". $_POST['product_id'];
314                    $classcategory_id1 = $_POST[$classcategory_id. '_1'];
315                    $classcategory_id2 = $_POST[$classcategory_id. '_2'];
316                    $quantity = "quantity". $_POST['product_id'];
317                    // 規格1が設定されていない場合
318                    if(!$this->tpl_classcat_find1[$_POST['product_id']]) {
319                        $classcategory_id1 = '0';
320                    }
321                    // 規格2が設定されていない場合
322                    if(!$this->tpl_classcat_find2[$_POST['product_id']]) {
323                        $classcategory_id2 = '0';
324                    }
325                    $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
326                    $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
327                    $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));
328                    exit;
329                }
330            }
331        }
332
333
334        // ページ送り機能用のURLを作成する。
335        $objURL = new Net_URL($_SERVER['PHP_SELF']);
336        foreach ($_REQUEST as $key => $value) {
337            if ($key == session_name() || $key == 'pageno') {
338                continue;
339            }
340            $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));
341        }
342
343        if ($this->objNavi->now_page > 1) {
344            $objURL->addQueryString('pageno', $this->objNavi->now_page - 1);
345            $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
346        }
347        if ($this->objNavi->now_page < $this->objNavi->max_page) {
348            $objURL->addQueryString('pageno', $this->objNavi->now_page + 1);
349            $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
350        }
351
352        $this->tpl_subtitle = $tpl_subtitle;
353        $this->tpl_search_mode = $tpl_search_mode;
354
355        // 支払方法の取得
356        $this->arrPayment = $this->lfGetPayment();
357        // 入力情報を渡す
358        $this->arrForm = $_POST;
359
360        $this->category_id = $arrCategory_id[0];
361        $this->arrSearch = $arrSearch;
362        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl";
363
364        $objView->assignobj($this);
365        $objView->display(SITE_FRAME);
366    }
367
368    /**
369     * デストラクタ.
370     *
371     * @return void
372     */
373    function destroy() {
374        parent::destroy();
375    }
376
377    /* カテゴリIDがルートかどうかの判定 */
378    function lfIsRootCategory($category_id) {
379        $objQuery = new SC_Query();
380        $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id));
381        if($level == 1) {
382            return true;
383        }
384        return false;
385    }
386
387    /* 商品一覧の表示 */
388    function lfDispProductsList($category_id, $name, $maker_id, $disp_num, $orderby) {
389
390        $objQuery = new SC_Query();
391        $objDb = new SC_Helper_DB_Ex();
392        $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno'];
393        $arrval = array();
394        $arrval_order = array();
395        $arrval_category = array();
396       
397        // カテゴリからのWHERE文字列取得
398        if ( $category_id ) {
399            list($tmp_where, $arrval_category) = $objDb->sfGetCatWhere($category_id);
400            if (strlen($tmp_where) >= 1) {
401                $where_category = "AND $tmp_where";
402            }
403        }
404
405        $col = <<< __EOS__
406             product_id
407            ,product_code_min
408            ,product_code_max
409            ,name
410            ,comment1
411            ,comment2
412            ,comment3
413            ,main_list_comment
414            ,main_image
415            ,main_list_image
416            ,price01_min
417            ,price01_max
418            ,price02_min
419            ,price02_max
420            ,stock_min
421            ,stock_max
422            ,stock_unlimited_min
423            ,stock_unlimited_max
424            ,point_rate
425            ,sale_limit
426            ,sale_unlimited
427            ,deliv_date_id
428            ,deliv_fee
429            ,status
430            ,product_flag
431            ,del_flg
432__EOS__;
433        $from = "vw_products_allclass AS allcls";
434       
435        //表示順序
436        switch($orderby) {
437
438            //販売価格順
439            case 'price':
440                $order = "price02_min, product_id";
441                break;
442
443            //新着順
444            case 'date':
445                $order = "create_date DESC, product_id";
446                break;
447
448            default:
449                $order = <<< __EOS__
450                    (
451                        SELECT
452                             T3.rank
453                        FROM
454                            dtb_product_categories T2
455                            JOIN dtb_category T3
456                                USING (category_id)
457                        WHERE T2.product_id = allcls.product_id
458                            $where_category
459                        ORDER BY T3.rank DESC, T2.rank DESC
460                        LIMIT 1
461                    ) DESC
462                    ,(
463                        SELECT
464                            T2.rank
465                        FROM
466                            dtb_product_categories T2
467                            JOIN dtb_category T3
468                                USING (category_id)
469                        WHERE T2.product_id = allcls.product_id
470                            $where_category
471                        ORDER BY T3.rank DESC, T2.rank DESC
472                        LIMIT 1
473                    ) DESC
474                    ,product_id
475__EOS__;
476                $arrval_order = array_merge($arrval_category, $arrval_category);
477                break;
478        }
479
480        // 商品検索条件の作成(未削除、表示)
481        $where = "del_flg = 0 AND status = 1 ";
482       
483        // 在庫無し商品の非表示
484        if (NOSTOCK_HIDDEN === true) {
485            $where .= ' AND (allcls.stock_max >= 1 OR allcls.stock_unlimited_max = 1)';
486        }
487       
488        if (strlen($where_category) >= 1) {
489            $where.= " $where_category";
490            $arrval = array_merge($arrval, $arrval_category);
491        }
492
493        // 商品名をwhere文に
494        $name = ereg_replace(",", "", $name);// XXX
495        // 全角スペースを半角スペースに変換
496        $name = str_replace(' ', ' ', $name);
497        // スペースでキーワードを分割
498        $names = preg_split("/ +/", $name);
499        // 分割したキーワードを一つずつwhere文に追加
500        foreach ($names as $val) {
501            if ( strlen($val) > 0 ){
502                $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) ";
503                $ret = SC_Utils_Ex::sfManualEscape($val);
504                $arrval[] = "%$ret%";
505                $arrval[] = "%$ret%";
506            }
507        }
508
509        // メーカーらのWHERE文字列取得
510        if ( $maker_id ) {
511            $where .= " AND maker_id = ? ";
512            $arrval[] = $maker_id;
513        }
514       
515        // 行数の取得
516        $linemax = count($objQuery->getAll("SELECT DISTINCT product_id "
517                                         . "FROM vw_products_allclass AS allcls "
518                                         . (!empty($where) ? " WHERE " . $where
519                                                           : ""), $arrval));
520
521        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用
522
523        // ページ送りの取得
524        $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);
525
526        $strnavi = $this->objNavi->strnavi;
527        $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi);
528        // 表示文字列
529        $this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi;
530        $startno = $this->objNavi->start_row;                 // 開始行
531
532        // 取得範囲の指定(開始行番号、行数のセット)
533        $objQuery->setlimitoffset($disp_num, $startno);
534        // 表示順序
535        $objQuery->setorder($order);
536
537        // 検索結果の取得
538        $this->arrProducts = $objQuery->select($col, $from, $where, array_merge($arrval, $arrval_order));
539
540        // 規格名一覧
541        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
542        // 規格分類名一覧
543        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
544        // 規格セレクトボックス設定
545        if($disp_num == 15) {
546            for($i = 0; $i < count($this->arrProducts); $i++) {
547                $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
548                // 購入制限数を取得
549                $this->lfGetSaleLimit($this->arrProducts[$i]);
550            }
551        }
552    }
553
554    /* 規格セレクトボックスの作成 */
555    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
556
557        $classcat_find1 = false;
558        $classcat_find2 = false;
559        // 在庫ありの商品の有無
560        $stock_find = false;
561
562        // 商品規格情報の取得
563        $arrProductsClass = $this->lfGetProductsClass($product_id);
564
565        // 規格1クラス名の取得
566        $this->tpl_class_name1[$product_id] =
567            isset($arrClassName[$arrProductsClass[0]['class_id1']])
568            ? $arrClassName[$arrProductsClass[0]['class_id1']]
569            : "";
570
571        // 規格2クラス名の取得
572        $this->tpl_class_name2[$product_id] =
573            isset($arrClassName[$arrProductsClass[0]['class_id2']])
574            ? $arrClassName[$arrProductsClass[0]['class_id2']]
575            : "";
576
577        // すべての組み合わせ数
578        $count = count($arrProductsClass);
579
580        $classcat_id1 = "";
581
582        $arrSele = array();
583        $arrList = array();
584
585        $list_id = 0;
586        $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
587        $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
588
589        for ($i = 0; $i < $count; $i++) {
590            // 在庫のチェック
591            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
592                continue;
593            }
594
595            $stock_find = true;
596
597            // 規格1のセレクトボックス用
598            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
599                $arrList[$list_id].=");\n";
600                $arrVal[$list_id].=");\n";
601                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
602                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
603                $list_id++;
604
605                $arrList[$list_id] = "";
606                $arrVal[$list_id] = "";
607            }
608
609            // 規格2のセレクトボックス用
610            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
611
612            // セレクトボックス表示値
613            if($arrList[$list_id] == "") {
614                $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
615            } else {
616                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
617            }
618
619            // セレクトボックスPOST値
620            if($arrVal[$list_id] == "") {
621                $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
622            } else {
623                $arrVal[$list_id].= ", '".$classcat_id2."'";
624            }
625        }
626
627        $arrList[$list_id].=");\n";
628        $arrVal[$list_id].=");\n";
629
630        // 規格1
631        $this->arrClassCat1[$product_id] = $arrSele;
632
633        $lists = "\tlists".$product_id. " = new Array(";
634        $no = 0;
635        foreach($arrList as $val) {
636            $this->tpl_javascript.= $val;
637            if ($no != 0) {
638                $lists.= ",list". $product_id. "_". $no;
639            } else {
640                $lists.= "list". $product_id. "_". $no;
641            }
642            $no++;
643        }
644        $this->tpl_javascript.= $lists.");\n";
645
646        $vals = "\tvals".$product_id. " = new Array(";
647        $no = 0;
648        foreach($arrVal as $val) {
649            $this->tpl_javascript.= $val;
650            if ($no != 0) {
651                $vals.= ",val". $product_id. "_". $no;
652            } else {
653                $vals.= "val". $product_id. "_". $no;
654            }
655            $no++;
656        }
657        $this->tpl_javascript.= $vals.");\n";
658
659        // 選択されている規格2ID
660        $classcategory_id = "classcategory_id". $product_id;
661
662        $classcategory_id_2 = $classcategory_id . "_2";
663        if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
664        if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";
665
666        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
667            . "'" . $classcategory_id_2 . "',"
668            . "'" . $product_id . "',"
669            . "'" . $_POST[$classcategory_id_2] ."'); ";
670
671        // 規格1が設定されている
672        if($arrProductsClass[0]['classcategory_id1'] != '0') {
673            $classcat_find1 = true;
674        }
675
676        // 規格2が設定されている
677        if($arrProductsClass[0]['classcategory_id2'] != '0') {
678            $classcat_find2 = true;
679        }
680
681        $this->tpl_classcat_find1[$product_id] = $classcat_find1;
682        $this->tpl_classcat_find2[$product_id] = $classcat_find2;
683        $this->tpl_stock_find[$product_id] = $stock_find;
684    }
685
686    /* 商品規格情報の取得 */
687    function lfGetProductsClass($product_id) {
688        $arrRet = array();
689        if(SC_Utils_Ex::sfIsInt($product_id)) {
690            // 商品規格取得
691            $objQuery = new SC_Query();
692            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
693            $table = "vw_product_class AS prdcls";
694            $where = "product_id = ?";
695            $objQuery->setorder("rank1 DESC, rank2 DESC");
696            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
697        }
698        return $arrRet;
699    }
700
701    /* 入力内容のチェック */
702    function lfCheckError($id) {
703
704        // 入力データを渡す。
705        $objErr = new SC_CheckError();
706
707        $classcategory_id1 = "classcategory_id". $id. "_1";
708        $classcategory_id2 = "classcategory_id". $id. "_2";
709        $quantity = "quantity". $id;
710        // 複数項目チェック
711        if ($this->tpl_classcat_find1[$id]) {
712            $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
713        }
714        if ($this->tpl_classcat_find2[$id]) {
715            $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
716        }
717        $objErr->doFunc(array("数量", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
718
719        return $objErr->arrErr;
720    }
721
722    // 購入制限数の設定
723    function lfGetSaleLimit($product) {
724        //在庫が無限または購入制限値が設定値より大きい場合
725        if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
726            $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
727        } else {
728            $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
729        }
730    }
731
732    //支払方法の取得
733    //payment_id    1:代金引換 2:銀行振り込み 3:現金書留
734    function lfGetPayment() {
735        $objQuery = new SC_Query;
736        $col = "payment_id, rule, payment_method";
737        $from = "dtb_payment";
738        $where = "del_flg = 0";
739        $order = "payment_id";
740        $objQuery->setorder($order);
741        $arrRet = $objQuery->select($col, $from, $where);
742        return $arrRet;
743    }
744
745    function lfconvertParam () {
746        foreach ($this->arrForm as $key => $value) {
747            if (preg_match('/^quantity[0-9]+/', $key)) {
748                 $this->arrForm[$key]
749                    = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE);
750            }
751        }
752    }
753}
754?>
Note: See TracBrowser for help on using the repository browser.