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