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

Revision 18833, 29.0 KB checked in by nanasess, 14 years ago (diff)

r18830 のコミット漏れ(#823)

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