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