- Timestamp:
- 2009/09/02 18:26:38 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/pages/products/LC_Page_Products_Detail.php
r18275 r18277 151 151 $this->lfMakeSelect($product_id); 152 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();'; 176 153 177 // 商品IDをFORM内に保持する。 154 178 $this->tpl_product_id = $product_id; 155 179 156 180 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 157 181 $arrErr = array(); 182 158 183 switch($_POST['mode']) { 159 case 'cart': 160 // 入力値の変換 161 $this->objFormParam->convParam(); 162 $this->arrErr = $this->lfCheckError(); 163 if(count($this->arrErr) == 0) { 164 $objCartSess = new SC_CartSession(); 165 $classcategory_id1 = $_POST['classcategory_id1']; 166 $classcategory_id2 = $_POST['classcategory_id2']; 167 168 if (!empty($_POST['gmo_oneclick'])) { 169 $objCartSess->delAllProducts(); 170 } 171 172 // 規格1が設定されていない場合 173 if(!$this->tpl_classcat_find1) { 174 $classcategory_id1 = '0'; 175 } 176 177 // 規格2が設定されていない場合 178 if(!$this->tpl_classcat_find2) { 179 $classcategory_id2 = '0'; 180 } 181 182 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 183 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 184 185 if (!empty($_POST['gmo_oneclick'])) { 186 $objSiteSess = new SC_SiteSession; 187 $objSiteSess->setRegistFlag(); 188 $objCartSess->saveCurrentCart($objSiteSess->getUniqId()); 189 190 $this->sendRedirect($this->getLocation( 191 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->setPrevURL($_SERVER['REQUEST_URI']); 208 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 209 210 if (!empty($_POST['gmo_oneclick'])) { 211 $objSiteSess = new SC_SiteSession; 212 $objSiteSess->setRegistFlag(); 213 $objCartSess->saveCurrentCart($objSiteSess->getUniqId()); 214 215 $this->sendRedirect($this->getLocation( 216 URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true)); 217 exit; 218 } 219 220 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 192 221 exit; 193 222 } 194 195 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 196 exit; 197 } 198 break; 199 200 default: 201 break; 202 } 203 204 $objQuery = new SC_Query(); 223 break; 224 225 default: 226 break; 227 } 228 $this->arrErr = $arrErr; 229 205 230 // DBから商品情報を取得する。 206 231 $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)); … … 510 535 511 536 /* 規格選択セレクトボックスの作成 */ 512 function lfMakeSelect($product_id) { 513 514 $objDb = new SC_Helper_DB_Ex(); 515 $classcat_find1 = false; 516 $classcat_find2 = false; 517 // 在庫ありの商品の有無 518 $stock_find = false; 519 520 // 規格名一覧 521 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 522 // 規格分類名一覧 523 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 524 // 商品規格情報の取得 525 $arrProductsClass = $this->lfGetProductsClass($product_id); 526 527 // 規格1クラス名の取得 528 $this->tpl_class_name1 = isset($arrClassName[$arrProductsClass[0]['class_id1']]) 529 ? $arrClassName[$arrProductsClass[0]['class_id1']] : ""; 530 // 規格2クラス名の取得 531 $this->tpl_class_name2 = isset($arrClassName[$arrProductsClass[0]['class_id2']]) 532 ? $arrClassName[$arrProductsClass[0]['class_id2']] : ""; 533 534 // すべての組み合わせ数 535 $count = count($arrProductsClass); 536 537 $classcat_id1 = ""; 538 539 $arrSele = array(); 540 $arrList = array(); 541 542 $list_id = 0; 543 $arrList[0] = "\tlist0 = new Array('選択してください'"; 544 $arrVal[0] = "\tval0 = new Array(''"; 545 546 for ($i = 0; $i < $count; $i++) { 547 // 在庫のチェック 548 if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 549 continue; 550 } 551 552 $stock_find = true; 553 554 // 規格1のセレクトボックス用 555 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 556 $arrList[$list_id].=");\n"; 557 $arrVal[$list_id].=");\n"; 558 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 559 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 560 $list_id++; 561 } 562 563 // 規格2のセレクトボックス用 564 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 565 566 // セレクトボックス表示値 567 if (!isset($arrList[$list_id])) $arrList[$list_id] = ""; 568 if($arrList[$list_id] == "") { 569 $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'"; 570 } else { 571 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 572 } 573 574 // セレクトボックスPOST値 575 if (!isset($arrVal[$list_id])) $arrVal[$list_id] = ""; 576 if($arrVal[$list_id] == "") { 577 $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'"; 578 } else { 579 $arrVal[$list_id].= ", '".$classcat_id2."'"; 580 } 581 } 582 583 $arrList[$list_id].=");\n"; 584 $arrVal[$list_id].=");\n"; 585 586 // 規格1 587 $this->arrClassCat1 = $arrSele; 588 589 $lists = "\tlists = new Array("; 590 $no = 0; 591 592 foreach($arrList as $val) { 593 $this->tpl_javascript.= $val; 594 if ($no != 0) { 595 $lists.= ",list".$no; 596 } else { 597 $lists.= "list".$no; 598 } 599 $no++; 600 } 601 $this->tpl_javascript.=$lists.");\n"; 602 603 $vals = "\tvals = new Array("; 604 $no = 0; 605 606 foreach($arrVal as $val) { 607 $this->tpl_javascript.= $val; 608 if ($no != 0) { 609 $vals.= ",val".$no; 610 } else { 611 $vals.= "val".$no; 612 } 613 $no++; 614 } 615 $this->tpl_javascript.=$vals.");\n"; 616 617 // 選択されている規格2ID 618 if (!isset($_POST['classcategory_id2'])) $_POST['classcategory_id2'] = ""; 619 $this->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . htmlspecialchars($_POST['classcategory_id2'], ENT_QUOTES) . "');"; 620 621 // 規格1が設定されている 622 if($arrProductsClass[0]['classcategory_id1'] != '0') { 623 $classcat_find1 = true; 624 } 625 626 // 規格2が設定されている 627 if($arrProductsClass[0]['classcategory_id2'] != '0') { 628 $classcat_find2 = true; 629 } 630 631 $this->tpl_classcat_find1 = $classcat_find1; 632 $this->tpl_classcat_find2 = $classcat_find2; 633 $this->tpl_stock_find = $stock_find; 537 function lfMakeSelect() { 538 539 // 選択されている規格 540 $classcategory_id1 541 = isset($_POST['classcategory_id1']) && is_numeric($_POST['classcategory_id1']) 542 ? $_POST['classcategory_id1'] 543 : ''; 544 545 $classcategory_id2 546 = isset($_POST['classcategory_id2']) && is_numeric($_POST['classcategory_id2']) 547 ? $_POST['classcategory_id2'] 548 : ''; 549 550 require_once DATA_PATH . 'module/Services/JSON.php'; 551 $this->js_lnOnload .= 'fnSetClassCategories(' 552 . 'document.form1, ' 553 . Services_JSON::encode($classcategory_id2) 554 . '); '; 634 555 } 635 556
Note: See TracChangeset
for help on using the changeset viewer.