source: tmp/version-2_5-test/data/class/pages/products/LC_Page_Products_Detail.php @ 18609

Revision 18609, 29.6 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

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