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

Revision 17969, 28.0 KB checked in by Seasoft, 15 years ago (diff)

rv r17968
・影響範囲に不安があるため、一旦差し戻します。

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