source: branches/feature-module-update/data/class/pages/products/LC_Page_Products_List.php @ 16574

Revision 16574, 24.9 KB checked in by nanasess, 16 years ago (diff)

カテゴリID の未定義チェック修正

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