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

Revision 16582, 25.6 KB checked in by nanasess, 17 years ago (diff)

ライセンス表記変更

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