| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 4 | * |
---|
| 5 | * http://www.lockon.co.jp/ |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | // {{{ requires |
---|
| 9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * 商品詳細 のページクラス. |
---|
| 13 | * |
---|
| 14 | * @package Page |
---|
| 15 | * @author LOCKON CO.,LTD. |
---|
| 16 | * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
| 17 | */ |
---|
| 18 | class LC_Page_Products_Detail extends LC_Page { |
---|
| 19 | |
---|
| 20 | /** ステータス */ |
---|
| 21 | var $arrSTATUS; |
---|
| 22 | |
---|
| 23 | /** ステータス画像 */ |
---|
| 24 | var $arrSTATUS_IMAGE; |
---|
| 25 | |
---|
| 26 | /** 発送予定日 */ |
---|
| 27 | var $arrDELIVERYDATE; |
---|
| 28 | |
---|
| 29 | /** おすすめレベル */ |
---|
| 30 | var $arrRECOMMEND; |
---|
| 31 | |
---|
| 32 | /** フォームパラメータ */ |
---|
| 33 | var $objFormParam; |
---|
| 34 | |
---|
| 35 | /** アップロードファイル */ |
---|
| 36 | var $objUpFile; |
---|
| 37 | |
---|
| 38 | // }}} |
---|
| 39 | // {{{ functions |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Page を初期化する. |
---|
| 43 | * |
---|
| 44 | * @return void |
---|
| 45 | */ |
---|
| 46 | function init() { |
---|
| 47 | parent::init(); |
---|
| 48 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 49 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
| 50 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
| 51 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
| 52 | $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend"); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /** |
---|
| 56 | * Page のプロセス. |
---|
| 57 | * |
---|
| 58 | * @return void |
---|
| 59 | */ |
---|
| 60 | function process() { |
---|
| 61 | $objView = new SC_SiteView(); |
---|
| 62 | $objCustomer = new SC_Customer(); |
---|
| 63 | $objQuery = new SC_Query(); |
---|
| 64 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 65 | |
---|
| 66 | // レイアウトデザインを取得 |
---|
| 67 | $helper = new SC_Helper_PageLayout_Ex(); |
---|
| 68 | $helper->sfGetPageLayout($this, false, "products/detail.php"); |
---|
| 69 | |
---|
| 70 | // パラメータ管理クラス |
---|
| 71 | $this->objFormParam = new SC_FormParam(); |
---|
| 72 | // パラメータ情報の初期化 |
---|
| 73 | $this->lfInitParam(); |
---|
| 74 | // POST値の取得 |
---|
| 75 | $this->objFormParam->setParam($_POST); |
---|
| 76 | |
---|
| 77 | // ファイル管理クラス |
---|
| 78 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
| 79 | // ファイル情報の初期化 |
---|
| 80 | $this->lfInitFile(); |
---|
| 81 | |
---|
| 82 | // 管理ページからの確認の場合は、非公開の商品も表示する。 |
---|
| 83 | if(isset($_GET['admin']) && $_GET['admin'] == 'on') { |
---|
| 84 | $where = "del_flg = 0"; |
---|
| 85 | } else { |
---|
| 86 | $where = "del_flg = 0 AND status = 1"; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | if(isset($_POST['mode']) && $_POST['mode'] != "") { |
---|
| 90 | $tmp_id = $_POST['product_id']; |
---|
| 91 | } else { |
---|
| 92 | $tmp_id = $_GET['product_id']; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | // 値の正当性チェック |
---|
| 96 | if(!SC_Utils_Ex::sfIsInt($_GET['product_id']) |
---|
| 97 | || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) { |
---|
| 98 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
| 99 | } |
---|
| 100 | // ログイン判定 |
---|
| 101 | if($objCustomer->isLoginSuccess()) { |
---|
| 102 | //お気に入りボタン表示 |
---|
| 103 | $this->tpl_login = true; |
---|
| 104 | |
---|
| 105 | /* 閲覧ログ機能は現在未使用 |
---|
| 106 | |
---|
| 107 | $table = "dtb_customer_reading"; |
---|
| 108 | $where = "customer_id = ? "; |
---|
| 109 | $arrval[] = $objCustomer->getValue('customer_id'); |
---|
| 110 | //顧客の閲覧商品数 |
---|
| 111 | $rpcnt = $objQuery->count($table, $where, $arrval); |
---|
| 112 | |
---|
| 113 | //閲覧数が設定数以下 |
---|
| 114 | if ($rpcnt < CUSTOMER_READING_MAX){ |
---|
| 115 | //閲覧履歴に新規追加 |
---|
| 116 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
| 117 | } else { |
---|
| 118 | //閲覧履歴の中で一番古いものを削除して新規追加 |
---|
| 119 | $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?"; |
---|
| 120 | $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id"))); |
---|
| 121 | $where = "customer_id = ? AND update_date = ? "; |
---|
| 122 | $arrval = array($objCustomer->getValue("customer_id"), $old); |
---|
| 123 | //削除 |
---|
| 124 | $objQuery->delete($table, $where, $arrval); |
---|
| 125 | //追加 |
---|
| 126 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
| 127 | } |
---|
| 128 | */ |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | // 規格選択セレクトボックスの作成 |
---|
| 133 | $this->lfMakeSelect($tmp_id); |
---|
| 134 | |
---|
| 135 | // 商品IDをFORM内に保持する。 |
---|
| 136 | $this->tpl_product_id = $tmp_id; |
---|
| 137 | |
---|
| 138 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
| 139 | |
---|
| 140 | switch($_POST['mode']) { |
---|
| 141 | case 'cart': |
---|
| 142 | // 入力値の変換 |
---|
| 143 | $this->objFormParam->convParam(); |
---|
| 144 | $this->arrErr = $this->lfCheckError(); |
---|
| 145 | if(count($this->arrErr) == 0) { |
---|
| 146 | $objCartSess = new SC_CartSession(); |
---|
| 147 | $classcategory_id1 = $_POST['classcategory_id1']; |
---|
| 148 | $classcategory_id2 = $_POST['classcategory_id2']; |
---|
| 149 | |
---|
| 150 | // 規格1が設定されていない場合 |
---|
| 151 | if(!$this->tpl_classcat_find1) { |
---|
| 152 | $classcategory_id1 = '0'; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | // 規格2が設定されていない場合 |
---|
| 156 | if(!$this->tpl_classcat_find2) { |
---|
| 157 | $classcategory_id2 = '0'; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
---|
| 161 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); |
---|
| 162 | $this->sendRedirect($this->getLocation(URL_CART_TOP)); |
---|
| 163 | exit; |
---|
| 164 | } |
---|
| 165 | break; |
---|
| 166 | |
---|
| 167 | default: |
---|
| 168 | break; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | $objQuery = new SC_Query(); |
---|
| 172 | // DBから商品情報を取得する。 |
---|
| 173 | $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); |
---|
| 174 | $this->arrProduct = $arrRet[0]; |
---|
| 175 | |
---|
| 176 | // 商品コードの取得 |
---|
| 177 | $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; |
---|
| 178 | $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); |
---|
| 179 | $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); |
---|
| 180 | $this->arrProductCode = $arrProductCode["product_code"]; |
---|
| 181 | |
---|
| 182 | // 購入制限数を取得 |
---|
| 183 | if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { |
---|
| 184 | $this->tpl_sale_limit = SALE_LIMIT_MAX; |
---|
| 185 | } else { |
---|
| 186 | $this->tpl_sale_limit = $this->arrProduct['sale_limit']; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | // サブタイトルを取得 |
---|
| 190 | $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); |
---|
| 191 | $this->tpl_subtitle = $arrFirstCat['name']; |
---|
| 192 | |
---|
| 193 | // DBからのデータを引き継ぐ |
---|
| 194 | $this->objUpFile->setDBFileList($this->arrProduct); |
---|
| 195 | // ファイル表示用配列を渡す |
---|
| 196 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); |
---|
| 197 | // 支払方法の取得 |
---|
| 198 | $this->arrPayment = $this->lfGetPayment(); |
---|
| 199 | // 入力情報を渡す |
---|
| 200 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
| 201 | //レビュー情報の取得 |
---|
| 202 | $this->arrReview = $this->lfGetReviewData($tmp_id); |
---|
| 203 | // トラックバック情報の取得 |
---|
| 204 | |
---|
| 205 | // トラックバック機能の稼働状況チェック |
---|
| 206 | if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { |
---|
| 207 | $this->arrTrackbackView = "OFF"; |
---|
| 208 | } else { |
---|
| 209 | $this->arrTrackbackView = "ON"; |
---|
| 210 | $this->arrTrackback = $this->lfGetTrackbackData($tmp_id); |
---|
| 211 | } |
---|
| 212 | $this->trackback_url = TRACKBACK_TO_URL . $tmp_id; |
---|
| 213 | // タイトルに商品名を入れる |
---|
| 214 | $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; |
---|
| 215 | //オススメ商品情報表示 |
---|
| 216 | $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); |
---|
| 217 | //この商品を買った人はこんな商品も買っています |
---|
| 218 | $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); |
---|
| 219 | |
---|
| 220 | // 拡大画像のウィンドウサイズをセット |
---|
| 221 | if (isset($this->arrFile["main_large_image"])) { |
---|
| 222 | $image_path = IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"]); |
---|
| 223 | } else { |
---|
| 224 | $image_path = ""; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | list($large_width, $large_height) = getimagesize($image_path); |
---|
| 228 | $this->tpl_large_width = $large_width + 60; |
---|
| 229 | $this->tpl_large_height = $large_height + 80; |
---|
| 230 | |
---|
| 231 | $this->lfConvertParam(); |
---|
| 232 | |
---|
| 233 | $objView->assignobj($this); |
---|
| 234 | $objView->display(SITE_FRAME); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | /** |
---|
| 238 | * デストラクタ. |
---|
| 239 | * |
---|
| 240 | * @return void |
---|
| 241 | */ |
---|
| 242 | function destroy() { |
---|
| 243 | parent::destroy(); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | /** |
---|
| 247 | * モバイルページを初期化する. |
---|
| 248 | * |
---|
| 249 | * @return void |
---|
| 250 | */ |
---|
| 251 | function mobileInit() { |
---|
| 252 | $this->init(); |
---|
| 253 | $this->tpl_mainpage = "products/detail.tpl"; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | /** |
---|
| 257 | * Page のプロセス(モバイル). |
---|
| 258 | * |
---|
| 259 | * @return void |
---|
| 260 | */ |
---|
| 261 | function mobileProcess() { |
---|
| 262 | $objView = new SC_MobileView(); |
---|
| 263 | $objCustomer = new SC_Customer(); |
---|
| 264 | $objQuery = new SC_Query(); |
---|
| 265 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 266 | |
---|
| 267 | // レイアウトデザインを取得 |
---|
| 268 | // $objPage = sfGetPageLayout($objPage, false, "products/detail.php"); |
---|
| 269 | |
---|
| 270 | // パラメータ管理クラス |
---|
| 271 | $this->objFormParam = new SC_FormParam(); |
---|
| 272 | // パラメータ情報の初期化 |
---|
| 273 | $this->lfInitParam(); |
---|
| 274 | // POST値の取得 |
---|
| 275 | $this->objFormParam->setParam($_POST); |
---|
| 276 | |
---|
| 277 | // ファイル管理クラス |
---|
| 278 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
| 279 | // ファイル情報の初期化 |
---|
| 280 | $this->lfInitFile(); |
---|
| 281 | |
---|
| 282 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
| 283 | |
---|
| 284 | if(!empty($_POST['mode'])) { |
---|
| 285 | $tmp_id = $_POST['product_id']; |
---|
| 286 | } else { |
---|
| 287 | $tmp_id = $_GET['product_id']; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | // 値の正当性チェック |
---|
| 291 | /*if(!SC_Utils_Ex::sfIsInt($_GET['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) { |
---|
| 292 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); |
---|
| 293 | }*/ |
---|
| 294 | // ログイン判定 |
---|
| 295 | if($objCustomer->isLoginSuccess()) { |
---|
| 296 | //お気に入りボタン表示 |
---|
| 297 | $this->tpl_login = true; |
---|
| 298 | |
---|
| 299 | /* 閲覧ログ機能は現在未使用 |
---|
| 300 | |
---|
| 301 | $table = "dtb_customer_reading"; |
---|
| 302 | $where = "customer_id = ? "; |
---|
| 303 | $arrval[] = $objCustomer->getValue('customer_id'); |
---|
| 304 | //顧客の閲覧商品数 |
---|
| 305 | $rpcnt = $objQuery->count($table, $where, $arrval); |
---|
| 306 | |
---|
| 307 | //閲覧数が設定数以下 |
---|
| 308 | if ($rpcnt < CUSTOMER_READING_MAX){ |
---|
| 309 | //閲覧履歴に新規追加 |
---|
| 310 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
| 311 | } else { |
---|
| 312 | //閲覧履歴の中で一番古いものを削除して新規追加 |
---|
| 313 | $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?"; |
---|
| 314 | $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id"))); |
---|
| 315 | $where = "customer_id = ? AND update_date = ? "; |
---|
| 316 | $arrval = array($objCustomer->getValue("customer_id"), $old); |
---|
| 317 | //削除 |
---|
| 318 | $objQuery->delete($table, $where, $arrval); |
---|
| 319 | //追加 |
---|
| 320 | lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); |
---|
| 321 | } |
---|
| 322 | */ |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | |
---|
| 326 | // 規格選択セレクトボックスの作成 |
---|
| 327 | $this->lfMakeSelect($tmp_id); |
---|
| 328 | |
---|
| 329 | // 商品IDをFORM内に保持する。 |
---|
| 330 | $this->tpl_product_id = $tmp_id; |
---|
| 331 | |
---|
| 332 | switch($_POST['mode']) { |
---|
| 333 | case 'select': |
---|
| 334 | // 規格1が設定されている場合 |
---|
| 335 | if($this->tpl_classcat_find1) { |
---|
| 336 | // templateの変更 |
---|
| 337 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
| 338 | break; |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | case 'select2': |
---|
| 342 | $this->arrErr = $this->lfCheckError(); |
---|
| 343 | |
---|
| 344 | // 規格1が設定されている場合 |
---|
| 345 | if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { |
---|
| 346 | // templateの変更 |
---|
| 347 | $this->tpl_mainpage = "products/select_find1.tpl"; |
---|
| 348 | break; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | // 規格2が設定されている場合 |
---|
| 352 | if($this->tpl_classcat_find2) { |
---|
| 353 | $this->arrErr = array(); |
---|
| 354 | |
---|
| 355 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
| 356 | break; |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | case 'selectItem': |
---|
| 360 | $this->arrErr = $this->lfCheckError(); |
---|
| 361 | |
---|
| 362 | // 規格1が設定されている場合 |
---|
| 363 | if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { |
---|
| 364 | // templateの変更 |
---|
| 365 | $this->tpl_mainpage = "products/select_find2.tpl"; |
---|
| 366 | break; |
---|
| 367 | } |
---|
| 368 | // 商品数の選択を行う |
---|
| 369 | $this->tpl_mainpage = "products/select_item.tpl"; |
---|
| 370 | break; |
---|
| 371 | |
---|
| 372 | case 'cart': |
---|
| 373 | // 入力値の変換 |
---|
| 374 | $this->objFormParam->convParam(); |
---|
| 375 | $this->arrErr = $this->lfCheckError(); |
---|
| 376 | if(count($this->arrErr) == 0) { |
---|
| 377 | $objCartSess = new SC_CartSession(); |
---|
| 378 | $classcategory_id1 = $_POST['classcategory_id1']; |
---|
| 379 | $classcategory_id2 = $_POST['classcategory_id2']; |
---|
| 380 | |
---|
| 381 | // 規格1が設定されていない場合 |
---|
| 382 | if(!$this->tpl_classcat_find1) { |
---|
| 383 | $classcategory_id1 = '0'; |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | // 規格2が設定されていない場合 |
---|
| 387 | if(!$this->tpl_classcat_find2) { |
---|
| 388 | $classcategory_id2 = '0'; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
---|
| 392 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); |
---|
| 393 | $this->sendRedirect(SC_Helper_Mobile_Ex::gfAddSessionId(MOBILE_URL_CART_TOP)); |
---|
| 394 | exit; |
---|
| 395 | } |
---|
| 396 | break; |
---|
| 397 | |
---|
| 398 | default: |
---|
| 399 | break; |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | $objQuery = new SC_Query(); |
---|
| 403 | // DBから商品情報を取得する。 |
---|
| 404 | $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); |
---|
| 405 | $this->arrProduct = $arrRet[0]; |
---|
| 406 | |
---|
| 407 | // 商品コードの取得 |
---|
| 408 | $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; |
---|
| 409 | $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); |
---|
| 410 | $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); |
---|
| 411 | $this->arrProductCode = $arrProductCode["product_code"]; |
---|
| 412 | |
---|
| 413 | // 購入制限数を取得 |
---|
| 414 | if($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { |
---|
| 415 | $this->tpl_sale_limit = SALE_LIMIT_MAX; |
---|
| 416 | } else { |
---|
| 417 | $this->tpl_sale_limit = $this->arrProduct['sale_limit']; |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | // サブタイトルを取得 |
---|
| 421 | $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); |
---|
| 422 | $tpl_subtitle = $arrFirstCat['name']; |
---|
| 423 | $this->tpl_subtitle = $tpl_subtitle; |
---|
| 424 | |
---|
| 425 | // DBからのデータを引き継ぐ |
---|
| 426 | $this->objUpFile->setDBFileList($this->arrProduct); |
---|
| 427 | // ファイル表示用配列を渡す |
---|
| 428 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); |
---|
| 429 | // 支払方法の取得 |
---|
| 430 | $this->arrPayment = $this->lfGetPayment(); |
---|
| 431 | // 入力情報を渡す |
---|
| 432 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
| 433 | //レビュー情報の取得 |
---|
| 434 | $this->arrReview = $this->lfGetReviewData($tmp_id); |
---|
| 435 | // タイトルに商品名を入れる |
---|
| 436 | $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; |
---|
| 437 | //オススメ商品情報表示 |
---|
| 438 | $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); |
---|
| 439 | //この商品を買った人はこんな商品も買っています |
---|
| 440 | $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); |
---|
| 441 | |
---|
| 442 | // 拡大画像のウィンドウサイズをセット |
---|
| 443 | if (!empty($this->arrFile["main_large_image"])) { |
---|
| 444 | list($large_width, $large_height) = getimagesize(IMAGE_SAVE_DIR . basename($this->arrFile["main_large_image"]["filepath"])); |
---|
| 445 | } |
---|
| 446 | $this->tpl_large_width = isset($large_width) ? $large_width + 60 : 0; |
---|
| 447 | $this->tpl_large_height = isset($large_height) ? $large_height + 80 : 0; |
---|
| 448 | |
---|
| 449 | $objView->assignobj($this); |
---|
| 450 | $objView->display(SITE_FRAME); |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | /* ファイル情報の初期化 */ |
---|
| 454 | function lfInitFile() { |
---|
| 455 | $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
| 456 | $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
| 457 | $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT); |
---|
| 458 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
| 459 | $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT); |
---|
| 460 | $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT); |
---|
| 461 | } |
---|
| 462 | $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT); |
---|
| 463 | $this->objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | /* 規格選択セレクトボックスの作成 */ |
---|
| 467 | function lfMakeSelect($product_id) { |
---|
| 468 | |
---|
| 469 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 470 | $classcat_find1 = false; |
---|
| 471 | $classcat_find2 = false; |
---|
| 472 | // 在庫ありの商品の有無 |
---|
| 473 | $stock_find = false; |
---|
| 474 | |
---|
| 475 | // 規格名一覧 |
---|
| 476 | $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); |
---|
| 477 | // 規格分類名一覧 |
---|
| 478 | $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
---|
| 479 | // 商品規格情報の取得 |
---|
| 480 | $arrProductsClass = $this->lfGetProductsClass($product_id); |
---|
| 481 | |
---|
| 482 | // 規格1クラス名の取得 |
---|
| 483 | $this->tpl_class_name1 = isset($arrClassName[$arrProductsClass[0]['class_id1']]) |
---|
| 484 | ? $arrClassName[$arrProductsClass[0]['class_id1']] : ""; |
---|
| 485 | // 規格2クラス名の取得 |
---|
| 486 | $this->tpl_class_name2 = isset($arrClassName[$arrProductsClass[0]['class_id2']]) |
---|
| 487 | ? $arrClassName[$arrProductsClass[0]['class_id2']] : ""; |
---|
| 488 | |
---|
| 489 | // すべての組み合わせ数 |
---|
| 490 | $count = count($arrProductsClass); |
---|
| 491 | |
---|
| 492 | $classcat_id1 = ""; |
---|
| 493 | |
---|
| 494 | $arrSele = array(); |
---|
| 495 | $arrList = array(); |
---|
| 496 | |
---|
| 497 | $list_id = 0; |
---|
| 498 | $arrList[0] = "\tlist0 = new Array('選択してください'"; |
---|
| 499 | $arrVal[0] = "\tval0 = new Array(''"; |
---|
| 500 | |
---|
| 501 | for ($i = 0; $i < $count; $i++) { |
---|
| 502 | // 在庫のチェック |
---|
| 503 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { |
---|
| 504 | continue; |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | $stock_find = true; |
---|
| 508 | |
---|
| 509 | // 規格1のセレクトボックス用 |
---|
| 510 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ |
---|
| 511 | $arrList[$list_id].=");\n"; |
---|
| 512 | $arrVal[$list_id].=");\n"; |
---|
| 513 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; |
---|
| 514 | $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; |
---|
| 515 | $list_id++; |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | // 規格2のセレクトボックス用 |
---|
| 519 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; |
---|
| 520 | |
---|
| 521 | // セレクトボックス表示値 |
---|
| 522 | if (!isset($arrList[$list_id])) $arrList[$list_id] = ""; |
---|
| 523 | if($arrList[$list_id] == "") { |
---|
| 524 | $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'"; |
---|
| 525 | } else { |
---|
| 526 | $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | // セレクトボックスPOST値 |
---|
| 530 | if (!isset($arrVal[$list_id])) $arrVal[$list_id] = ""; |
---|
| 531 | if($arrVal[$list_id] == "") { |
---|
| 532 | $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'"; |
---|
| 533 | } else { |
---|
| 534 | $arrVal[$list_id].= ", '".$classcat_id2."'"; |
---|
| 535 | } |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | $arrList[$list_id].=");\n"; |
---|
| 539 | $arrVal[$list_id].=");\n"; |
---|
| 540 | |
---|
| 541 | // 規格1 |
---|
| 542 | $this->arrClassCat1 = $arrSele; |
---|
| 543 | |
---|
| 544 | $lists = "\tlists = new Array("; |
---|
| 545 | $no = 0; |
---|
| 546 | |
---|
| 547 | foreach($arrList as $val) { |
---|
| 548 | $this->tpl_javascript.= $val; |
---|
| 549 | if ($no != 0) { |
---|
| 550 | $lists.= ",list".$no; |
---|
| 551 | } else { |
---|
| 552 | $lists.= "list".$no; |
---|
| 553 | } |
---|
| 554 | $no++; |
---|
| 555 | } |
---|
| 556 | $this->tpl_javascript.=$lists.");\n"; |
---|
| 557 | |
---|
| 558 | $vals = "\tvals = new Array("; |
---|
| 559 | $no = 0; |
---|
| 560 | |
---|
| 561 | foreach($arrVal as $val) { |
---|
| 562 | $this->tpl_javascript.= $val; |
---|
| 563 | if ($no != 0) { |
---|
| 564 | $vals.= ",val".$no; |
---|
| 565 | } else { |
---|
| 566 | $vals.= "val".$no; |
---|
| 567 | } |
---|
| 568 | $no++; |
---|
| 569 | } |
---|
| 570 | $this->tpl_javascript.=$vals.");\n"; |
---|
| 571 | |
---|
| 572 | // 選択されている規格2ID |
---|
| 573 | if (!isset($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = ""; |
---|
| 574 | $this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');"; |
---|
| 575 | |
---|
| 576 | // 規格1が設定されている |
---|
| 577 | if($arrProductsClass[0]['classcategory_id1'] != '0') { |
---|
| 578 | $classcat_find1 = true; |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | // 規格2が設定されている |
---|
| 582 | if($arrProductsClass[0]['classcategory_id2'] != '0') { |
---|
| 583 | $classcat_find2 = true; |
---|
| 584 | } |
---|
| 585 | |
---|
| 586 | $this->tpl_classcat_find1 = $classcat_find1; |
---|
| 587 | $this->tpl_classcat_find2 = $classcat_find2; |
---|
| 588 | $this->tpl_stock_find = $stock_find; |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | /* パラメータ情報の初期化 */ |
---|
| 592 | function lfInitParam() { |
---|
| 593 | $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 594 | $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 595 | $this->objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | /* 商品規格情報の取得 */ |
---|
| 599 | function lfGetProductsClass($product_id) { |
---|
| 600 | $arrRet = array(); |
---|
| 601 | if(SC_Utils_Ex::sfIsInt($product_id)) { |
---|
| 602 | // 商品規格取得 |
---|
| 603 | $objQuery = new SC_Query(); |
---|
| 604 | $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; |
---|
| 605 | $table = "vw_product_class AS prdcls"; |
---|
| 606 | $where = "product_id = ?"; |
---|
| 607 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
---|
| 608 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
| 609 | } |
---|
| 610 | return $arrRet; |
---|
| 611 | } |
---|
| 612 | |
---|
| 613 | /* 登録済みオススメ商品の読み込み */ |
---|
| 614 | function lfPreGetRecommendProducts($product_id) { |
---|
| 615 | $arrRecommend = array(); |
---|
| 616 | $objQuery = new SC_Query(); |
---|
| 617 | $objQuery->setorder("rank DESC"); |
---|
| 618 | $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); |
---|
| 619 | $max = count($arrRet); |
---|
| 620 | $no = 0; |
---|
| 621 | for($i = 0; $i < $max; $i++) { |
---|
| 622 | $where = "del_flg = 0 AND product_id = ? AND status = 1"; |
---|
| 623 | $arrProductInfo = $objQuery->select("main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate", "vw_products_allclass AS allcls", $where, array($arrRet[$i]['recommend_product_id'])); |
---|
| 624 | |
---|
| 625 | if(count($arrProductInfo) > 0) { |
---|
| 626 | $arrRecommend[$no] = $arrProductInfo[0]; |
---|
| 627 | $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id']; |
---|
| 628 | $arrRecommend[$no]['comment'] = $arrRet[$i]['comment']; |
---|
| 629 | $no++; |
---|
| 630 | } |
---|
| 631 | } |
---|
| 632 | return $arrRecommend; |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | /* 入力内容のチェック */ |
---|
| 636 | function lfCheckError() { |
---|
| 637 | // 入力データを渡す。 |
---|
| 638 | $arrRet = $this->objFormParam->getHashArray(); |
---|
| 639 | $objErr = new SC_CheckError($arrRet); |
---|
| 640 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
| 641 | |
---|
| 642 | // 複数項目チェック |
---|
| 643 | if ($this->tpl_classcat_find1) { |
---|
| 644 | $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); |
---|
| 645 | } |
---|
| 646 | if ($this->tpl_classcat_find2) { |
---|
| 647 | $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); |
---|
| 648 | } |
---|
| 649 | |
---|
| 650 | return $objErr->arrErr; |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | //閲覧履歴新規登録 |
---|
| 654 | function lfRegistReadingData($tmp_id, $customer_id){ |
---|
| 655 | $objQuery = new SC_Query; |
---|
| 656 | $sqlval['customer_id'] = $customer_id; |
---|
| 657 | $sqlval['reading_product_id'] = $tmp_id; |
---|
| 658 | $sqlval['create_date'] = 'NOW()'; |
---|
| 659 | $sqlval['update_date'] = 'NOW()'; |
---|
| 660 | $objQuery->insert("dtb_customer_reading", $sqlval); |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | //この商品を買った人はこんな商品も買っています |
---|
| 664 | function lfGetRelateProducts($tmp_id) { |
---|
| 665 | $objQuery = new SC_Query; |
---|
| 666 | //自動抽出 |
---|
| 667 | $objQuery->setorder("random()"); |
---|
| 668 | //表示件数の制限 |
---|
| 669 | $objQuery->setlimit(RELATED_PRODUCTS_MAX); |
---|
| 670 | //検索条件 |
---|
| 671 | $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate"; |
---|
| 672 | $from = "vw_products_allclass AS allcls "; |
---|
| 673 | $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? "; |
---|
| 674 | $arrval[] = $tmp_id; |
---|
| 675 | //結果の取得 |
---|
| 676 | $arrProducts = $objQuery->select($col, $from, $where, $arrval); |
---|
| 677 | |
---|
| 678 | return $arrProducts; |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | //商品ごとのレビュー情報を取得する |
---|
| 682 | function lfGetReviewData($id) { |
---|
| 683 | $objQuery = new SC_Query; |
---|
| 684 | //商品ごとのレビュー情報を取得する |
---|
| 685 | $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment"; |
---|
| 686 | $from = "dtb_review"; |
---|
| 687 | $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX; |
---|
| 688 | $arrval[] = $id; |
---|
| 689 | $arrReview = $objQuery->select($col, $from, $where, $arrval); |
---|
| 690 | return $arrReview; |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | /* |
---|
| 694 | * 商品ごとのトラックバック情報を取得する |
---|
| 695 | * |
---|
| 696 | * @param $product_id |
---|
| 697 | * @return $arrTrackback |
---|
| 698 | */ |
---|
| 699 | function lfGetTrackbackData($product_id) { |
---|
| 700 | |
---|
| 701 | $arrTrackback = array(); |
---|
| 702 | |
---|
| 703 | $objQuery = new SC_Query; |
---|
| 704 | //商品ごとのトラックバック情報を取得する |
---|
| 705 | $col = "blog_name, url, title, excerpt, title, create_date"; |
---|
| 706 | $from = "dtb_trackback"; |
---|
| 707 | $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX; |
---|
| 708 | $arrval[] = $product_id; |
---|
| 709 | $arrTrackback = $objQuery->select($col, $from, $where, $arrval); |
---|
| 710 | return $arrTrackback; |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | //支払方法の取得 |
---|
| 714 | //payment_id 1:クレジット 2:ショッピングローン |
---|
| 715 | function lfGetPayment() { |
---|
| 716 | $objQuery = new SC_Query; |
---|
| 717 | $col = "payment_id, rule, payment_method"; |
---|
| 718 | $from = "dtb_payment"; |
---|
| 719 | $where = "del_flg = 0"; |
---|
| 720 | $order = "payment_id"; |
---|
| 721 | $objQuery->setorder($order); |
---|
| 722 | $arrRet = $objQuery->select($col, $from, $where); |
---|
| 723 | return $arrRet; |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | function lfConvertParam() { |
---|
| 727 | if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = ""; |
---|
| 728 | $value = $this->arrForm['quantity']['value']; |
---|
| 729 | $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE); |
---|
| 730 | } |
---|
| 731 | } |
---|
| 732 | ?> |
---|