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

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

Revision 17193, 26.5 KB checked in by adachi, 16 years ago (diff)

merge r17159 version-2 branch r17159 - r17192

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