| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2013 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 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
| 25 | |
---|
| 26 | if (file_exists(MODULE_REALDIR . 'mdl_gmopg/inc/function.php')) { |
---|
| 27 | require_once MODULE_REALDIR . 'mdl_gmopg/inc/function.php'; |
---|
| 28 | } |
---|
| 29 | /** |
---|
| 30 | * 商品詳細 のページクラス. |
---|
| 31 | * |
---|
| 32 | * @package Page |
---|
| 33 | * @author LOCKON CO.,LTD. |
---|
| 34 | * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
| 35 | */ |
---|
| 36 | class LC_Page_Products_Detail extends LC_Page_Ex |
---|
| 37 | { |
---|
| 38 | /** 商品ステータス */ |
---|
| 39 | public $arrSTATUS; |
---|
| 40 | |
---|
| 41 | /** 商品ステータス画像 */ |
---|
| 42 | public $arrSTATUS_IMAGE; |
---|
| 43 | |
---|
| 44 | /** 発送予定日 */ |
---|
| 45 | public $arrDELIVERYDATE; |
---|
| 46 | |
---|
| 47 | /** おすすめレベル */ |
---|
| 48 | public $arrRECOMMEND; |
---|
| 49 | |
---|
| 50 | /** フォームパラメーター */ |
---|
| 51 | public $objFormParam; |
---|
| 52 | |
---|
| 53 | /** アップロードファイル */ |
---|
| 54 | public $objUpFile; |
---|
| 55 | |
---|
| 56 | /** モード */ |
---|
| 57 | public $mode; |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * Page を初期化する. |
---|
| 61 | * |
---|
| 62 | * @return void |
---|
| 63 | */ |
---|
| 64 | public function init() |
---|
| 65 | { |
---|
| 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 | // POST に限定する mode |
---|
| 74 | $this->arrLimitPostMode[] = 'cart'; |
---|
| 75 | $this->arrLimitPostMode[] = 'add_favorite'; |
---|
| 76 | $this->arrLimitPostMode[] = 'add_favorite_sphone'; |
---|
| 77 | $this->arrLimitPostMode[] = 'select'; |
---|
| 78 | $this->arrLimitPostMode[] = 'select2'; |
---|
| 79 | $this->arrLimitPostMode[] = 'selectItem'; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * Page のプロセス. |
---|
| 84 | * |
---|
| 85 | * @return void |
---|
| 86 | */ |
---|
| 87 | public function process() |
---|
| 88 | { |
---|
| 89 | parent::process(); |
---|
| 90 | $this->action(); |
---|
| 91 | $this->sendResponse(); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /** |
---|
| 95 | * Page のAction. |
---|
| 96 | * |
---|
| 97 | * @return void |
---|
| 98 | */ |
---|
| 99 | public function action() |
---|
| 100 | { |
---|
| 101 | //決済処理中ステータスのロールバック |
---|
| 102 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 103 | $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); |
---|
| 104 | |
---|
| 105 | // 会員クラス |
---|
| 106 | $objCustomer = new SC_Customer_Ex(); |
---|
| 107 | |
---|
| 108 | // パラメーター管理クラス |
---|
| 109 | $this->objFormParam = new SC_FormParam_Ex(); |
---|
| 110 | // パラメーター情報の初期化 |
---|
| 111 | $this->arrForm = $this->lfInitParam($this->objFormParam); |
---|
| 112 | // ファイル管理クラス |
---|
| 113 | $this->objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
| 114 | // ファイル情報の初期化 |
---|
| 115 | $this->objUpFile = $this->lfInitFile($this->objUpFile); |
---|
| 116 | |
---|
| 117 | // プロダクトIDの正当性チェック |
---|
| 118 | $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'), $this->objFormParam->getValue('product_id')); |
---|
| 119 | $this->mode = $this->getMode(); |
---|
| 120 | |
---|
| 121 | $objProduct = new SC_Product_Ex(); |
---|
| 122 | $objProduct->setProductsClassByProductIds(array($product_id)); |
---|
| 123 | |
---|
| 124 | // 規格1クラス名 |
---|
| 125 | $this->tpl_class_name1 = $objProduct->className1[$product_id]; |
---|
| 126 | |
---|
| 127 | // 規格2クラス名 |
---|
| 128 | $this->tpl_class_name2 = $objProduct->className2[$product_id]; |
---|
| 129 | |
---|
| 130 | // 規格1 |
---|
| 131 | $this->arrClassCat1 = $objProduct->classCats1[$product_id]; |
---|
| 132 | |
---|
| 133 | // 規格1が設定されている |
---|
| 134 | $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; |
---|
| 135 | // 規格2が設定されている |
---|
| 136 | $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; |
---|
| 137 | |
---|
| 138 | $this->tpl_stock_find = $objProduct->stock_find[$product_id]; |
---|
| 139 | $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_class_id']; |
---|
| 140 | $this->tpl_product_type = $objProduct->classCategories[$product_id]['__unselected']['__unselected']['product_type']; |
---|
| 141 | |
---|
| 142 | // 在庫が無い場合は、OnLoadしない。(javascriptエラー防止) |
---|
| 143 | if ($this->tpl_stock_find) { |
---|
| 144 | // 規格選択セレクトボックスの作成 |
---|
| 145 | $this->js_lnOnload .= $this->lfMakeSelect(); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | $this->tpl_javascript .= 'eccube.classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';'; |
---|
| 149 | $this->tpl_javascript .= 'function lnOnLoad() |
---|
| 150 | {' . $this->js_lnOnload . '}'; |
---|
| 151 | $this->tpl_onload .= 'lnOnLoad();'; |
---|
| 152 | |
---|
| 153 | // モバイル用 規格選択セレクトボックスの作成 |
---|
| 154 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
| 155 | $this->lfMakeSelectMobile($this, $product_id, $this->objFormParam->getValue('classcategory_id1')); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | // 商品IDをFORM内に保持する |
---|
| 159 | $this->tpl_product_id = $product_id; |
---|
| 160 | |
---|
| 161 | switch ($this->mode) { |
---|
| 162 | case 'cart': |
---|
| 163 | $this->doCart(); |
---|
| 164 | break; |
---|
| 165 | |
---|
| 166 | case 'add_favorite': |
---|
| 167 | $this->doAddFavorite($objCustomer); |
---|
| 168 | break; |
---|
| 169 | |
---|
| 170 | case 'add_favorite_sphone': |
---|
| 171 | $this->doAddFavoriteSphone($objCustomer); |
---|
| 172 | break; |
---|
| 173 | |
---|
| 174 | case 'select': |
---|
| 175 | case 'select2': |
---|
| 176 | case 'selectItem': |
---|
| 177 | /** |
---|
| 178 | * モバイルの数量指定・規格選択の際に、 |
---|
| 179 | * $_SESSION['cart_referer_url'] を上書きさせないために、 |
---|
| 180 | * 何もせずbreakする。 |
---|
| 181 | */ |
---|
| 182 | break; |
---|
| 183 | |
---|
| 184 | default: |
---|
| 185 | $this->doDefault(); |
---|
| 186 | break; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | // モバイル用 ポストバック処理 |
---|
| 190 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
| 191 | switch ($this->mode) { |
---|
| 192 | case 'select': |
---|
| 193 | $this->doMobileSelect(); |
---|
| 194 | break; |
---|
| 195 | |
---|
| 196 | case 'select2': |
---|
| 197 | $this->doMobileSelect2(); |
---|
| 198 | break; |
---|
| 199 | |
---|
| 200 | case 'selectItem': |
---|
| 201 | $this->doMobileSelectItem(); |
---|
| 202 | break; |
---|
| 203 | |
---|
| 204 | case 'cart': |
---|
| 205 | $this->doMobileCart(); |
---|
| 206 | break; |
---|
| 207 | |
---|
| 208 | default: |
---|
| 209 | $this->doMobileDefault(); |
---|
| 210 | break; |
---|
| 211 | } |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | // 商品詳細を取得 |
---|
| 215 | $this->arrProduct = $objProduct->getDetail($product_id); |
---|
| 216 | |
---|
| 217 | // サブタイトルを取得 |
---|
| 218 | $this->tpl_subtitle = $this->arrProduct['name']; |
---|
| 219 | |
---|
| 220 | // 関連カテゴリを取得 |
---|
| 221 | $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); |
---|
| 222 | |
---|
| 223 | // 商品ステータスを取得 |
---|
| 224 | $this->productStatus = $objProduct->getProductStatus($product_id); |
---|
| 225 | |
---|
| 226 | // 画像ファイル指定がない場合の置換処理 |
---|
| 227 | $this->arrProduct['main_image'] |
---|
| 228 | = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); |
---|
| 229 | |
---|
| 230 | $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile); |
---|
| 231 | //レビュー情報の取得 |
---|
| 232 | $this->arrReview = $this->lfGetReviewData($product_id); |
---|
| 233 | |
---|
| 234 | //関連商品情報表示 |
---|
| 235 | $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); |
---|
| 236 | |
---|
| 237 | // ログイン判定 |
---|
| 238 | if ($objCustomer->isLoginSuccess() === true) { |
---|
| 239 | //お気に入りボタン表示 |
---|
| 240 | $this->tpl_login = true; |
---|
| 241 | $this->is_favorite = SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($objCustomer->getValue('customer_id'), $product_id)); |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | /* プロダクトIDの正当性チェック */ |
---|
| 246 | public function lfCheckProductId($admin_mode, $product_id) |
---|
| 247 | { |
---|
| 248 | // 管理機能からの確認の場合は、非公開の商品も表示する。 |
---|
| 249 | if (isset($admin_mode) && $admin_mode == 'on') { |
---|
| 250 | SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex()); |
---|
| 251 | $status = true; |
---|
| 252 | $where = 'del_flg = 0'; |
---|
| 253 | } else { |
---|
| 254 | $status = false; |
---|
| 255 | $where = 'del_flg = 0 AND status = 1'; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | if (!SC_Utils_Ex::sfIsInt($product_id) |
---|
| 259 | || SC_Utils_Ex::sfIsZeroFilling($product_id) |
---|
| 260 | || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array) $product_id, $where) |
---|
| 261 | ) { |
---|
| 262 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | return $product_id; |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | /* ファイル情報の初期化 */ |
---|
| 269 | public function lfInitFile($objUpFile) |
---|
| 270 | { |
---|
| 271 | $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg'), IMAGE_SIZE); |
---|
| 272 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 273 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | return $objUpFile; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | /* 規格選択セレクトボックスの作成 */ |
---|
| 280 | public function lfMakeSelect() |
---|
| 281 | { |
---|
| 282 | return 'fnSetClassCategories(' |
---|
| 283 | . 'document.form1, ' |
---|
| 284 | . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2')) |
---|
| 285 | . '); '; |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | /* 規格選択セレクトボックスの作成(モバイル) */ |
---|
| 289 | public function lfMakeSelectMobile(&$objPage, $product_id, $request_classcategory_id1) |
---|
| 290 | { |
---|
| 291 | $classcat_find1 = false; |
---|
| 292 | $classcat_find2 = false; |
---|
| 293 | |
---|
| 294 | // 規格名一覧 |
---|
| 295 | $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_class', 'class_id', 'name'); |
---|
| 296 | // 規格分類名一覧 |
---|
| 297 | $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList('dtb_classcategory', 'classcategory_id', 'name'); |
---|
| 298 | // 商品規格情報の取得 |
---|
| 299 | $arrProductsClass = $this->lfGetProductsClass($product_id); |
---|
| 300 | |
---|
| 301 | // 規格1クラス名の取得 |
---|
| 302 | $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']]; |
---|
| 303 | // 規格2クラス名の取得 |
---|
| 304 | $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']]; |
---|
| 305 | |
---|
| 306 | // 全ての組み合わせ数 |
---|
| 307 | $count = count($arrProductsClass); |
---|
| 308 | |
---|
| 309 | $classcat_id1 = ''; |
---|
| 310 | |
---|
| 311 | $arrSele1 = array(); |
---|
| 312 | $arrSele2 = array(); |
---|
| 313 | |
---|
| 314 | for ($i = 0; $i < $count; $i++) { |
---|
| 315 | // 在庫のチェック |
---|
| 316 | if ($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { |
---|
| 317 | continue; |
---|
| 318 | } |
---|
| 319 | |
---|
| 320 | // 規格1のセレクトボックス用 |
---|
| 321 | if ($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']) { |
---|
| 322 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; |
---|
| 323 | $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1]; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | // 規格2のセレクトボックス用 |
---|
| 327 | if ($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) { |
---|
| 328 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; |
---|
| 329 | $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2]; |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | // 規格1 |
---|
| 334 | $objPage->arrClassCat1 = $arrSele1; |
---|
| 335 | $objPage->arrClassCat2 = $arrSele2; |
---|
| 336 | |
---|
| 337 | // 規格1が設定されている |
---|
| 338 | if (isset($arrProductsClass[0]['classcategory_id1']) && $arrProductsClass[0]['classcategory_id1'] != '0') { |
---|
| 339 | $classcat_find1 = true; |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | // 規格2が設定されている |
---|
| 343 | if (isset($arrProductsClass[0]['classcategory_id2']) && $arrProductsClass[0]['classcategory_id2'] != '0') { |
---|
| 344 | $classcat_find2 = true; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | $objPage->tpl_classcat_find1 = $classcat_find1; |
---|
| 348 | $objPage->tpl_classcat_find2 = $classcat_find2; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | /* パラメーター情報の初期化 */ |
---|
| 352 | public function lfInitParam(&$objFormParam) |
---|
| 353 | { |
---|
| 354 | $objFormParam->addParam('規格1', 'classcategory_id1', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 355 | $objFormParam->addParam('規格2', 'classcategory_id2', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 356 | $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 357 | $objFormParam->addParam('管理者ログイン', 'admin', INT_LEN, 'a', array('ALNUM_CHECK','MAX_LENGTH_CHECK')); |
---|
| 358 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 359 | $objFormParam->addParam('お気に入り商品ID', 'favorite_product_id', INT_LEN, 'n', array('ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 360 | $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 361 | // 値の取得 |
---|
| 362 | $objFormParam->setParam($_REQUEST); |
---|
| 363 | // 入力値の変換 |
---|
| 364 | $objFormParam->convParam(); |
---|
| 365 | // 入力情報を渡す |
---|
| 366 | return $objFormParam->getFormParamList(); |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | /* 商品規格情報の取得 */ |
---|
| 370 | public function lfGetProductsClass($product_id) |
---|
| 371 | { |
---|
| 372 | $objProduct = new SC_Product_Ex(); |
---|
| 373 | |
---|
| 374 | return $objProduct->getProductsClassFullByProductId($product_id); |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | /* 登録済み関連商品の読み込み */ |
---|
| 378 | public function lfPreGetRecommendProducts($product_id) |
---|
| 379 | { |
---|
| 380 | $objProduct = new SC_Product_Ex(); |
---|
| 381 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 382 | |
---|
| 383 | $objQuery->setOrder('rank DESC'); |
---|
| 384 | $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id)); |
---|
| 385 | |
---|
| 386 | $recommendProductIds = array(); |
---|
| 387 | foreach ($arrRecommendData as $recommend) { |
---|
| 388 | $recommendProductIds[] = $recommend['recommend_product_id']; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 392 | $arrProducts = $objProduct->getListByProductIds($objQuery, $recommendProductIds); |
---|
| 393 | |
---|
| 394 | foreach ($arrRecommendData as $key => $arrRow) { |
---|
| 395 | $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]); |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | return $arrRecommendData; |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | /* 入力内容のチェック */ |
---|
| 402 | public function lfCheckError($mode, &$objFormParam, $tpl_classcat_find1 = null , $tpl_classcat_find2 = null) |
---|
| 403 | { |
---|
| 404 | switch ($mode) { |
---|
| 405 | case 'add_favorite_sphone': |
---|
| 406 | case 'add_favorite': |
---|
| 407 | $objCustomer = new SC_Customer_Ex(); |
---|
| 408 | $objErr = new SC_CheckError_Ex(); |
---|
| 409 | $customer_id = $objCustomer->getValue('customer_id'); |
---|
| 410 | if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { |
---|
| 411 | $objErr->arrErr['add_favorite'.$favorite_product_id] = '※ この商品は既にお気に入りに追加されています。<br />'; |
---|
| 412 | } |
---|
| 413 | break; |
---|
| 414 | default: |
---|
| 415 | // 入力データを渡す。 |
---|
| 416 | $arrRet = $objFormParam->getHashArray(); |
---|
| 417 | $objErr = new SC_CheckError_Ex($arrRet); |
---|
| 418 | $objErr->arrErr = $objFormParam->checkError(); |
---|
| 419 | |
---|
| 420 | // 複数項目チェック |
---|
| 421 | if ($tpl_classcat_find1) { |
---|
| 422 | $objErr->doFunc(array('規格1', 'classcategory_id1'), array('EXIST_CHECK')); |
---|
| 423 | } |
---|
| 424 | if ($tpl_classcat_find2) { |
---|
| 425 | $objErr->doFunc(array('規格2', 'classcategory_id2'), array('EXIST_CHECK')); |
---|
| 426 | } |
---|
| 427 | break; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | return $objErr->arrErr; |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | //商品ごとのレビュー情報を取得する |
---|
| 434 | public function lfGetReviewData($product_id) |
---|
| 435 | { |
---|
| 436 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 437 | //商品ごとのレビュー情報を取得する |
---|
| 438 | $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment'; |
---|
| 439 | $from = 'dtb_review'; |
---|
| 440 | $where = 'del_flg = 0 AND status = 1 AND product_id = ?'; |
---|
| 441 | $objQuery->setOrder('create_date DESC'); |
---|
| 442 | $objQuery->setLimit(REVIEW_REGIST_MAX); |
---|
| 443 | $arrWhereVal = array($product_id); |
---|
| 444 | $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal); |
---|
| 445 | |
---|
| 446 | return $arrReview; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | /* |
---|
| 450 | * ファイルの情報をセットする |
---|
| 451 | * @return $subImageFlag |
---|
| 452 | */ |
---|
| 453 | public function lfSetFile($objUpFile, $arrProduct, &$arrFile) |
---|
| 454 | { |
---|
| 455 | // DBからのデータを引き継ぐ |
---|
| 456 | $objUpFile->setDBFileList($arrProduct); |
---|
| 457 | // ファイル表示用配列を渡す |
---|
| 458 | $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true); |
---|
| 459 | |
---|
| 460 | // サブ画像の有無を判定 |
---|
| 461 | $subImageFlag = false; |
---|
| 462 | for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { |
---|
| 463 | if ($arrFile['sub_image' . $i]['filepath'] != '') { |
---|
| 464 | $subImageFlag = true; |
---|
| 465 | } |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | return $subImageFlag; |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | /* |
---|
| 472 | * お気に入り商品登録 |
---|
| 473 | * @return void |
---|
| 474 | */ |
---|
| 475 | public function lfRegistFavoriteProduct($favorite_product_id, $customer_id) |
---|
| 476 | { |
---|
| 477 | // ログイン中のユーザが商品をお気に入りにいれる処理 |
---|
| 478 | if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) { |
---|
| 479 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
| 480 | |
---|
| 481 | return false; |
---|
| 482 | } else { |
---|
| 483 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 484 | $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id)); |
---|
| 485 | |
---|
| 486 | if (!$exists) { |
---|
| 487 | $sqlval['customer_id'] = $customer_id; |
---|
| 488 | $sqlval['product_id'] = $favorite_product_id; |
---|
| 489 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 490 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 491 | |
---|
| 492 | $objQuery->begin(); |
---|
| 493 | $objQuery->insert('dtb_customer_favorite_products', $sqlval); |
---|
| 494 | $objQuery->commit(); |
---|
| 495 | } |
---|
| 496 | // お気に入りに登録したことを示すフラグ |
---|
| 497 | $this->just_added_favorite = true; |
---|
| 498 | |
---|
| 499 | return true; |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | /** |
---|
| 504 | * Add product(s) into the cart. |
---|
| 505 | * |
---|
| 506 | * @return void |
---|
| 507 | */ |
---|
| 508 | public function doCart() |
---|
| 509 | { |
---|
| 510 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam, |
---|
| 511 | $this->tpl_classcat_find1, |
---|
| 512 | $this->tpl_classcat_find2); |
---|
| 513 | if (count($this->arrErr) == 0) { |
---|
| 514 | $objCartSess = new SC_CartSession_Ex(); |
---|
| 515 | $product_class_id = $this->objFormParam->getValue('product_class_id'); |
---|
| 516 | |
---|
| 517 | $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity')); |
---|
| 518 | |
---|
| 519 | // 開いているカテゴリーツリーを維持するためのパラメーター |
---|
| 520 | $arrQueryString = array( |
---|
| 521 | 'product_id' => $this->objFormParam->getValue('product_id'), |
---|
| 522 | ); |
---|
| 523 | |
---|
| 524 | SC_Response_Ex::sendRedirect(CART_URLPATH, $arrQueryString); |
---|
| 525 | SC_Response_Ex::actionExit(); |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | /** |
---|
| 530 | * Add product to authenticated user's favorites. |
---|
| 531 | * |
---|
| 532 | * @param type $objCustomer |
---|
| 533 | * @return void |
---|
| 534 | */ |
---|
| 535 | public function doAddFavorite(&$objCustomer) |
---|
| 536 | { |
---|
| 537 | // ログイン中のユーザが商品をお気に入りにいれる処理 |
---|
| 538 | if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { |
---|
| 539 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); |
---|
| 540 | if (count($this->arrErr) == 0) { |
---|
| 541 | if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { |
---|
| 542 | SC_Response_Ex::actionExit(); |
---|
| 543 | } |
---|
| 544 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 545 | $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this)); |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | /** |
---|
| 551 | * Add product to authenticated user's favorites. (for Smart phone) |
---|
| 552 | * |
---|
| 553 | * @param type $objCustomer |
---|
| 554 | * @return void |
---|
| 555 | */ |
---|
| 556 | public function doAddFavoriteSphone($objCustomer) |
---|
| 557 | { |
---|
| 558 | // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用) |
---|
| 559 | if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) { |
---|
| 560 | $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); |
---|
| 561 | if (count($this->arrErr) == 0) { |
---|
| 562 | if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) { |
---|
| 563 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
| 564 | $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this)); |
---|
| 565 | print 'true'; |
---|
| 566 | SC_Response_Ex::actionExit(); |
---|
| 567 | } |
---|
| 568 | } |
---|
| 569 | print 'error'; |
---|
| 570 | SC_Response_Ex::actionExit(); |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | /** |
---|
| 575 | * |
---|
| 576 | * |
---|
| 577 | * @return void |
---|
| 578 | */ |
---|
| 579 | public function doDefault() |
---|
| 580 | { |
---|
| 581 | // カート「戻るボタン」用に保持 |
---|
| 582 | $netURL = new Net_URL(); |
---|
| 583 | $_SESSION['cart_referer_url'] = $netURL->getURL(); |
---|
| 584 | } |
---|
| 585 | |
---|
| 586 | /** |
---|
| 587 | * |
---|
| 588 | * @return void |
---|
| 589 | */ |
---|
| 590 | public function doMobileSelect() |
---|
| 591 | { |
---|
| 592 | // 規格1が設定されている場合 |
---|
| 593 | if ($this->tpl_classcat_find1) { |
---|
| 594 | // templateの変更 |
---|
| 595 | $this->tpl_mainpage = 'products/select_find1.tpl'; |
---|
| 596 | |
---|
| 597 | return; |
---|
| 598 | } |
---|
| 599 | |
---|
| 600 | // 数量の入力を行う |
---|
| 601 | $this->tpl_mainpage = 'products/select_item.tpl'; |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | /** |
---|
| 605 | * |
---|
| 606 | * @return type |
---|
| 607 | */ |
---|
| 608 | public function doMobileSelect2() |
---|
| 609 | { |
---|
| 610 | $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); |
---|
| 611 | |
---|
| 612 | // 規格1が設定されていて、エラーを検出した場合 |
---|
| 613 | if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { |
---|
| 614 | // templateの変更 |
---|
| 615 | $this->tpl_mainpage = 'products/select_find1.tpl'; |
---|
| 616 | |
---|
| 617 | return; |
---|
| 618 | } |
---|
| 619 | |
---|
| 620 | // 規格2が設定されている場合 |
---|
| 621 | if ($this->tpl_classcat_find2) { |
---|
| 622 | $this->arrErr = array(); |
---|
| 623 | |
---|
| 624 | $this->tpl_mainpage = 'products/select_find2.tpl'; |
---|
| 625 | |
---|
| 626 | return; |
---|
| 627 | } |
---|
| 628 | |
---|
| 629 | $this->doMobileSelectItem(); |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | /** |
---|
| 633 | * |
---|
| 634 | * @return void |
---|
| 635 | */ |
---|
| 636 | public function doMobileSelectItem() |
---|
| 637 | { |
---|
| 638 | $objProduct = new SC_Product_Ex(); |
---|
| 639 | |
---|
| 640 | $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2); |
---|
| 641 | |
---|
| 642 | // この段階では、商品規格ID・数量の入力チェックエラーを出させない。 |
---|
| 643 | // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる |
---|
| 644 | unset($this->arrErr['product_class_id']); |
---|
| 645 | unset($this->arrErr['quantity']); |
---|
| 646 | |
---|
| 647 | // 規格2が設定されていて、エラーを検出した場合 |
---|
| 648 | if ($this->tpl_classcat_find2 and !empty($this->arrErr)) { |
---|
| 649 | // templateの変更 |
---|
| 650 | $this->tpl_mainpage = 'products/select_find2.tpl'; |
---|
| 651 | |
---|
| 652 | return; |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | $product_id = $this->objFormParam->getValue('product_id'); |
---|
| 656 | |
---|
| 657 | $value1 = $this->objFormParam->getValue('classcategory_id1'); |
---|
| 658 | if (strlen($value1) === 0) { |
---|
| 659 | $value1 = '__unselected'; |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | // 規格2が設定されている場合. |
---|
| 663 | if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) { |
---|
| 664 | $value2 = '#' . $this->objFormParam->getValue('classcategory_id2'); |
---|
| 665 | } else { |
---|
| 666 | $value2 = '#0'; |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | $objProduct->setProductsClassByProductIds(array($product_id)); |
---|
| 670 | $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id']; |
---|
| 671 | |
---|
| 672 | // 数量の入力を行う |
---|
| 673 | $this->tpl_mainpage = 'products/select_item.tpl'; |
---|
| 674 | } |
---|
| 675 | |
---|
| 676 | /** |
---|
| 677 | * |
---|
| 678 | * @return void |
---|
| 679 | */ |
---|
| 680 | public function doMobileCart() |
---|
| 681 | { |
---|
| 682 | // この段階でエラーが出る場合は、数量の入力エラーのはず |
---|
| 683 | if (count($this->arrErr)) { |
---|
| 684 | // 数量の入力を行う |
---|
| 685 | $this->tpl_mainpage = 'products/select_item.tpl'; |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | /** |
---|
| 690 | * |
---|
| 691 | * @return void |
---|
| 692 | */ |
---|
| 693 | public function doMobileDefault() |
---|
| 694 | { |
---|
| 695 | $this->tpl_mainpage = 'products/detail.tpl'; |
---|
| 696 | } |
---|
| 697 | } |
---|