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