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

Revision 19670, 27.0 KB checked in by nanasess, 13 years ago (diff)

スマートフォン対応(#787)

  • r19668 の差し戻し
  • SC_Helper_Session::getToken() 内の SC_Helper_Session::createToken() を static に変更
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-2010 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_PATH . "pages/LC_Page.php");
26
27if (file_exists(MODULE_PATH . "mdl_gmopg/inc/function.php")) {
28    require_once(MODULE_PATH . "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 {
38
39    /** ステータス */
40    var $arrSTATUS;
41
42    /** ステータス画像 */
43    var $arrSTATUS_IMAGE;
44
45    /** 発送予定日 */
46    var $arrDELIVERYDATE;
47
48    /** おすすめレベル */
49    var $arrRECOMMEND;
50
51    /** フォームパラメータ */
52    var $objFormParam;
53
54    /** アップロードファイル */
55    var $objUpFile;
56
57    // }}}
58    // {{{ functions
59
60    /**
61     * Page を初期化する.
62     *
63     * @return void
64     */
65    function init() {
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        parent::process();
81        $this->action();
82        $this->sendResponse();
83    }
84
85    /**
86     * Page のAction.
87     *
88     * @return void
89     */
90    function action() {
91        // プロダクトIDの正当性チェック
92        $product_id = $this->lfCheckProductId();
93
94        $objView = new SC_SiteView(strlen($_POST['mode']) == 0);
95        $objCustomer = new SC_Customer();
96        $objQuery = new SC_Query();
97        $objDb = new SC_Helper_DB_Ex();
98
99        // レイアウトデザインを取得
100        $helper = new SC_Helper_PageLayout_Ex();
101        $helper->sfGetPageLayout($this, false, "products/detail.php");
102
103        // ログイン中のユーザが商品をお気に入りにいれる処理
104        if ($objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) {
105            // 値の正当性チェック
106            if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
107                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
108                exit;
109            } else {
110                $this->arrErr = $this->lfCheckError();
111                if(count($this->arrErr) == 0) {
112                    $customer_id = $objCustomer->getValue('customer_id');
113                    $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);
114                }
115            }
116        }
117
118        // パラメータ管理クラス
119        $this->objFormParam = new SC_FormParam();
120        // パラメータ情報の初期化
121        $this->lfInitParam();
122        // POST値の取得
123        $this->objFormParam->setParam($_POST);
124
125        // ファイル管理クラス
126        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
127        // ファイル情報の初期化
128        $this->lfInitFile();
129
130        // ログイン判定
131        if ($objCustomer->isLoginSuccess() === true) {
132            //お気に入りボタン表示
133            $this->tpl_login = true;
134        }
135
136        // 規格選択セレクトボックスの作成
137        $this->lfMakeSelect($product_id);
138
139        $objProduct = new SC_Product();
140        $objProduct->setProductsClassByProductIds(array($product_id));
141
142        // 規格1クラス名
143        $this->tpl_class_name1 = $objProduct->className1[$product_id];
144
145        // 規格2クラス名
146        $this->tpl_class_name2 = $objProduct->className2[$product_id];
147
148        // 規格1
149        $this->arrClassCat1 = $objProduct->classCats1[$product_id];
150
151        // 規格1が設定されている
152        $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id];
153        // 規格2が設定されている
154        $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id];
155
156        $this->tpl_stock_find = $objProduct->stock_find[$product_id];
157        $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id'];
158        $this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type'];
159
160        require_once DATA_PATH . 'module/Services/JSON.php';
161        $objJson = new Services_JSON();
162        $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';';
163        $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}';
164        $this->tpl_onload .= 'lnOnLoad();';
165
166        // 商品IDをFORM内に保持する。
167        $this->tpl_product_id = $product_id;
168
169        if (!isset($_POST['mode'])) $_POST['mode'] = "";
170        $arrErr = array();
171
172        switch($_POST['mode']) {
173            case 'cart':
174                // 入力値の変換
175                $this->objFormParam->convParam();
176                $arrErr = $this->lfCheckError();
177                if (count($arrErr) == 0) {
178                    $objCartSess = new SC_CartSession();
179                    $classcategory_id1 = $_POST['classcategory_id1'];
180                    $classcategory_id2 = $_POST['classcategory_id2'];
181                    $product_class_id = $_POST['product_class_id'];
182                    $product_type = $_POST['product_type'];
183
184                    if (!empty($_POST['gmo_oneclick'])) {
185                        $objCartSess->delAllProducts();
186                    }
187
188                    // 規格1が設定されていない場合
189                    if(!$this->tpl_classcat_find1) {
190                        $classcategory_id1 = '0';
191                    }
192
193                    // 規格2が設定されていない場合
194                    if(!$this->tpl_classcat_find2) {
195                        $classcategory_id2 = '0';
196                    }
197                    $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'), $product_type);
198
199                    if (!empty($_POST['gmo_oneclick'])) {
200                        $objSiteSess = new SC_SiteSession;
201                        $objSiteSess->setRegistFlag();
202                        $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
203
204                        $this->objDisplay->redirect($this->getLocation(
205                            URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
206                        exit;
207                    }
208
209                    $this->objDisplay->redirect($this->getLocation(URL_CART_TOP));
210                    exit;
211                }
212                break;
213
214            default:
215                break;
216        }
217        $this->arrErr = $arrErr;
218
219        // 商品詳細を取得
220        $this->arrProduct = $objProduct->getDetail($product_id);
221
222        // サブタイトルを取得
223        $this->tpl_subtitle = $this->arrProduct['name'];
224
225        // 関連カテゴリを取得
226        $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id);
227
228        // 商品ステータスを取得
229        $this->productStatus = $objProduct->getProductStatus($product_id);
230
231        // 画像ファイル指定がない場合の置換処理
232        $this->arrProduct['main_image']
233            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
234
235        $this->lfSetFile();
236        // 支払方法の取得
237        $this->arrPayment = $this->lfGetPayment();
238        // 入力情報を渡す
239        $this->arrForm = $this->objFormParam->getFormParamList();
240        //レビュー情報の取得
241        $this->arrReview = $this->lfGetReviewData($product_id);
242        // トラックバック情報の取得
243
244        // トラックバック機能の稼働状況チェック
245        if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
246            $this->arrTrackbackView = "OFF";
247        } else {
248            $this->arrTrackbackView = "ON";
249            $this->arrTrackback = $this->lfGetTrackbackData($product_id);
250        }
251        $this->trackback_url = TRACKBACK_TO_URL . $product_id;
252        //関連商品情報表示
253        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
254
255        $this->lfConvertParam();
256
257        //$objView->assignobj($this);
258        //$objView->display(SITE_FRAME);
259    }
260
261    /**
262     * デストラクタ.
263     *
264     * @return void
265     */
266    function destroy() {
267        parent::destroy();
268    }
269
270    /**
271     * モバイルページを初期化する.
272     *
273     * @return void
274     */
275    function mobileInit() {
276        $this->init();
277        $this->tpl_mainpage = "products/detail.tpl";
278    }
279
280    /**
281     * Page のプロセス(モバイル).
282     * @return void
283     */
284    function mobileProcess() {
285        parent::mobileProcess();
286        $this->mobileAction();
287        $this->sendResponse();
288    }
289
290    /**
291     * Page のAction(モバイル).
292     *
293     * FIXME 要リファクタリング
294     *
295     * @return void
296     */
297    function mobileAction() {
298        // プロダクトIDの正当性チェック
299        $product_id = $this->lfCheckProductId();
300
301        //$objView = new SC_MobileView();
302        $objCustomer = new SC_Customer();
303        $objQuery = new SC_Query();
304        $objDb = new SC_Helper_DB_Ex();
305
306        // パラメータ管理クラス
307        $this->objFormParam = new SC_FormParam();
308        // パラメータ情報の初期化
309        $this->lfInitParam();
310        // POST値の取得
311        $this->objFormParam->setParam($_POST);
312
313        // ファイル管理クラス
314        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
315        // ファイル情報の初期化
316        $this->lfInitFile();
317
318        // ログイン判定
319        if($objCustomer->isLoginSuccess(true)) {
320            //お気に入りボタン表示
321            $this->tpl_login = true;
322        }
323
324        // 規格選択セレクトボックスの作成
325        $this->lfMakeSelectMobile($this, $product_id);
326
327        // 商品IDをFORM内に保持する。
328        $this->tpl_product_id = $product_id;
329
330        switch($_POST['mode']) {
331        case 'select':
332            // 規格1が設定されている場合
333            if($this->tpl_classcat_find1) {
334                // templateの変更
335                $this->tpl_mainpage = "products/select_find1.tpl";
336                break;
337            }
338
339        case 'select2':
340            $this->arrErr = $this->lfCheckError();
341
342            // 規格1が設定されている場合
343            if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
344                // templateの変更
345                $this->tpl_mainpage = "products/select_find1.tpl";
346                break;
347            }
348
349            // 規格2が設定されている場合
350            if($this->tpl_classcat_find2) {
351                $this->arrErr = array();
352
353                $this->tpl_mainpage = "products/select_find2.tpl";
354                break;
355            }
356
357        case 'selectItem':
358            $this->arrErr = $this->lfCheckError();
359
360            // 規格1が設定されている場合
361            if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
362                // templateの変更
363                $this->tpl_mainpage = "products/select_find2.tpl";
364                break;
365            }
366            // 商品数の選択を行う
367            $this->tpl_mainpage = "products/select_item.tpl";
368            break;
369
370        case 'cart':
371            // 入力値の変換
372            $this->objFormParam->convParam();
373            $this->arrErr = $this->lfCheckError();
374            if(count($this->arrErr) == 0) {
375                $objCartSess = new SC_CartSession();
376                $product_class_id = $_POST['product_class_id'];
377                $classcategory_id1 = $_POST['classcategory_id1'];
378                $classcategory_id2 = $_POST['classcategory_id2'];
379
380                // 規格1が設定されていない場合
381                if(!$this->tpl_classcat_find1) {
382                    $classcategory_id1 = '0';
383                }
384
385                // 規格2が設定されていない場合
386                if(!$this->tpl_classcat_find2) {
387                    $classcategory_id2 = '0';
388                }
389
390                $objCartSess->addProduct(array($_POST['product_id'], $product_class_id, $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
391                $this->objDisplay->redirect($this->getLocation(MOBILE_URL_CART_TOP));
392                exit;
393            }
394            break;
395
396        default:
397            break;
398        }
399
400        // 商品詳細を取得
401        $objProduct = new SC_Product();
402        $this->arrProduct = $objProduct->getDetail($product_id);
403
404        // サブタイトルを取得
405        $this->tpl_subtitle = $this->arrProduct["name"];
406
407        // 画像ファイル指定がない場合の置換処理
408        $this->arrProduct['main_image']
409            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']);
410
411        // ファイル情報のセット
412        $this->lfSetFile();
413        // 支払方法の取得
414        $this->arrPayment = $this->lfGetPayment();
415        // 入力情報を渡す
416        $this->arrForm = $this->objFormParam->getFormParamList();
417        //レビュー情報の取得
418        $this->arrReview = $this->lfGetReviewData($product_id);
419        // タイトルに商品名を入れる
420        $this->tpl_title = "商品詳細 ". $this->arrProduct["name"];
421        //関連商品情報表示
422        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id);
423
424        //$objView->assignobj($this);
425        //$objView->display(SITE_FRAME);
426    }
427
428    /* プロダクトIDの正当性チェック */
429    function lfCheckProductId() {
430        // 管理機能からの確認の場合は、非公開の商品も表示する。
431        if (isset($_GET['admin']) && $_GET['admin'] == 'on') {
432            SC_Utils_Ex::sfIsSuccess(new SC_Session());
433            $status = true;
434            $where = 'del_flg = 0';
435        } else {
436            $status = false;
437            $where = 'del_flg = 0 AND status = 1';
438        }
439
440        if (defined('MOBILE_SITE')) {
441            if (!isset($_POST['mode'])) $_POST['mode'] = "";
442            if (!empty($_POST['mode'])) {
443                $product_id = $_POST['product_id'];
444            } else {
445                $product_id = $_GET['product_id'];
446            }
447        } else {
448            if(isset($_POST['mode']) && $_POST['mode'] != '') {
449                $product_id = $_POST['product_id'];
450            } else {
451                $product_id = $_GET['product_id'];
452            }
453        }
454
455        $objDb = new SC_Helper_DB_Ex();
456        if(!SC_Utils_Ex::sfIsInt($product_id)
457            || SC_Utils_Ex::sfIsZeroFilling($product_id)
458            || !$objDb->sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where))
459            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
460        return $product_id;
461    }
462
463    /* ファイル情報の初期化 */
464    function lfInitFile() {
465        $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
466        for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
467            $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);
468        }
469    }
470
471    /* 規格選択セレクトボックスの作成 */
472    function lfMakeSelect() {
473
474        // 選択されている規格
475        $classcategory_id1
476            = isset($_POST['classcategory_id1']) && is_numeric($_POST['classcategory_id1'])
477            ? $_POST['classcategory_id1']
478            : '';
479
480        $classcategory_id2
481            = isset($_POST['classcategory_id2']) && is_numeric($_POST['classcategory_id2'])
482            ? $_POST['classcategory_id2']
483            : '';
484
485        require_once DATA_PATH . 'module/Services/JSON.php';
486        $this->js_lnOnload .= 'fnSetClassCategories('
487            . 'document.form1, '
488            . Services_JSON::encode($classcategory_id2)
489            . '); ';
490    }
491
492    /* 規格選択セレクトボックスの作成
493     * FIXME 要リファクタリング
494     */
495    function lfMakeSelectMobile(&$objPage, $product_id) {
496
497        $objDb = new SC_Helper_DB_Ex();
498        $classcat_find1 = false;
499        $classcat_find2 = false;
500        // 在庫ありの商品の有無
501        $stock_find = false;
502
503        // 規格名一覧
504        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
505        // 規格分類名一覧
506        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
507        /*
508         * FIXME
509         * パフォーマンスが出ないため,
510         * SC_Product::getProductsClassByProductIds() を使用した実装に変更
511         */
512        // 商品規格情報の取得
513        $arrProductsClass = $this->lfGetProductsClass($product_id);
514
515        // 規格1クラス名の取得
516        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
517        // 規格2クラス名の取得
518        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
519
520        // すべての組み合わせ数
521        $count = count($arrProductsClass);
522
523        $classcat_id1 = "";
524
525        $arrSele1 = array();
526        $arrSele2 = array();
527
528        for ($i = 0; $i < $count; $i++) {
529            // 在庫のチェック
530            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
531                continue;
532            }
533
534            $stock_find = true;
535
536            // 規格1のセレクトボックス用
537            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
538                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
539                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
540            }
541
542            // 規格2のセレクトボックス用
543            if($arrProductsClass[$i]['classcategory_id1'] == $_POST['classcategory_id1'] and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
544                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
545                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
546            }
547        }
548
549        // 規格1
550        $objPage->arrClassCat1 = $arrSele1;
551        $objPage->arrClassCat2 = $arrSele2;
552
553        // 規格1が設定されている
554        if($arrProductsClass[0]['classcategory_id1'] != '0') {
555            $classcat_find1 = true;
556        }
557
558        // 規格2が設定されている
559        if($arrProductsClass[0]['classcategory_id2'] != '0') {
560            $classcat_find2 = true;
561        }
562
563        $objPage->tpl_classcat_find1 = $classcat_find1;
564        $objPage->tpl_classcat_find2 = $classcat_find2;
565        $objPage->tpl_stock_find = $stock_find;
566    }
567
568    /* パラメータ情報の初期化 */
569    function lfInitParam() {
570        $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
571        $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
572        $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
573    }
574
575    /* 商品規格情報の取得 */
576    function lfGetProductsClass($product_id) {
577        $arrRet = array();
578        if(SC_Utils_Ex::sfIsInt($product_id)) {
579            // 商品規格取得
580            $objQuery = new SC_Query();
581            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
582            $table = "vw_product_class AS prdcls";
583            $where = "product_id = ?";
584            $objQuery->setOrder("rank1 DESC, rank2 DESC");
585            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
586        }
587        return $arrRet;
588    }
589
590    /* 登録済み関連商品の読み込み */
591    function lfPreGetRecommendProducts($product_id) {
592        $arrRecommend = array();
593        $objQuery = new SC_Query();
594        $objQuery->setOrder("rank DESC");
595        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
596        $max = count($arrRet);
597        $no = 0;
598        // FIXME SC_Product クラスを使用した実装
599        $from = "vw_products_allclass AS T1 "
600                . " JOIN ("
601                . " SELECT max(T2.rank) AS product_rank, "
602                . "        T2.product_id"
603                . "   FROM dtb_product_categories T2  "
604                . " GROUP BY product_id) AS T3 USING (product_id)";
605        $objQuery->setOrder("T3.product_rank DESC");
606        for($i = 0; $i < $max; $i++) {
607            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1";
608            $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, T3.product_rank", $from, $where, array($arrRet[$i]['recommend_product_id']));
609
610            if(count($arrProductInfo) > 0) {
611                $arrRecommend[$no] = $arrProductInfo[0];
612                $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
613                $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
614                $no++;
615            }
616        }
617        return $arrRecommend;
618    }
619
620    /* 入力内容のチェック */
621    function lfCheckError() {
622        if ($_POST['mode'] == "add_favorite") {
623            $objCustomer = new SC_Customer();
624            $objErr = new SC_CheckError();
625            $customer_id = $objCustomer->getValue('customer_id');
626            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
627                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
628            }
629        } else {
630            // 入力データを渡す。
631            $arrRet =  $this->objFormParam->getHashArray();
632            $objErr = new SC_CheckError($arrRet);
633            $objErr->arrErr = $this->objFormParam->checkError();
634
635            // 複数項目チェック
636            if ($this->tpl_classcat_find1) {
637                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK"));
638            }
639            if ($this->tpl_classcat_find2) {
640                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK"));
641            }
642        }
643
644        return $objErr->arrErr;
645    }
646
647    //閲覧履歴新規登録
648    function lfRegistReadingData($product_id, $customer_id){
649        $objQuery = new SC_Query;
650        $sqlval['customer_id'] = $customer_id;
651        $sqlval['reading_product_id'] = $product_id;
652        $sqlval['create_date'] = 'NOW()';
653        $sqlval['update_date'] = 'NOW()';
654        $objQuery->insert("dtb_customer_reading", $sqlval);
655    }
656
657    //商品ごとのレビュー情報を取得する
658    function lfGetReviewData($id) {
659        $objQuery = new SC_Query;
660        //商品ごとのレビュー情報を取得する
661        $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
662        $from = "dtb_review";
663        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
664        $arrval[] = $id;
665        $arrReview = $objQuery->select($col, $from, $where, $arrval);
666        return $arrReview;
667    }
668
669    /*
670     * 商品ごとのトラックバック情報を取得する
671     *
672     * @param $product_id
673     * @return $arrTrackback
674     */
675    function lfGetTrackbackData($product_id) {
676
677        $arrTrackback = array();
678
679        $objQuery = new SC_Query;
680        //商品ごとのトラックバック情報を取得する
681        $col = "blog_name, url, title, excerpt, title, create_date";
682        $from = "dtb_trackback";
683        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX;
684        $arrval[] = $product_id;
685        $arrTrackback = $objQuery->select($col, $from, $where, $arrval);
686        return $arrTrackback;
687    }
688
689    //支払方法の取得
690    //payment_id    1:クレジット 2:ショッピングローン
691    function lfGetPayment() {
692        $objQuery = new SC_Query;
693        $col = "payment_id, rule, payment_method";
694        $from = "dtb_payment";
695        $where = "del_flg = 0";
696        $order = "payment_id";
697        $objQuery->setOrder($order);
698        $arrRet = $objQuery->select($col, $from, $where);
699        return $arrRet;
700    }
701
702    function lfConvertParam() {
703        if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
704        $value = $this->arrForm['quantity']['value'];
705        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
706    }
707
708    /*
709     * ファイルの情報をセットする
710     *
711     */
712    function lfSetFile() {
713        // DBからのデータを引き継ぐ
714        $this->objUpFile->setDBFileList($this->arrProduct);
715        // ファイル表示用配列を渡す
716        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
717
718        // サブ画像の有無を判定
719        $this->subImageFlag = false;
720        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
721            if ($this->arrFile["sub_image" . $i]["filepath"] != "") {
722                $this->subImageFlag = true;
723            }
724        }
725    }
726
727    /*
728     * お気に入り商品登録
729     */
730    function lfRegistFavoriteProduct($customer_id, $product_id) {
731        $objQuery = new SC_Query();
732        $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id));
733
734        if ($count == 0) {
735            $sqlval['customer_id'] = $customer_id;
736            $sqlval['product_id'] = $product_id;
737            $sqlval['update_date'] = "now()";
738            $sqlval['create_date'] = "now()";
739
740            $objQuery->begin();
741            $objQuery->insert('dtb_customer_favorite_products', $sqlval);
742            $objQuery->commit();
743        }
744    }
745
746}
747?>
Note: See TracBrowser for help on using the repository browser.