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

Revision 17744, 27.8 KB checked in by Seasoft, 15 years ago (diff)

・商品一覧の見出しを変更 (親カテゴリ名称→表示中カテゴリ名称)

 http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=3286&forum=8

・DB関連のヘルパークラスに sfGetCat() を追加。引数・戻り値は sfGetFirstCat() に準拠する。

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