source: branches/version-2/data/class/pages/products/LC_Page_Products_List.php @ 17506

Revision 17506, 27.1 KB checked in by adachi, 16 years ago (diff)

#200 商品の AND 検索のパッチ適応(nanasess, pineray)

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