source: branches/version-2_13_0/data/class/pages/products/LC_Page_Products_Detail.php @ 23071

Revision 23071, 24.9 KB checked in by h_yoshimoto, 11 years ago (diff)

#2342 基本情報管理>SHOPマスターにてJSエラーで登録処理が動かなかったので一旦戻します

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