source: branches/camp/camp-2_5-C/data/class/pages/admin/products/LC_Page_Admin_Products_Preview.php @ 19635

Revision 19635, 29.9 KB checked in by kishik, 13 years ago (diff)

商品登録前プレビュー

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