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

Revision 18113, 27.0 KB checked in by kajiwara, 15 years ago (diff)

#416 商品一覧画面のソースにおいて、不必要と思われる部分を削除

  • 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            $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)) {
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
383        //表示順序
384        switch($orderby) {
385
386        //価格順
387        case 'price':
388            $col = "DISTINCT price02_min, product_id, product_code_min, product_code_max,"
389                . " name, comment1, comment2, comment3,"
390                . " main_list_comment, main_image, main_list_image,"
391                . " price01_min, price01_max, price02_max,"
392                . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
393                . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
394                . " status, product_flag, create_date, del_flg";
395            $from = "vw_products_allclass AS T1";
396            $order = "price02_min, product_id";
397            break;
398
399        //新着順
400        case 'date':
401            $col = "DISTINCT create_date, product_id, product_code_min, product_code_max,"
402                . " name, comment1, comment2, comment3,"
403                . " main_list_comment, main_image, main_list_image,"
404                . " price01_min, price01_max, price02_min, price02_max,"
405                . " stock_min, stock_max, stock_unlimited_min, stock_unlimited_max,"
406                . " point_rate, sale_limit, sale_unlimited, deliv_date_id, deliv_fee,"
407                . " status, product_flag, del_flg";
408            $from = "vw_products_allclass AS T1";
409            $order = "create_date DESC, product_id";
410            break;
411
412        default:
413            $col = "DISTINCT T1.product_id, product_code_min, product_code_max,"
414                . " price01_min, price01_max, price02_min, price02_max,"
415                . " stock_min, stock_max, stock_unlimited_min,"
416                . " stock_unlimited_max, del_flg, status, name, comment1,"
417                . " comment2, comment3, main_list_comment, main_image,"
418                . " main_list_image, product_flag, deliv_date_id, sale_limit,"
419                . " point_rate, sale_unlimited, create_date, deliv_fee, "
420                . " T4.product_rank, T4.category_rank";
421            $from = "vw_products_allclass AS T1"
422                . " JOIN ("
423                . " SELECT max(T3.rank) AS category_rank,"
424                . "        max(T2.rank) AS product_rank,"
425                . "        T2.product_id"
426                . "   FROM dtb_product_categories T2"
427                . "   JOIN dtb_category T3 USING (category_id)"
428                . " GROUP BY product_id) AS T4 USING (product_id)";
429            $order = "T4.category_rank DESC, T4.product_rank DESC";
430            break;
431        }
432
433        // 商品検索条件の作成(未削除、表示)
434        $where = "del_flg = 0 AND status = 1 ";
435        // カテゴリからのWHERE文字列取得
436        if ( $category_id ) {
437            list($tmp_where, $arrval) = $objDb->sfGetCatWhere($category_id);
438            if($tmp_where != "") {
439                $where.= " AND $tmp_where";
440            }
441        }
442
443        // 商品名をwhere文に
444        $name = ereg_replace(",", "", $name);// XXX
445        // 全角スペースを半角スペースに変換
446        $name = str_replace(' ', ' ', $name);
447        // スペースでキーワードを分割
448        $names = preg_split("/ +/", $name);
449        // 分割したキーワードを一つずつwhere文に追加
450        foreach ($names as $val) {
451            if ( strlen($val) > 0 ){
452                $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) ";
453                $ret = SC_Utils_Ex::sfManualEscape($val);
454                $arrval[] = "%$ret%";
455                $arrval[] = "%$ret%";
456            }
457        }
458
459        if (empty($arrval)) {
460            $arrval = array();
461        }
462
463        // 行数の取得
464        $linemax = count($objQuery->getAll("SELECT DISTINCT product_id "
465                                         . "FROM vw_products_allclass AS allcls "
466                                         . (!empty($where) ? " WHERE " . $where
467                                                           : ""), $arrval));
468
469        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用
470
471        // ページ送りの取得
472        $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);
473
474        $strnavi = $this->objNavi->strnavi;
475        $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi);
476        // 表示文字列
477        $this->tpl_strnavi = empty($strnavi) ? "&nbsp;" : $strnavi;
478        $startno = $this->objNavi->start_row;                 // 開始行
479
480        // 取得範囲の指定(開始行番号、行数のセット)
481        $objQuery->setlimitoffset($disp_num, $startno);
482        // 表示順序
483        $objQuery->setorder($order);
484
485        // 検索結果の取得
486        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
487
488        // 規格名一覧
489        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
490        // 規格分類名一覧
491        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
492        // 規格セレクトボックス設定
493        if($disp_num == 15) {
494            for($i = 0; $i < count($this->arrProducts); $i++) {
495                $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
496                // 購入制限数を取得
497                $this->lfGetSaleLimit($this->arrProducts[$i]);
498            }
499        }
500    }
501
502    /* 規格セレクトボックスの作成 */
503    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
504
505        $classcat_find1 = false;
506        $classcat_find2 = false;
507        // 在庫ありの商品の有無
508        $stock_find = false;
509
510        // 商品規格情報の取得
511        $arrProductsClass = $this->lfGetProductsClass($product_id);
512
513        // 規格1クラス名の取得
514        $this->tpl_class_name1[$product_id] =
515            isset($arrClassName[$arrProductsClass[0]['class_id1']])
516            ? $arrClassName[$arrProductsClass[0]['class_id1']]
517            : "";
518
519        // 規格2クラス名の取得
520        $this->tpl_class_name2[$product_id] =
521            isset($arrClassName[$arrProductsClass[0]['class_id2']])
522            ? $arrClassName[$arrProductsClass[0]['class_id2']]
523            : "";
524
525        // すべての組み合わせ数
526        $count = count($arrProductsClass);
527
528        $classcat_id1 = "";
529
530        $arrSele = array();
531        $arrList = array();
532
533        $list_id = 0;
534        $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
535        $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
536
537        for ($i = 0; $i < $count; $i++) {
538            // 在庫のチェック
539            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
540                continue;
541            }
542
543            $stock_find = true;
544
545            // 規格1のセレクトボックス用
546            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
547                $arrList[$list_id].=");\n";
548                $arrVal[$list_id].=");\n";
549                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
550                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
551                $list_id++;
552
553                $arrList[$list_id] = "";
554                $arrVal[$list_id] = "";
555            }
556
557            // 規格2のセレクトボックス用
558            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
559
560            // セレクトボックス表示値
561            if($arrList[$list_id] == "") {
562                $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
563            } else {
564                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
565            }
566
567            // セレクトボックスPOST値
568            if($arrVal[$list_id] == "") {
569                $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
570            } else {
571                $arrVal[$list_id].= ", '".$classcat_id2."'";
572            }
573        }
574
575        $arrList[$list_id].=");\n";
576        $arrVal[$list_id].=");\n";
577
578        // 規格1
579        $this->arrClassCat1[$product_id] = $arrSele;
580
581        $lists = "\tlists".$product_id. " = new Array(";
582        $no = 0;
583        foreach($arrList as $val) {
584            $this->tpl_javascript.= $val;
585            if ($no != 0) {
586                $lists.= ",list". $product_id. "_". $no;
587            } else {
588                $lists.= "list". $product_id. "_". $no;
589            }
590            $no++;
591        }
592        $this->tpl_javascript.= $lists.");\n";
593
594        $vals = "\tvals".$product_id. " = new Array(";
595        $no = 0;
596        foreach($arrVal as $val) {
597            $this->tpl_javascript.= $val;
598            if ($no != 0) {
599                $vals.= ",val". $product_id. "_". $no;
600            } else {
601                $vals.= "val". $product_id. "_". $no;
602            }
603            $no++;
604        }
605        $this->tpl_javascript.= $vals.");\n";
606
607        // 選択されている規格2ID
608        $classcategory_id = "classcategory_id". $product_id;
609
610        $classcategory_id_2 = $classcategory_id . "_2";
611        if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
612        if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";
613
614        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
615            . "'" . $classcategory_id_2 . "',"
616            . "'" . $product_id . "',"
617            . "'" . $_POST[$classcategory_id_2] ."'); ";
618
619        // 規格1が設定されている
620        if($arrProductsClass[0]['classcategory_id1'] != '0') {
621            $classcat_find1 = true;
622        }
623
624        // 規格2が設定されている
625        if($arrProductsClass[0]['classcategory_id2'] != '0') {
626            $classcat_find2 = true;
627        }
628
629        $this->tpl_classcat_find1[$product_id] = $classcat_find1;
630        $this->tpl_classcat_find2[$product_id] = $classcat_find2;
631        $this->tpl_stock_find[$product_id] = $stock_find;
632    }
633
634    /* 商品規格情報の取得 */
635    function lfGetProductsClass($product_id) {
636        $arrRet = array();
637        if(SC_Utils_Ex::sfIsInt($product_id)) {
638            // 商品規格取得
639            $objQuery = new SC_Query();
640            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
641            $table = "vw_product_class AS prdcls";
642            $where = "product_id = ?";
643            $objQuery->setorder("rank1 DESC, rank2 DESC");
644            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
645        }
646        return $arrRet;
647    }
648
649    /* 入力内容のチェック */
650    function lfCheckError($id) {
651
652        // 入力データを渡す。
653        $objErr = new SC_CheckError();
654
655        $classcategory_id1 = "classcategory_id". $id. "_1";
656        $classcategory_id2 = "classcategory_id". $id. "_2";
657        $quantity = "quantity". $id;
658        // 複数項目チェック
659        if ($this->tpl_classcat_find1[$id]) {
660            $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
661        }
662        if ($this->tpl_classcat_find2[$id]) {
663            $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
664        }
665        $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
666
667        return $objErr->arrErr;
668    }
669
670    // 購入制限数の設定
671    function lfGetSaleLimit($product) {
672        //在庫が無限または購入制限値が設定値より大きい場合
673        if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
674            $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
675        } else {
676            $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
677        }
678    }
679
680    //支払方法の取得
681    //payment_id    1:代金引換 2:銀行振り込み 3:現金書留
682    function lfGetPayment() {
683        $objQuery = new SC_Query;
684        $col = "payment_id, rule, payment_method";
685        $from = "dtb_payment";
686        $where = "del_flg = 0";
687        $order = "payment_id";
688        $objQuery->setorder($order);
689        $arrRet = $objQuery->select($col, $from, $where);
690        return $arrRet;
691    }
692
693    function lfconvertParam () {
694        foreach ($this->arrForm as $key => $value) {
695            if (preg_match('/^quantity[0-9]+/', $key)) {
696                 $this->arrForm[$key]
697                    = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE);
698            }
699        }
700    }
701}
702?>
Note: See TracBrowser for help on using the repository browser.