source: branches/comu-ver2/data/class/pages/products/LC_Page_Products_Detail.php @ 18636

Revision 18636, 29.0 KB checked in by Seasoft, 14 years ago (diff)

merge r18516(一部)

  • 取得元: version-2_4
  • /data/class/helper/SC_Helper_DB.php は反映を保留。#545 で仕様変更が決定しているため。

【取得元のログメッセージ】
merged r18465

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