1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2007 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 | /** |
---|
28 | * 商品詳細 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
33 | */ |
---|
34 | class LC_Page_Products_Detail extends LC_Page { |
---|
35 | |
---|
36 | /** ステータス */ |
---|
37 | var $arrSTATUS; |
---|
38 | |
---|
39 | /** ステータス画像 */ |
---|
40 | var $arrSTATUS_IMAGE; |
---|
41 | |
---|
42 | /** 発送予定日 */ |
---|
43 | var $arrDELIVERYDATE; |
---|
44 | |
---|
45 | /** おすすめレベル */ |
---|
46 | var $arrRECOMMEND; |
---|
47 | |
---|
48 | /** フォームパラメータ */ |
---|
49 | var $objFormParam; |
---|
50 | |
---|
51 | /** アップロードファイル */ |
---|
52 | var $objUpFile; |
---|
53 | |
---|
54 | // }}} |
---|
55 | // {{{ functions |
---|
56 | |
---|
57 | /** |
---|
58 | * Page を初期化する. |
---|
59 | * |
---|
60 | * @return void |
---|
61 | */ |
---|
62 | function init() { |
---|
63 | parent::init(); |
---|
64 | $masterData = new SC_DB_MasterData_Ex(); |
---|
65 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
66 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
67 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
68 | $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend"); |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * Page のプロセス. |
---|
73 | * |
---|
74 | * @return void |
---|
75 | */ |
---|
76 | function process() { |
---|
77 | $objView = new SC_SiteView(); |
---|
78 | $objCustomer = new SC_Customer(); |
---|
79 | $objQuery = new SC_Query(); |
---|
80 | $objDb = new SC_Helper_DB_Ex(); |
---|
81 | |
---|
82 | // レイアウトデザインを取得 |
---|
83 | $helper = new SC_Helper_PageLayout_Ex(); |
---|
84 | $helper->sfGetPageLayout($this, false, "products/detail.php"); |
---|
85 | |
---|
86 | // パラメータ管理クラス |
---|
87 | $this->objFormParam = new SC_FormParam(); |
---|
88 | // パラメータ情報の初期化 |
---|
89 | $this->lfInitParam(); |
---|
90 | // POST値の取得 |
---|
91 | $this->objFormParam->setParam($_POST); |
---|
92 | |
---|
93 | // ファイル管理クラス |
---|
94 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
95 | // ファイル情報の初期化 |
---|
96 | $this->lfInitFile(); |
---|
97 | |
---|
98 | // 管理ページからの確認の場合は、非公開の商品も表示する。 |
---|
99 | if(isset($_GET['admin']) && $_GET['admin'] == 'on') { |
---|
100 | SC_Utils_Ex::sfIsSuccess(new SC_Session()); |
---|
101 | $status = true; |
---|
102 | $where = "del_flg = 0"; |
---|
103 | } else { |
---|
104 | $status = false; |
---|
105 | $where = "del_flg = 0 AND status = 1"; |
---|
106 | } |
---|
107 | |
---|
108 | if(isset($_POST['mode']) && $_POST['mode'] != "") { |
---|
109 | $tmp_id = $_POST['product_id']; |
---|
110 | } else { |
---|
111 | $tmp_id = $_GET['product_id']; |
---|
112 | } |
---|
113 | |
---|
114 | // 値の正当性チェック |
---|
115 | if(!SC_Utils_Ex::sfIsInt($_GET['product_id']) |
---|
116 | || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) { |
---|
117 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
118 | } |
---|
119 | // ログイン判定 |
---|
120 | if($objCustomer->isLoginSuccess()) { |
---|
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($tmp_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($tmp_id, $objCustomer->getValue('customer_id')); |
---|
146 | } |
---|
147 | */ |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | // 規格選択セレクトボックスの作成 |
---|
152 | $this->lfMakeSelect($tmp_id); |
---|
153 | |
---|
154 | // 商品IDをFORM内に保持する。 |
---|
155 | $this->tpl_product_id = $tmp_id; |
---|
156 | |
---|
157 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
158 | |
---|
159 | switch($_POST['mode']) { |
---|
160 | case 'cart': |
---|
161 | // 入力値の変換 |
---|
162 | $this->objFormParam->convParam(); |
---|
163 | $this->arrErr = $this->lfCheckError(); |
---|
164 | if(count($this->arrErr) == 0) { |
---|
165 | $objCartSess = new SC_CartSession(); |
---|
166 | $classcategory_id1 = $_POST['classcategory_id1']; |
---|
167 | $classcategory_id2 = $_POST['classcategory_id2']; |
---|
168 | |
---|
169 | // 規格1が設定されていない場合 |
---|
170 | if(!$this->tpl_classcat_find1) { |
---|
171 | $classcategory_id1 = '0'; |
---|
172 | } |
---|
173 | |
---|
174 | // 規格2が設定されていない場合 |
---|
175 | if(!$this->tpl_classcat_find2) { |
---|
176 | $classcategory_id2 = '0'; |
---|
177 | } |
---|
178 | |
---|
179 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
---|
180 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); |
---|
181 | $this->sendRedirect($this->getLocation(URL_CART_TOP)); |
---|
182 | exit; |
---|
183 | } |
---|
184 | break; |
---|
185 | |
---|
186 | default: |
---|
187 | break; |
---|
188 | } |
---|
189 | |
---|
190 | $objQuery = new SC_Query(); |
---|
191 | // DBから商品情報を取得する。 |
---|
192 | $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); |
---|
193 | $this->arrProduct = $arrRet[0]; |
---|
194 | |
---|
195 | // 商品コードの取得 |
---|
196 | $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; |
---|
197 | $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); |
---|
198 | $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); |
---|
199 | $this->arrProductCode = $arrProductCode["product_code"]; |
---|
200 | |
---|
201 | // 購入制限数を取得 |
---|
202 | if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { |
---|
203 | $this->tpl_sale_limit = SALE_LIMIT_MAX; |
---|
204 | } else { |
---|
205 | $this->tpl_sale_limit = $this->arrProduct['sale_limit']; |
---|
206 | } |
---|
207 | // サブタイトルを取得 |
---|
208 | $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], $status); |
---|
209 | $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); |
---|
210 | $this->tpl_subtitle = $arrFirstCat['name']; |
---|
211 | |
---|
212 | // DBからのデータを引き継ぐ |
---|
213 | $this->objUpFile->setDBFileList($this->arrProduct); |
---|
214 | // ファイル表示用配列を渡す |
---|
215 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); |
---|
216 | // 支払方法の取得 |
---|
217 | $this->arrPayment = $this->lfGetPayment(); |
---|
218 | // 入力情報を渡す |
---|
219 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
220 | //レビュー情報の取得 |
---|
221 | $this->arrReview = $this->lfGetReviewData($tmp_id); |
---|
222 | // トラックバック情報の取得 |
---|
223 | |
---|
224 | // トラックバック機能の稼働状況チェック |
---|
225 | if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { |
---|
226 | $this->arrTrackbackView = "OFF"; |
---|
227 | } else { |
---|
228 | $this->arrTrackbackView = "ON"; |
---|
229 | $this->arrTrackback = $this->lfGetTrackbackData($tmp_id); |
---|
230 | } |
---|
231 | $this->trackback_url = TRACKBACK_TO_URL . $tmp_id; |
---|
232 | // タイトルに商品名を入れる |
---|
233 | $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; |
---|
234 | //オススメ商品情報表示 |
---|
235 | $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); |
---|
236 | //この商品を買った人はこんな商品も買っています |
---|
237 | $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); |
---|
238 | |
---|
239 | // 拡大画像のウィンドウサイズをセット |
---|
240 | if (isset($this->arrFile["main_large_image"])) { |
---|
241 | $image_path = IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]); |
---|
242 | } else { |
---|
243 | $image_path = ""; |
---|
244 | } |
---|
245 | |
---|
246 | list($large_width, $large_height) = getimagesize($image_path); |
---|
247 | $this->tpl_large_width = $large_width + 60; |
---|
248 | $this->tpl_large_height = $large_height + 80; |
---|
249 | |
---|
250 | $this->lfConvertParam(); |
---|
251 | |
---|
252 | $objView->assignobj($this); |
---|
253 | $objView->display(SITE_FRAME); |
---|
254 | } |
---|
255 | |
---|
256 | /** |
---|
257 | * デストラクタ. |
---|
258 | * |
---|
259 | * @return void |
---|
260 | */ |
---|
261 | function destroy() { |
---|
262 | parent::destroy(); |
---|
263 | } |
---|
264 | |
---|
265 | /** |
---|
266 | * モバイルページを初期化する. |
---|
267 | * |
---|
268 | * @return void |
---|
269 | */ |
---|
270 | function mobileInit() { |
---|
271 | $this->init(); |
---|
272 | $this->tpl_mainpage = "products/detail.tpl"; |
---|
273 | } |
---|
274 | |
---|
275 | /** |
---|
276 | * Page のプロセス(モバイル). |
---|
277 | * |
---|
278 | * FIXME 要リファクタリング |
---|
279 | * |
---|
280 | * @return void |
---|
281 | */ |
---|
282 | function mobileProcess() { |
---|
283 | $objView = new SC_MobileView(); |
---|
284 | $objCustomer = new SC_Customer(); |
---|
285 | $objQuery = new SC_Query(); |
---|
286 | $objDb = new SC_Helper_DB_Ex(); |
---|
287 | |
---|
288 | // パラメータ管理クラス |
---|
289 | $this->objFormParam = new SC_FormParam(); |
---|
290 | // パラメータ情報の初期化 |
---|
291 | $this->lfInitParam(); |
---|
292 | // POST値の取得 |
---|
293 | $this->objFormParam->setParam($_POST); |
---|
294 | |
---|
295 | // ファイル管理クラス |
---|
296 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
297 | // ファイル情報の初期化 |
---|
298 | $this->lfInitFile(); |
---|
299 | |
---|
300 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
301 | |
---|
302 | if(!empty($_POST['mode'])) { |
---|
303 | $tmp_id = $_POST['product_id']; |
---|
304 | } else { |
---|
305 | $tmp_id = $_GET['product_id']; |
---|
306 | } |
---|
307 | |
---|
308 | // ログイン判定 |
---|
309 | if($objCustomer->isLoginSuccess(true)) { |
---|
310 | //お気に入りボタン表示 |
---|
311 | $this->tpl_login = true; |
---|
312 | |
---|
313 | /* 閲覧ログ機能は現在未使用 |
---|
314 | |
---|
315 | $table = "dtb_customer_reading"; |
---|
316 | $where = "customer_id = ? "; |
---|
317 | $arrval[] = $objCustomer->getValue('customer_id'); |
---|
318 | //顧客の閲覧商品数 |
---|
319 | $rpcnt = $objQuery->count($table, $where, $arrval); |
---|
320 | |
---|
321 | //閲覧数が設定数以下 |
---|
322 | if ($rpcnt < CUSTOMER_READING_MAX){ |
---|
323 | //閲覧履歴に新規追加 |
---|
324 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
325 | } else { |
---|
326 | //閲覧履歴の中で一番古いものを削除して新規追加 |
---|
327 | $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?"; |
---|
328 | $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id"))); |
---|
329 | $where = "customer_id = ? AND update_date = ? "; |
---|
330 | $arrval = array($objCustomer->getValue("customer_id"), $old); |
---|
331 | //削除 |
---|
332 | $objQuery->delete($table, $where, $arrval); |
---|
333 | //追加 |
---|
334 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
335 | } |
---|
336 | */ |
---|
337 | } |
---|
338 | |
---|
339 | |
---|
340 | // 規格選択セレクトボックスの作成 |
---|
341 | $this->lfMakeSelectMobile($this, $tmp_id); |
---|
342 | |
---|
343 | // 商品IDをFORM内に保持する。 |
---|
344 | $this->tpl_product_id = $tmp_id; |
---|
345 | |
---|
346 | switch($_POST['mode']) { |
---|
347 | case 'select': |
---|
348 | // 規格1が設定されている場合 |
---|
349 | if($this->tpl_classcat_find1) { |
---|
350 | // templateの変更 |
---|
351 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
352 | break; |
---|
353 | } |
---|
354 | |
---|
355 | case 'select2': |
---|
356 | $this->arrErr = $this->lfCheckError(); |
---|
357 | |
---|
358 | // 規格1が設定されている場合 |
---|
359 | if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { |
---|
360 | // templateの変更 |
---|
361 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
362 | break; |
---|
363 | } |
---|
364 | |
---|
365 | // 規格2が設定されている場合 |
---|
366 | if($this->tpl_classcat_find2) { |
---|
367 | $this->arrErr = array(); |
---|
368 | |
---|
369 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
370 | break; |
---|
371 | } |
---|
372 | |
---|
373 | case 'selectItem': |
---|
374 | $this->arrErr = $this->lfCheckError(); |
---|
375 | |
---|
376 | // 規格1が設定されている場合 |
---|
377 | if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { |
---|
378 | // templateの変更 |
---|
379 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
380 | break; |
---|
381 | } |
---|
382 | // 商品数の選択を行う |
---|
383 | $this->tpl_mainpage = "products/select_item.tpl"; |
---|
384 | break; |
---|
385 | |
---|
386 | case 'cart': |
---|
387 | // 入力値の変換 |
---|
388 | $this->objFormParam->convParam(); |
---|
389 | $this->arrErr = $this->lfCheckError(); |
---|
390 | if(count($this->arrErr) == 0) { |
---|
391 | $objCartSess = new SC_CartSession(); |
---|
392 | $classcategory_id1 = $_POST['classcategory_id1']; |
---|
393 | $classcategory_id2 = $_POST['classcategory_id2']; |
---|
394 | |
---|
395 | // 規格1が設定されていない場合 |
---|
396 | if(!$this->tpl_classcat_find1) { |
---|
397 | $classcategory_id1 = '0'; |
---|
398 | } |
---|
399 | |
---|
400 | // 規格2が設定されていない場合 |
---|
401 | if(!$this->tpl_classcat_find2) { |
---|
402 | $classcategory_id2 = '0'; |
---|
403 | } |
---|
404 | |
---|
405 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
---|
406 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); |
---|
407 | $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true); |
---|
408 | exit; |
---|
409 | } |
---|
410 | break; |
---|
411 | |
---|
412 | default: |
---|
413 | break; |
---|
414 | } |
---|
415 | |
---|
416 | $objQuery = new SC_Query(); |
---|
417 | // DBから商品情報を取得する。 |
---|
418 | $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); |
---|
419 | $this->arrProduct = $arrRet[0]; |
---|
420 | |
---|
421 | // 商品コードの取得 |
---|
422 | $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; |
---|
423 | $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); |
---|
424 | $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); |
---|
425 | $this->arrProductCode = $arrProductCode["product_code"]; |
---|
426 | |
---|
427 | // 購入制限数を取得 |
---|
428 | if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { |
---|
429 | $this->tpl_sale_limit = SALE_LIMIT_MAX; |
---|
430 | } else { |
---|
431 | $this->tpl_sale_limit = $this->arrProduct['sale_limit']; |
---|
432 | } |
---|
433 | |
---|
434 | // サブタイトルを取得 |
---|
435 | $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); |
---|
436 | $tpl_subtitle = $arrFirstCat['name']; |
---|
437 | $this->tpl_subtitle = $tpl_subtitle; |
---|
438 | |
---|
439 | // DBからのデータを引き継ぐ |
---|
440 | $this->objUpFile->setDBFileList($this->arrProduct); |
---|
441 | // ファイル表示用配列を渡す |
---|
442 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); |
---|
443 | // 支払方法の取得 |
---|
444 | $this->arrPayment = $this->lfGetPayment(); |
---|
445 | // 入力情報を渡す |
---|
446 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
447 | //レビュー情報の取得 |
---|
448 | $this->arrReview = $this->lfGetReviewData($tmp_id); |
---|
449 | // タイトルに商品名を入れる |
---|
450 | $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; |
---|
451 | //オススメ商品情報表示 |
---|
452 | $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); |
---|
453 | //この商品を買った人はこんな商品も買っています |
---|
454 | $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); |
---|
455 | |
---|
456 | // 拡大画像のウィンドウサイズをセット |
---|
457 | if (!empty($this->arrFile["main_large_image"])) { |
---|
458 | list($large_width, $large_height) = getimagesize(IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"])); |
---|
459 | } |
---|
460 | $this->tpl_large_width = isset($large_width) ? $large_width + 60 : 0; |
---|
461 | $this->tpl_large_height = isset($large_height) ? $large_height + 80 : 0; |
---|
462 | |
---|
463 | $objView->assignobj($this); |
---|
464 | $objView->display(SITE_FRAME); |
---|
465 | } |
---|
466 | |
---|
467 | /* ファイル情報の初期化 */ |
---|
468 | function lfInitFile() { |
---|
469 | $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
470 | $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
471 | $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT); |
---|
472 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
473 | $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT); |
---|
474 | $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT); |
---|
475 | } |
---|
476 | $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT); |
---|
477 | $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false); |
---|
478 | } |
---|
479 | |
---|
480 | /* 規格選択セレクトボックスの作成 */ |
---|
481 | function lfMakeSelect($product_id) { |
---|
482 | |
---|
483 | $objDb = new SC_Helper_DB_Ex(); |
---|
484 | $classcat_find1 = false; |
---|
485 | $classcat_find2 = false; |
---|
486 | // 在庫ありの商品の有無 |
---|
487 | $stock_find = false; |
---|
488 | |
---|
489 | // 規格名一覧 |
---|
490 | $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); |
---|
491 | // 規格分類名一覧 |
---|
492 | $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
---|
493 | // 商品規格情報の取得 |
---|
494 | $arrProductsClass = $this->lfGetProductsClass($product_id); |
---|
495 | |
---|
496 | // 規格1クラス名の取得 |
---|
497 | $this->tpl_class_name1 = isset($arrClassName[$arrProductsClass[0]['class_id1']]) |
---|
498 | ? $arrClassName[$arrProductsClass[0]['class_id1']] : ""; |
---|
499 | // 規格2クラス名の取得 |
---|
500 | $this->tpl_class_name2 = isset($arrClassName[$arrProductsClass[0]['class_id2']]) |
---|
501 | ? $arrClassName[$arrProductsClass[0]['class_id2']] : ""; |
---|
502 | |
---|
503 | // すべての組み合わせ数 |
---|
504 | $count = count($arrProductsClass); |
---|
505 | |
---|
506 | $classcat_id1 = ""; |
---|
507 | |
---|
508 | $arrSele = array(); |
---|
509 | $arrList = array(); |
---|
510 | |
---|
511 | $list_id = 0; |
---|
512 | $arrList[0] = "\tlist0 = new Array('選択してください'"; |
---|
513 | $arrVal[0] = "\tval0 = new Array(''"; |
---|
514 | |
---|
515 | for ($i = 0; $i < $count; $i++) { |
---|
516 | // 在庫のチェック |
---|
517 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { |
---|
518 | continue; |
---|
519 | } |
---|
520 | |
---|
521 | $stock_find = true; |
---|
522 | |
---|
523 | // 規格1のセレクトボックス用 |
---|
524 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ |
---|
525 | $arrList[$list_id].=");\n"; |
---|
526 | $arrVal[$list_id].=");\n"; |
---|
527 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; |
---|
528 | $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; |
---|
529 | $list_id++; |
---|
530 | } |
---|
531 | |
---|
532 | // 規格2のセレクトボックス用 |
---|
533 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; |
---|
534 | |
---|
535 | // セレクトボックス表示値 |
---|
536 | if (!isset($arrList[$list_id])) $arrList[$list_id] = ""; |
---|
537 | if($arrList[$list_id] == "") { |
---|
538 | $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'"; |
---|
539 | } else { |
---|
540 | $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; |
---|
541 | } |
---|
542 | |
---|
543 | // セレクトボックスPOST値 |
---|
544 | if (!isset($arrVal[$list_id])) $arrVal[$list_id] = ""; |
---|
545 | if($arrVal[$list_id] == "") { |
---|
546 | $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'"; |
---|
547 | } else { |
---|
548 | $arrVal[$list_id].= ", '".$classcat_id2."'"; |
---|
549 | } |
---|
550 | } |
---|
551 | |
---|
552 | $arrList[$list_id].=");\n"; |
---|
553 | $arrVal[$list_id].=");\n"; |
---|
554 | |
---|
555 | // 規格1 |
---|
556 | $this->arrClassCat1 = $arrSele; |
---|
557 | |
---|
558 | $lists = "\tlists = new Array("; |
---|
559 | $no = 0; |
---|
560 | |
---|
561 | foreach($arrList as $val) { |
---|
562 | $this->tpl_javascript.= $val; |
---|
563 | if ($no != 0) { |
---|
564 | $lists.= ",list".$no; |
---|
565 | } else { |
---|
566 | $lists.= "list".$no; |
---|
567 | } |
---|
568 | $no++; |
---|
569 | } |
---|
570 | $this->tpl_javascript.=$lists.");\n"; |
---|
571 | |
---|
572 | $vals = "\tvals = new Array("; |
---|
573 | $no = 0; |
---|
574 | |
---|
575 | foreach($arrVal as $val) { |
---|
576 | $this->tpl_javascript.= $val; |
---|
577 | if ($no != 0) { |
---|
578 | $vals.= ",val".$no; |
---|
579 | } else { |
---|
580 | $vals.= "val".$no; |
---|
581 | } |
---|
582 | $no++; |
---|
583 | } |
---|
584 | $this->tpl_javascript.=$vals.");\n"; |
---|
585 | |
---|
586 | // 選択されている規格2ID |
---|
587 | if (!isset($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = ""; |
---|
588 | $this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');"; |
---|
589 | |
---|
590 | // 規格1が設定されている |
---|
591 | if($arrProductsClass[0]['classcategory_id1'] != '0') { |
---|
592 | $classcat_find1 = true; |
---|
593 | } |
---|
594 | |
---|
595 | // 規格2が設定されている |
---|
596 | if($arrProductsClass[0]['classcategory_id2'] != '0') { |
---|
597 | $classcat_find2 = true; |
---|
598 | } |
---|
599 | |
---|
600 | $this->tpl_classcat_find1 = $classcat_find1; |
---|
601 | $this->tpl_classcat_find2 = $classcat_find2; |
---|
602 | $this->tpl_stock_find = $stock_find; |
---|
603 | } |
---|
604 | |
---|
605 | /* 規格選択セレクトボックスの作成 |
---|
606 | * FIXME 要リファクタリング |
---|
607 | */ |
---|
608 | function lfMakeSelectMobile(&$objPage, $product_id) { |
---|
609 | |
---|
610 | $objDb = new SC_Helper_DB_Ex(); |
---|
611 | $classcat_find1 = false; |
---|
612 | $classcat_find2 = false; |
---|
613 | // 在庫ありの商品の有無 |
---|
614 | $stock_find = false; |
---|
615 | |
---|
616 | // 規格名一覧 |
---|
617 | $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); |
---|
618 | // 規格分類名一覧 |
---|
619 | $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
---|
620 | // 商品規格情報の取得 |
---|
621 | $arrProductsClass = $this->lfGetProductsClass($product_id); |
---|
622 | |
---|
623 | // 規格1クラス名の取得 |
---|
624 | $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']]; |
---|
625 | // 規格2クラス名の取得 |
---|
626 | $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']]; |
---|
627 | |
---|
628 | // すべての組み合わせ数 |
---|
629 | $count = count($arrProductsClass); |
---|
630 | |
---|
631 | $classcat_id1 = ""; |
---|
632 | |
---|
633 | $arrSele1 = array(); |
---|
634 | $arrSele2 = array(); |
---|
635 | |
---|
636 | for ($i = 0; $i < $count; $i++) { |
---|
637 | // 在庫のチェック |
---|
638 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { |
---|
639 | continue; |
---|
640 | } |
---|
641 | |
---|
642 | $stock_find = true; |
---|
643 | |
---|
644 | // 規格1のセレクトボックス用 |
---|
645 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ |
---|
646 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; |
---|
647 | $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1]; |
---|
648 | } |
---|
649 | |
---|
650 | // 規格2のセレクトボックス用 |
---|
651 | if($arrProductsClass[$i]['classcategory_id1'] == $_POST['classcategory_id1'] and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) { |
---|
652 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; |
---|
653 | $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2]; |
---|
654 | } |
---|
655 | } |
---|
656 | |
---|
657 | // 規格1 |
---|
658 | $objPage->arrClassCat1 = $arrSele1; |
---|
659 | $objPage->arrClassCat2 = $arrSele2; |
---|
660 | |
---|
661 | // 規格1が設定されている |
---|
662 | if($arrProductsClass[0]['classcategory_id1'] != '0') { |
---|
663 | $classcat_find1 = true; |
---|
664 | } |
---|
665 | |
---|
666 | // 規格2が設定されている |
---|
667 | if($arrProductsClass[0]['classcategory_id2'] != '0') { |
---|
668 | $classcat_find2 = true; |
---|
669 | } |
---|
670 | |
---|
671 | $objPage->tpl_classcat_find1 = $classcat_find1; |
---|
672 | $objPage->tpl_classcat_find2 = $classcat_find2; |
---|
673 | $objPage->tpl_stock_find = $stock_find; |
---|
674 | } |
---|
675 | |
---|
676 | /* パラメータ情報の初期化 */ |
---|
677 | function lfInitParam() { |
---|
678 | $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
679 | $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
680 | $this->objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
681 | } |
---|
682 | |
---|
683 | /* 商品規格情報の取得 */ |
---|
684 | function lfGetProductsClass($product_id) { |
---|
685 | $arrRet = array(); |
---|
686 | if(SC_Utils_Ex::sfIsInt($product_id)) { |
---|
687 | // 商品規格取得 |
---|
688 | $objQuery = new SC_Query(); |
---|
689 | $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; |
---|
690 | $table = "vw_product_class AS prdcls"; |
---|
691 | $where = "product_id = ?"; |
---|
692 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
---|
693 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
694 | } |
---|
695 | return $arrRet; |
---|
696 | } |
---|
697 | |
---|
698 | /* 登録済みオススメ商品の読み込み */ |
---|
699 | function lfPreGetRecommendProducts($product_id) { |
---|
700 | $arrRecommend = array(); |
---|
701 | $objQuery = new SC_Query(); |
---|
702 | $objQuery->setorder("rank DESC"); |
---|
703 | $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
704 | $max = count($arrRet); |
---|
705 | $no = 0; |
---|
706 | $from = "vw_products_allclass AS T1 " |
---|
707 | . " JOIN (" |
---|
708 | . " SELECT max(T2.rank) AS product_rank, " |
---|
709 | . " T2.product_id" |
---|
710 | . " FROM dtb_product_categories T2 " |
---|
711 | . " GROUP BY product_id) AS T3 USING (product_id)"; |
---|
712 | $objQuery->setorder("product_rank DESC"); |
---|
713 | for($i = 0; $i < $max; $i++) { |
---|
714 | $where = "del_flg = 0 AND product_id = ? AND status = 1"; |
---|
715 | $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate, product_rank", $from, $where, array($arrRet[$i]['recommend_product_id'])); |
---|
716 | |
---|
717 | if(count($arrProductInfo) > 0) { |
---|
718 | $arrRecommend[$no] = $arrProductInfo[0]; |
---|
719 | $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id']; |
---|
720 | $arrRecommend[$no]['comment'] = $arrRet[$i]['comment']; |
---|
721 | $no++; |
---|
722 | } |
---|
723 | } |
---|
724 | return $arrRecommend; |
---|
725 | } |
---|
726 | |
---|
727 | /* 入力内容のチェック */ |
---|
728 | function lfCheckError() { |
---|
729 | // 入力データを渡す。 |
---|
730 | $arrRet = $this->objFormParam->getHashArray(); |
---|
731 | $objErr = new SC_CheckError($arrRet); |
---|
732 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
733 | |
---|
734 | // 複数項目チェック |
---|
735 | if ($this->tpl_classcat_find1) { |
---|
736 | $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); |
---|
737 | } |
---|
738 | if ($this->tpl_classcat_find2) { |
---|
739 | $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); |
---|
740 | } |
---|
741 | |
---|
742 | return $objErr->arrErr; |
---|
743 | } |
---|
744 | |
---|
745 | //閲覧履歴新規登録 |
---|
746 | function lfRegistReadingData($tmp_id, $customer_id){ |
---|
747 | $objQuery = new SC_Query; |
---|
748 | $sqlval['customer_id'] = $customer_id; |
---|
749 | $sqlval['reading_product_id'] = $tmp_id; |
---|
750 | $sqlval['create_date'] = 'NOW()'; |
---|
751 | $sqlval['update_date'] = 'NOW()'; |
---|
752 | $objQuery->insert("dtb_customer_reading", $sqlval); |
---|
753 | } |
---|
754 | |
---|
755 | //この商品を買った人はこんな商品も買っています FIXME |
---|
756 | function lfGetRelateProducts($tmp_id) { |
---|
757 | $objQuery = new SC_Query; |
---|
758 | //自動抽出 |
---|
759 | $objQuery->setorder("random()"); |
---|
760 | //表示件数の制限 |
---|
761 | $objQuery->setlimit(RELATED_PRODUCTS_MAX); |
---|
762 | //検索条件 |
---|
763 | $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate"; |
---|
764 | $from = "vw_products_allclass AS allcls "; |
---|
765 | $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? "; |
---|
766 | $arrval[] = $tmp_id; |
---|
767 | //結果の取得 |
---|
768 | $arrProducts = $objQuery->select($col, $from, $where, $arrval); |
---|
769 | |
---|
770 | return $arrProducts; |
---|
771 | } |
---|
772 | |
---|
773 | //商品ごとのレビュー情報を取得する |
---|
774 | function lfGetReviewData($id) { |
---|
775 | $objQuery = new SC_Query; |
---|
776 | //商品ごとのレビュー情報を取得する |
---|
777 | $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment"; |
---|
778 | $from = "dtb_review"; |
---|
779 | $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX; |
---|
780 | $arrval[] = $id; |
---|
781 | $arrReview = $objQuery->select($col, $from, $where, $arrval); |
---|
782 | return $arrReview; |
---|
783 | } |
---|
784 | |
---|
785 | /* |
---|
786 | * 商品ごとのトラックバック情報を取得する |
---|
787 | * |
---|
788 | * @param $product_id |
---|
789 | * @return $arrTrackback |
---|
790 | */ |
---|
791 | function lfGetTrackbackData($product_id) { |
---|
792 | |
---|
793 | $arrTrackback = array(); |
---|
794 | |
---|
795 | $objQuery = new SC_Query; |
---|
796 | //商品ごとのトラックバック情報を取得する |
---|
797 | $col = "blog_name, url, title, excerpt, title, create_date"; |
---|
798 | $from = "dtb_trackback"; |
---|
799 | $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX; |
---|
800 | $arrval[] = $product_id; |
---|
801 | $arrTrackback = $objQuery->select($col, $from, $where, $arrval); |
---|
802 | return $arrTrackback; |
---|
803 | } |
---|
804 | |
---|
805 | //支払方法の取得 |
---|
806 | //payment_id 1:クレジット 2:ショッピングローン |
---|
807 | function lfGetPayment() { |
---|
808 | $objQuery = new SC_Query; |
---|
809 | $col = "payment_id, rule, payment_method"; |
---|
810 | $from = "dtb_payment"; |
---|
811 | $where = "del_flg = 0"; |
---|
812 | $order = "payment_id"; |
---|
813 | $objQuery->setorder($order); |
---|
814 | $arrRet = $objQuery->select($col, $from, $where); |
---|
815 | return $arrRet; |
---|
816 | } |
---|
817 | |
---|
818 | function lfConvertParam() { |
---|
819 | if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = ""; |
---|
820 | $value = $this->arrForm['quantity']['value']; |
---|
821 | $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE); |
---|
822 | } |
---|
823 | } |
---|
824 | ?> |
---|