source: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php @ 23447

Revision 23447, 25.0 KB checked in by pineray, 10 years ago (diff)

#2481 管理者にログインしていない場合にadmin=onにすると管理画面が表示されてしまう不具合を修正.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26if (file_exists(MODULE_REALDIR . 'mdl_gmopg/inc/function.php')) {
27    require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php';
28}
29/**
30 * 商品詳細 のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
35 */
36class LC_Page_Products_Detail extends LC_Page_Ex
37{
38    /** 商品ステータス */
39    public $arrSTATUS;
40
41    /** 商品ステータス画像 */
42    public $arrSTATUS_IMAGE;
43
44    /** 発送予定日 */
45    public $arrDELIVERYDATE;
46
47    /** おすすめレベル */
48    public $arrRECOMMEND;
49
50    /** フォームパラメーター */
51    public $objFormParam;
52
53    /** アップロードファイル */
54    public $objUpFile;
55
56    /** モード */
57    public $mode;
58
59    /**
60     * Page を初期化する.
61     *
62     * @return void
63     */
64    public function init()
65    {
66        parent::init();
67        $masterData = new SC_DB_MasterData_Ex();
68        $this->arrSTATUS = $masterData->getMasterData('mtb_status');
69        $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
70        $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date');
71        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
72
73        // POST に限定する mode
74        $this->arrLimitPostMode[] = 'cart';
75        $this->arrLimitPostMode[] = 'add_favorite';
76        $this->arrLimitPostMode[] = 'add_favorite_sphone';
77        $this->arrLimitPostMode[] = 'select';
78        $this->arrLimitPostMode[] = 'select2';
79        $this->arrLimitPostMode[] = 'selectItem';
80    }
81
82    /**
83     * Page のプロセス.
84     *
85     * @return void
86     */
87    public function process()
88    {
89        parent::process();
90        $this->action();
91        $this->sendResponse();
92    }
93
94    /**
95     * Page のAction.
96     *
97     * @return void
98     */
99    public function action()
100    {
101        //決済処理中ステータスのロールバック
102        $objPurchase = new SC_Helper_Purchase_Ex();
103        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
104
105        // 会員クラス
106        $objCustomer = new SC_Customer_Ex();
107
108        // パラメーター管理クラス
109        $this->objFormParam = new SC_FormParam_Ex();
110        // パラメーター情報の初期化
111        $this->arrForm = $this->lfInitParam($this->objFormParam);
112        // ファイル管理クラス
113        $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
114        // ファイル情報の初期化
115        $this->objUpFile = $this->lfInitFile($this->objUpFile);
116
117        // プロダクトIDの正当性チェック
118        $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id'));
119        $this->mode = $this->getMode();
120
121        $objProduct = new SC_Product_Ex();
122        $objProduct->setProductsClassByProductIds(array($product_id));
123
124        // 規格1クラス名
125        $this->tpl_class_name1 = $objProduct->className1[$product_id];
126
127        // 規格2クラス名
128        $this->tpl_class_name2 = $objProduct->className2[$product_id];
129
130        // 規格1
131        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
132
133        // 規格1が設定されている
134        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
135        // 規格2が設定されている
136        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
137
138        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
139        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id'];
140        $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type'];
141
142        // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止)
143        if ($this->tpl_stock_find) {
144            // 規格選択セレクトボックスの作成
145            $this->js_lnOnload .= $this->lfMakeSelect();
146        }
147
148        $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
149        $this->tpl_javascript .= 'function lnOnLoad()
150        {' . $this->js_lnOnload . '}';
151        $this->tpl_onload .= 'lnOnLoad();';
152
153        // モバイル用 規格選択セレクトボックスの作成
154        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
155            $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1'));
156        }
157
158        // 商品IDをFORM内に保持する
159        $this->tpl_product_id = $product_id;
160
161        switch ($this->mode) {
162            case 'cart':
163                $this->doCart();
164                break;
165
166            case 'add_favorite':
167                $this->doAddFavorite($objCustomer);
168                break;
169
170            case 'add_favorite_sphone':
171                $this->doAddFavoriteSphone($objCustomer);
172                break;
173
174            case 'select':
175            case 'select2':
176            case 'selectItem':
177                /**
178                 * モバイルの数量指定・規格選択の際に、
179                 * $_SESSION['cart_referer_url'] を上書きさせないために、
180                 * 何もせずbreakする。
181                 */
182                break;
183
184            default:
185                $this->doDefault();
186                break;
187        }
188
189        // モバイル用 ポストバック処理
190        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
191            switch ($this->mode) {
192                case 'select':
193                    $this->doMobileSelect();
194                    break;
195
196                case 'select2':
197                    $this->doMobileSelect2();
198                    break;
199
200                case 'selectItem':
201                    $this->doMobileSelectItem();
202                    break;
203
204                case 'cart':
205                    $this->doMobileCart();
206                    break;
207
208                default:
209                    $this->doMobileDefault();
210                    break;
211            }
212        }
213
214        // 商品詳細を取得
215        $this->arrProduct = $objProduct->getDetail($product_id);
216
217        // サブタイトルを取得
218        $this->tpl_subtitle = $this->arrProduct['name'];
219
220        // 関連カテゴリを取得
221        $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
222
223        // 商品ステータスを取得
224        $this->productStatus = $objProduct->getProductStatus($product_id);
225
226        // 画像ファイル指定がない場合の置換処理
227        $this->arrProduct['main_image']
228            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
229
230        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
231        //レビュー情報の取得
232        $this->arrReview = $this->lfGetReviewData($product_id);
233
234        //関連商品情報表示
235        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
236
237        // ログイン判定
238        if ($objCustomer->isLoginSuccess() === true) {
239            //お気に入りボタン表示
240            $this->tpl_login = true;
241            $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id));
242        }
243    }
244
245    /* プロダクトIDの正当性チェック */
246    public function lfCheckProductId($admin_mode, $product_id)
247    {
248        // 管理機能からの確認の場合は、非公開の商品も表示する。
249        if (isset($admin_mode) && $admin_mode == 'on' && SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex(), false)) {
250            $where = 'del_flg = 0';
251        } else {
252            $where = 'del_flg = 0 AND status = 1';
253        }
254
255        if (!SC_Utils_Ex::sfIsInt($product_id)
256            || SC_Utils_Ex::sfIsZeroFilling($product_id)
257            || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array) $product_id, $where)
258        ) {
259                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
260        }
261
262        return $product_id;
263    }
264
265    /* ファイル情報の初期化 */
266    public function lfInitFile($objUpFile)
267    {
268        $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE);
269        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
270            $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE);
271        }
272
273        return $objUpFile;
274    }
275
276    /* 規格選択セレクトボックスの作成 */
277    public function lfMakeSelect()
278    {
279        return 'fnSetClassCategories('
280            . 'document.form1, '
281            . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
282            . '); ';
283    }
284
285    /* 規格選択セレクトボックスの作成(モバイル) */
286    public function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1)
287    {
288        $classcat_find1 = false;
289        $classcat_find2 = false;
290
291        // 規格名一覧
292        $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name');
293        // 規格分類名一覧
294        $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name');
295        // 商品規格情報の取得
296        $arrProductsClass = $this->lfGetProductsClass($product_id);
297
298        // 規格1クラス名の取得
299        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
300        // 規格2クラス名の取得
301        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
302
303        // 全ての組み合わせ数
304        $count = count($arrProductsClass);
305
306        $classcat_id1 = '';
307
308        $arrSele1 = array();
309        $arrSele2 = array();
310
311        for ($i = 0; $i < $count; $i++) {
312            // 在庫のチェック
313            if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
314                continue;
315            }
316
317            // 規格1のセレクトボックス用
318            if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) {
319                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
320                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
321            }
322
323            // 規格2のセレクトボックス用
324            if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
325                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
326                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
327            }
328        }
329
330        // 規格1
331        $objPage->arrClassCat1 = $arrSele1;
332        $objPage->arrClassCat2 = $arrSele2;
333
334        // 規格1が設定されている
335        if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') {
336            $classcat_find1 = true;
337        }
338
339        // 規格2が設定されている
340        if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') {
341            $classcat_find2 = true;
342        }
343
344        $objPage->tpl_classcat_find1 = $classcat_find1;
345        $objPage->tpl_classcat_find2 = $classcat_find2;
346    }
347
348    /* パラメーター情報の初期化 */
349    public function lfInitParam(&$objFormParam)
350    {
351        $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
352        $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
353        $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
354        $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK','MAX_LENGTH_CHECK'));
355        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
356        $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
357        $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
358        // 値の取得
359        $objFormParam->setParam($_REQUEST);
360        // 入力値の変換
361        $objFormParam->convParam();
362        // 入力情報を渡す
363        return $objFormParam->getFormParamList();
364    }
365
366    /* 商品規格情報の取得 */
367    public function lfGetProductsClass($product_id)
368    {
369        $objProduct = new SC_Product_Ex();
370
371        return $objProduct->getProductsClassFullByProductId($product_id);
372    }
373
374    /* 登録済み関連商品の読み込み */
375    public function lfPreGetRecommendProducts($product_id)
376    {
377        $objProduct = new SC_Product_Ex();
378        $objQuery =& SC_Query_Ex::getSingletonInstance();
379
380        $objQuery->setOrder('rank DESC');
381        $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
382
383        $recommendProductIds = array();
384        foreach ($arrRecommendData as $recommend) {
385            $recommendProductIds[] = $recommend['recommend_product_id'];
386        }
387
388        $objQuery =& SC_Query_Ex::getSingletonInstance();
389        $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds);
390
391        foreach ($arrRecommendData as $key => $arrRow) {
392            $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
393        }
394
395        return $arrRecommendData;
396    }
397
398    /* 入力内容のチェック */
399    public function lfCheckError($mode, &$objFormParam, $tpl_classcat_find1 = null , $tpl_classcat_find2 = null)
400    {
401        switch ($mode) {
402        case 'add_favorite_sphone':
403        case 'add_favorite':
404            $objCustomer = new SC_Customer_Ex();
405            $objErr = new SC_CheckError_Ex();
406            $customer_id = $objCustomer->getValue('customer_id');
407            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
408                $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />';
409            }
410            break;
411        default:
412            // 入力データを渡す。
413            $arrRet =  $objFormParam->getHashArray();
414            $objErr = new SC_CheckError_Ex($arrRet);
415            $objErr->arrErr = $objFormParam->checkError();
416
417            // 複数項目チェック
418            if ($tpl_classcat_find1) {
419                $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK'));
420            }
421            if ($tpl_classcat_find2) {
422                $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK'));
423            }
424            break;
425        }
426
427        return $objErr->arrErr;
428    }
429
430    //商品ごとのレビュー情報を取得する
431    public function lfGetReviewData($product_id)
432    {
433        $objQuery =& SC_Query_Ex::getSingletonInstance();
434        //商品ごとのレビュー情報を取得する
435        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
436        $from = 'dtb_review';
437        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
438        $objQuery->setOrder('create_date DESC');
439        $objQuery->setLimit(REVIEW_REGIST_MAX);
440        $arrWhereVal = array($product_id);
441        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
442
443        return $arrReview;
444    }
445
446    /*
447     * ファイルの情報をセットする
448     * @return $subImageFlag
449     */
450    public function lfSetFile($objUpFile, $arrProduct, &$arrFile)
451    {
452        // DBからのデータを引き継ぐ
453        $objUpFile->setDBFileList($arrProduct);
454        // ファイル表示用配列を渡す
455        $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
456
457        // サブ画像の有無を判定
458        $subImageFlag = false;
459        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
460            if ($arrFile['sub_image' . $i]['filepath'] != '') {
461                $subImageFlag = true;
462            }
463        }
464
465        return $subImageFlag;
466    }
467
468    /*
469     * お気に入り商品登録
470     * @return void
471     */
472    public function lfRegistFavoriteProduct($favorite_product_id, $customer_id)
473    {
474        // ログイン中のユーザが商品をお気に入りにいれる処理
475        if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) {
476            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
477
478            return false;
479        } else {
480            $objQuery =& SC_Query_Ex::getSingletonInstance();
481            $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id));
482
483            if (!$exists) {
484                $sqlval['customer_id'] = $customer_id;
485                $sqlval['product_id'] = $favorite_product_id;
486                $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
487                $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
488
489                $objQuery->begin();
490                $objQuery->insert('dtb_customer_favorite_products', $sqlval);
491                $objQuery->commit();
492            }
493            // お気に入りに登録したことを示すフラグ
494            $this->just_added_favorite = true;
495
496            return true;
497        }
498    }
499
500    /**
501     * Add product(s) into the cart.
502     *
503     * @return void
504     */
505    public function doCart()
506    {
507        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
508                                            $this->tpl_classcat_find1,
509                                            $this->tpl_classcat_find2);
510        if (count($this->arrErr) == 0) {
511            $objCartSess = new SC_CartSession_Ex();
512            $product_class_id = $this->objFormParam->getValue('product_class_id');
513
514            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
515
516            // 開いているカテゴリーツリーを維持するためのパラメーター
517            $arrQueryString = array(
518                'product_id' => $this->objFormParam->getValue('product_id'),
519            );
520
521            SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString);
522            SC_Response_Ex::actionExit();
523        }
524    }
525
526    /**
527     * Add product to authenticated user's favorites.
528     *
529     * @param  type $objCustomer
530     * @return void
531     */
532    public function doAddFavorite(&$objCustomer)
533    {
534        // ログイン中のユーザが商品をお気に入りにいれる処理
535        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
536            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
537            if (count($this->arrErr) == 0) {
538                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
539                    SC_Response_Ex::actionExit();
540                }
541                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
542                $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
543            }
544        }
545    }
546
547    /**
548     * Add product to authenticated user's favorites. (for Smart phone)
549     *
550     * @param  type $objCustomer
551     * @return void
552     */
553    public function doAddFavoriteSphone($objCustomer)
554    {
555        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
556        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
557            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
558            if (count($this->arrErr) == 0) {
559                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
560                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
561                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
562                    print 'true';
563                    SC_Response_Ex::actionExit();
564                }
565            }
566            print 'error';
567            SC_Response_Ex::actionExit();
568        }
569    }
570
571    /**
572     *
573     *
574     * @return void
575     */
576    public function doDefault()
577    {
578        // カート「戻るボタン」用に保持
579        $netURL = new Net_URL();
580        $_SESSION['cart_referer_url'] = $netURL->getURL();
581    }
582
583    /**
584     *
585     * @return void
586     */
587    public function doMobileSelect()
588    {
589        // 規格1が設定されている場合
590        if ($this->tpl_classcat_find1) {
591            // templateの変更
592            $this->tpl_mainpage = 'products/select_find1.tpl';
593
594            return;
595        }
596
597        // 数量の入力を行う
598        $this->tpl_mainpage = 'products/select_item.tpl';
599    }
600
601    /**
602     *
603     * @return type
604     */
605    public function doMobileSelect2()
606    {
607        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
608
609        // 規格1が設定されていて、エラーを検出した場合
610        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
611            // templateの変更
612            $this->tpl_mainpage = 'products/select_find1.tpl';
613
614            return;
615        }
616
617        // 規格2が設定されている場合
618        if ($this->tpl_classcat_find2) {
619            $this->arrErr = array();
620
621            $this->tpl_mainpage = 'products/select_find2.tpl';
622
623            return;
624        }
625
626        $this->doMobileSelectItem();
627    }
628
629    /**
630     *
631     * @return void
632     */
633    public function doMobileSelectItem()
634    {
635        $objProduct = new SC_Product_Ex();
636
637        $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
638
639        // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
640        // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
641        unset($this->arrErr['product_class_id']);
642        unset($this->arrErr['quantity']);
643
644        // 規格2が設定されていて、エラーを検出した場合
645        if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
646            // templateの変更
647            $this->tpl_mainpage = 'products/select_find2.tpl';
648
649            return;
650        }
651
652        $product_id = $this->objFormParam->getValue('product_id');
653
654        $value1 = $this->objFormParam->getValue('classcategory_id1');
655        if (strlen($value1) === 0) {
656            $value1 = '__unselected';
657        }
658
659        // 規格2が設定されている場合.
660        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
661            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
662        } else {
663            $value2 = '#0';
664        }
665
666        $objProduct->setProductsClassByProductIds(array($product_id));
667        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
668
669        // 数量の入力を行う
670        $this->tpl_mainpage = 'products/select_item.tpl';
671    }
672
673    /**
674     *
675     * @return void
676     */
677    public function doMobileCart()
678    {
679        // この段階でエラーが出る場合は、数量の入力エラーのはず
680        if (count($this->arrErr)) {
681            // 数量の入力を行う
682            $this->tpl_mainpage = 'products/select_item.tpl';
683        }
684    }
685
686    /**
687     *
688     * @return void
689     */
690    public function doMobileDefault()
691    {
692        $this->tpl_mainpage = 'products/detail.tpl';
693    }
694}
Note: See TracBrowser for help on using the repository browser.