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

Revision 18826, 29.0 KB checked in by eccuore, 14 years ago (diff)

#792(ダウンロード販売機能) カートに商品が入らない不具合修正

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