1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | // {{{ requires |
---|
9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
10 | |
---|
11 | /** |
---|
12 | * 受注管理 のページクラス. |
---|
13 | * |
---|
14 | * @package Page |
---|
15 | * @author LOCKON CO.,LTD. |
---|
16 | * @version $Id$ |
---|
17 | */ |
---|
18 | class LC_Page_Admin_Order extends LC_Page { |
---|
19 | |
---|
20 | // }}} |
---|
21 | // {{{ functions |
---|
22 | |
---|
23 | /** |
---|
24 | * Page を初期化する. |
---|
25 | * |
---|
26 | * @return void |
---|
27 | */ |
---|
28 | function init() { |
---|
29 | parent::init(); |
---|
30 | $this->tpl_mainpage = 'order/index.tpl'; |
---|
31 | $this->tpl_subnavi = 'order/subnavi.tpl'; |
---|
32 | $this->tpl_mainno = 'order'; |
---|
33 | $this->tpl_subno = 'index'; |
---|
34 | $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl'; |
---|
35 | $this->tpl_subtitle = '受注管理'; |
---|
36 | |
---|
37 | $masterData = new SC_DB_MasterData_Ex(); |
---|
38 | $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status"); |
---|
39 | $this->arrORDERSTATUS_COLOR = $masterData->getMasterData("mtb_order_status_color"); |
---|
40 | $this->arrSex = $masterData->getMasterData("mtb_sex"); |
---|
41 | $this->arrPageMax = $masterData->getMasterData("mtb_page_max"); |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * Page のプロセス. |
---|
46 | * |
---|
47 | * @return void |
---|
48 | */ |
---|
49 | function process() { |
---|
50 | $conn = new SC_DBConn(); |
---|
51 | $objView = new SC_AdminView(); |
---|
52 | $objDb = new SC_Helper_DB_Ex(); |
---|
53 | $objSess = new SC_Session(); |
---|
54 | // パラメータ管理クラス |
---|
55 | $this->objFormParam = new SC_FormParam(); |
---|
56 | // パラメータ情報の初期化 |
---|
57 | $this->lfInitParam(); |
---|
58 | $this->objFormParam->setParam($_POST); |
---|
59 | |
---|
60 | $this->objFormParam->splitParamCheckBoxes('search_order_sex'); |
---|
61 | $this->objFormParam->splitParamCheckBoxes('search_payment_id'); |
---|
62 | |
---|
63 | // 検索ワードの引き継ぎ |
---|
64 | foreach ($_POST as $key => $val) { |
---|
65 | if (ereg("^search_", $key)) { |
---|
66 | switch($key) { |
---|
67 | case 'search_order_sex': |
---|
68 | case 'search_payment_id': |
---|
69 | $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val); |
---|
70 | break; |
---|
71 | default: |
---|
72 | $this->arrHidden[$key] = $val; |
---|
73 | break; |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | // ページ送り用 |
---|
79 | $this->arrHidden['search_pageno'] = |
---|
80 | isset($_POST['search_pageno']) ? $_POST['search_pageno'] : ""; |
---|
81 | |
---|
82 | // 認証可否の判定 |
---|
83 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
84 | |
---|
85 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
86 | if (!isset($arrRet)) $arrRet = array(); |
---|
87 | |
---|
88 | if($_POST['mode'] == 'delete') { |
---|
89 | if(sfIsInt($_POST['order_id'])) { |
---|
90 | $objQuery = new SC_Query(); |
---|
91 | $where = "order_id = ?"; |
---|
92 | $sqlval['del_flg'] = '1'; |
---|
93 | $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id'])); |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | switch($_POST['mode']) { |
---|
98 | case 'delete': |
---|
99 | case 'csv': |
---|
100 | case 'delete_all': |
---|
101 | case 'search': |
---|
102 | // 入力値の変換 |
---|
103 | $this->objFormParam->convParam(); |
---|
104 | $this->arrErr = $this->lfCheckError($arrRet); |
---|
105 | $arrRet = $this->objFormParam->getHashArray(); |
---|
106 | // 入力なし |
---|
107 | if (count($this->arrErr) == 0) { |
---|
108 | $where = "del_flg = 0"; |
---|
109 | foreach ($arrRet as $key => $val) { |
---|
110 | if($val == "") { |
---|
111 | continue; |
---|
112 | } |
---|
113 | $val = SC_Utils_Ex::sfManualEscape($val); |
---|
114 | |
---|
115 | switch ($key) { |
---|
116 | case 'search_order_name': |
---|
117 | if(DB_TYPE == "pgsql"){ |
---|
118 | $where .= " AND order_name01||order_name02 ILIKE ?"; |
---|
119 | }elseif(DB_TYPE == "mysql"){ |
---|
120 | $where .= " AND concat(order_name01,order_name02) ILIKE ?"; |
---|
121 | } |
---|
122 | $nonsp_val = ereg_replace("[ ]+","",$val); |
---|
123 | $arrval[] = "%$nonsp_val%"; |
---|
124 | break; |
---|
125 | case 'search_order_kana': |
---|
126 | if(DB_TYPE == "pgsql"){ |
---|
127 | $where .= " AND order_kana01||order_kana02 ILIKE ?"; |
---|
128 | }elseif(DB_TYPE == "mysql"){ |
---|
129 | $where .= " AND concat(order_kana01,order_kana02) ILIKE ?"; |
---|
130 | } |
---|
131 | $nonsp_val = ereg_replace("[ ]+","",$val); |
---|
132 | $arrval[] = "%$nonsp_val%"; |
---|
133 | break; |
---|
134 | case 'search_order_id1': |
---|
135 | $where .= " AND order_id >= ?"; |
---|
136 | $arrval[] = $val; |
---|
137 | break; |
---|
138 | case 'search_order_id2': |
---|
139 | $where .= " AND order_id <= ?"; |
---|
140 | $arrval[] = $val; |
---|
141 | break; |
---|
142 | case 'search_order_sex': |
---|
143 | $tmp_where = ""; |
---|
144 | foreach($val as $element) { |
---|
145 | if($element != "") { |
---|
146 | if($tmp_where == "") { |
---|
147 | $tmp_where .= " AND (order_sex = ?"; |
---|
148 | } else { |
---|
149 | $tmp_where .= " OR order_sex = ?"; |
---|
150 | } |
---|
151 | $arrval[] = $element; |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | if($tmp_where != "") { |
---|
156 | $tmp_where .= ")"; |
---|
157 | $where .= " $tmp_where "; |
---|
158 | } |
---|
159 | break; |
---|
160 | case 'search_order_tel': |
---|
161 | if(DB_TYPE == "pgsql"){ |
---|
162 | $where .= " AND (order_tel01||order_tel02||order_tel03) ILIKE ?"; |
---|
163 | }elseif(DB_TYPE == "mysql"){ |
---|
164 | $where .= " AND concat(order_tel01,order_tel02,order_tel03) ILIKE ?"; |
---|
165 | } |
---|
166 | $nonmark_val = ereg_replace("[()-]+","",$val); |
---|
167 | $arrval[] = "$nonmark_val%"; |
---|
168 | break; |
---|
169 | case 'search_order_email': |
---|
170 | $where .= " AND order_email ILIKE ?"; |
---|
171 | $arrval[] = "%$val%"; |
---|
172 | break; |
---|
173 | case 'search_payment_id': |
---|
174 | $tmp_where = ""; |
---|
175 | foreach($val as $element) { |
---|
176 | if($element != "") { |
---|
177 | if($tmp_where == "") { |
---|
178 | $tmp_where .= " AND (payment_id = ?"; |
---|
179 | } else { |
---|
180 | $tmp_where .= " OR payment_id = ?"; |
---|
181 | } |
---|
182 | $arrval[] = $element; |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | if($tmp_where != "") { |
---|
187 | $tmp_where .= ")"; |
---|
188 | $where .= " $tmp_where "; |
---|
189 | } |
---|
190 | break; |
---|
191 | case 'search_total1': |
---|
192 | $where .= " AND total >= ?"; |
---|
193 | $arrval[] = $val; |
---|
194 | break; |
---|
195 | case 'search_total2': |
---|
196 | $where .= " AND total <= ?"; |
---|
197 | $arrval[] = $val; |
---|
198 | break; |
---|
199 | case 'search_startyear': |
---|
200 | $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']); |
---|
201 | $where.= " AND update_date >= ?"; |
---|
202 | $arrval[] = $date; |
---|
203 | break; |
---|
204 | case 'search_endyear': |
---|
205 | $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday'], true); |
---|
206 | $where.= " AND update_date <= ?"; |
---|
207 | $arrval[] = $date; |
---|
208 | break; |
---|
209 | case 'search_sbirthyear': |
---|
210 | $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']); |
---|
211 | $where.= " AND order_birth >= ?"; |
---|
212 | $arrval[] = $date; |
---|
213 | break; |
---|
214 | case 'search_ebirthyear': |
---|
215 | $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true); |
---|
216 | $where.= " AND order_birth <= ?"; |
---|
217 | $arrval[] = $date; |
---|
218 | break; |
---|
219 | case 'search_order_status': |
---|
220 | $where.= " AND status = ?"; |
---|
221 | $arrval[] = $val; |
---|
222 | break; |
---|
223 | default: |
---|
224 | if (!isset($arrval)) $arrval = array(); |
---|
225 | break; |
---|
226 | } |
---|
227 | } |
---|
228 | |
---|
229 | $order = "update_date DESC"; |
---|
230 | |
---|
231 | switch($_POST['mode']) { |
---|
232 | case 'csv': |
---|
233 | |
---|
234 | require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php"); |
---|
235 | $objCSV = new SC_Helper_CSV_Ex(); |
---|
236 | // オプションの指定 |
---|
237 | $option = "ORDER BY $order"; |
---|
238 | |
---|
239 | // CSV出力タイトル行の作成 |
---|
240 | $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1")); |
---|
241 | |
---|
242 | if (count($arrCsvOutput) <= 0) break; |
---|
243 | |
---|
244 | $arrCsvOutputCols = $arrCsvOutput['col']; |
---|
245 | $arrCsvOutputTitle = $arrCsvOutput['disp_name']; |
---|
246 | $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle); |
---|
247 | $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols); |
---|
248 | |
---|
249 | // CSVを送信する。 |
---|
250 | SC_Utils_Ex::sfCSVDownload($head.$data); |
---|
251 | exit; |
---|
252 | break; |
---|
253 | case 'delete_all': |
---|
254 | // 検索結果をすべて削除 |
---|
255 | $sqlval['del_flg'] = 1; |
---|
256 | $objQuery = new SC_Query(); |
---|
257 | $objQuery->update("dtb_order", $sqlval, $where, $arrval); |
---|
258 | break; |
---|
259 | default: |
---|
260 | // 読み込む列とテーブルの指定 |
---|
261 | $col = "*"; |
---|
262 | $from = "dtb_order"; |
---|
263 | |
---|
264 | $objQuery = new SC_Query(); |
---|
265 | // 行数の取得 |
---|
266 | $linemax = $objQuery->count($from, $where, $arrval); |
---|
267 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
268 | |
---|
269 | // ページ送りの処理 |
---|
270 | if(is_numeric($_POST['search_page_max'])) { |
---|
271 | $page_max = $_POST['search_page_max']; |
---|
272 | } else { |
---|
273 | $page_max = SEARCH_PMAX; |
---|
274 | } |
---|
275 | |
---|
276 | // ページ送りの取得 |
---|
277 | $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], |
---|
278 | $linemax, $page_max, |
---|
279 | "fnNaviSearchPage", NAVI_PMAX); |
---|
280 | $startno = $objNavi->start_row; |
---|
281 | $this->arrPagenavi = $objNavi->arrPagenavi; |
---|
282 | |
---|
283 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
284 | $objQuery->setlimitoffset($page_max, $startno); |
---|
285 | // 表示順序 |
---|
286 | $objQuery->setorder($order); |
---|
287 | // 検索結果の取得 |
---|
288 | $this->arrResults = $objQuery->select($col, $from, $where, $arrval); |
---|
289 | } |
---|
290 | } |
---|
291 | break; |
---|
292 | |
---|
293 | default: |
---|
294 | break; |
---|
295 | } |
---|
296 | |
---|
297 | $objDate = new SC_Date(); |
---|
298 | // 登録・更新日検索用 |
---|
299 | $objDate->setStartYear(RELEASE_YEAR); |
---|
300 | $objDate->setEndYear(DATE("Y")); |
---|
301 | $this->arrRegistYear = $objDate->getYear(); |
---|
302 | // 生年月日検索用 |
---|
303 | $objDate->setStartYear(BIRTH_YEAR); |
---|
304 | $objDate->setEndYear(DATE("Y")); |
---|
305 | $this->arrBirthYear = $objDate->getYear(); |
---|
306 | // 月日の設定 |
---|
307 | $this->arrMonth = $objDate->getMonth(); |
---|
308 | $this->arrDay = $objDate->getDay(); |
---|
309 | |
---|
310 | // 入力値の取得 |
---|
311 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
312 | // 支払い方法の取得 |
---|
313 | $arrRet = $objDb->sfGetPayment(); |
---|
314 | $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method'); |
---|
315 | |
---|
316 | $objView->assignobj($this); |
---|
317 | $objView->display(MAIN_FRAME); |
---|
318 | } |
---|
319 | |
---|
320 | /** |
---|
321 | * デストラクタ. |
---|
322 | * |
---|
323 | * @return void |
---|
324 | */ |
---|
325 | function destroy() { |
---|
326 | parent::destroy(); |
---|
327 | } |
---|
328 | |
---|
329 | /* パラメータ情報の初期化 */ |
---|
330 | function lfInitParam() { |
---|
331 | $this->objFormParam->addParam("受注番号1", "search_order_id1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
332 | $this->objFormParam->addParam("受注番号2", "search_order_id2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
333 | $this->objFormParam->addParam("対応状況", "search_order_status", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
334 | $this->objFormParam->addParam("顧客名", "search_order_name", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); |
---|
335 | $this->objFormParam->addParam("顧客名(カナ)", "search_order_kana", STEXT_LEN, "KVCa", array("KANA_CHECK","MAX_LENGTH_CHECK")); |
---|
336 | $this->objFormParam->addParam("性別", "search_order_sex", INT_LEN, "n", array("MAX_LENGTH_CHECK")); |
---|
337 | $this->objFormParam->addParam("年齢1", "search_age1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
338 | $this->objFormParam->addParam("年齢2", "search_age2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
339 | $this->objFormParam->addParam("メールアドレス", "search_order_email", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); |
---|
340 | $this->objFormParam->addParam("TEL", "search_order_tel", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); |
---|
341 | $this->objFormParam->addParam("支払い方法", "search_payment_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
342 | $this->objFormParam->addParam("購入金額1", "search_total1", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
343 | $this->objFormParam->addParam("購入金額2", "search_total2", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
344 | $this->objFormParam->addParam("表示件数", "search_page_max", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
345 | $this->objFormParam->addParam("開始日", "search_startyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
346 | $this->objFormParam->addParam("開始日", "search_startmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
347 | $this->objFormParam->addParam("開始日", "search_startday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
348 | $this->objFormParam->addParam("終了日", "search_endyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
349 | $this->objFormParam->addParam("終了日", "search_endmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
350 | $this->objFormParam->addParam("終了日", "search_endday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
351 | $this->objFormParam->addParam("開始日", "search_sbirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
352 | $this->objFormParam->addParam("開始日", "search_sbirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
353 | $this->objFormParam->addParam("開始日", "search_sbirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
354 | $this->objFormParam->addParam("終了日", "search_ebirthyear", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
355 | $this->objFormParam->addParam("終了日", "search_ebirthmonth", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
356 | $this->objFormParam->addParam("終了日", "search_ebirthday", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
357 | } |
---|
358 | |
---|
359 | /* 入力内容のチェック */ |
---|
360 | function lfCheckError() { |
---|
361 | // 入力データを渡す。 |
---|
362 | $arrRet = $this->objFormParam->getHashArray(); |
---|
363 | $objErr = new SC_CheckError($arrRet); |
---|
364 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
365 | |
---|
366 | // 特殊項目チェック |
---|
367 | $objErr->doFunc(array("受注番号1", "受注番号2", "search_order_id1", "search_order_id2"), array("GREATER_CHECK")); |
---|
368 | $objErr->doFunc(array("年齢1", "年齢2", "search_age1", "search_age2"), array("GREATER_CHECK")); |
---|
369 | $objErr->doFunc(array("購入金額1", "購入金額2", "search_total1", "search_total2"), array("GREATER_CHECK")); |
---|
370 | $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE")); |
---|
371 | $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE")); |
---|
372 | $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM")); |
---|
373 | |
---|
374 | $objErr->doFunc(array("開始日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday"), array("CHECK_DATE")); |
---|
375 | $objErr->doFunc(array("終了日", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_DATE")); |
---|
376 | $objErr->doFunc(array("開始日", "終了日", "search_sbirthyear", "search_sbirthmonth", "search_sbirthday", "search_ebirthyear", "search_ebirthmonth", "search_ebirthday"), array("CHECK_SET_TERM")); |
---|
377 | |
---|
378 | return $objErr->arrErr; |
---|
379 | } |
---|
380 | |
---|
381 | |
---|
382 | } |
---|
383 | ?> |
---|