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

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