1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
|
---|
5 | *
|
---|
6 | * http://www.lockon.co.jp/
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * モバイルサイト/商品一覧
|
---|
10 | */
|
---|
11 |
|
---|
12 | require_once('../require.php');
|
---|
13 |
|
---|
14 | class LC_Page {
|
---|
15 | function LC_Page() {
|
---|
16 | global $arrSTATUS;
|
---|
17 | $this->arrSTATUS = $arrSTATUS;
|
---|
18 | global $arrSTATUS_IMAGE;
|
---|
19 | $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE;
|
---|
20 | global $arrDELIVERYDATE;
|
---|
21 | $this->arrDELIVERYDATE = $arrDELIVERYDATE;
|
---|
22 | global $arrPRODUCTLISTMAX;
|
---|
23 | $this->arrPRODUCTLISTMAX = $arrPRODUCTLISTMAX;
|
---|
24 | /*
|
---|
25 | session_start時のno-cacheヘッダーを抑制することで
|
---|
26 | 「戻る」ボタン使用時の有効期限切れ表示を抑制する。
|
---|
27 | private-no-expire:クライアントのキャッシュを許可する。
|
---|
28 | */
|
---|
29 | session_cache_limiter('private-no-expire');
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | $objPage = new LC_Page();
|
---|
34 | $conn = new SC_DBConn();
|
---|
35 |
|
---|
36 | //表示件数の選択
|
---|
37 | if(sfIsInt($_REQUEST['disp_number'])) {
|
---|
38 | $objPage->disp_number = $_REQUEST['disp_number'];
|
---|
39 | } else {
|
---|
40 | //最小表示件数を選択
|
---|
41 | $objPage->disp_number = current(array_keys($arrPRODUCTLISTMAX));
|
---|
42 | }
|
---|
43 |
|
---|
44 | //表示順序の保存
|
---|
45 | $objPage->orderby = $_REQUEST['orderby'];
|
---|
46 |
|
---|
47 | // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
|
---|
48 | $category_id = sfGetCategoryId("", $_GET['category_id']);
|
---|
49 |
|
---|
50 | // タイトル編集
|
---|
51 | $tpl_subtitle = "";
|
---|
52 | $tpl_search_mode = false;
|
---|
53 | if($_GET['mode'] == 'search'){
|
---|
54 | $tpl_subtitle = "検索結果";
|
---|
55 | $tpl_search_mode = true;
|
---|
56 | }elseif ($category_id == "" ) {
|
---|
57 | $tpl_subtitle = "全商品";
|
---|
58 | }else{
|
---|
59 | $arrFirstCat = sfGetFirstCat($category_id);
|
---|
60 | $tpl_subtitle = $arrFirstCat['name'];
|
---|
61 | }
|
---|
62 |
|
---|
63 | $objQuery = new SC_Query();
|
---|
64 | $count = $objQuery->count("dtb_best_products", "category_id = ?", array($category_id));
|
---|
65 |
|
---|
66 | // 以下の条件でBEST商品を表示する
|
---|
67 | // ・BEST最大数の商品が登録されている。
|
---|
68 | // ・カテゴリIDがルートIDである。
|
---|
69 | // ・検索モードでない。
|
---|
70 | if(($count >= BEST_MIN) && lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) {
|
---|
71 | // 商品TOPの表示処理
|
---|
72 | /** 必ず指定する **/
|
---|
73 | $objPage->tpl_mainpage = "products/list.tpl"; // メインテンプレート
|
---|
74 |
|
---|
75 | $objPage->arrBestItems = sfGetBestProducts($conn, $category_id);
|
---|
76 | $objPage->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2);
|
---|
77 | } else {
|
---|
78 | if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){
|
---|
79 | // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
|
---|
80 | $category_id = '';
|
---|
81 | }
|
---|
82 |
|
---|
83 | // 商品一覧の表示処理
|
---|
84 | $objPage = lfDispProductsList($category_id, $_GET['name'], $objPage->disp_number, $_REQUEST['orderby']);
|
---|
85 |
|
---|
86 | // 検索条件を画面に表示
|
---|
87 | // カテゴリー検索条件
|
---|
88 | if (strlen($_GET['category_id']) == 0) {
|
---|
89 | $arrSearch['category'] = "指定なし";
|
---|
90 | }else{
|
---|
91 | $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id));
|
---|
92 | $arrSearch['category'] = $arrCat;
|
---|
93 | }
|
---|
94 |
|
---|
95 | // 商品名検索条件
|
---|
96 | if ($_GET['name'] === "") {
|
---|
97 | $arrSearch['name'] = "指定なし";
|
---|
98 | }else{
|
---|
99 | $arrSearch['name'] = $_GET['name'];
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | // レイアウトデザインを取得
|
---|
104 | $objPage = sfGetPageLayout($objPage, false, "products/list.php");
|
---|
105 |
|
---|
106 | if($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
|
---|
107 | // 値の正当性チェック
|
---|
108 | if(!sfIsInt($_POST['product_id']) || !sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
|
---|
109 | sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
|
---|
110 | } else {
|
---|
111 | // 入力値の変換
|
---|
112 | $objPage->arrErr = lfCheckError($_POST['product_id']);
|
---|
113 | if(count($objPage->arrErr) == 0) {
|
---|
114 | $objCartSess = new SC_CartSession();
|
---|
115 | $classcategory_id = "classcategory_id". $_POST['product_id'];
|
---|
116 | $classcategory_id1 = $_POST[$classcategory_id. '_1'];
|
---|
117 | $classcategory_id2 = $_POST[$classcategory_id. '_2'];
|
---|
118 | $quantity = "quantity". $_POST['product_id'];
|
---|
119 | // 規格1が設定されていない場合
|
---|
120 | if(!$objPage->tpl_classcat_find1[$_POST['product_id']]) {
|
---|
121 | $classcategory_id1 = '0';
|
---|
122 | }
|
---|
123 | // 規格2が設定されていない場合
|
---|
124 | if(!$objPage->tpl_classcat_find2[$_POST['product_id']]) {
|
---|
125 | $classcategory_id2 = '0';
|
---|
126 | }
|
---|
127 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
|
---|
128 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
|
---|
129 | header("Location: " . MOBILE_URL_CART_TOP);
|
---|
130 | exit;
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 |
|
---|
136 | // ページ送り機能用のURLを作成する。
|
---|
137 | $objURL = new Net_URL($_SERVER['PHP_SELF']);
|
---|
138 | foreach ($_REQUEST as $key => $value) {
|
---|
139 | if ($key == session_name() || $key == 'pageno') {
|
---|
140 | continue;
|
---|
141 | }
|
---|
142 | $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', 'EUC-JP'));
|
---|
143 | }
|
---|
144 |
|
---|
145 | if ($objPage->objNavi->now_page > 1) {
|
---|
146 | $objURL->addQueryString('pageno', $objPage->objNavi->now_page - 1);
|
---|
147 | $objPage->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
|
---|
148 | }
|
---|
149 | if ($objPage->objNavi->now_page < $objPage->objNavi->max_page) {
|
---|
150 | $objURL->addQueryString('pageno', $objPage->objNavi->now_page + 1);
|
---|
151 | $objPage->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | $objPage->tpl_subtitle = $tpl_subtitle;
|
---|
156 | $objPage->tpl_search_mode = $tpl_search_mode;
|
---|
157 |
|
---|
158 | // 支払方法の取得
|
---|
159 | $objPage->arrPayment = lfGetPayment();
|
---|
160 | // 入力情報を渡す
|
---|
161 | $objPage->arrForm = $_POST;
|
---|
162 |
|
---|
163 | $objPage->category_id = $category_id;
|
---|
164 | $objPage->arrSearch = $arrSearch;
|
---|
165 |
|
---|
166 | sfCustomDisplay($objPage, true);
|
---|
167 |
|
---|
168 | //-----------------------------------------------------------------------------------------------------------------------------------
|
---|
169 | /* カテゴリIDがルートかどうかの判定 */
|
---|
170 | function lfIsRootCategory($category_id) {
|
---|
171 | $objQuery = new SC_Query();
|
---|
172 | $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id));
|
---|
173 | if($level == 1) {
|
---|
174 | return true;
|
---|
175 | }
|
---|
176 | return false;
|
---|
177 | }
|
---|
178 |
|
---|
179 | /* 商品一覧の表示 */
|
---|
180 | function lfDispProductsList($category_id, $name, $disp_num, $orderby) {
|
---|
181 | global $objPage;
|
---|
182 | $objQuery = new SC_Query();
|
---|
183 | $objPage->tpl_pageno = $_REQUEST['pageno'];
|
---|
184 |
|
---|
185 | //表示件数でテンプレートを切り替える
|
---|
186 | $objPage->tpl_mainpage = "products/list.tpl"; // メインテンプレート
|
---|
187 |
|
---|
188 | //表示順序
|
---|
189 | switch($orderby) {
|
---|
190 | //価格順
|
---|
191 | case 'price':
|
---|
192 | $order = "price02_min ASC";
|
---|
193 | break;
|
---|
194 | //新着順
|
---|
195 | case 'date':
|
---|
196 | $order = "create_date DESC";
|
---|
197 | break;
|
---|
198 | default:
|
---|
199 | $order = "category_rank DESC, rank DESC";
|
---|
200 | break;
|
---|
201 | }
|
---|
202 |
|
---|
203 | // 商品検索条件の作成(未削除、表示)
|
---|
204 | $where = "del_flg = 0 AND status = 1 ";
|
---|
205 | // カテゴリからのWHERE文字列取得
|
---|
206 | if ( $category_id ) {
|
---|
207 | $where .= 'AND category_id = ?';
|
---|
208 | $arrval = array($category_id);
|
---|
209 | }
|
---|
210 |
|
---|
211 | // 商品名をwhere文に
|
---|
212 | $name = ereg_replace(",", "", $name);
|
---|
213 | if ( strlen($name) > 0 ){
|
---|
214 | $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) ";
|
---|
215 | $ret = sfManualEscape($name);
|
---|
216 | $arrval[] = "%$ret%";
|
---|
217 | $arrval[] = "%$ret%";
|
---|
218 | }
|
---|
219 |
|
---|
220 | // 行数の取得
|
---|
221 | $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval);
|
---|
222 | $objPage->tpl_linemax = $linemax; // 何件が該当しました。表示用
|
---|
223 |
|
---|
224 | // ページ送りの取得
|
---|
225 | $objNavi = new SC_PageNavi($_REQUEST['pageno'], $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);
|
---|
226 |
|
---|
227 | $strnavi = $objNavi->strnavi;
|
---|
228 | $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi);
|
---|
229 | $objPage->tpl_strnavi = $strnavi; // 表示文字列
|
---|
230 | $startno = $objNavi->start_row; // 開始行
|
---|
231 |
|
---|
232 | // 取得範囲の指定(開始行番号、行数のセット)
|
---|
233 | $objQuery->setlimitoffset($disp_num, $startno);
|
---|
234 | // 表示順序
|
---|
235 | $objQuery->setorder($order);
|
---|
236 | // 検索結果の取得
|
---|
237 | $objPage->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval);
|
---|
238 |
|
---|
239 | // 規格名一覧
|
---|
240 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
|
---|
241 | // 規格分類名一覧
|
---|
242 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
|
---|
243 | // 企画セレクトボックス設定
|
---|
244 | if($disp_num == 15) {
|
---|
245 | for($i = 0; $i < count($objPage->arrProducts); $i++) {
|
---|
246 | $objPage = lfMakeSelect($objPage->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
|
---|
247 | // 購入制限数を取得
|
---|
248 | $objPage = lfGetSaleLimit($objPage->arrProducts[$i]);
|
---|
249 | }
|
---|
250 | }
|
---|
251 |
|
---|
252 | $objPage->objNavi =& $objNavi;
|
---|
253 | return $objPage;
|
---|
254 | }
|
---|
255 |
|
---|
256 | /* 規格セレクトボックスの作成 */
|
---|
257 | function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
|
---|
258 | global $objPage;
|
---|
259 |
|
---|
260 | $classcat_find1 = false;
|
---|
261 | $classcat_find2 = false;
|
---|
262 | // 在庫ありの商品の有無
|
---|
263 | $stock_find = false;
|
---|
264 |
|
---|
265 | // 商品規格情報の取得
|
---|
266 | $arrProductsClass = lfGetProductsClass($product_id);
|
---|
267 |
|
---|
268 | // 規格1クラス名の取得
|
---|
269 | $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']];
|
---|
270 | // 規格2クラス名の取得
|
---|
271 | $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']];
|
---|
272 |
|
---|
273 | // すべての組み合わせ数
|
---|
274 | $count = count($arrProductsClass);
|
---|
275 |
|
---|
276 | $classcat_id1 = "";
|
---|
277 |
|
---|
278 | $arrSele = array();
|
---|
279 | $arrList = array();
|
---|
280 |
|
---|
281 | $list_id = 0;
|
---|
282 | $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
|
---|
283 | $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
|
---|
284 |
|
---|
285 | for ($i = 0; $i < $count; $i++) {
|
---|
286 | // 在庫のチェック
|
---|
287 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
|
---|
288 | continue;
|
---|
289 | }
|
---|
290 |
|
---|
291 | $stock_find = true;
|
---|
292 |
|
---|
293 | // 規格1のセレクトボックス用
|
---|
294 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
|
---|
295 | $arrList[$list_id].=");\n";
|
---|
296 | $arrVal[$list_id].=");\n";
|
---|
297 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
|
---|
298 | $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
|
---|
299 | $list_id++;
|
---|
300 | }
|
---|
301 |
|
---|
302 | // 規格2のセレクトボックス用
|
---|
303 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
|
---|
304 |
|
---|
305 | // セレクトボックス表示値
|
---|
306 | if($arrList[$list_id] == "") {
|
---|
307 | $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
|
---|
308 | } else {
|
---|
309 | $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
|
---|
310 | }
|
---|
311 |
|
---|
312 | // セレクトボックスPOST値
|
---|
313 | if($arrVal[$list_id] == "") {
|
---|
314 | $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
|
---|
315 | } else {
|
---|
316 | $arrVal[$list_id].= ", '".$classcat_id2."'";
|
---|
317 | }
|
---|
318 | }
|
---|
319 |
|
---|
320 | $arrList[$list_id].=");\n";
|
---|
321 | $arrVal[$list_id].=");\n";
|
---|
322 |
|
---|
323 | // 規格1
|
---|
324 | $objPage->arrClassCat1[$product_id] = $arrSele;
|
---|
325 |
|
---|
326 | $lists = "\tlists".$product_id. " = new Array(";
|
---|
327 | $no = 0;
|
---|
328 | foreach($arrList as $val) {
|
---|
329 | $objPage->tpl_javascript.= $val;
|
---|
330 | if ($no != 0) {
|
---|
331 | $lists.= ",list". $product_id. "_". $no;
|
---|
332 | } else {
|
---|
333 | $lists.= "list". $product_id. "_". $no;
|
---|
334 | }
|
---|
335 | $no++;
|
---|
336 | }
|
---|
337 | $objPage->tpl_javascript.= $lists.");\n";
|
---|
338 |
|
---|
339 | $vals = "\tvals".$product_id. " = new Array(";
|
---|
340 | $no = 0;
|
---|
341 | foreach($arrVal as $val) {
|
---|
342 | $objPage->tpl_javascript.= $val;
|
---|
343 | if ($no != 0) {
|
---|
344 | $vals.= ",val". $product_id. "_". $no;
|
---|
345 | } else {
|
---|
346 | $vals.= "val". $product_id. "_". $no;
|
---|
347 | }
|
---|
348 | $no++;
|
---|
349 | }
|
---|
350 | $objPage->tpl_javascript.= $vals.");\n";
|
---|
351 |
|
---|
352 | // 選択されている規格2ID
|
---|
353 | $classcategory_id = "classcategory_id". $product_id;
|
---|
354 | $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); ";
|
---|
355 |
|
---|
356 | // 規格1が設定されている
|
---|
357 | if($arrProductsClass[0]['classcategory_id1'] != '0') {
|
---|
358 | $classcat_find1 = true;
|
---|
359 | }
|
---|
360 |
|
---|
361 | // 規格2が設定されている
|
---|
362 | if($arrProductsClass[0]['classcategory_id2'] != '0') {
|
---|
363 | $classcat_find2 = true;
|
---|
364 | }
|
---|
365 |
|
---|
366 | $objPage->tpl_classcat_find1[$product_id] = $classcat_find1;
|
---|
367 | $objPage->tpl_classcat_find2[$product_id] = $classcat_find2;
|
---|
368 | $objPage->tpl_stock_find[$product_id] = $stock_find;
|
---|
369 |
|
---|
370 | return $objPage;
|
---|
371 | }
|
---|
372 | /* 商品規格情報の取得 */
|
---|
373 | function lfGetProductsClass($product_id) {
|
---|
374 | $arrRet = array();
|
---|
375 | if(sfIsInt($product_id)) {
|
---|
376 | // 商品規格取得
|
---|
377 | $objQuery = new SC_Query();
|
---|
378 | $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
|
---|
379 | $table = "vw_product_class AS prdcls";
|
---|
380 | $where = "product_id = ?";
|
---|
381 | $objQuery->setorder("rank1 DESC, rank2 DESC");
|
---|
382 | $arrRet = $objQuery->select($col, $table, $where, array($product_id));
|
---|
383 | }
|
---|
384 | return $arrRet;
|
---|
385 | }
|
---|
386 |
|
---|
387 | /* 入力内容のチェック */
|
---|
388 | function lfCheckError($id) {
|
---|
389 | global $objPage;
|
---|
390 |
|
---|
391 | // 入力データを渡す。
|
---|
392 | $objErr = new SC_CheckError();
|
---|
393 |
|
---|
394 | $classcategory_id1 = "classcategory_id". $id. "_1";
|
---|
395 | $classcategory_id2 = "classcategory_id". $id. "_2";
|
---|
396 | $quantity = "quantity". $id;
|
---|
397 | // 複数項目チェック
|
---|
398 | if ($objPage->tpl_classcat_find1[$id]) {
|
---|
399 | $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
---|
400 | }
|
---|
401 | if ($objPage->tpl_classcat_find2[$id]) {
|
---|
402 | $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
---|
403 | }
|
---|
404 | $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
---|
405 |
|
---|
406 | return $objErr->arrErr;
|
---|
407 | }
|
---|
408 |
|
---|
409 | // 購入制限数の設定
|
---|
410 | function lfGetSaleLimit($product) {
|
---|
411 | global $objPage;
|
---|
412 | //在庫が無限または購入制限値が設定値より大きい場合
|
---|
413 | if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
|
---|
414 | $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
|
---|
415 | } else {
|
---|
416 | $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
|
---|
417 | }
|
---|
418 |
|
---|
419 | return $objPage;
|
---|
420 | }
|
---|
421 |
|
---|
422 | //支払方法の取得
|
---|
423 | //payment_id 1:代金引換 2:銀行振り込み 3:現金書留
|
---|
424 | function lfGetPayment() {
|
---|
425 | $objQuery = new SC_Query;
|
---|
426 | $col = "payment_id, rule, payment_method";
|
---|
427 | $from = "dtb_payment";
|
---|
428 | $where = "del_flg = 0";
|
---|
429 | $order = "payment_id";
|
---|
430 | $objQuery->setorder($order);
|
---|
431 | $arrRet = $objQuery->select($col, $from, $where);
|
---|
432 | return $arrRet;
|
---|
433 | }
|
---|
434 |
|
---|
435 | ?>
|
---|