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

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