1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品一覧 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Products_List extends LC_Page { |
---|
35 | |
---|
36 | // {{{ properties |
---|
37 | |
---|
38 | /** テンプレートクラス名1 */ |
---|
39 | var $tpl_class_name1 = array(); |
---|
40 | |
---|
41 | /** テンプレートクラス名2 */ |
---|
42 | var $tpl_class_name2 = array(); |
---|
43 | |
---|
44 | /** JavaScript テンプレート */ |
---|
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 = ''; |
---|
61 | |
---|
62 | // }}} |
---|
63 | // {{{ functions |
---|
64 | |
---|
65 | /** |
---|
66 | * Page を初期化する. |
---|
67 | * |
---|
68 | * @return void |
---|
69 | */ |
---|
70 | function init() { |
---|
71 | parent::init(); |
---|
72 | |
---|
73 | $masterData = new SC_DB_MasterData_Ex(); |
---|
74 | $this->arrSTATUS = $masterData->getMasterData("mtb_status"); |
---|
75 | $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); |
---|
76 | $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); |
---|
77 | $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Page のプロセス. |
---|
82 | * |
---|
83 | * @return void |
---|
84 | */ |
---|
85 | function process() { |
---|
86 | parent::process(); |
---|
87 | $this->action(); |
---|
88 | $this->sendResponse(); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * Page のAction. |
---|
93 | * |
---|
94 | * @return void |
---|
95 | */ |
---|
96 | function action() { |
---|
97 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
98 | $objDb = new SC_Helper_DB_Ex();//$this->helperDBにしたい |
---|
99 | $objProduct = new SC_Product(); |
---|
100 | |
---|
101 | $this->arrForm = $_GET; |
---|
102 | //modeの取得 |
---|
103 | $this->mode = $this->getMode(); |
---|
104 | |
---|
105 | //表示条件の取得 |
---|
106 | $this->arrSearchData = array( |
---|
107 | 'category_id' => $this->lfGetCategoryId($this->arrForm['category_id']), |
---|
108 | 'maker_id'=>$this->arrForm['maker_id'], |
---|
109 | 'name'=>$this->arrForm['name'] |
---|
110 | ); |
---|
111 | $this->orderby = $this->arrForm['orderby']; |
---|
112 | |
---|
113 | //ページング設定 |
---|
114 | $this->tpl_pageno = $this->arrForm['pageno']; |
---|
115 | $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); |
---|
116 | $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; |
---|
117 | $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam); |
---|
118 | |
---|
119 | // 画面に表示するサブタイトルの設定 |
---|
120 | $this->tpl_subtitle = $this->lfGetPageTitle($this->mode,$this->arrSearchData['category_id']); |
---|
121 | |
---|
122 | // 画面に表示する検索条件を設定 |
---|
123 | $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData); |
---|
124 | //この辺まではinit()に書いちゃダメなのかな? |
---|
125 | |
---|
126 | // 商品一覧データの取得 |
---|
127 | $searchCondition = $this->lfGetSearchCondition($arrSearchData); |
---|
128 | $this->tpl_linemax = $this->lfGetProductAllNum($searchCondition); |
---|
129 | $this->arrProducts = $this->lfGetProductsList($searchCondition,$this->disp_number,$this->objNavi->start_row,$this->tpl_linemax,&$objProduct); |
---|
130 | |
---|
131 | //商品一覧の表示処理 |
---|
132 | $strnavi = $this->objNavi->strnavi; |
---|
133 | // 表示文字列 |
---|
134 | $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; |
---|
135 | |
---|
136 | // 規格1クラス名 |
---|
137 | $this->tpl_class_name1 = $objProduct->className1; |
---|
138 | |
---|
139 | // 規格2クラス名 |
---|
140 | $this->tpl_class_name2 = $objProduct->className2; |
---|
141 | |
---|
142 | // 規格1 |
---|
143 | $this->arrClassCat1 = $objProduct->classCats1; |
---|
144 | |
---|
145 | // 規格1が設定されている |
---|
146 | $this->tpl_classcat_find1 = $objProduct->classCat1_find; |
---|
147 | // 規格2が設定されている |
---|
148 | $this->tpl_classcat_find2 = $objProduct->classCat2_find; |
---|
149 | |
---|
150 | $this->tpl_stock_find = $objProduct->stock_find; |
---|
151 | $this->tpl_product_class_id = $objProduct->product_class_id; |
---|
152 | $this->tpl_product_type = $objProduct->product_type; |
---|
153 | |
---|
154 | // 商品ステータスを取得 |
---|
155 | $this->productStatus = $this->arrProducts["productStatus"]; |
---|
156 | unset($this->arrProducts["productStatus"]); |
---|
157 | |
---|
158 | $productsClassCategories = $objProduct->classCategories; |
---|
159 | |
---|
160 | $objJson = new Services_JSON(); |
---|
161 | $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($productsClassCategories) . '; '; |
---|
162 | |
---|
163 | |
---|
164 | //onloadスクリプトを設定 |
---|
165 | foreach ($this->arrProducts as $arrProduct) { |
---|
166 | $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; |
---|
167 | } |
---|
168 | |
---|
169 | //カート処理 |
---|
170 | if (intval($this->arrForm['product_id']) > 0) { |
---|
171 | // 商品IDの正当性チェック |
---|
172 | if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { |
---|
173 | SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); |
---|
174 | } |
---|
175 | $product_id = $this->arrForm['product_id']; |
---|
176 | // 入力内容のチェック |
---|
177 | $arrErr = $this->lfCheckError($product_id); |
---|
178 | if (count($arrErr) == 0) { |
---|
179 | $classcategory_id1 = $this->arrForm['classcategory_id1']; |
---|
180 | $classcategory_id2 = $this->arrForm['classcategory_id2']; |
---|
181 | // 規格1が設定されていない場合 |
---|
182 | if (!$this->tpl_classcat_find1[$product_id]) { |
---|
183 | $classcategory_id1 = '0'; |
---|
184 | } |
---|
185 | // 規格2が設定されていない場合 |
---|
186 | if (!$this->tpl_classcat_find2[$product_id]) { |
---|
187 | $classcategory_id2 = '0'; |
---|
188 | } |
---|
189 | // 規格IDを取得 |
---|
190 | $objProduct = new SC_Product(); |
---|
191 | $product_class_id = $this->arrForm['product_class_id']; |
---|
192 | $product_type = $this->arrForm['product_type']; |
---|
193 | $objCartSess = new SC_CartSession(); |
---|
194 | $objCartSess->addProduct($product_class_id, $this->arrForm['quantity'], $product_type); |
---|
195 | |
---|
196 | // カート「戻るボタン」用に保持 |
---|
197 | if (SC_Utils_Ex::sfIsInternalDomain($_SERVER['HTTP_REFERER'])) { |
---|
198 | $_SESSION['cart_referer_url'] = $_SERVER['HTTP_REFERER']; |
---|
199 | } |
---|
200 | |
---|
201 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
202 | exit; |
---|
203 | } |
---|
204 | foreach (array_keys($this->arrProducts) as $key) { |
---|
205 | $arrProduct =& $this->arrProducts[$key]; |
---|
206 | if ($arrProduct['product_id'] == $product_id) { |
---|
207 | $arrProduct['product_class_id'] = $this->arrForm['product_class_id']; |
---|
208 | $arrProduct['classcategory_id1'] = $this->arrForm['classcategory_id1']; |
---|
209 | $arrProduct['classcategory_id2'] = $this->arrForm['classcategory_id2']; |
---|
210 | $arrProduct['quantity'] = $this->arrForm['quantity']; |
---|
211 | $arrProduct['arrErr'] = $arrErr; |
---|
212 | $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']}, '{$this->arrForm['classcategory_id2']}');\n"; |
---|
213 | } |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | // ページャ用データ設定(モバイル) |
---|
218 | if (Net_UserAgent_Mobile::isMobile() === true) { |
---|
219 | $this->lfSetPagerMobile(); |
---|
220 | } |
---|
221 | |
---|
222 | $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; |
---|
223 | $this->tpl_onload .= 'fnOnLoad(); '; |
---|
224 | |
---|
225 | $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); |
---|
226 | } |
---|
227 | |
---|
228 | /** |
---|
229 | * デストラクタ. |
---|
230 | * |
---|
231 | * @return void |
---|
232 | */ |
---|
233 | function destroy() { |
---|
234 | parent::destroy(); |
---|
235 | } |
---|
236 | |
---|
237 | /** |
---|
238 | * カテゴリIDの取得 |
---|
239 | * |
---|
240 | * @return integer カテゴリID |
---|
241 | */ |
---|
242 | function lfGetCategoryId($category_id) { |
---|
243 | // 指定なしの場合、0 を返す |
---|
244 | if ( |
---|
245 | strlen($category_id) == 0 |
---|
246 | || (String) $category_id == '0' |
---|
247 | ) { |
---|
248 | return 0; |
---|
249 | } |
---|
250 | |
---|
251 | // 正当性チェック |
---|
252 | if ( |
---|
253 | !SC_Utils_Ex::sfIsInt($category_id) |
---|
254 | || SC_Utils_Ex::sfIsZeroFilling($category_id) |
---|
255 | || !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0') |
---|
256 | ) { |
---|
257 | SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); |
---|
258 | } |
---|
259 | |
---|
260 | // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。 |
---|
261 | $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id); |
---|
262 | |
---|
263 | if (empty($arrCategory_id)) { |
---|
264 | SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); |
---|
265 | } |
---|
266 | |
---|
267 | return $arrCategory_id[0]; |
---|
268 | } |
---|
269 | |
---|
270 | /* 商品一覧の表示 */ |
---|
271 | function lfGetProductsList($searchCondition,$disp_number,$startno,$linemax,&$objProduct) { |
---|
272 | |
---|
273 | $arrval_order = array(); |
---|
274 | |
---|
275 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
276 | // 表示順序 |
---|
277 | switch ($this->orderby) { |
---|
278 | // 販売価格が安い順 |
---|
279 | case 'price': |
---|
280 | $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC'); |
---|
281 | break; |
---|
282 | |
---|
283 | // 新着順 |
---|
284 | case 'date': |
---|
285 | $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC'); |
---|
286 | break; |
---|
287 | |
---|
288 | default: |
---|
289 | if (strlen($searchCondition["where_category"]) >= 1) { |
---|
290 | $dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE ".$searchCondition["where_category"].")"; |
---|
291 | $arrval_order = $searchCondition["arrvalCategory"]; |
---|
292 | } else { |
---|
293 | $dtb_product_categories = 'dtb_product_categories'; |
---|
294 | } |
---|
295 | $order = <<< __EOS__ |
---|
296 | ( |
---|
297 | SELECT |
---|
298 | T3.rank |
---|
299 | FROM |
---|
300 | $dtb_product_categories T2 |
---|
301 | JOIN dtb_category T3 |
---|
302 | USING (category_id) |
---|
303 | WHERE T2.product_id = alldtl.product_id |
---|
304 | ORDER BY T3.rank DESC, T2.rank DESC |
---|
305 | LIMIT 1 |
---|
306 | ) DESC |
---|
307 | ,( |
---|
308 | SELECT |
---|
309 | T2.rank |
---|
310 | FROM |
---|
311 | $dtb_product_categories T2 |
---|
312 | JOIN dtb_category T3 |
---|
313 | USING (category_id) |
---|
314 | WHERE T2.product_id = alldtl.product_id |
---|
315 | ORDER BY T3.rank DESC, T2.rank DESC |
---|
316 | LIMIT 1 |
---|
317 | ) DESC |
---|
318 | ,product_id |
---|
319 | __EOS__; |
---|
320 | $objQuery->setOrder($order); |
---|
321 | break; |
---|
322 | } |
---|
323 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
324 | $objQuery->setLimitOffset($disp_number, $startno); |
---|
325 | $objQuery->setWhere($searchCondition["where"]); |
---|
326 | |
---|
327 | // 表示すべきIDとそのIDの並び順を一気に取得 |
---|
328 | $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition["arrval"], $arrval_order)); |
---|
329 | |
---|
330 | // 取得した表示すべきIDだけを指定して情報を取得。 < 謎の処理 |
---|
331 | $where = ""; |
---|
332 | if (is_array($arrProduct_id) && !empty($arrProduct_id)) { |
---|
333 | $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')'; |
---|
334 | } else { |
---|
335 | // 一致させない |
---|
336 | $where = '0<>0'; |
---|
337 | } |
---|
338 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
339 | $objQuery->setWhere($where); |
---|
340 | $arrProducts = $objProduct->lists($objQuery, $arrProduct_id); |
---|
341 | |
---|
342 | //取得している並び順で並び替え |
---|
343 | $arrProducts2 = array(); |
---|
344 | foreach($arrProducts as $item) { |
---|
345 | $arrProducts2[ $item['product_id'] ] = $item; |
---|
346 | } |
---|
347 | $arrProducts = array(); |
---|
348 | foreach($arrProduct_id as $product_id) { |
---|
349 | $arrProducts[] = $arrProducts2[$product_id]; |
---|
350 | } |
---|
351 | |
---|
352 | // 規格を設定 |
---|
353 | $objProduct->setProductsClassByProductIds($arrProduct_id); |
---|
354 | $arrProducts += array("productStatus"=>$objProduct->getProductStatus($arrProduct_id)); |
---|
355 | return $arrProducts; |
---|
356 | } |
---|
357 | |
---|
358 | /* 入力内容のチェック */ |
---|
359 | function lfCheckError($id) { |
---|
360 | |
---|
361 | // 入力データを渡す。 |
---|
362 | $objErr = new SC_CheckError($this->arrForm); |
---|
363 | |
---|
364 | // 複数項目チェック |
---|
365 | if ($this->tpl_classcat_find1[$id]) { |
---|
366 | $objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
367 | } |
---|
368 | if ($this->tpl_classcat_find2[$id]) { |
---|
369 | $objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
370 | } |
---|
371 | $objErr->doFunc(array("数量", 'quantity', INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
372 | |
---|
373 | return $objErr->arrErr; |
---|
374 | } |
---|
375 | |
---|
376 | /** |
---|
377 | * パラメータの読み込み |
---|
378 | * |
---|
379 | * @return void |
---|
380 | */ |
---|
381 | function lfGetDisplayNum($display_number) { |
---|
382 | // 表示件数 |
---|
383 | if (!isset($display_number) |
---|
384 | OR !SC_Utils_Ex::sfIsInt($display_number) |
---|
385 | ) { |
---|
386 | //最小表示件数を選択 |
---|
387 | return current(array_keys($this->arrPRODUCTLISTMAX)); |
---|
388 | } |
---|
389 | return $display_number; |
---|
390 | } |
---|
391 | |
---|
392 | /** |
---|
393 | * ページャ用データ設定(モバイル) |
---|
394 | * |
---|
395 | * @return void |
---|
396 | */ |
---|
397 | function lfSetPagerMobile() { |
---|
398 | // ページ送り機能用のURLを作成する。 |
---|
399 | $objURL = new Net_URL($_SERVER['PHP_SELF']); |
---|
400 | foreach ($_REQUEST as $key => $value) { |
---|
401 | if ($key == session_name() || $key == 'pageno') { |
---|
402 | continue; |
---|
403 | } |
---|
404 | $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE)); |
---|
405 | } |
---|
406 | |
---|
407 | if ($this->objNavi->now_page > 1) { |
---|
408 | $objURL->addQueryString('pageno', $this->objNavi->now_page - 1); |
---|
409 | $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString(); |
---|
410 | } |
---|
411 | if ($this->objNavi->now_page < $this->objNavi->max_page) { |
---|
412 | $objURL->addQueryString('pageno', $this->objNavi->now_page + 1); |
---|
413 | $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString(); |
---|
414 | } |
---|
415 | } |
---|
416 | |
---|
417 | /** |
---|
418 | * ページタイトルの設定 |
---|
419 | * |
---|
420 | * @return str |
---|
421 | */ |
---|
422 | function lfGetPageTitle($mode,$category_id = 0){ |
---|
423 | if ($mode == 'search') { |
---|
424 | return "検索結果"; |
---|
425 | } elseif ($category_id == 0) { |
---|
426 | return "全商品"; |
---|
427 | } else { |
---|
428 | $arrCat = SC_Helper_DB_Ex::sfGetCat($category_id); |
---|
429 | return $arrCat['name']; |
---|
430 | } |
---|
431 | return ""; |
---|
432 | } |
---|
433 | |
---|
434 | /** |
---|
435 | * 表示用検索条件の設定 |
---|
436 | * |
---|
437 | * @return array |
---|
438 | */ |
---|
439 | function lfGetSearchConditionDisp($arrSearchData){ |
---|
440 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
441 | $arrSearch = array('category'=>"指定なし",'maker'=>"指定なし",'name'=>"指定なし"); |
---|
442 | // カテゴリー検索条件 |
---|
443 | if ($arrSearchData['category_id'] > 0) { |
---|
444 | $arrSearch['category'] = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($arrSearchData['category_id'])); |
---|
445 | } |
---|
446 | |
---|
447 | // メーカー検索条件 |
---|
448 | if (strlen($arrSearchData['maker_id']) > 0) { |
---|
449 | $arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", array($arrSearchData['maker_id'])); |
---|
450 | } |
---|
451 | |
---|
452 | // 商品名検索条件 |
---|
453 | if (strlen($arrSearchData['name']) > 0) { |
---|
454 | $arrSearch['name'] = $arrSearchData['name']; |
---|
455 | } |
---|
456 | return $arrSearch; |
---|
457 | } |
---|
458 | |
---|
459 | /** |
---|
460 | * 該当件数の取得 |
---|
461 | * |
---|
462 | * @return int |
---|
463 | */ |
---|
464 | function lfGetProductAllNum($searchCondition){ |
---|
465 | // 検索結果対象となる商品の数を取得 |
---|
466 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
467 | $objQuery->setWhere($searchCondition["where"]); |
---|
468 | $objProduct = new SC_Product(); |
---|
469 | return $objProduct->findProductCount($objQuery, $searchCondition["arrval"]); |
---|
470 | } |
---|
471 | |
---|
472 | /** |
---|
473 | * 検索条件のwhere文とかを取得 |
---|
474 | * |
---|
475 | * @return array |
---|
476 | */ |
---|
477 | function lfGetSearchCondition($arrSearchData){ |
---|
478 | $searchCondition = array( |
---|
479 | "where"=>"", |
---|
480 | "arrval"=>array(), |
---|
481 | "where_category"=>"", |
---|
482 | "arrvalCategory"=>array() |
---|
483 | ); |
---|
484 | |
---|
485 | // カテゴリからのWHERE文字列取得 |
---|
486 | if ($arrSearchData["category_id"] != 0) { |
---|
487 | list($searchCondition["where_category"], $searchCondition["arrvalCategory"]) = SC_Helper_DB_Ex::sfGetCatWhere($arrSearchData["category_id"]); |
---|
488 | } |
---|
489 | // ▼対象商品IDの抽出 |
---|
490 | // 商品検索条件の作成(未削除、表示) |
---|
491 | $searchCondition["where"] = "alldtl.del_flg = 0 AND alldtl.status = 1 "; |
---|
492 | |
---|
493 | // 在庫無し商品の非表示 |
---|
494 | if (NOSTOCK_HIDDEN === true) { |
---|
495 | $searchCondition["where"] .= ' AND (stock >= 1 OR stock_unlimited = 1)'; |
---|
496 | } |
---|
497 | |
---|
498 | if (strlen($searchCondition["where_category"]) >= 1) { |
---|
499 | $searchCondition["where"] .= " AND T2.".$searchCondition["where_category"]; |
---|
500 | $searchCondition["arrval"] = array_merge($searchCondition["arrval"], $searchCondition["arrvalCategory"]); |
---|
501 | } |
---|
502 | |
---|
503 | // 商品名をwhere文に |
---|
504 | $name = $arrSearchData['name']; |
---|
505 | $name = ereg_replace(",", "", $name);// XXX |
---|
506 | // 全角スペースを半角スペースに変換 |
---|
507 | $name = str_replace(' ', ' ', $name); |
---|
508 | // スペースでキーワードを分割 |
---|
509 | $names = preg_split("/ +/", $name); |
---|
510 | // 分割したキーワードを一つずつwhere文に追加 |
---|
511 | foreach ($names as $val) { |
---|
512 | if ( strlen($val) > 0 ) { |
---|
513 | $searchCondition["where"] .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) "; |
---|
514 | $searchCondition["arrval"][] = "%$val%"; |
---|
515 | $searchCondition["arrval"][] = "%$val%"; |
---|
516 | } |
---|
517 | } |
---|
518 | |
---|
519 | // メーカーらのWHERE文字列取得 |
---|
520 | if ($arrSearchData['maker_id']) { |
---|
521 | $searchCondition["where"] .= " AND alldtl.maker_id = ? "; |
---|
522 | $searchCondition["arrval"][] = $arrSearchData['maker_id']; |
---|
523 | } |
---|
524 | return $searchCondition; |
---|
525 | } |
---|
526 | } |
---|
527 | ?> |
---|