Warning: Can't use blame annotator:
svn blame failed on branches/version-2_4-dev/data/class/pages/products/LC_Page_Products_List.php: バイナリファイル 'file:///home/svn/open/branches/version-2_4-dev/data/class/pages/products/LC_Page_Products_List.php' に対しては blame で各行の最終変更者を計算できません 195004

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

Revision 18465, 26.9 KB checked in by Yammy, 14 years ago (diff)

http://svn.ec-cube.net/open_trac/ticket/545
SALE_LIMIT_MAX が無視されている

対応

  • 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
RevLine 
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[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        }
481
482        //表示順序
483        switch($orderby) {
484
485            //販売価格順
486            case 'price':
487                $order = "price02_min, product_id";
488                break;
489
490            //新着順
491            case 'date':
492                $order = "create_date DESC, product_id";
493                break;
494
495            default:
496                $order = <<< __EOS__
497                    (
498                        SELECT
499                             T3.rank
500                        FROM
501                            dtb_product_categories T2
502                            JOIN dtb_category T3
503                                USING (category_id)
504                        WHERE T2.product_id = alldtl.product_id
505                            $where_category_order
506                        ORDER BY T3.rank DESC, T2.rank DESC
507                        LIMIT 1
508                    ) DESC
509                    ,(
510                        SELECT
511                            T2.rank
512                        FROM
513                            dtb_product_categories T2
514                            JOIN dtb_category T3
515                                USING (category_id)
516                        WHERE T2.product_id = alldtl.product_id
517                            $where_category_order
518                        ORDER BY T3.rank DESC, T2.rank DESC
519                        LIMIT 1
520                    ) DESC
521                    ,product_id
522__EOS__;
523                $arrval_order = array_merge($arrval_category, $arrval_category);
524                break;
525        }
526
527        // 取得範囲の指定(開始行番号、行数のセット)
528        $objQuery->setlimitoffset($disp_num, $startno);
529        // 表示順序
530        $objQuery->setorder($order);
531
532        // 検索結果の取得
533        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order);
534        // ▲商品詳細取得
535
536        // 規格名一覧
537        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
538        // 規格分類名一覧
539        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
540        // 規格セレクトボックス設定
541        if($disp_num == 15) {
542            for($i = 0; $i < count($this->arrProducts); $i++) {
543                $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
544            }
545        }
546    }
547
548    /* 規格セレクトボックスの作成 */
549    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
550
551        $classcat_find1 = false;
552        $classcat_find2 = false;
553        // 在庫ありの商品の有無
554        $stock_find = false;
555
556        // 商品規格情報の取得
557        $arrProductsClass = $this->lfGetProductsClass($product_id);
558
559        // 規格1クラス名の取得
560        $this->tpl_class_name1[$product_id] =
561            isset($arrClassName[$arrProductsClass[0]['class_id1']])
562            ? $arrClassName[$arrProductsClass[0]['class_id1']]
563            : "";
564
565        // 規格2クラス名の取得
566        $this->tpl_class_name2[$product_id] =
567            isset($arrClassName[$arrProductsClass[0]['class_id2']])
568            ? $arrClassName[$arrProductsClass[0]['class_id2']]
569            : "";
570
571        // すべての組み合わせ数
572        $count = count($arrProductsClass);
573
574        $classcat_id1 = "";
575
576        $arrSele = array();
577        $arrList = array();
578
579        $list_id = 0;
580        $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
581        $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
582
583        for ($i = 0; $i < $count; $i++) {
584            // 在庫のチェック
585            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
586                continue;
587            }
588
589            $stock_find = true;
590
591            // 規格1のセレクトボックス用
592            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
593                $arrList[$list_id].=");\n";
594                $arrVal[$list_id].=");\n";
595                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
596                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
597                $list_id++;
598
599                $arrList[$list_id] = "";
600                $arrVal[$list_id] = "";
601            }
602
603            // 規格2のセレクトボックス用
604            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
605
606            // セレクトボックス表示値
607            if($arrList[$list_id] == "") {
608                $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
609            } else {
610                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
611            }
612
613            // セレクトボックスPOST値
614            if($arrVal[$list_id] == "") {
615                $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
616            } else {
617                $arrVal[$list_id].= ", '".$classcat_id2."'";
618            }
619        }
620
621        $arrList[$list_id].=");\n";
622        $arrVal[$list_id].=");\n";
623
624        // 規格1
625        $this->arrClassCat1[$product_id] = $arrSele;
626
627        $lists = "\tlists".$product_id. " = new Array(";
628        $no = 0;
629        foreach($arrList as $val) {
630            $this->tpl_javascript.= $val;
631            if ($no != 0) {
632                $lists.= ",list". $product_id. "_". $no;
633            } else {
634                $lists.= "list". $product_id. "_". $no;
635            }
636            $no++;
637        }
638        $this->tpl_javascript.= $lists.");\n";
639
640        $vals = "\tvals".$product_id. " = new Array(";
641        $no = 0;
642        foreach($arrVal as $val) {
643            $this->tpl_javascript.= $val;
644            if ($no != 0) {
645                $vals.= ",val". $product_id. "_". $no;
646            } else {
647                $vals.= "val". $product_id. "_". $no;
648            }
649            $no++;
650        }
651        $this->tpl_javascript.= $vals.");\n";
652
653        // 選択されている規格2ID
654        $classcategory_id = "classcategory_id". $product_id;
655
656        $classcategory_id_2 = $classcategory_id . "_2";
657        if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
658        if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";
659
660        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
661            . "'" . $classcategory_id_2 . "',"
662            . "'" . $product_id . "',"
663            . "'" . $_POST[$classcategory_id_2] ."'); ";
664
665        // 規格1が設定されている
666        if($arrProductsClass[0]['classcategory_id1'] != '0') {
667            $classcat_find1 = true;
668        }
669
670        // 規格2が設定されている
671        if($arrProductsClass[0]['classcategory_id2'] != '0') {
672            $classcat_find2 = true;
673        }
674
675        $this->tpl_classcat_find1[$product_id] = $classcat_find1;
676        $this->tpl_classcat_find2[$product_id] = $classcat_find2;
677        $this->tpl_stock_find[$product_id] = $stock_find;
678    }
679
680    /* 商品規格情報の取得 */
681    function lfGetProductsClass($product_id) {
682        $arrRet = array();
683        if(SC_Utils_Ex::sfIsInt($product_id)) {
684            // 商品規格取得
685            $objQuery = new SC_Query();
686            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
687            $table = "vw_product_class AS prdcls";
688            $where = "product_id = ?";
689            $objQuery->setorder("rank1 DESC, rank2 DESC");
690            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
691        }
692        return $arrRet;
693    }
694
695    /* 入力内容のチェック */
696    function lfCheckError($id) {
697
698        // 入力データを渡す。
699        $objErr = new SC_CheckError();
700
701        $classcategory_id1 = "classcategory_id". $id. "_1";
702        $classcategory_id2 = "classcategory_id". $id. "_2";
703        $quantity = "quantity". $id;
704        // 複数項目チェック
705        if ($this->tpl_classcat_find1[$id]) {
706            $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
707        }
708        if ($this->tpl_classcat_find2[$id]) {
709            $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
710        }
711        $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
712
713        return $objErr->arrErr;
714    }
715
716    //支払方法の取得
717    //payment_id    1:代金引換 2:銀行振り込み 3:現金書留
718    function lfGetPayment() {
719        $objQuery = new SC_Query;
720        $col = "payment_id, rule, payment_method";
721        $from = "dtb_payment";
722        $where = "del_flg = 0";
723        $order = "payment_id";
724        $objQuery->setorder($order);
725        $arrRet = $objQuery->select($col, $from, $where);
726        return $arrRet;
727    }
728
729    function lfconvertParam () {
730        foreach ($this->arrForm as $key => $value) {
731            if (preg_match('/^quantity[0-9]+/', $key)) {
732                 $this->arrForm[$key]
733                    = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE);
734            }
735        }
736    }
737}
738?>
Note: See TracBrowser for help on using the repository browser.