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

Revision 19802, 26.7 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部改修

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