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