- Timestamp:
- 2010/03/11 10:35:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tmp/version-2_5-test/data/class/pages/products/LC_Page_Products_Detail.php
r18562 r18609 78 78 */ 79 79 function process() { 80 $objView = new SC_SiteView(); 80 // プロダクトIDの正当性チェック 81 $product_id = $this->lfCheckProductId(); 82 83 $objView = new SC_SiteView(strlen($_POST['mode']) == 0); 81 84 $objCustomer = new SC_Customer(); 82 85 $objQuery = new SC_Query(); … … 86 89 $helper = new SC_Helper_PageLayout_Ex(); 87 90 $helper->sfGetPageLayout($this, false, "products/detail.php"); 91 92 // ログイン中のユーザが商品をお気に入りにいれる処理 93 if ($objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) { 94 // 値の正当性チェック 95 if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) { 96 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 97 exit; 98 } else { 99 $this->arrErr = $this->lfCheckError(); 100 if(count($this->arrErr) == 0) { 101 $customer_id = $objCustomer->getValue('customer_id'); 102 $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']); 103 } 104 } 105 } 88 106 89 107 // パラメータ管理クラス … … 99 117 $this->lfInitFile(); 100 118 101 // 管理ページからの確認の場合は、非公開の商品も表示する。102 if(isset($_GET['admin']) && $_GET['admin'] == 'on') {103 SC_Utils_Ex::sfIsSuccess(new SC_Session());104 $status = true;105 $where = "del_flg = 0";106 } else {107 $status = false;108 $where = "del_flg = 0 AND status = 1";109 }110 111 if(isset($_POST['mode']) && $_POST['mode'] != "") {112 $tmp_id = $_POST['product_id'];113 } else {114 $tmp_id = $_GET['product_id'];115 }116 117 // 値の正当性チェック118 if(!SC_Utils_Ex::sfIsInt($_GET['product_id'])119 || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {120 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);121 }122 119 // ログイン判定 123 if ($objCustomer->isLoginSuccess() === true) {120 if ($objCustomer->isLoginSuccess() === true) { 124 121 //お気に入りボタン表示 125 122 $this->tpl_login = true; … … 136 133 if ($rpcnt < CUSTOMER_READING_MAX){ 137 134 //閲覧履歴に新規追加 138 lfRegistReadingData($ tmp_id, $objCustomer->getValue('customer_id'));135 lfRegistReadingData($product_id, $objCustomer->getValue('customer_id')); 139 136 } else { 140 137 //閲覧履歴の中で一番古いものを削除して新規追加 … … 146 143 $objQuery->delete($table, $where, $arrval); 147 144 //追加 148 lfRegistReadingData($ tmp_id, $objCustomer->getValue('customer_id'));145 lfRegistReadingData($product_id, $objCustomer->getValue('customer_id')); 149 146 } 150 147 */ 151 148 } 152 149 153 154 150 // 規格選択セレクトボックスの作成 155 $this->lfMakeSelect($tmp_id); 151 $this->lfMakeSelect($product_id); 152 153 require_once CLASS_PATH . 'SC_Product.php'; 154 $objProduct = new SC_Product($product_id); 155 // 規格1クラス名 156 $this->tpl_class_name1 = $objProduct->className1[$product_id]; 157 158 // 規格2クラス名 159 $this->tpl_class_name2 = $objProduct->className2[$product_id]; 160 161 // 規格1 162 $this->arrClassCat1 = $objProduct->classCats1[$product_id]; 163 164 // 規格1が設定されている 165 $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; 166 // 規格2が設定されている 167 $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; 168 169 $this->tpl_stock_find = $objProduct->stock_find[$product_id]; 170 171 require_once DATA_PATH . 'module/Services/JSON.php'; 172 $objJson = new Services_JSON(); 173 $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';'; 174 $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}'; 175 $this->tpl_onload .= 'lnOnLoad();'; 156 176 157 177 // 商品IDをFORM内に保持する。 158 $this->tpl_product_id = $ tmp_id;178 $this->tpl_product_id = $product_id; 159 179 160 180 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 161 181 $arrErr = array(); 182 162 183 switch($_POST['mode']) { 163 case 'cart': 164 // 入力値の変換 165 $this->objFormParam->convParam(); 166 $this->arrErr = $this->lfCheckError(); 167 if(count($this->arrErr) == 0) { 168 $objCartSess = new SC_CartSession(); 169 $classcategory_id1 = $_POST['classcategory_id1']; 170 $classcategory_id2 = $_POST['classcategory_id2']; 171 172 if (!empty($_POST['gmo_oneclick'])) { 173 $objCartSess->delAllProducts(); 174 } 175 176 // 規格1が設定されていない場合 177 if(!$this->tpl_classcat_find1) { 178 $classcategory_id1 = '0'; 179 } 180 181 // 規格2が設定されていない場合 182 if(!$this->tpl_classcat_find2) { 183 $classcategory_id2 = '0'; 184 } 185 186 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 187 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 188 189 if (!empty($_POST['gmo_oneclick'])) { 190 $objSiteSess = new SC_SiteSession; 191 $objSiteSess->setRegistFlag(); 192 $objCartSess->saveCurrentCart($objSiteSess->getUniqId()); 193 194 $this->sendRedirect($this->getLocation( 195 URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true)); 184 case 'cart': 185 // 入力値の変換 186 $this->objFormParam->convParam(); 187 $arrErr = $this->lfCheckError(); 188 if (count($arrErr) == 0) { 189 $objCartSess = new SC_CartSession(); 190 $classcategory_id1 = $_POST['classcategory_id1']; 191 $classcategory_id2 = $_POST['classcategory_id2']; 192 193 if (!empty($_POST['gmo_oneclick'])) { 194 $objCartSess->delAllProducts(); 195 } 196 197 // 規格1が設定されていない場合 198 if(!$this->tpl_classcat_find1) { 199 $classcategory_id1 = '0'; 200 } 201 202 // 規格2が設定されていない場合 203 if(!$this->tpl_classcat_find2) { 204 $classcategory_id2 = '0'; 205 } 206 207 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 208 209 if (!empty($_POST['gmo_oneclick'])) { 210 $objSiteSess = new SC_SiteSession; 211 $objSiteSess->setRegistFlag(); 212 $objCartSess->saveCurrentCart($objSiteSess->getUniqId()); 213 214 $this->sendRedirect($this->getLocation( 215 URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true)); 216 exit; 217 } 218 219 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 196 220 exit; 197 221 } 198 199 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 200 exit; 201 } 202 break; 203 204 case 'add_favorite': 205 // お気に入りに追加する 206 $this->lfAddFavoriteProduct($objCustomer); 207 break; 208 209 default: 210 break; 211 } 212 213 $objQuery = new SC_Query(); 222 break; 223 224 default: 225 break; 226 } 227 $this->arrErr = $arrErr; 228 214 229 // DBから商品情報を取得する。 215 $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = alldtl.product_id) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $tmp_id));230 $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE product_id = alldtl.product_id AND customer_id = ?) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $product_id)); 216 231 $this->arrProduct = $arrRet[0]; 217 232 218 // 商品コードの取得 219 $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; 220 $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); 221 $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); 222 $this->arrProductCode = $arrProductCode["product_code"]; 223 233 // 購入制限数を取得 234 if (!SC_Utils_Ex::sfIsInt($this->arrProduct['sale_limit']) || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { 235 $this->tpl_sale_limit = SALE_LIMIT_MAX; 236 } else { 237 $this->tpl_sale_limit = $this->arrProduct['sale_limit']; 238 } 239 224 240 // サブタイトルを取得 225 $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'],'',$status); 226 $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 227 $this->tpl_subtitle = $arrFirstCat['name']; 228 241 $this->tpl_subtitle = $this->arrProduct['name']; 242 229 243 // 関連カテゴリを取得 230 $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id); 231 232 // DBからのデータを引き継ぐ 233 $this->objUpFile->setDBFileList($this->arrProduct); 234 // ファイル表示用配列を渡す 235 $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); 244 $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id); 245 246 // 画像ファイル指定がない場合の置換処理 247 $this->arrProduct['main_image'] 248 = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 249 250 $this->lfSetFile(); 236 251 // 支払方法の取得 237 252 $this->arrPayment = $this->lfGetPayment(); … … 239 254 $this->arrForm = $this->objFormParam->getFormParamList(); 240 255 //レビュー情報の取得 241 $this->arrReview = $this->lfGetReviewData($ tmp_id);256 $this->arrReview = $this->lfGetReviewData($product_id); 242 257 // トラックバック情報の取得 243 258 … … 247 262 } else { 248 263 $this->arrTrackbackView = "ON"; 249 $this->arrTrackback = $this->lfGetTrackbackData($tmp_id); 250 } 251 $this->trackback_url = TRACKBACK_TO_URL . $tmp_id; 252 // タイトルに商品名を入れる 253 $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; 254 //オススメ商品情報表示 255 $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); 256 //この商品を買った人はこんな商品も買っています 257 $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); 264 $this->arrTrackback = $this->lfGetTrackbackData($product_id); 265 } 266 $this->trackback_url = TRACKBACK_TO_URL . $product_id; 267 //関連商品情報表示 268 $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 258 269 259 270 $this->lfConvertParam(); … … 290 301 */ 291 302 function mobileProcess() { 303 // プロダクトIDの正当性チェック 304 $product_id = $this->lfCheckProductId(); 305 292 306 $objView = new SC_MobileView(); 293 307 $objCustomer = new SC_Customer(); … … 307 321 $this->lfInitFile(); 308 322 309 if (!isset($_POST['mode'])) $_POST['mode'] = "";310 311 if(!empty($_POST['mode'])) {312 $tmp_id = $_POST['product_id'];313 } else {314 $tmp_id = $_GET['product_id'];315 }316 317 // 値の正当性チェック318 if(!SC_Utils_Ex::sfIsInt($tmp_id)319 || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) {320 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);321 }322 323 323 // ログイン判定 324 324 if($objCustomer->isLoginSuccess(true)) { … … 337 337 if ($rpcnt < CUSTOMER_READING_MAX){ 338 338 //閲覧履歴に新規追加 339 lfRegistReadingData($ tmp_id, $objCustomer->getValue('customer_id'));339 lfRegistReadingData($product_id, $objCustomer->getValue('customer_id')); 340 340 } else { 341 341 //閲覧履歴の中で一番古いものを削除して新規追加 … … 347 347 $objQuery->delete($table, $where, $arrval); 348 348 //追加 349 lfRegistReadingData($ tmp_id, $objCustomer->getValue('customer_id'));349 lfRegistReadingData($product_id, $objCustomer->getValue('customer_id')); 350 350 } 351 351 */ … … 354 354 355 355 // 規格選択セレクトボックスの作成 356 $this->lfMakeSelectMobile($this, $ tmp_id);356 $this->lfMakeSelectMobile($this, $product_id); 357 357 358 358 // 商品IDをFORM内に保持する。 359 $this->tpl_product_id = $ tmp_id;359 $this->tpl_product_id = $product_id; 360 360 361 361 switch($_POST['mode']) { … … 418 418 } 419 419 420 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);421 420 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 422 421 $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true); … … 431 430 $objQuery = new SC_Query(); 432 431 // DBから商品情報を取得する。 433 $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($ tmp_id));432 $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($product_id)); 434 433 $this->arrProduct = $arrRet[0]; 435 434 436 // 商品コードの取得 437 $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; 438 $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); 439 $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode); 440 $this->arrProductCode = $arrProductCode["product_code"]; 435 // 購入制限数を取得 436 if (!SC_Utils_Ex::sfIsInt($this->arrProduct['sale_limit']) || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { 437 $this->tpl_sale_limit = SALE_LIMIT_MAX; 438 } else { 439 $this->tpl_sale_limit = $this->arrProduct['sale_limit']; 440 } 441 441 442 442 // サブタイトルを取得 443 $ arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']);444 $tpl_subtitle = $arrFirstCat['name'];445 $this->tpl_subtitle = $tpl_subtitle;446 447 // DBからのデータを引き継ぐ448 $this->objUpFile->setDBFileList($this->arrProduct);449 // ファイル 表示用配列を渡す450 $this-> arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);443 $this->tpl_subtitle = $this->arrProduct["name"]; 444 445 // 画像ファイル指定がない場合の置換処理 446 $this->arrProduct['main_image'] 447 = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 448 449 // ファイル情報のセット 450 $this->lfSetFile(); 451 451 // 支払方法の取得 452 452 $this->arrPayment = $this->lfGetPayment(); … … 454 454 $this->arrForm = $this->objFormParam->getFormParamList(); 455 455 //レビュー情報の取得 456 $this->arrReview = $this->lfGetReviewData($ tmp_id);456 $this->arrReview = $this->lfGetReviewData($product_id); 457 457 // タイトルに商品名を入れる 458 458 $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; 459 //オススメ商品情報表示 460 $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); 461 //この商品を買った人はこんな商品も買っています 462 $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); 459 //関連商品情報表示 460 $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 463 461 464 462 $objView->assignobj($this); … … 466 464 } 467 465 466 /* プロダクトIDの正当性チェック */ 467 function lfCheckProductId() { 468 // 管理機能からの確認の場合は、非公開の商品も表示する。 469 if (isset($_GET['admin']) && $_GET['admin'] == 'on') { 470 SC_Utils_Ex::sfIsSuccess(new SC_Session()); 471 $status = true; 472 $where = 'del_flg = 0'; 473 } else { 474 $status = false; 475 $where = 'del_flg = 0 AND status = 1'; 476 } 477 478 if (defined('MOBILE_SITE')) { 479 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 480 if (!empty($_POST['mode'])) { 481 $product_id = $_POST['product_id']; 482 } else { 483 $product_id = $_GET['product_id']; 484 } 485 } else { 486 if(isset($_POST['mode']) && $_POST['mode'] != '') { 487 $product_id = $_POST['product_id']; 488 } else { 489 $product_id = $_GET['product_id']; 490 } 491 } 492 493 $objDb = new SC_Helper_DB_Ex(); 494 if(!SC_Utils_Ex::sfIsInt($product_id) 495 || SC_Utils_Ex::sfIsZeroFilling($product_id) 496 || !$objDb->sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where)) 497 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 498 return $product_id; 499 } 500 468 501 /* ファイル情報の初期化 */ 469 502 function lfInitFile() { 470 $this->objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);471 503 $this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); 472 $this->objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT);473 504 for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { 474 505 $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT); 475 $this->objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT);476 506 } 477 507 $this->objUpFile->addFile("商品比較画像", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT); … … 480 510 481 511 /* 規格選択セレクトボックスの作成 */ 482 function lfMakeSelect($product_id) { 512 function lfMakeSelect() { 513 514 // 選択されている規格 515 $classcategory_id1 516 = isset($_POST['classcategory_id1']) && is_numeric($_POST['classcategory_id1']) 517 ? $_POST['classcategory_id1'] 518 : ''; 519 520 $classcategory_id2 521 = isset($_POST['classcategory_id2']) && is_numeric($_POST['classcategory_id2']) 522 ? $_POST['classcategory_id2'] 523 : ''; 524 525 require_once DATA_PATH . 'module/Services/JSON.php'; 526 $this->js_lnOnload .= 'fnSetClassCategories(' 527 . 'document.form1, ' 528 . Services_JSON::encode($classcategory_id2) 529 . '); '; 530 } 531 532 /* 規格選択セレクトボックスの作成 533 * FIXME 要リファクタリング 534 */ 535 function lfMakeSelectMobile(&$objPage, $product_id) { 483 536 484 537 $objDb = new SC_Helper_DB_Ex(); … … 496 549 497 550 // 規格1クラス名の取得 498 $this->tpl_class_name1 = isset($arrClassName[$arrProductsClass[0]['class_id1']]) 499 ? $arrClassName[$arrProductsClass[0]['class_id1']] : ""; 551 $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']]; 500 552 // 規格2クラス名の取得 501 $this->tpl_class_name2 = isset($arrClassName[$arrProductsClass[0]['class_id2']]) 502 ? $arrClassName[$arrProductsClass[0]['class_id2']] : ""; 553 $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']]; 503 554 504 555 // すべての組み合わせ数 … … 507 558 $classcat_id1 = ""; 508 559 509 $arrSele = array(); 510 $arrList = array(); 511 512 $list_id = 0; 513 $arrList[0] = "\tlist0 = new Array('選択してください'"; 514 $arrVal[0] = "\tval0 = new Array(''"; 560 $arrSele1 = array(); 561 $arrSele2 = array(); 515 562 516 563 for ($i = 0; $i < $count; $i++) { … … 524 571 // 規格1のセレクトボックス用 525 572 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 526 $arrList[$list_id].=");\n";527 $arrVal[$list_id].=");\n";528 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];529 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];530 $list_id++;531 }532 533 // 規格2のセレクトボックス用534 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];535 536 // セレクトボックス表示値537 if (!isset($arrList[$list_id])) $arrList[$list_id] = "";538 if($arrList[$list_id] == "") {539 $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'";540 } else {541 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";542 }543 544 // セレクトボックスPOST値545 if (!isset($arrVal[$list_id])) $arrVal[$list_id] = "";546 if($arrVal[$list_id] == "") {547 $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'";548 } else {549 $arrVal[$list_id].= ", '".$classcat_id2."'";550 }551 }552 553 $arrList[$list_id].=");\n";554 $arrVal[$list_id].=");\n";555 556 // 規格1557 $this->arrClassCat1 = $arrSele;558 559 $lists = "\tlists = new Array(";560 $no = 0;561 562 foreach($arrList as $val) {563 $this->tpl_javascript.= $val;564 if ($no != 0) {565 $lists.= ",list".$no;566 } else {567 $lists.= "list".$no;568 }569 $no++;570 }571 $this->tpl_javascript.=$lists.");\n";572 573 $vals = "\tvals = new Array(";574 $no = 0;575 576 foreach($arrVal as $val) {577 $this->tpl_javascript.= $val;578 if ($no != 0) {579 $vals.= ",val".$no;580 } else {581 $vals.= "val".$no;582 }583 $no++;584 }585 $this->tpl_javascript.=$vals.");\n";586 587 // 選択されている規格2ID588 if (!isset($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = "";589 $this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');";590 591 // 規格1が設定されている592 if($arrProductsClass[0]['classcategory_id1'] != '0') {593 $classcat_find1 = true;594 }595 596 // 規格2が設定されている597 if($arrProductsClass[0]['classcategory_id2'] != '0') {598 $classcat_find2 = true;599 }600 601 $this->tpl_classcat_find1 = $classcat_find1;602 $this->tpl_classcat_find2 = $classcat_find2;603 $this->tpl_stock_find = $stock_find;604 }605 606 /* 規格選択セレクトボックスの作成607 * FIXME 要リファクタリング608 */609 function lfMakeSelectMobile(&$objPage, $product_id) {610 611 $objDb = new SC_Helper_DB_Ex();612 $classcat_find1 = false;613 $classcat_find2 = false;614 // 在庫ありの商品の有無615 $stock_find = false;616 617 // 規格名一覧618 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");619 // 規格分類名一覧620 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");621 // 商品規格情報の取得622 $arrProductsClass = $this->lfGetProductsClass($product_id);623 624 // 規格1クラス名の取得625 $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];626 // 規格2クラス名の取得627 $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];628 629 // すべての組み合わせ数630 $count = count($arrProductsClass);631 632 $classcat_id1 = "";633 634 $arrSele1 = array();635 $arrSele2 = array();636 637 for ($i = 0; $i < $count; $i++) {638 // 在庫のチェック639 if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {640 continue;641 }642 643 $stock_find = true;644 645 // 規格1のセレクトボックス用646 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){647 573 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 648 574 $arrSele1[$classcat_id1] = $arrClassCatName[$classcat_id1]; … … 679 605 $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 680 606 $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 681 $this->objFormParam->addParam(" 個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));607 $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 682 608 } 683 609 … … 697 623 } 698 624 699 /* 登録済み オススメ商品の読み込み */625 /* 登録済み関連商品の読み込み */ 700 626 function lfPreGetRecommendProducts($product_id) { 701 627 $arrRecommend = array(); … … 728 654 /* 入力内容のチェック */ 729 655 function lfCheckError() { 730 // 入力データを渡す。 731 $arrRet = $this->objFormParam->getHashArray(); 732 $objErr = new SC_CheckError($arrRet); 733 $objErr->arrErr = $this->objFormParam->checkError(); 734 735 // 複数項目チェック 736 if ($this->tpl_classcat_find1) { 737 $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 738 } 739 if ($this->tpl_classcat_find2) { 740 $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 656 if ($_POST['mode'] == "add_favorite") { 657 $objCustomer = new SC_Customer(); 658 $objErr = new SC_CheckError(); 659 $customer_id = $objCustomer->getValue('customer_id'); 660 if (SC_Helper_DB_Ex::sfDataExists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id))) { 661 $objErr->arrErr['add_favorite'.$favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 662 } 663 } else { 664 // 入力データを渡す。 665 $arrRet = $this->objFormParam->getHashArray(); 666 $objErr = new SC_CheckError($arrRet); 667 $objErr->arrErr = $this->objFormParam->checkError(); 668 669 // 複数項目チェック 670 if ($this->tpl_classcat_find1) { 671 $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 672 } 673 if ($this->tpl_classcat_find2) { 674 $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 675 } 741 676 } 742 677 … … 745 680 746 681 //閲覧履歴新規登録 747 function lfRegistReadingData($ tmp_id, $customer_id){682 function lfRegistReadingData($product_id, $customer_id){ 748 683 $objQuery = new SC_Query; 749 684 $sqlval['customer_id'] = $customer_id; 750 $sqlval['reading_product_id'] = $ tmp_id;685 $sqlval['reading_product_id'] = $product_id; 751 686 $sqlval['create_date'] = 'NOW()'; 752 687 $sqlval['update_date'] = 'NOW()'; 753 688 $objQuery->insert("dtb_customer_reading", $sqlval); 754 }755 756 //この商品を買った人はこんな商品も買っています FIXME757 function lfGetRelateProducts($tmp_id) {758 $objQuery = new SC_Query;759 //自動抽出760 $objQuery->setorder("random()");761 //表示件数の制限762 $objQuery->setlimit(RELATED_PRODUCTS_MAX);763 //検索条件764 $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate";765 $from = "vw_products_allclass AS allcls ";766 $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? ";767 $arrval[] = $tmp_id;768 //結果の取得769 $arrProducts = $objQuery->select($col, $from, $where, $arrval);770 771 return $arrProducts;772 689 } 773 690 … … 823 740 } 824 741 825 /** 826 * 商品をお気に入りにいれる処理 827 * @param object 顧客管理用クラスオブジェクト 828 */ 829 function lfAddFavoriteProduct($objCustomer) 830 { 831 // ログイン中のユーザーかつ、お気に入り商品機能ONの時 832 if ( $objCustomer->isLoginSuccess() === true && OPTION_FAVOFITE_PRODUCT == 1 ){ 833 $add_favorite_product_id = $_POST['favorite_product_id']; // お気に入りに追加する商品ID 834 $customer_id = $objCustomer->getValue('customer_id'); // ログイン中の顧客ID 835 836 // お気に入りに商品を追加する際のエラーチェックを行う 837 $this->arrErr = array(); // エラー内容 838 $this->lfCheckAddFavoriteProduct($customer_id, $add_favorite_product_id); 839 840 if( count($this->arrErr) == 0 ) { 841 // お気に入りに商品を追加する 842 $this->lfRegistFavoriteProduct($customer_id, $add_favorite_product_id); 843 } 844 } 845 return ; 846 } 847 848 /** 849 * 商品をお気に入りにいれる際のエラーチェックを行う 850 * @param int $customer_id 顧客ID 851 * @param int $add_favorite_product_id お気に入りに追加する商品ID 852 */ 853 function lfCheckAddFavoriteProduct($customer_id, $add_favorite_product_id) 854 { 855 // 値の正当性チェック 856 $objDb = new SC_Helper_DB_Ex(); 857 if( !SC_Utils_Ex::sfIsInt($add_favorite_product_id) || !$objDb->sfIsRecord('dtb_products', 'product_id', $add_favorite_product_id, 'del_flg = 0 AND status = 1') ) { 858 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 859 exit; 860 } 861 862 // 既にお気に入り商品として追加されていないかチェック 863 if (SC_Helper_DB_Ex::sfDataExists( 'dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $add_favorite_product_id)) ) { 864 $this->arrErr['add_favorite'.$add_favorite_product_id] = "※ この商品は既にお気に入りに追加されています。<br />"; 865 $this->add_favorite_product_id = $add_favorite_product_id; 866 } 867 } 868 869 /** 742 /* 743 * ファイルの情報をセットする 744 * 745 */ 746 function lfSetFile() { 747 // DBからのデータを引き継ぐ 748 $this->objUpFile->setDBFileList($this->arrProduct); 749 // ファイル表示用配列を渡す 750 $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); 751 752 // サブ画像の有無を判定 753 $this->subImageFlag = false; 754 for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { 755 if ($this->arrFile["sub_image" . $i]["filepath"] != "") { 756 $this->subImageFlag = true; 757 } 758 } 759 } 760 761 /* 870 762 * お気に入り商品登録 871 * @param int $customer_id 顧客ID 872 * @param int $add_favorite_product_id お気に入りに追加する商品ID 873 */ 874 function lfRegistFavoriteProduct($customer_id, $add_favorite_product_id) { 875 $sqlval = array(); 876 $sqlval['customer_id'] = $customer_id; 877 $sqlval['product_id'] = $add_favorite_product_id; 878 $sqlval['update_date'] = "now()"; 879 $sqlval['create_date'] = "now()"; 880 763 */ 764 function lfRegistFavoriteProduct($customer_id, $product_id) { 881 765 $objQuery = new SC_Query(); 882 $objQuery->begin(); 883 $objQuery->insert('dtb_customer_favorite_products', $sqlval); 884 $objQuery->commit(); 885 } 766 $objConn = new SC_DbConn(); 767 $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_favorite_products WHERE customer_id = ? AND product_id = ?", array($customer_id, $product_id)); 768 769 if ($count == 0) { 770 $sqlval['customer_id'] = $customer_id; 771 $sqlval['product_id'] = $product_id; 772 $sqlval['update_date'] = "now()"; 773 $sqlval['create_date'] = "now()"; 774 775 $objQuery->begin(); 776 $objQuery->insert('dtb_customer_favorite_products', $sqlval); 777 $objQuery->commit(); 778 } 779 } 780 886 781 } 887 782 ?>
Note: See TracChangeset
for help on using the changeset viewer.