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

Revision 22856, 24.5 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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