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

Revision 22567, 24.3 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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