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