1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * 対応状況管理 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Order_Status extends LC_Page_Admin_Ex { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_mainpage = 'order/status.tpl'; |
---|
47 | $this->tpl_mainno = 'order'; |
---|
48 | $this->tpl_subno = 'status'; |
---|
49 | $this->tpl_maintitle = '受注管理'; |
---|
50 | $this->tpl_subtitle = '対応状況管理'; |
---|
51 | |
---|
52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
53 | $this->arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); |
---|
54 | $this->arrORDERSTATUS_COLOR = $masterData->getMasterData('mtb_order_status_color'); |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Page のプロセス. |
---|
59 | * |
---|
60 | * @return void |
---|
61 | */ |
---|
62 | function process() { |
---|
63 | $this->action(); |
---|
64 | $this->sendResponse(); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * Page のアクション. |
---|
69 | * |
---|
70 | * @return void |
---|
71 | */ |
---|
72 | function action() { |
---|
73 | // フックポイント. |
---|
74 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
75 | $objPlugin->doAction('lc_page_admin_order_status_action_start', array($this)); |
---|
76 | |
---|
77 | $objDb = new SC_Helper_DB_Ex(); |
---|
78 | |
---|
79 | // パラメーター管理クラス |
---|
80 | $objFormParam = new SC_FormParam_Ex(); |
---|
81 | // パラメーター情報の初期化 |
---|
82 | $this->lfInitParam($objFormParam); |
---|
83 | $objFormParam->setParam($_POST); |
---|
84 | // 入力値の変換 |
---|
85 | $objFormParam->convParam(); |
---|
86 | |
---|
87 | $this->arrForm = $objFormParam->getHashArray(); |
---|
88 | // $this->arrForm = $_POST; |
---|
89 | |
---|
90 | //支払方法の取得 |
---|
91 | $this->arrPayment = $objDb->sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method'); |
---|
92 | |
---|
93 | switch ($this->getMode()) { |
---|
94 | case 'update': |
---|
95 | switch ($objFormParam->getValue('change_status')) { |
---|
96 | case '': |
---|
97 | break; |
---|
98 | // 削除 |
---|
99 | case 'delete': |
---|
100 | $this->lfDelete($objFormParam->getValue('move')); |
---|
101 | break; |
---|
102 | // 更新 |
---|
103 | default: |
---|
104 | $this->lfStatusMove($objFormParam->getValue('change_status'), $objFormParam->getValue('move')); |
---|
105 | break; |
---|
106 | } |
---|
107 | |
---|
108 | // 対応状況 |
---|
109 | $status = !is_null($objFormParam->getValue('status')) ? $objFormParam->getValue('status') : ''; |
---|
110 | break; |
---|
111 | |
---|
112 | case 'search': |
---|
113 | // 対応状況 |
---|
114 | $status = !is_null($_POST['status']) ? $objFormParam->getValue('status') : ''; |
---|
115 | break; |
---|
116 | |
---|
117 | default: |
---|
118 | // 対応状況 |
---|
119 | //デフォルトで新規受付一覧表示 |
---|
120 | $status = ORDER_NEW; |
---|
121 | break; |
---|
122 | } |
---|
123 | |
---|
124 | // 対応状況 |
---|
125 | $this->SelectedStatus = $status; |
---|
126 | //検索結果の表示 |
---|
127 | $this->lfStatusDisp($status, $objFormParam->getValue('search_pageno')); |
---|
128 | |
---|
129 | // フックポイント. |
---|
130 | $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); |
---|
131 | $objPlugin->doAction('lc_page_admin_order_status_action_end', array($this)); |
---|
132 | } |
---|
133 | |
---|
134 | /** |
---|
135 | * パラメーター情報の初期化 |
---|
136 | * @param SC_FormParam |
---|
137 | */ |
---|
138 | function lfInitParam(&$objFormParam) { |
---|
139 | $objFormParam->addParam('注文番号', 'order_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
140 | $objFormParam->addParam('変更前対応状況', 'status', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
141 | $objFormParam->addParam('変更後対応状況', 'change_status', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
142 | $objFormParam->addParam('ページ番号', 'search_pageno', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
143 | $objFormParam->addParam('移動注文番号', 'move', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * 入力内容のチェック |
---|
148 | * @param SC_FormParam |
---|
149 | */ |
---|
150 | function lfCheckError(&$objFormParam) { |
---|
151 | // 入力データを渡す。 |
---|
152 | $arrRet = $objFormParam->getHashArray(); |
---|
153 | $arrErr = $objFormParam->checkError(); |
---|
154 | if (is_null($objFormParam->getValue('search_pageno'))) { |
---|
155 | $objFormParam->setValue('search_pageno', 1); |
---|
156 | } |
---|
157 | |
---|
158 | if ($this->getMode() == 'change') { |
---|
159 | if (is_null($objFormParam->getValue('change_status'))) { |
---|
160 | $objFormParam->setValue('change_status',''); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | } |
---|
165 | |
---|
166 | /** |
---|
167 | * デストラクタ. |
---|
168 | * |
---|
169 | * @return void |
---|
170 | */ |
---|
171 | function destroy() { |
---|
172 | parent::destroy(); |
---|
173 | } |
---|
174 | |
---|
175 | // 対応状況一覧の表示 |
---|
176 | function lfStatusDisp($status,$pageno) { |
---|
177 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
178 | |
---|
179 | $select ='*'; |
---|
180 | $from = 'dtb_order'; |
---|
181 | $where = 'del_flg = 0 AND status = ?'; |
---|
182 | $arrWhereVal = array($status); |
---|
183 | $order = 'order_id DESC'; |
---|
184 | |
---|
185 | $linemax = $objQuery->count($from, $where, $arrWhereVal); |
---|
186 | $this->tpl_linemax = $linemax; |
---|
187 | |
---|
188 | // ページ送りの処理 |
---|
189 | $page_max = ORDER_STATUS_MAX; |
---|
190 | |
---|
191 | // ページ送りの取得 |
---|
192 | $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, 'fnNaviSearchOnlyPage', NAVI_PMAX); |
---|
193 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
194 | $startno = $objNavi->start_row; |
---|
195 | |
---|
196 | $this->tpl_pageno = $pageno; |
---|
197 | |
---|
198 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
199 | $objQuery->setLimitOffset($page_max, $startno); |
---|
200 | |
---|
201 | //表示順序 |
---|
202 | $objQuery->setOrder($order); |
---|
203 | |
---|
204 | //検索結果の取得 |
---|
205 | $this->arrStatus = $objQuery->select($select, $from, $where, $arrWhereVal); |
---|
206 | } |
---|
207 | |
---|
208 | /** |
---|
209 | * 対応状況の更新 |
---|
210 | */ |
---|
211 | function lfStatusMove($statusId, $arrOrderId) { |
---|
212 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
213 | $objQuery = new SC_Query_Ex(); |
---|
214 | |
---|
215 | if (!isset($arrOrderId) || !is_array($arrOrderId)) { |
---|
216 | return false; |
---|
217 | } |
---|
218 | $masterData = new SC_DB_MasterData_Ex(); |
---|
219 | $arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); |
---|
220 | |
---|
221 | $objQuery->begin(); |
---|
222 | |
---|
223 | foreach ($arrOrderId as $orderId) { |
---|
224 | $objPurchase->sfUpdateOrderStatus($orderId, $statusId); |
---|
225 | } |
---|
226 | |
---|
227 | $objQuery->commit(); |
---|
228 | |
---|
229 | $this->tpl_onload = "window.alert('選択項目を" . $arrORDERSTATUS[$statusId] . "へ移動しました。');"; |
---|
230 | return true; |
---|
231 | } |
---|
232 | |
---|
233 | /** |
---|
234 | * 受注テーブルの論理削除 |
---|
235 | */ |
---|
236 | function lfDelete($arrOrderId) { |
---|
237 | $objQuery = new SC_Query_Ex(); |
---|
238 | |
---|
239 | if (!isset($arrOrderId) || !is_array($arrOrderId)) { |
---|
240 | return false; |
---|
241 | } |
---|
242 | |
---|
243 | $arrUpdate = array( |
---|
244 | 'del_flg' => 1, |
---|
245 | 'update_date' => 'CURRENT_TIMESTAMP', |
---|
246 | ); |
---|
247 | |
---|
248 | $objQuery->begin(); |
---|
249 | |
---|
250 | foreach ($arrOrderId as $orderId) { |
---|
251 | $objQuery->update('dtb_order', $arrUpdate, 'order_id = ?', array($orderId)); |
---|
252 | } |
---|
253 | |
---|
254 | $objQuery->commit(); |
---|
255 | |
---|
256 | $this->tpl_onload = "window.alert('選択項目を削除しました。');"; |
---|
257 | return true; |
---|
258 | } |
---|
259 | } |
---|