1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * 商品選択 のページクラス. |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class LC_Page_Admin_Products_ProductSelect extends LC_Page_Admin_Ex |
---|
34 | { |
---|
35 | /** |
---|
36 | * Page を初期化する. |
---|
37 | * |
---|
38 | * @return void |
---|
39 | */ |
---|
40 | public function init() |
---|
41 | { |
---|
42 | parent::init(); |
---|
43 | $this->tpl_mainpage = 'products/product_select.tpl'; |
---|
44 | $this->tpl_mainno = 'products'; |
---|
45 | $this->tpl_subno = ''; |
---|
46 | $this->tpl_maintitle = '商品管理'; |
---|
47 | $this->tpl_subtitle = '商品選択'; |
---|
48 | |
---|
49 | $masterData = new SC_DB_MasterData_Ex(); |
---|
50 | $this->arrPRODUCTSTATUS_COLOR = $masterData->getMasterData('mtb_product_status_color'); |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Page のプロセス. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | public function process() |
---|
59 | { |
---|
60 | $this->action(); |
---|
61 | $this->sendResponse(); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Page のアクション. |
---|
66 | * |
---|
67 | * @return void |
---|
68 | */ |
---|
69 | public function action() |
---|
70 | { |
---|
71 | $objDb = new SC_Helper_DB_Ex(); |
---|
72 | |
---|
73 | $objFormParam = new SC_FormParam_Ex(); |
---|
74 | $this->lfInitParam($objFormParam); |
---|
75 | $objFormParam->setParam($_POST); |
---|
76 | $objFormParam->convParam(); |
---|
77 | $this->arrForm = $objFormParam->getHashArray(); |
---|
78 | |
---|
79 | switch ($this->getMode()) { |
---|
80 | case 'search': |
---|
81 | $this->arrProducts = $this->lfGetProducts($objDb); |
---|
82 | break; |
---|
83 | default: |
---|
84 | break; |
---|
85 | } |
---|
86 | |
---|
87 | // カテゴリ取得 |
---|
88 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
89 | $this->setTemplate($this->tpl_mainpage); |
---|
90 | } |
---|
91 | |
---|
92 | /** |
---|
93 | * パラメーター情報の初期化を行う. |
---|
94 | * |
---|
95 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
96 | * @return void |
---|
97 | */ |
---|
98 | public function lfInitParam(&$objFormParam) |
---|
99 | { |
---|
100 | $objFormParam->addParam('カテゴリ', 'search_category_id', STEXT_LEN, 'n'); |
---|
101 | $objFormParam->addParam('商品名', 'search_name', STEXT_LEN, 'KVa'); |
---|
102 | $objFormParam->addParam('商品コード', 'search_product_code', STEXT_LEN, 'KVa'); |
---|
103 | } |
---|
104 | |
---|
105 | /* 商品検索結果取得 */ |
---|
106 | public function lfGetProducts(&$objDb) |
---|
107 | { |
---|
108 | $where = 'del_flg = 0'; |
---|
109 | $arrWhereVal = array(); |
---|
110 | |
---|
111 | /* 入力エラーなし */ |
---|
112 | foreach ($this->arrForm AS $key=>$val) { |
---|
113 | if ($val == '') continue; |
---|
114 | |
---|
115 | switch ($key) { |
---|
116 | case 'search_name': |
---|
117 | $where .= ' AND name ILIKE ?'; |
---|
118 | $arrWhereVal[] = "%$val%"; |
---|
119 | break; |
---|
120 | case 'search_category_id': |
---|
121 | list($tmp_where, $arrTmp) = $objDb->sfGetCatWhere($val); |
---|
122 | if ($tmp_where != '') { |
---|
123 | $where.= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; |
---|
124 | $arrWhereVal = array_merge((array) $arrWhereVal, (array) $arrTmp); |
---|
125 | } |
---|
126 | break; |
---|
127 | case 'search_product_code': |
---|
128 | $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ?)'; |
---|
129 | $arrWhereVal[] = "$val%"; |
---|
130 | break; |
---|
131 | default: |
---|
132 | break; |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | $order = 'update_date DESC, product_id DESC '; |
---|
137 | |
---|
138 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
139 | // 行数の取得 |
---|
140 | $linemax = $objQuery->count('dtb_products', $where, $arrWhereVal); |
---|
141 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
142 | |
---|
143 | // ページ送りの処理 |
---|
144 | $page_max = SC_Utils_Ex::sfGetSearchPageMax($_POST['search_page_max']); |
---|
145 | |
---|
146 | // ページ送りの取得 |
---|
147 | $objNavi = new SC_PageNavi_Ex($_POST['search_pageno'], $linemax, $page_max, 'fnNaviSearchOnlyPage', NAVI_PMAX); |
---|
148 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
149 | $startno = $objNavi->start_row; |
---|
150 | |
---|
151 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
152 | $objQuery->setLimitOffset($page_max, $startno); |
---|
153 | // 表示順序 |
---|
154 | $objQuery->setOrder($order); |
---|
155 | |
---|
156 | // 検索結果の取得 |
---|
157 | // FIXME 商品コードの表示 |
---|
158 | $arrProducts = $objQuery->select('*', SC_Product_Ex::alldtlSQL(), $where, $arrWhereVal); |
---|
159 | |
---|
160 | return $arrProducts; |
---|
161 | } |
---|
162 | } |
---|