- 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_List.php
r18562 r18609 37 37 38 38 /** テンプレートクラス名1 */ 39 var $tpl_class_name1 ;39 var $tpl_class_name1 = array(); 40 40 41 41 /** テンプレートクラス名2 */ 42 var $tpl_class_name2 ;42 var $tpl_class_name2 = array(); 43 43 44 44 /** JavaScript テンプレート */ 45 45 var $tpl_javascript; 46 47 var $orderby; 48 49 var $mode; 50 51 /** 検索条件(内部データ) */ 52 var $arrSearchData = array(); 53 54 /** 検索条件(表示用) */ 55 var $arrSearch = array(); 56 57 var $tpl_subtitle = ''; 58 59 /** ランダム文字列 **/ 60 var $tpl_rnd = ''; 46 61 47 62 // }}} … … 61 76 $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); 62 77 $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); 63 64 $this->tpl_class_name1 = array();65 $this->tpl_class_name2 = array();66 $this->allowClientCache();67 78 } 68 79 … … 73 84 */ 74 85 function process() { 75 $objView = new SC_SiteView(); 86 $this->lfLoadParam(); 87 88 $objView = new SC_SiteView(!$this->inCart); 76 89 $conn = new SC_DBConn(); 77 90 $objDb = new SC_Helper_DB_Ex(); 78 91 79 //表示件数の選択80 if(isset($_POST['disp_number'])81 && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) {82 $this->disp_number = $_POST['disp_number'];83 } else {84 //最小表示件数を選択85 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));86 }87 88 //表示順序の保存89 $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : "";90 91 // GETのカテゴリIDを元に正しいカテゴリIDを取得する。92 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);93 94 if (!isset($_GET['mode'])) $_GET['mode'] = "";95 if (!isset($_GET['name'])) $_GET['name'] = "";96 if (!isset($_POST['orderby'])) $_POST['orderby'] = "";97 if (empty($arrCategory_id)) $arrCategory_id = array("0");98 99 92 // タイトル編集 100 $tpl_subtitle = ""; 101 if ($_GET['mode'] == 'search') { 102 $tpl_subtitle = "検索結果"; 103 } elseif (empty($arrCategory_id[0])) { 104 $tpl_subtitle = "全商品"; 105 } else { 106 $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 107 $tpl_subtitle = $arrFirstCat['name']; 93 if ($this->mode == 'search') { 94 $this->tpl_subtitle = "検索結果"; 95 } elseif ($this->arrSearchData['category_id'] == 0) { 96 $this->tpl_subtitle = "全商品"; 97 } else { 98 $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 99 $this->tpl_subtitle = $arrCat['name']; 108 100 } 109 101 110 102 $objQuery = new SC_Query(); 111 $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 112 113 // 以下の条件でBEST商品を表示する 114 // ・BEST最大数の商品が登録されている。 115 // ・カテゴリIDがルートIDである。 116 // ・検索モードでない。 117 if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 118 // 商品TOPの表示処理 119 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 120 $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 121 } else { 122 if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 123 // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 124 $arrCategory_id = array(0); 125 } 126 127 // 商品一覧の表示処理 128 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); 129 130 // 検索条件を画面に表示 131 // カテゴリー検索条件 132 if (strlen($_GET['category_id']) == 0) { 133 $arrSearch['category'] = "指定なし"; 134 }else{ 135 $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); 136 $arrSearch['category'] = $arrCat; 137 } 138 139 // 商品名検索条件 140 if ($_GET['name'] === "") { 141 $arrSearch['name'] = "指定なし"; 142 }else{ 143 $arrSearch['name'] = $_GET['name']; 144 } 103 $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 104 105 // 商品一覧の表示処理 106 $this->lfDispProductsList(); 107 108 // 検索条件を画面に表示 109 // カテゴリー検索条件 110 if ($this->arrSearchData['category_id'] == 0) { 111 $this->arrSearch['category'] = "指定なし"; 112 } else { 113 $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($this->arrSearchData['category_id'])); 114 $this->arrSearch['category'] = $arrCat; 115 } 116 117 // メーカー検索条件 118 if (strlen($this->arrSearchData['maker_id']) == 0) { 119 $this->arrSearch['maker'] = "指定なし"; 120 } else { 121 $this->arrSearch['maker'] = $conn->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", $this->arrSearchData['maker_id']); 122 } 123 124 // 商品名検索条件 125 if (strlen($this->arrSearchData['name']) == 0) { 126 $this->arrSearch['name'] = "指定なし"; 127 } else { 128 $this->arrSearch['name'] = $this->arrSearchData['name']; 145 129 } 146 130 … … 149 133 $layout->sfGetPageLayout($this, false, "products/list.php"); 150 134 151 if(isset($_POST['mode']) && $_POST['mode'] == "cart" 152 && $_POST['product_id'] != "") { 153 154 // 値の正当性チェック 155 if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 135 foreach ($this->arrProducts as $arrProduct) { 136 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 137 } 138 139 if ($this->inCart) { 140 // 商品IDの正当性チェック 141 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { 156 142 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 157 } else { 158 // 入力値の変換 159 $this->arrErr = $this->lfCheckError($_POST['product_id']); 160 if(count($this->arrErr) == 0) { 161 $objCartSess = new SC_CartSession(); 162 $classcategory_id = "classcategory_id". $_POST['product_id']; 163 $classcategory_id1 = $_POST[$classcategory_id. '_1']; 164 $classcategory_id2 = $_POST[$classcategory_id. '_2']; 165 $quantity = "quantity". $_POST['product_id']; 143 } 144 $product_id = $this->arrForm['product_id']; 145 // 入力内容のチェック 146 $arrErr = $this->lfCheckError($product_id); 147 if (count($arrErr) == 0) { 148 $classcategory_id1 = $this->arrForm['classcategory_id1']; 149 $classcategory_id2 = $this->arrForm['classcategory_id2']; 166 150 // 規格1が設定されていない場合 167 if(!$this->tpl_classcat_find1[$_POST['product_id']]) {151 if (!$this->tpl_classcat_find1[$product_id]) { 168 152 $classcategory_id1 = '0'; 169 153 } 170 154 // 規格2が設定されていない場合 171 if(!$this->tpl_classcat_find2[$_POST['product_id']]) {155 if (!$this->tpl_classcat_find2[$product_id]) { 172 156 $classcategory_id2 = '0'; 173 157 } 174 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);175 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);158 $objCartSess = new SC_CartSession(); 159 $objCartSess->addProduct(array($product_id, $classcategory_id1, $classcategory_id2), $this->arrForm['quantity']); 176 160 $this->sendRedirect($this->getLocation(URL_CART_TOP)); 177 161 exit; 162 } 163 foreach (array_keys($this->arrProducts) as $key) { 164 $arrProduct =& $this->arrProducts[$key]; 165 if ($arrProduct['product_id'] == $product_id) { 166 $arrProduct['classcategory_id1'] = $this->arrForm['classcategory_id1']; 167 $arrProduct['classcategory_id2'] = $this->arrForm['classcategory_id2']; 168 $arrProduct['quantity'] = $this->arrForm['quantity']; 169 $arrProduct['arrErr'] = $arrErr; 170 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']}, '{$this->arrForm['classcategory_id2']}');\n"; 178 171 } 179 172 } 180 173 } 181 182 $this->tpl_subtitle = $tpl_subtitle; 183 184 // 支払方法の取得 185 $this->arrPayment = $this->lfGetPayment(); 186 // 入力情報を渡す 187 $this->arrForm = $_POST; 188 189 $this->lfConvertParam(); 190 191 $this->category_id = $arrCategory_id[0]; 192 $this->arrSearch = $arrSearch; 174 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 175 $this->tpl_onload .= 'fnOnLoad(); '; 176 177 $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); 193 178 194 179 $objView->assignobj($this); … … 213 198 */ 214 199 function mobileProcess() { 200 $this->lfLoadParam(); 201 215 202 $objView = new SC_MobileView(); 216 203 $conn = new SC_DBConn(); 217 204 $objDb = new SC_Helper_DB_Ex(); 218 205 219 //表示件数の選択220 if(isset($_REQUEST['disp_number'])221 && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {222 $this->disp_number = $_REQUEST['disp_number'];223 } else {224 //最小表示件数を選択225 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));226 }227 228 //表示順序の保存229 $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";230 231 // GETのカテゴリIDを元に正しいカテゴリIDを取得する。232 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);233 234 235 206 // タイトル編集 236 $tpl_subtitle = "";237 207 $tpl_search_mode = false; 238 208 239 if (!isset($_GET['mode'])) $_GET['mode'] = ""; 240 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 241 if (!isset($_GET['name'])) $_GET['name'] = ""; 242 if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = ""; 243 if (empty($arrCategory_id)) $arrCategory_id = array("0"); 244 245 if($_GET['mode'] == 'search'){ 246 $tpl_subtitle = "検索結果"; 209 if ($this->mode == 'search') { 210 $this->tpl_subtitle = "検索結果"; 247 211 $tpl_search_mode = true; 248 } elseif (empty($arrCategory_id[0])) {249 $t pl_subtitle = "全商品";250 } else{251 $arr FirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);252 $t pl_subtitle = $arrFirstCat['name'];212 } elseif ($this->arrSearchData['category_id'] == 0) { 213 $this->tpl_subtitle = "全商品"; 214 } else { 215 $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 216 $this->tpl_subtitle = $arrCat['name']; 253 217 } 254 218 255 219 $objQuery = new SC_Query(); 256 $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 257 258 // 以下の条件でBEST商品を表示する 259 // ・BEST最大数の商品が登録されている。 260 // ・カテゴリIDがルートIDである。 261 // ・検索モードでない。 262 if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 263 // 商品TOPの表示処理 264 265 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 266 $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 267 } else { 268 if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 269 // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 270 $arrCategory_id = array(""); 271 } 220 $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 272 221 273 222 // 商品一覧の表示処理 274 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']);223 $this->lfDispProductsList(); 275 224 276 225 // 検索条件を画面に表示 277 226 // カテゴリー検索条件 278 if (strlen($_GET['category_id'])== 0) {279 $arrSearch['category'] = "指定なし";280 }else{227 if ($this->arrSearchData['category_id'] == 0) { 228 $this->arrSearch['category'] = "指定なし"; 229 } else { 281 230 $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); 282 $arrSearch['category'] = $arrCat;231 $this->arrSearch['category'] = $arrCat; 283 232 } 284 233 285 234 // 商品名検索条件 286 if ($_GET['name'] === "") { 287 $arrSearch['name'] = "指定なし"; 288 }else{ 289 $arrSearch['name'] = $_GET['name']; 290 } 291 } 292 293 if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 294 // 値の正当性チェック 295 if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 296 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); 235 if ($this->arrForm['name'] === "") { 236 $this->arrSearch['name'] = "指定なし"; 297 237 } else { 298 // 入力値の変換 299 $this->arrErr = $this->lfCheckError($_POST['product_id']); 300 if(count($this->arrErr) == 0) { 301 $objCartSess = new SC_CartSession(); 302 $classcategory_id = "classcategory_id". $_POST['product_id']; 303 $classcategory_id1 = $_POST[$classcategory_id. '_1']; 304 $classcategory_id2 = $_POST[$classcategory_id. '_2']; 305 $quantity = "quantity". $_POST['product_id']; 306 // 規格1が設定されていない場合 307 if(!$this->tpl_classcat_find1[$_POST['product_id']]) { 308 $classcategory_id1 = '0'; 238 $this->arrSearch['name'] = $this->arrForm['name']; 309 239 } 310 // 規格2が設定されていない場合311 if(!$this->tpl_classcat_find2[$_POST['product_id']]) {312 $classcategory_id2 = '0';313 }314 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);315 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);316 $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));317 exit;318 }319 }320 }321 322 240 323 241 // ページ送り機能用のURLを作成する。 … … 339 257 } 340 258 341 $this->tpl_subtitle = $tpl_subtitle;342 259 $this->tpl_search_mode = $tpl_search_mode; 343 260 344 // 支払方法の取得345 $this->arrPayment = $this->lfGetPayment();346 // 入力情報を渡す347 $this->arrForm = $_POST;348 349 $this->category_id = $arrCategory_id[0];350 $this->arrSearch = $arrSearch;351 261 $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; 352 262 … … 364 274 } 365 275 366 /* カテゴリIDがルートかどうかの判定 */ 367 function lfIsRootCategory($category_id) { 368 $objQuery = new SC_Query(); 369 $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id)); 370 if($level == 1) { 371 return true; 372 } 373 return false; 276 /** 277 * カテゴリIDの取得 278 * 279 * @return integer カテゴリID 280 */ 281 function lfGetCategoryId($category_id) { 282 $objDb = new SC_Helper_DB_Ex(); 283 284 // 指定なしの場合、0 を返す 285 if ( 286 strlen($category_id) == 0 287 || (String) $category_id == '0' 288 ) { 289 return 0; 290 } 291 292 // 正当性チェック 293 if ( 294 !SC_Utils_Ex::sfIsInt($category_id) 295 || SC_Utils_Ex::sfIsZeroFilling($category_id) 296 || !$objDb->sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0') 297 ) { 298 SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); 299 } 300 301 // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。 302 $arrCategory_id = $objDb->sfGetCategoryId('', $category_id); 303 304 if (empty($arrCategory_id)) { 305 SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); 306 } 307 308 return $arrCategory_id[0]; 374 309 } 375 310 376 311 /* 商品一覧の表示 */ 377 function lfDispProductsList( $category_id, $name, $disp_num, $orderby) {312 function lfDispProductsList() { 378 313 379 314 $objQuery = new SC_Query(); 380 315 $objDb = new SC_Helper_DB_Ex(); 381 $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno'];382 316 $arrval = array(); 383 317 $arrval_order = array(); 384 318 $arrval_category = array(); 385 319 386 320 // カテゴリからのWHERE文字列取得 387 388 if ( $category_id ) { 389 list($tmp_where, $arrval_category) = $objDb->sfGetCatWhere($category_id); 390 if (strlen($tmp_where) >= 1) { 391 $where_category = "AND $tmp_where"; 392 //並び替え用(MySQL4.1対応) 393 $where_category_order = "AND " ."T2.".trim($tmp_where); 394 } 395 } 396 321 if ($this->arrSearchData['category_id'] != 0) { 322 list($where_category, $arrval_category) = $objDb->sfGetCatWhere($this->arrSearchData['category_id']); 323 } 324 397 325 // ▼対象商品IDの抽出 398 326 // 商品検索条件の作成(未削除、表示) 399 327 $where = "del_flg = 0 AND status = 1 "; 400 328 401 329 // 在庫無し商品の非表示 402 330 if (NOSTOCK_HIDDEN === true) { 403 331 $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; 404 332 } 405 333 406 334 if (strlen($where_category) >= 1) { 407 $where.= " $where_category";335 $where.= " AND $where_category"; 408 336 $arrval = array_merge($arrval, $arrval_category); 409 337 } 410 338 411 339 // 商品名をwhere文に 340 $name = $this->arrSearchData['name']; 412 341 $name = ereg_replace(",", "", $name);// XXX 413 342 // 全角スペースを半角スペースに変換 … … 417 346 // 分割したキーワードを一つずつwhere文に追加 418 347 foreach ($names as $val) { 419 if ( strlen($val) > 0 ) {348 if ( strlen($val) > 0 ) { 420 349 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 421 350 $ret = SC_Utils_Ex::sfManualEscape($val); … … 425 354 } 426 355 356 // メーカーらのWHERE文字列取得 357 if ($this->arrSearchData['maker_id']) { 358 $where .= " AND maker_id = ? "; 359 $arrval[] = $this->arrSearchData['maker_id']; 360 } 361 362 // 対象商品IDの抽出 427 363 $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); 428 // ▲対象商品IDの抽出 429 364 430 365 // 行数の取得 431 366 $linemax = count($arrProduct_id); … … 434 369 435 370 // ページ送りの取得 436 $ this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);437 371 $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; 372 $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam); 438 373 $strnavi = $this->objNavi->strnavi; 439 $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 374 440 375 // 表示文字列 441 376 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 442 377 $startno = $this->objNavi->start_row; // 開始行 443 378 444 379 // ▼商品詳細取得 445 380 $col = <<< __EOS__ … … 464 399 ,point_rate 465 400 ,sale_limit 466 ,sale_unlimited467 401 ,deliv_date_id 468 402 ,deliv_fee … … 471 405 ,del_flg 472 406 __EOS__; 473 407 474 408 $from = "vw_products_allclass_detail AS alldtl"; 475 409 476 410 // WHERE 句 477 411 $where = '0=0'; … … 482 416 $where .= ' AND 0<>0'; 483 417 } 484 485 // 表示順序486 switch ($orderby) {487 488 // 販売価格順418 419 // 表示順序 420 switch ($this->orderby) { 421 422 // 販売価格順 489 423 case 'price': 490 424 $order = "price02_min, product_id"; 491 425 break; 492 426 493 // 新着順427 // 新着順 494 428 case 'date': 495 429 $order = "create_date DESC, product_id"; … … 497 431 498 432 default: 433 if (strlen($where_category) >= 1) { 434 $dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE $where_category)"; 435 $arrval_order = array_merge($arrval_category, $arrval_category); 436 } else { 437 $dtb_product_categories = 'dtb_product_categories'; 438 } 499 439 $order = <<< __EOS__ 500 440 ( … … 502 442 T3.rank 503 443 FROM 504 dtb_product_categories T2444 $dtb_product_categories T2 505 445 JOIN dtb_category T3 506 446 USING (category_id) 507 447 WHERE T2.product_id = alldtl.product_id 508 $where_category_order509 448 ORDER BY T3.rank DESC, T2.rank DESC 510 449 LIMIT 1 … … 514 453 T2.rank 515 454 FROM 516 dtb_product_categories T2455 $dtb_product_categories T2 517 456 JOIN dtb_category T3 518 457 USING (category_id) 519 458 WHERE T2.product_id = alldtl.product_id 520 $where_category_order521 459 ORDER BY T3.rank DESC, T2.rank DESC 522 460 LIMIT 1 … … 524 462 ,product_id 525 463 __EOS__; 526 $arrval_order = array_merge($arrval_category, $arrval_category);527 464 break; 528 465 } 529 466 530 467 // 取得範囲の指定(開始行番号、行数のセット) 531 $objQuery->setlimitoffset($ disp_num, $startno);468 $objQuery->setlimitoffset($this->disp_number, $startno); 532 469 // 表示順序 533 470 $objQuery->setorder($order); 534 471 535 472 // 検索結果の取得 536 473 $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); 537 474 // ▲商品詳細取得 538 539 // 規格名一覧 540 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 541 // 規格分類名一覧 542 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 475 476 $arrProductId = array(); 543 477 // 規格セレクトボックス設定 544 if($disp_num == 15) { 545 for($i = 0; $i < count($this->arrProducts); $i++) { 546 $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 547 } 548 } 549 } 550 551 /* 規格セレクトボックスの作成 */ 552 function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 553 554 $classcat_find1 = false; 555 $classcat_find2 = false; 556 // 在庫ありの商品の有無 557 $stock_find = false; 558 559 // 商品規格情報の取得 560 $arrProductsClass = $this->lfGetProductsClass($product_id); 561 562 // 規格1クラス名の取得 563 $this->tpl_class_name1[$product_id] = 564 isset($arrClassName[$arrProductsClass[0]['class_id1']]) 565 ? $arrClassName[$arrProductsClass[0]['class_id1']] 566 : ""; 567 568 // 規格2クラス名の取得 569 $this->tpl_class_name2[$product_id] = 570 isset($arrClassName[$arrProductsClass[0]['class_id2']]) 571 ? $arrClassName[$arrProductsClass[0]['class_id2']] 572 : ""; 573 574 // すべての組み合わせ数 575 $count = count($arrProductsClass); 576 577 $classcat_id1 = ""; 578 579 $arrSele = array(); 580 $arrList = array(); 581 582 $list_id = 0; 583 $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'"; 584 $arrVal[0] = "\tval". $product_id. "_0 = new Array(''"; 585 586 for ($i = 0; $i < $count; $i++) { 587 // 在庫のチェック 588 if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 589 continue; 590 } 591 592 $stock_find = true; 593 594 // 規格1のセレクトボックス用 595 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 596 $arrList[$list_id].=");\n"; 597 $arrVal[$list_id].=");\n"; 598 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 599 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 600 $list_id++; 601 602 $arrList[$list_id] = ""; 603 $arrVal[$list_id] = ""; 604 } 605 606 // 規格2のセレクトボックス用 607 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 608 609 // セレクトボックス表示値 610 if($arrList[$list_id] == "") { 611 $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'"; 612 } else { 613 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 614 } 615 616 // セレクトボックスPOST値 617 if($arrVal[$list_id] == "") { 618 $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'"; 619 } else { 620 $arrVal[$list_id].= ", '".$classcat_id2."'"; 621 } 622 } 623 624 $arrList[$list_id].=");\n"; 625 $arrVal[$list_id].=");\n"; 626 478 foreach ($this->arrProducts as $product) { 479 $arrProductId[] = $product['product_id']; 480 // 購入制限数を取得 481 $this->lfGetSaleLimit($product); 482 } 483 484 require_once CLASS_PATH . 'SC_Product.php'; 485 $objProduct = new SC_Product($arrProductId); 486 487 // 規格1クラス名 488 $this->tpl_class_name1 = $objProduct->className1; 489 490 // 規格2クラス名 491 $this->tpl_class_name2 = $objProduct->className2; 492 627 493 // 規格1 628 $this->arrClassCat1[$product_id] = $arrSele; 629 630 $lists = "\tlists".$product_id. " = new Array("; 631 $no = 0; 632 foreach($arrList as $val) { 633 $this->tpl_javascript.= $val; 634 if ($no != 0) { 635 $lists.= ",list". $product_id. "_". $no; 636 } else { 637 $lists.= "list". $product_id. "_". $no; 638 } 639 $no++; 640 } 641 $this->tpl_javascript.= $lists.");\n"; 642 643 $vals = "\tvals".$product_id. " = new Array("; 644 $no = 0; 645 foreach($arrVal as $val) { 646 $this->tpl_javascript.= $val; 647 if ($no != 0) { 648 $vals.= ",val". $product_id. "_". $no; 649 } else { 650 $vals.= "val". $product_id. "_". $no; 651 } 652 $no++; 653 } 654 $this->tpl_javascript.= $vals.");\n"; 655 656 // 選択されている規格2ID 657 $classcategory_id = "classcategory_id". $product_id; 658 659 $classcategory_id_2 = $classcategory_id . "_2"; 660 if (!isset($classcategory_id_2)) $classcategory_id_2 = ""; 661 if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = ""; 662 663 $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', " 664 . "'" . $classcategory_id_2 . "'," 665 . "'" . $product_id . "'," 666 . "'" . $_POST[$classcategory_id_2] ."'); "; 494 $this->arrClassCat1 = $objProduct->classCats1; 667 495 668 496 // 規格1が設定されている 669 if($arrProductsClass[0]['classcategory_id1'] != '0') { 670 $classcat_find1 = true; 671 } 672 497 $this->tpl_classcat_find1 = $objProduct->classCat1_find; 673 498 // 規格2が設定されている 674 if($arrProductsClass[0]['classcategory_id2'] != '0') { 675 $classcat_find2 = true; 676 } 677 678 $this->tpl_classcat_find1[$product_id] = $classcat_find1; 679 $this->tpl_classcat_find2[$product_id] = $classcat_find2; 680 $this->tpl_stock_find[$product_id] = $stock_find; 681 } 682 683 /* 商品規格情報の取得 */ 684 function lfGetProductsClass($product_id) { 685 $arrRet = array(); 686 if(SC_Utils_Ex::sfIsInt($product_id)) { 687 // 商品規格取得 688 $objQuery = new SC_Query(); 689 $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 690 $table = "vw_product_class AS prdcls"; 691 $where = "product_id = ?"; 692 $objQuery->setorder("rank1 DESC, rank2 DESC"); 693 $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 694 } 695 return $arrRet; 499 $this->tpl_classcat_find2 = $objProduct->classCat2_find; 500 501 $this->tpl_stock_find = $objProduct->stock_find; 502 503 $productsClassCategories = $objProduct->classCategories; 504 505 require_once DATA_PATH . 'module/Services/JSON.php'; 506 $objJson = new Services_JSON(); 507 $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($productsClassCategories) . '; '; 696 508 } 697 509 … … 700 512 701 513 // 入力データを渡す。 702 $objErr = new SC_CheckError(); 703 704 $classcategory_id1 = "classcategory_id". $id. "_1"; 705 $classcategory_id2 = "classcategory_id". $id. "_2"; 706 $quantity = "quantity". $id; 514 $objErr = new SC_CheckError($this->arrForm); 515 707 516 // 複数項目チェック 708 517 if ($this->tpl_classcat_find1[$id]) { 709 $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));518 $objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 710 519 } 711 520 if ($this->tpl_classcat_find2[$id]) { 712 $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));713 } 714 $objErr->doFunc(array(" 個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));521 $objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 522 } 523 $objErr->doFunc(array("数量", 'quantity', INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 715 524 716 525 return $objErr->arrErr; 717 526 } 718 527 719 //支払方法の取得 720 //payment_id 1:代金引換 2:銀行振り込み 3:現金書留 721 function lfGetPayment() { 722 $objQuery = new SC_Query; 723 $col = "payment_id, rule, payment_method"; 724 $from = "dtb_payment"; 725 $where = "del_flg = 0"; 726 $order = "payment_id"; 727 $objQuery->setorder($order); 728 $arrRet = $objQuery->select($col, $from, $where); 729 return $arrRet; 730 } 731 732 function lfconvertParam () { 733 foreach ($this->arrForm as $key => $value) { 734 if (preg_match('/^quantity[0-9]+/', $key)) { 735 $this->arrForm[$key] 736 = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); 737 } 738 } 528 // 購入制限数の設定 529 // XXX 標準実装では「tpl_sale_limit」は利用されていないようである。カスタマイズ用? 530 function lfGetSaleLimit($arrProduct) { 531 //在庫が無限または購入制限値が設定値より大きい場合 532 if (!SC_Utils_Ex::sfIsInt($arrProduct['sale_limit']) || $arrProduct['sale_limit'] > SALE_LIMIT_MAX) { 533 $this->tpl_sale_limit[$arrProduct['product_id']] = SALE_LIMIT_MAX; 534 } else { 535 $this->tpl_sale_limit[$arrProduct['product_id']] = $arrProduct['sale_limit']; 536 } 537 } 538 539 /** 540 * パラメータの読み込み 541 * 542 * @return void 543 */ 544 function lfLoadParam() { 545 $this->arrForm = $_GET; 546 547 $this->mode = $this->arrForm['mode']; 548 $this->arrSearchData['category_id'] = $this->lfGetCategoryId($this->arrForm['category_id']); 549 $this->arrSearchData['maker_id'] = $this->arrForm['maker_id']; 550 $this->arrSearchData['name'] = $this->arrForm['name']; 551 $this->orderby = $this->arrForm['orderby']; 552 // 表示件数 553 if ( 554 isset($this->arrForm['disp_number']) 555 && SC_Utils_Ex::sfIsInt($this->arrForm['disp_number']) 556 ) { 557 $this->disp_number = $this->arrForm['disp_number']; 558 } else { 559 //最小表示件数を選択 560 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 561 } 562 $this->tpl_pageno = $this->arrForm['pageno']; 563 $this->inCart = strlen($this->arrForm['product_id']) >= 1; 739 564 } 740 565 }
Note: See TracChangeset
for help on using the changeset viewer.