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/admin/LC_Page_Admin.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品選択 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Products_ProductSelect extends LC_Page_Admin { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_mainpage = 'products/product_select.tpl'; |
---|
47 | $this->tpl_mainno = 'products'; |
---|
48 | $this->tpl_subnavi = ''; |
---|
49 | $this->tpl_subno = ""; |
---|
50 | $this->tpl_subtitle = '商品選択'; |
---|
51 | |
---|
52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
53 | $this->arrPRODUCTSTATUS_COLOR = $masterData->getMasterData("mtb_product_status_color"); |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * Page のプロセス. |
---|
58 | * |
---|
59 | * @return void |
---|
60 | */ |
---|
61 | function process() { |
---|
62 | $this->action(); |
---|
63 | $this->sendResponse(); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * Page のアクション. |
---|
68 | * |
---|
69 | * @return void |
---|
70 | */ |
---|
71 | function action() { |
---|
72 | $objSess = new SC_Session(); |
---|
73 | $objDb = new SC_Helper_DB_Ex(); |
---|
74 | |
---|
75 | // 認証可否の判定 |
---|
76 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
77 | |
---|
78 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
79 | |
---|
80 | if ($_POST['mode'] == "search") { |
---|
81 | |
---|
82 | // POST値の引き継ぎ |
---|
83 | $this->arrForm = $_POST; |
---|
84 | // 入力文字の強制変換 |
---|
85 | $this->lfConvertParam(); |
---|
86 | |
---|
87 | $where = "del_flg = 0"; |
---|
88 | |
---|
89 | /* 入力エラーなし */ |
---|
90 | foreach ($this->arrForm as $key => $val) { |
---|
91 | if($val == "") { |
---|
92 | continue; |
---|
93 | } |
---|
94 | |
---|
95 | switch ($key) { |
---|
96 | case 'search_name': |
---|
97 | $where .= " AND name ILIKE ?"; |
---|
98 | $arrval[] = "%$val%"; |
---|
99 | break; |
---|
100 | case 'search_category_id': |
---|
101 | list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); |
---|
102 | if($tmp_where != "") { |
---|
103 | $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; |
---|
104 | $arrval = array_merge((array)$arrval, (array)$tmp_arrval); |
---|
105 | } |
---|
106 | break; |
---|
107 | case 'search_product_code': |
---|
108 | $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)"; |
---|
109 | $arrval[] = "$val%"; |
---|
110 | break; |
---|
111 | default: |
---|
112 | break; |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | $order = "update_date DESC, product_id DESC "; |
---|
117 | |
---|
118 | $objQuery = new SC_Query(); |
---|
119 | // 行数の取得 |
---|
120 | if (empty($arrval)) { |
---|
121 | $arrval = array(); |
---|
122 | } |
---|
123 | $linemax = $objQuery->count("dtb_products", $where, $arrval); |
---|
124 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
125 | |
---|
126 | // ページ送りの処理 |
---|
127 | if(isset($_POST['search_page_max']) |
---|
128 | && is_numeric($_POST['search_page_max'])) { |
---|
129 | $page_max = $_POST['search_page_max']; |
---|
130 | } else { |
---|
131 | $page_max = SEARCH_PMAX; |
---|
132 | } |
---|
133 | |
---|
134 | // ページ送りの取得 |
---|
135 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
136 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
137 | $startno = $objNavi->start_row; |
---|
138 | |
---|
139 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
140 | $objQuery->setLimitOffset($page_max, $startno); |
---|
141 | // 表示順序 |
---|
142 | $objQuery->setOrder($order); |
---|
143 | |
---|
144 | // 検索結果の取得 |
---|
145 | // FIXME 商品コードの表示 |
---|
146 | $this->arrProducts = $objQuery->select("*", SC_Product::alldtlSQL(), $where, $arrval); |
---|
147 | } |
---|
148 | |
---|
149 | // カテゴリ取得 |
---|
150 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
151 | } |
---|
152 | |
---|
153 | /** |
---|
154 | * デストラクタ. |
---|
155 | * |
---|
156 | * @return void |
---|
157 | */ |
---|
158 | function destroy() { |
---|
159 | parent::destroy(); |
---|
160 | } |
---|
161 | |
---|
162 | /* 取得文字列の変換 */ |
---|
163 | function lfConvertParam() { |
---|
164 | /* |
---|
165 | * 文字列の変換 |
---|
166 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
167 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
168 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
169 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
170 | */ |
---|
171 | $arrConvList['search_name'] = "KVa"; |
---|
172 | $arrConvList['search_product_code'] = "KVa"; |
---|
173 | |
---|
174 | // 文字変換 |
---|
175 | foreach ($arrConvList as $key => $val) { |
---|
176 | // POSTされてきた値のみ変換する。 |
---|
177 | if(isset($this->arrForm[$key])) { |
---|
178 | $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val); |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | ?> |
---|