Warning: Can't use blame annotator:
svn blame failed on branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php: バイナリファイル 'file:///home/svn/open/branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php' に対しては blame で各行の最終変更者を計算できません 195004

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

Revision 18824, 28.8 KB checked in by eccuore, 14 years ago (diff)

#792(ダウンロード販売機能) vw_download_class削除、product_class_id対応(規格構成変更と並行作業中なので、作業途中の部分有)

  • 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
RevLine 
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                    $product_class_id = $_POST['product_class_id'];
192                    $classcategory_id1 = $_POST['classcategory_id1'];
193                    $classcategory_id2 = $_POST['classcategory_id2'];
194
195                    if (!empty($_POST['gmo_oneclick'])) {
196                        $objCartSess->delAllProducts();
197                    }
198
199                    // 規格1が設定されていない場合
200                    if(!$this->tpl_classcat_find1) {
201                        $classcategory_id1 = '0';
202                    }
203
204                    // 規格2が設定されていない場合
205                    if(!$this->tpl_classcat_find2) {
206                        $classcategory_id2 = '0';
207                    }
208
209                    $objCartSess->addProduct(array($_POST['product_id'], $product_class_id, $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
210
211                    if (!empty($_POST['gmo_oneclick'])) {
212                        $objSiteSess = new SC_SiteSession;
213                        $objSiteSess->setRegistFlag();
214                        $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
215
216                        $this->sendRedirect($this->getLocation(
217                            URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
218                        exit;
219                    }
220
221                    $this->sendRedirect($this->getLocation(URL_CART_TOP));
222                    exit;
223                }
224                break;
225
226            default:
227                break;
228        }
229        $this->arrErr = $arrErr;
230
231        // 商品詳細を取得
232        $this->arrProduct = $objProduct->getDetail($product_id);
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                $product_class_id = $_POST['product_class_id'];
402                $classcategory_id1 = $_POST['classcategory_id1'];
403                $classcategory_id2 = $_POST['classcategory_id2'];
404
405                // 規格1が設定されていない場合
406                if(!$this->tpl_classcat_find1) {
407                    $classcategory_id1 = '0';
408                }
409
410                // 規格2が設定されていない場合
411                if(!$this->tpl_classcat_find2) {
412                    $classcategory_id2 = '0';
413                }
414
415                $objCartSess->addProduct(array($_POST['product_id'], $product_class_id, $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
416                $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true);
417                exit;
418            }
419            break;
420
421        default:
422            break;
423        }
424
425        // 商品詳細を取得
426        $objProduct = new SC_Product();
427        $this->arrProduct = $objProduct->getDetail($product_id);
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         * FIXME
536         * パフォーマンスが出ないため,
537         * SC_Product::getProductsClassByProductIds() を使用した実装に変更
538         */
539        // 商品規格情報の取得
540        $arrProductsClass = $this->lfGetProductsClass($product_id);
541
542        // 規格1クラス名の取得
543        $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
544        // 規格2クラス名の取得
545        $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
546
547        // すべての組み合わせ数
548        $count = count($arrProductsClass);
549
550        $classcat_id1 = "";
551
552        $arrSele1 = array();
553        $arrSele2 = array();
554
555        for ($i = 0; $i < $count; $i++) {
556            // 在庫のチェック
557            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
558                continue;
559            }
560
561            $stock_find = true;
562
563            // 規格1のセレクトボックス用
564            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
565                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
566                $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1];
567            }
568
569            // 規格2のセレクトボックス用
570            if($arrProductsClass[$i]['classcategory_id1'] == $_POST['classcategory_id1'] and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {
571                $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
572                $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2];
573            }
574        }
575
576        // 規格1
577        $objPage->arrClassCat1 = $arrSele1;
578        $objPage->arrClassCat2 = $arrSele2;
579
580        // 規格1が設定されている
581        if($arrProductsClass[0]['classcategory_id1'] != '0') {
582            $classcat_find1 = true;
583        }
584
585        // 規格2が設定されている
586        if($arrProductsClass[0]['classcategory_id2'] != '0') {
587            $classcat_find2 = true;
588        }
589
590        $objPage->tpl_classcat_find1 = $classcat_find1;
591        $objPage->tpl_classcat_find2 = $classcat_find2;
592        $objPage->tpl_stock_find = $stock_find;
593    }
594
595    /* パラメータ情報の初期化 */
596    function lfInitParam() {
597        $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
598        $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
599        $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
600    }
601
602    /* 商品規格情報の取得 */
603    function lfGetProductsClass($product_id) {
604        $arrRet = array();
605        if(SC_Utils_Ex::sfIsInt($product_id)) {
606            // 商品規格取得
607            $objQuery = new SC_Query();
608            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
609            $table = "vw_product_class AS prdcls";
610            $where = "product_id = ?";
611            $objQuery->setOrder("rank1 DESC, rank2 DESC");
612            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
613        }
614        return $arrRet;
615    }
616
617    /* 登録済み関連商品の読み込み */
618    function lfPreGetRecommendProducts($product_id) {
619        $arrRecommend = array();
620        $objQuery = new SC_Query();
621        $objQuery->setOrder("rank DESC");
622        $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
623        $max = count($arrRet);
624        $no = 0;
625        // FIXME SC_Product クラスを使用した実装
626        $from = "vw_products_allclass AS T1 "
627                . " JOIN ("
628                . " SELECT max(T2.rank) AS product_rank, "
629                . "        T2.product_id"
630                . "   FROM dtb_product_categories T2  "
631                . " GROUP BY product_id) AS T3 USING (product_id)";
632        $objQuery->setOrder("T3.product_rank DESC");
633        for($i = 0; $i < $max; $i++) {
634            $where = "del_flg = 0 AND T3.product_id = ? AND status = 1";
635            $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']));
636
637            if(count($arrProductInfo) > 0) {
638                $arrRecommend[$no] = $arrProductInfo[0];
639                $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
640                $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
641                $no++;
642            }
643        }
644        return $arrRecommend;
645    }
646
647    /* 入力内容のチェック */
648    function lfCheckError() {
649        if ($_POST['mode'] == "add_favorite") {
650            $objCustomer = new SC_Customer();
651            $objErr = new SC_CheckError();
652            $customer_id = $objCustomer->getValue('customer_id');
653            if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) {
654                $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />";
655            }
656        } else {
657            // 入力データを渡す。
658            $arrRet =  $this->objFormParam->getHashArray();
659            $objErr = new SC_CheckError($arrRet);
660            $objErr->arrErr = $this->objFormParam->checkError();
661
662            // 複数項目チェック
663            if ($this->tpl_classcat_find1) {
664                $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK"));
665            }
666            if ($this->tpl_classcat_find2) {
667                $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK"));
668            }
669        }
670
671        return $objErr->arrErr;
672    }
673
674    //閲覧履歴新規登録
675    function lfRegistReadingData($product_id, $customer_id){
676        $objQuery = new SC_Query;
677        $sqlval['customer_id'] = $customer_id;
678        $sqlval['reading_product_id'] = $product_id;
679        $sqlval['create_date'] = 'NOW()';
680        $sqlval['update_date'] = 'NOW()';
681        $objQuery->insert("dtb_customer_reading", $sqlval);
682    }
683
684    //商品ごとのレビュー情報を取得する
685    function lfGetReviewData($id) {
686        $objQuery = new SC_Query;
687        //商品ごとのレビュー情報を取得する
688        $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
689        $from = "dtb_review";
690        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX;
691        $arrval[] = $id;
692        $arrReview = $objQuery->select($col, $from, $where, $arrval);
693        return $arrReview;
694    }
695
696    /*
697     * 商品ごとのトラックバック情報を取得する
698     *
699     * @param $product_id
700     * @return $arrTrackback
701     */
702    function lfGetTrackbackData($product_id) {
703
704        $arrTrackback = array();
705
706        $objQuery = new SC_Query;
707        //商品ごとのトラックバック情報を取得する
708        $col = "blog_name, url, title, excerpt, title, create_date";
709        $from = "dtb_trackback";
710        $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX;
711        $arrval[] = $product_id;
712        $arrTrackback = $objQuery->select($col, $from, $where, $arrval);
713        return $arrTrackback;
714    }
715
716    //支払方法の取得
717    //payment_id    1:クレジット 2:ショッピングローン
718    function lfGetPayment() {
719        $objQuery = new SC_Query;
720        $col = "payment_id, rule, payment_method";
721        $from = "dtb_payment";
722        $where = "del_flg = 0";
723        $order = "payment_id";
724        $objQuery->setOrder($order);
725        $arrRet = $objQuery->select($col, $from, $where);
726        return $arrRet;
727    }
728
729    function lfConvertParam() {
730        if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = "";
731        $value = $this->arrForm['quantity']['value'];
732        $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE);
733    }
734
735    /*
736     * ファイルの情報をセットする
737     *
738     */
739    function lfSetFile() {
740        // DBからのデータを引き継ぐ
741        $this->objUpFile->setDBFileList($this->arrProduct);
742        // ファイル表示用配列を渡す
743        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
744
745        // サブ画像の有無を判定
746        $this->subImageFlag = false;
747        for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
748            if ($this->arrFile["sub_image" . $i]["filepath"] != "") {
749                $this->subImageFlag = true;
750            }
751        }
752    }
753
754    /*
755     * お気に入り商品登録
756     */
757    function lfRegistFavoriteProduct($customer_id, $product_id) {
758        $objQuery = new SC_Query();
759        $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id));
760
761        if ($count == 0) {
762            $sqlval['customer_id'] = $customer_id;
763            $sqlval['product_id'] = $product_id;
764            $sqlval['update_date'] = "now()";
765            $sqlval['create_date'] = "now()";
766
767            $objQuery->begin();
768            $objQuery->insert('dtb_customer_favorite_products', $sqlval);
769            $objQuery->commit();
770        }
771    }
772
773}
774?>
Note: See TracBrowser for help on using the repository browser.