Changeset 17952 for branches/version-2_4/data/class/pages/admin/products/LC_Page_Admin_Products_ProductSelect.php
- Timestamp:
- 2009/04/03 11:14:09 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_4/data/class/pages/admin/products/LC_Page_Admin_Products_ProductSelect.php
r17777 r17952 62 62 $objSess = new SC_Session(); 63 63 $objDb = new SC_Helper_DB_Ex(); 64 $objQuery = new SC_Query();65 64 66 65 // 認証可否の判定 … … 68 67 69 68 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 70 71 if ($_GET['no'] != '') {72 $this->tpl_no = strval($_GET['no']);73 }elseif ($_POST['no'] != '') {74 $this->tpl_no = strval($_POST['no']);75 }76 69 77 70 if ($_POST['mode'] == "search") { … … 89 82 continue; 90 83 } 84 91 85 switch ($key) { 92 86 case 'search_name': … … 110 104 } 111 105 112 113 /*114 106 $order = "update_date DESC, product_id DESC "; 115 107 … … 117 109 $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited"; 118 110 $from = "vw_products_nonclass AS noncls "; 119 */120 $col = "DISTINCT T1.product_id, product_code_min, product_code_max,"121 . " price01_min, price01_max, price02_min, price02_max,"122 . " stock_min, stock_max, stock_unlimited_min,"123 . " stock_unlimited_max, del_flg, status, name, comment1,"124 . " comment2, comment3, main_list_comment, main_image,"125 . " main_list_image, product_flag, deliv_date_id, sale_limit,"126 . " point_rate, sale_unlimited, create_date, deliv_fee, "127 . " T4.product_rank, T4.category_rank";128 $from = "vw_products_allclass AS T1"129 . " JOIN ("130 . " SELECT max(T3.rank) AS category_rank,"131 . " max(T2.rank) AS product_rank,"132 . " T2.product_id"133 . " FROM dtb_product_categories T2"134 . " JOIN dtb_category T3 USING (category_id)"135 . " GROUP BY product_id) AS T4 USING (product_id)";136 $order = "T4.category_rank DESC, T4.product_rank DESC";137 111 138 112 $objQuery = new SC_Query(); … … 167 141 // 検索結果の取得 168 142 $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); 169 170 // 規格名一覧171 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");172 173 // 規格分類名一覧174 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");175 176 // 規格セレクトボックス設定177 for($i = 0; $i < count($this->arrProducts); $i++) {178 $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);179 // 購入制限数を取得180 $this->lfGetSaleLimit($this->arrProducts[$i]);181 }182 143 } 183 144 … … 219 180 } 220 181 } 221 222 /* 規格セレクトボックスの作成 */223 function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {224 225 $classcat_find1 = false;226 $classcat_find2 = false;227 // 在庫ありの商品の有無228 $stock_find = false;229 230 // 商品規格情報の取得231 $arrProductsClass = $this->lfGetProductsClass($product_id);232 233 // 規格1クラス名の取得234 $this->tpl_class_name1[$product_id] =235 isset($arrClassName[$arrProductsClass[0]['class_id1']])236 ? $arrClassName[$arrProductsClass[0]['class_id1']]237 : "";238 239 // 規格2クラス名の取得240 $this->tpl_class_name2[$product_id] =241 isset($arrClassName[$arrProductsClass[0]['class_id2']])242 ? $arrClassName[$arrProductsClass[0]['class_id2']]243 : "";244 245 // すべての組み合わせ数246 $count = count($arrProductsClass);247 248 $classcat_id1 = "";249 250 $arrSele = array();251 $arrList = array();252 253 $list_id = 0;254 $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";255 $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";256 257 for ($i = 0; $i < $count; $i++) {258 // 在庫のチェック259 if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {260 continue;261 }262 263 $stock_find = true;264 265 // 規格1のセレクトボックス用266 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){267 $arrList[$list_id].=");\n";268 $arrVal[$list_id].=");\n";269 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];270 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];271 $list_id++;272 273 $arrList[$list_id] = "";274 $arrVal[$list_id] = "";275 }276 277 // 規格2のセレクトボックス用278 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];279 280 // セレクトボックス表示値281 if($arrList[$list_id] == "") {282 $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";283 } else {284 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";285 }286 287 // セレクトボックスPOST値288 if($arrVal[$list_id] == "") {289 $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";290 } else {291 $arrVal[$list_id].= ", '".$classcat_id2."'";292 }293 }294 295 $arrList[$list_id].=");\n";296 $arrVal[$list_id].=");\n";297 298 // 規格1299 $this->arrClassCat1[$product_id] = $arrSele;300 301 $lists = "\tlists".$product_id. " = new Array(";302 $no = 0;303 foreach($arrList as $val) {304 $this->tpl_javascript.= $val;305 if ($no != 0) {306 $lists.= ",list". $product_id. "_". $no;307 } else {308 $lists.= "list". $product_id. "_". $no;309 }310 $no++;311 }312 $this->tpl_javascript.= $lists.");\n";313 314 $vals = "\tvals".$product_id. " = new Array(";315 $no = 0;316 foreach($arrVal as $val) {317 $this->tpl_javascript.= $val;318 if ($no != 0) {319 $vals.= ",val". $product_id. "_". $no;320 } else {321 $vals.= "val". $product_id. "_". $no;322 }323 $no++;324 }325 $this->tpl_javascript.= $vals.");\n";326 327 // 選択されている規格2ID328 $classcategory_id = "classcategory_id". $product_id;329 330 $classcategory_id_2 = $classcategory_id . "_2";331 if (!isset($classcategory_id_2)) $classcategory_id_2 = "";332 if (!isset($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";333 334 $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "335 . "'" . $classcategory_id_2 . "',"336 . "'" . $product_id . "',"337 . "'" . $_POST[$classcategory_id_2] ."'); ";338 339 // 規格1が設定されている340 if($arrProductsClass[0]['classcategory_id1'] != '0') {341 $classcat_find1 = true;342 }343 344 // 規格2が設定されている345 if($arrProductsClass[0]['classcategory_id2'] != '0') {346 $classcat_find2 = true;347 }348 349 $this->tpl_classcat_find1[$product_id] = $classcat_find1;350 $this->tpl_classcat_find2[$product_id] = $classcat_find2;351 $this->tpl_stock_find[$product_id] = $stock_find;352 }353 354 /* 商品規格情報の取得 */355 function lfGetProductsClass($product_id) {356 $arrRet = array();357 if(SC_Utils_Ex::sfIsInt($product_id)) {358 // 商品規格取得359 $objQuery = new SC_Query();360 $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";361 $table = "vw_product_class AS prdcls";362 $where = "product_id = ?";363 $objQuery->setorder("rank1 DESC, rank2 DESC");364 $arrRet = $objQuery->select($col, $table, $where, array($product_id));365 }366 return $arrRet;367 }368 369 // 購入制限数の設定370 function lfGetSaleLimit($product) {371 //在庫が無限または購入制限値が設定値より大きい場合372 if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {373 $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;374 } else {375 $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];376 }377 }378 182 } 379 183 ?>
Note: See TracChangeset
for help on using the changeset viewer.