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

Revision 17263, 27.0 KB checked in by Yammy, 16 years ago (diff)

メーカー検索機能
http://svn.ec-cube.net/open_trac/ticket/273
実装

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