source: trunk/data/class/pages/products/LC_Page_Products_List.php @ 18758

Revision 18758, 27.0 KB checked in by kajiwara, 14 years ago (diff)

EC-CUBE Ver2.4.4 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=223

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