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

Revision 19684, 26.8 KB checked in by nanasess, 13 years ago (diff)

#635 処理の単純化

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