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

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

#416(商品一覧のレイアウト取得に不具合)を改修。

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