1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
26 | |
---|
27 | if (file_exists(MODULE_REALDIR . "mdl_gmopg/inc/function.php")) { |
---|
28 | require_once MODULE_REALDIR . '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_Products_Detail extends LC_Page_Ex { |
---|
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 | var $mode; |
---|
59 | |
---|
60 | // }}} |
---|
61 | // {{{ functions |
---|
62 | |
---|
63 | /** |
---|
64 | * Page を初期化する. |
---|
65 | * |
---|
66 | * @return void |
---|
67 | */ |
---|
68 | function init() { |
---|
69 | parent::init(); |
---|
70 | $masterData = new SC_DB_MasterData_Ex(); |
---|
71 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
72 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
73 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
74 | $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend"); |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * Page のプロセス. |
---|
79 | * |
---|
80 | * @return void |
---|
81 | */ |
---|
82 | function process() { |
---|
83 | parent::process(); |
---|
84 | $this->action(); |
---|
85 | $this->sendResponse(); |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * Page のAction. |
---|
90 | * |
---|
91 | * @return void |
---|
92 | */ |
---|
93 | function action() { |
---|
94 | // 会員クラス |
---|
95 | $objCustomer = new SC_Customer_Ex(); |
---|
96 | |
---|
97 | // パラメーター管理クラス |
---|
98 | $this->objFormParam = new SC_FormParam_Ex(); |
---|
99 | // パラメーター情報の初期化 |
---|
100 | $this->arrForm = $this->lfInitParam($this->objFormParam); |
---|
101 | // ファイル管理クラス |
---|
102 | $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
103 | // ファイル情報の初期化 |
---|
104 | $this->objUpFile = $this->lfInitFile($this->objUpFile); |
---|
105 | |
---|
106 | // プロダクトIDの正当性チェック |
---|
107 | $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'),$this->objFormParam->getValue('product_id')); |
---|
108 | $this->mode = $this->getMode(); |
---|
109 | |
---|
110 | // 規格選択セレクトボックスの作成 |
---|
111 | $this->js_lnOnload .= $this->lfMakeSelect(); |
---|
112 | |
---|
113 | $objProduct = new SC_Product_Ex(); |
---|
114 | $objProduct->setProductsClassByProductIds(array($product_id)); |
---|
115 | |
---|
116 | // 規格1クラス名 |
---|
117 | $this->tpl_class_name1 = $objProduct->className1[$product_id]; |
---|
118 | |
---|
119 | // 規格2クラス名 |
---|
120 | $this->tpl_class_name2 = $objProduct->className2[$product_id]; |
---|
121 | |
---|
122 | // 規格1 |
---|
123 | $this->arrClassCat1 = $objProduct->classCats1[$product_id]; |
---|
124 | |
---|
125 | // 規格1が設定されている |
---|
126 | $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; |
---|
127 | // 規格2が設定されている |
---|
128 | $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; |
---|
129 | |
---|
130 | $this->tpl_stock_find = $objProduct->stock_find[$product_id]; |
---|
131 | $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id']; |
---|
132 | $this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type']; |
---|
133 | |
---|
134 | $this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';'; |
---|
135 | $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}'; |
---|
136 | $this->tpl_onload .= 'lnOnLoad();'; |
---|
137 | |
---|
138 | // モバイル用 規格選択セレクトボックスの作成 |
---|
139 | if(SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
140 | $this->lfMakeSelectMobile($this, $product_id,$this->objFormParam->getValue('classcategory_id1')); |
---|
141 | } |
---|
142 | |
---|
143 | // 商品IDをFORM内に保持する |
---|
144 | $this->tpl_product_id = $product_id; |
---|
145 | |
---|
146 | switch ($this->mode) { |
---|
147 | case 'cart': |
---|
148 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam, |
---|
149 | $this->tpl_classcat_find1, |
---|
150 | $this->tpl_classcat_find2); |
---|
151 | if (count($this->arrErr) == 0) { |
---|
152 | $objCartSess = new SC_CartSession_Ex(); |
---|
153 | $product_class_id = $this->objFormParam->getValue('product_class_id'); |
---|
154 | |
---|
155 | $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); |
---|
156 | |
---|
157 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
158 | exit; |
---|
159 | } |
---|
160 | break; |
---|
161 | case "add_favorite": |
---|
162 | // ログイン中のユーザが商品をお気に入りにいれる処理 |
---|
163 | if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0 ) { |
---|
164 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); |
---|
165 | if(count($this->arrErr) == 0){ |
---|
166 | if(!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))){ |
---|
167 | exit; |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | break; |
---|
172 | |
---|
173 | case "add_favorite_sphone": |
---|
174 | // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) |
---|
175 | if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0 ) { |
---|
176 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); |
---|
177 | if(count($this->arrErr) == 0){ |
---|
178 | if($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))){ |
---|
179 | print "true"; |
---|
180 | exit; |
---|
181 | } |
---|
182 | } |
---|
183 | print "error"; |
---|
184 | exit; |
---|
185 | } |
---|
186 | break; |
---|
187 | |
---|
188 | default: |
---|
189 | // カート「戻るボタン」用に保持 |
---|
190 | $netURL = new Net_URL(); |
---|
191 | $_SESSION['cart_referer_url'] = $netURL->getURL(); |
---|
192 | break; |
---|
193 | } |
---|
194 | |
---|
195 | // モバイル用 ポストバック処理 |
---|
196 | if(SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
197 | switch($this->mode) { |
---|
198 | case 'select': |
---|
199 | // 規格1が設定されている場合 |
---|
200 | if($this->tpl_classcat_find1) { |
---|
201 | // templateの変更 |
---|
202 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
203 | break; |
---|
204 | } |
---|
205 | |
---|
206 | case 'select2': |
---|
207 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); |
---|
208 | |
---|
209 | // 規格1が設定されていて、エラーを検出した場合 |
---|
210 | if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { |
---|
211 | // templateの変更 |
---|
212 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
213 | break; |
---|
214 | } |
---|
215 | |
---|
216 | // 規格2が設定されている場合 |
---|
217 | if($this->tpl_classcat_find2) { |
---|
218 | $this->arrErr = array(); |
---|
219 | |
---|
220 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
221 | break; |
---|
222 | } |
---|
223 | |
---|
224 | case 'selectItem': |
---|
225 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); |
---|
226 | |
---|
227 | // 規格2が設定されていて、エラーを検出した場合 |
---|
228 | if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { |
---|
229 | // templateの変更 |
---|
230 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
231 | break; |
---|
232 | } |
---|
233 | |
---|
234 | $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$this->objFormParam->getValue('classcategory_id1')]['#' . $this->objFormParam->getValue('classcategory_id2')]['product_class_id']; |
---|
235 | |
---|
236 | // 数量の入力を行う |
---|
237 | $this->tpl_mainpage = "products/select_item.tpl"; |
---|
238 | break; |
---|
239 | |
---|
240 | default: |
---|
241 | $this->tpl_mainpage = "products/detail.tpl"; |
---|
242 | break; |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | // 商品詳細を取得 |
---|
247 | $this->arrProduct = $objProduct->getDetail($product_id); |
---|
248 | |
---|
249 | // サブタイトルを取得 |
---|
250 | $this->tpl_subtitle = $this->arrProduct['name']; |
---|
251 | |
---|
252 | // 関連カテゴリを取得 |
---|
253 | $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); |
---|
254 | |
---|
255 | // 商品ステータスを取得 |
---|
256 | $this->productStatus = $objProduct->getProductStatus($product_id); |
---|
257 | |
---|
258 | // 画像ファイル指定がない場合の置換処理 |
---|
259 | $this->arrProduct['main_image'] |
---|
260 | = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); |
---|
261 | |
---|
262 | $this->subImageFlag = $this->lfSetFile($this->objUpFile,$this->arrProduct,$this->arrFile); |
---|
263 | //レビュー情報の取得 |
---|
264 | $this->arrReview = $this->lfGetReviewData($product_id); |
---|
265 | |
---|
266 | //関連商品情報表示 |
---|
267 | $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); |
---|
268 | |
---|
269 | // ログイン判定 |
---|
270 | if ($objCustomer->isLoginSuccess() === true) { |
---|
271 | //お気に入りボタン表示 |
---|
272 | $this->tpl_login = true; |
---|
273 | $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id)); |
---|
274 | } |
---|
275 | |
---|
276 | } |
---|
277 | |
---|
278 | /** |
---|
279 | * デストラクタ. |
---|
280 | * |
---|
281 | * @return void |
---|
282 | */ |
---|
283 | function destroy() { |
---|
284 | parent::destroy(); |
---|
285 | } |
---|
286 | |
---|
287 | /* プロダクトIDの正当性チェック */ |
---|
288 | function lfCheckProductId($admin_mode,$product_id) { |
---|
289 | // 管理機能からの確認の場合は、非公開の商品も表示する。 |
---|
290 | if (isset($admin_mode) && $admin_mode == 'on') { |
---|
291 | SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex()); |
---|
292 | $status = true; |
---|
293 | $where = 'del_flg = 0'; |
---|
294 | } else { |
---|
295 | $status = false; |
---|
296 | $where = 'del_flg = 0 AND status = 1'; |
---|
297 | } |
---|
298 | |
---|
299 | if(!SC_Utils_Ex::sfIsInt($product_id) |
---|
300 | || SC_Utils_Ex::sfIsZeroFilling($product_id) |
---|
301 | || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where)) |
---|
302 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
303 | return $product_id; |
---|
304 | } |
---|
305 | |
---|
306 | /* ファイル情報の初期化 */ |
---|
307 | function lfInitFile($objUpFile) { |
---|
308 | $objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE); |
---|
309 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
310 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE); |
---|
311 | } |
---|
312 | return $objUpFile; |
---|
313 | } |
---|
314 | |
---|
315 | /* 規格選択セレクトボックスの作成 */ |
---|
316 | function lfMakeSelect() { |
---|
317 | return 'fnSetClassCategories(' |
---|
318 | . 'document.form1, ' |
---|
319 | . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2')) |
---|
320 | . '); '; |
---|
321 | } |
---|
322 | |
---|
323 | /* 規格選択セレクトボックスの作成(モバイル) */ |
---|
324 | function lfMakeSelectMobile(&$objPage, $product_id,$request_classcategory_id1) { |
---|
325 | |
---|
326 | $classcat_find1 = false; |
---|
327 | $classcat_find2 = false; |
---|
328 | // 在庫ありの商品の有無 |
---|
329 | $stock_find = false; |
---|
330 | |
---|
331 | // 規格名一覧 |
---|
332 | $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_class", "class_id", 'name'); |
---|
333 | // 規格分類名一覧 |
---|
334 | $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_classcategory", "classcategory_id", 'name'); |
---|
335 | // 商品規格情報の取得 |
---|
336 | $arrProductsClass = $this->lfGetProductsClass($product_id); |
---|
337 | |
---|
338 | // 規格1クラス名の取得 |
---|
339 | $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']]; |
---|
340 | // 規格2クラス名の取得 |
---|
341 | $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']]; |
---|
342 | |
---|
343 | // すべての組み合わせ数 |
---|
344 | $count = count($arrProductsClass); |
---|
345 | |
---|
346 | $classcat_id1 = ""; |
---|
347 | |
---|
348 | $arrSele1 = array(); |
---|
349 | $arrSele2 = array(); |
---|
350 | |
---|
351 | for ($i = 0; $i < $count; $i++) { |
---|
352 | // 在庫のチェック |
---|
353 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { |
---|
354 | continue; |
---|
355 | } |
---|
356 | |
---|
357 | $stock_find = true; |
---|
358 | |
---|
359 | // 規格1のセレクトボックス用 |
---|
360 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ |
---|
361 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; |
---|
362 | $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1]; |
---|
363 | } |
---|
364 | |
---|
365 | // 規格2のセレクトボックス用 |
---|
366 | if($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) { |
---|
367 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; |
---|
368 | $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2]; |
---|
369 | } |
---|
370 | } |
---|
371 | |
---|
372 | // 規格1 |
---|
373 | $objPage->arrClassCat1 = $arrSele1; |
---|
374 | $objPage->arrClassCat2 = $arrSele2; |
---|
375 | |
---|
376 | // 規格1が設定されている |
---|
377 | if(isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') { |
---|
378 | $classcat_find1 = true; |
---|
379 | } |
---|
380 | |
---|
381 | // 規格2が設定されている |
---|
382 | if(isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') { |
---|
383 | $classcat_find2 = true; |
---|
384 | } |
---|
385 | |
---|
386 | $objPage->tpl_classcat_find1 = $classcat_find1; |
---|
387 | $objPage->tpl_classcat_find2 = $classcat_find2; |
---|
388 | $objPage->tpl_stock_find = $stock_find; |
---|
389 | } |
---|
390 | |
---|
391 | /* パラメーター情報の初期化 */ |
---|
392 | function lfInitParam(&$objFormParam) { |
---|
393 | $objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
394 | $objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
395 | $objFormParam->addParam("数量", 'quantity', INT_LEN, 'n', array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
396 | $objFormParam->addParam("管理者ログイン", 'admin', INT_LEN, 'a', array('ALNUM_CHECK',"MAX_LENGTH_CHECK")); |
---|
397 | $objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
398 | $objFormParam->addParam("お気に入り商品ID", "favorite_product_id", INT_LEN, 'n', array("ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
399 | $objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
400 | // 値の取得 |
---|
401 | $objFormParam->setParam($_REQUEST); |
---|
402 | // 入力値の変換 |
---|
403 | $objFormParam->convParam(); |
---|
404 | // 入力情報を渡す |
---|
405 | return $objFormParam->getFormParamList(); |
---|
406 | } |
---|
407 | |
---|
408 | /* 商品規格情報の取得 */ |
---|
409 | function lfGetProductsClass($product_id) { |
---|
410 | $objProduct = new SC_Product_Ex(); |
---|
411 | return $objProduct->getProductsClassFullByProductId($product_id); |
---|
412 | } |
---|
413 | |
---|
414 | /* 登録済み関連商品の読み込み */ |
---|
415 | function lfPreGetRecommendProducts($product_id) { |
---|
416 | $arrRecommend = array(); |
---|
417 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
418 | $objQuery->setOrder("rank DESC"); |
---|
419 | $arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
420 | |
---|
421 | $arrRecommendProductId = array(); |
---|
422 | foreach($arrRecommendData as $recommend){ |
---|
423 | $arrRecommendProductId[] = $recommend["recommend_product_id"]; |
---|
424 | $arrRecommendData[$recommend["recommend_product_id"]] = $recommend['comment']; |
---|
425 | } |
---|
426 | |
---|
427 | $objProduct = new SC_Product_Ex(); |
---|
428 | |
---|
429 | $where = ""; |
---|
430 | if (!empty($arrRecommendProductId)) { |
---|
431 | $where = 'product_id IN (' . implode(',', $arrRecommendProductId) . ')'; |
---|
432 | } else { |
---|
433 | return $arrRecommend; |
---|
434 | } |
---|
435 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
436 | $objQuery->setWhere($where); |
---|
437 | $arrProducts = $objProduct->lists($objQuery, $arrRecommendProductId); |
---|
438 | |
---|
439 | //取得している並び順で並び替え |
---|
440 | // FIXME SC_Productあたりにソート処理はもってくべき |
---|
441 | $arrProducts2 = array(); |
---|
442 | foreach($arrProducts as $item) { |
---|
443 | $arrProducts2[ $item['product_id'] ] = $item; |
---|
444 | } |
---|
445 | $arrProducts = array(); |
---|
446 | foreach($arrRecommendProductId as $product_id) { |
---|
447 | $arrProducts2[$product_id]['comment'] = $arrRecommendData[$product_id]; |
---|
448 | $arrRecommend[] = $arrProducts2[$product_id]; |
---|
449 | } |
---|
450 | |
---|
451 | return $arrRecommend; |
---|
452 | } |
---|
453 | |
---|
454 | /* 入力内容のチェック */ |
---|
455 | function lfCheckError($mode,&$objFormParam,$tpl_classcat_find1 = null ,$tpl_classcat_find2 = null) { |
---|
456 | |
---|
457 | switch ($mode) { |
---|
458 | case 'add_favorite_sphone': |
---|
459 | case 'add_favorite': |
---|
460 | $objCustomer = new SC_Customer_Ex(); |
---|
461 | $objErr = new SC_CheckError_Ex(); |
---|
462 | $customer_id = $objCustomer->getValue('customer_id'); |
---|
463 | if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { |
---|
464 | $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; |
---|
465 | } |
---|
466 | break; |
---|
467 | default: |
---|
468 | // 入力データを渡す。 |
---|
469 | $arrRet = $objFormParam->getHashArray(); |
---|
470 | $objErr = new SC_CheckError_Ex($arrRet); |
---|
471 | $objErr->arrErr = $objFormParam->checkError(); |
---|
472 | |
---|
473 | // 複数項目チェック |
---|
474 | if ($tpl_classcat_find1) { |
---|
475 | $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); |
---|
476 | } |
---|
477 | if ($tpl_classcat_find2) { |
---|
478 | $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); |
---|
479 | } |
---|
480 | break; |
---|
481 | } |
---|
482 | |
---|
483 | return $objErr->arrErr; |
---|
484 | } |
---|
485 | |
---|
486 | //商品ごとのレビュー情報を取得する |
---|
487 | function lfGetReviewData($id) { |
---|
488 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
489 | //商品ごとのレビュー情報を取得する |
---|
490 | $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment"; |
---|
491 | $from = "dtb_review"; |
---|
492 | $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX; |
---|
493 | $arrval[] = $id; |
---|
494 | $arrReview = $objQuery->select($col, $from, $where, $arrval); |
---|
495 | return $arrReview; |
---|
496 | } |
---|
497 | |
---|
498 | /* |
---|
499 | * ファイルの情報をセットする |
---|
500 | * @return $subImageFlag |
---|
501 | */ |
---|
502 | function lfSetFile($objUpFile,$arrProduct,&$arrFile) { |
---|
503 | // DBからのデータを引き継ぐ |
---|
504 | $objUpFile->setDBFileList($arrProduct); |
---|
505 | // ファイル表示用配列を渡す |
---|
506 | $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true); |
---|
507 | |
---|
508 | // サブ画像の有無を判定 |
---|
509 | $subImageFlag = false; |
---|
510 | for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { |
---|
511 | if ($arrFile["sub_image" . $i]['filepath'] != "") { |
---|
512 | $subImageFlag = true; |
---|
513 | } |
---|
514 | } |
---|
515 | return $subImageFlag; |
---|
516 | } |
---|
517 | |
---|
518 | /* |
---|
519 | * お気に入り商品登録 |
---|
520 | * @return void |
---|
521 | */ |
---|
522 | function lfRegistFavoriteProduct($favorite_product_id,$customer_id) { |
---|
523 | // ログイン中のユーザが商品をお気に入りにいれる処理 |
---|
524 | if(!SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $favorite_product_id, "del_flg = 0 AND status = 1")) { |
---|
525 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
526 | return false; |
---|
527 | } else { |
---|
528 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
529 | $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $favorite_product_id)); |
---|
530 | |
---|
531 | if ($count == 0) { |
---|
532 | $sqlval['customer_id'] = $customer_id; |
---|
533 | $sqlval['product_id'] = $favorite_product_id; |
---|
534 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
535 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
536 | |
---|
537 | $objQuery->begin(); |
---|
538 | $objQuery->insert('dtb_customer_favorite_products', $sqlval); |
---|
539 | $objQuery->commit(); |
---|
540 | } |
---|
541 | // お気に入りに登録したことを示すフラグ |
---|
542 | $this->just_added_favorite = true; |
---|
543 | return true; |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | ?> |
---|