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