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