1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.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 { |
---|
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_subnavi = 'order/subnavi.tpl'; |
---|
48 | $this->tpl_mainno = 'order'; |
---|
49 | $this->tpl_subno = 'status'; |
---|
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 | $objView = new SC_AdminView(); |
---|
64 | $objSess = new SC_Session(); |
---|
65 | $objDb = new SC_Helper_DB_Ex(); |
---|
66 | $objQuery = new SC_Query(); |
---|
67 | |
---|
68 | // 認証可否の判定 |
---|
69 | $objSess = new SC_Session(); |
---|
70 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
71 | |
---|
72 | $this->arrForm = $_POST; |
---|
73 | |
---|
74 | //支払方法の取得 |
---|
75 | $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); |
---|
76 | |
---|
77 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
78 | if (!isset($_POST['search_pageno'])) $_POST['search_pageno'] = 1; |
---|
79 | |
---|
80 | switch ($_POST['mode']){ |
---|
81 | |
---|
82 | case 'update': |
---|
83 | if (!isset($_POST['change_status'])) $_POST['change_status'] = ""; |
---|
84 | if (!empty($_POST['change_status'])) { |
---|
85 | $this->lfStatusMove($_POST['change_status'], $_POST['move']); |
---|
86 | } |
---|
87 | //ステータス情報 |
---|
88 | $status = isset($_POST['status']) ? $_POST['status'] : ""; |
---|
89 | break; |
---|
90 | |
---|
91 | case 'search': |
---|
92 | //ステータス情報 |
---|
93 | $status = isset($_POST['status']) ? $_POST['status'] : ""; |
---|
94 | break; |
---|
95 | |
---|
96 | default: |
---|
97 | //ステータス情報 |
---|
98 | //デフォルトで新規受付一覧表示 |
---|
99 | $status = ORDER_NEW; |
---|
100 | break; |
---|
101 | } |
---|
102 | |
---|
103 | //ステータス情報 |
---|
104 | $this->SelectedStatus = $status; |
---|
105 | //検索結果の表示 |
---|
106 | $this->lfStatusDisp($status, $_POST['search_pageno']); |
---|
107 | |
---|
108 | $objView->assignobj($this); |
---|
109 | $objView->display(MAIN_FRAME); |
---|
110 | } |
---|
111 | /** |
---|
112 | * デストラクタ. |
---|
113 | * |
---|
114 | * @return void |
---|
115 | */ |
---|
116 | function destroy() { |
---|
117 | parent::destroy(); |
---|
118 | } |
---|
119 | |
---|
120 | //ステータス一覧の表示 |
---|
121 | function lfStatusDisp($status,$pageno){ |
---|
122 | $objQuery = new SC_Query(); |
---|
123 | |
---|
124 | $select ="*"; |
---|
125 | $from = "dtb_order"; |
---|
126 | $where = "del_flg = 0 AND status = ?"; |
---|
127 | $arrval[] = $status; |
---|
128 | $order = "order_id DESC"; |
---|
129 | |
---|
130 | $linemax = $objQuery->count($from, $where, $arrval); |
---|
131 | $this->tpl_linemax = $linemax; |
---|
132 | |
---|
133 | // ページ送りの処理 |
---|
134 | $page_max = ORDER_STATUS_MAX; |
---|
135 | |
---|
136 | // ページ送りの取得 |
---|
137 | $objNavi = new SC_PageNavi($pageno, $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
138 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
139 | $startno = $objNavi->start_row; |
---|
140 | |
---|
141 | $this->tpl_pageno = $pageno; |
---|
142 | |
---|
143 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
144 | $objQuery->setlimitoffset($page_max, $startno); |
---|
145 | |
---|
146 | //表示順序 |
---|
147 | $objQuery->setorder($order); |
---|
148 | |
---|
149 | //検索結果の取得 |
---|
150 | $this->arrStatus = $objQuery->select($select, $from, $where, $arrval); |
---|
151 | } |
---|
152 | |
---|
153 | //ステータス情報の更新(削除) |
---|
154 | function lfStatusMove($status_id, $arrMove){ |
---|
155 | $objQuery = new SC_Query(); |
---|
156 | $masterData = new SC_DB_MasterData_Ex(); |
---|
157 | $arrORDERSTATUS = $masterData->getMasterData("mtb_order_status"); |
---|
158 | |
---|
159 | $table = 'dtb_order'; |
---|
160 | $where = 'order_id = ?'; |
---|
161 | $arrUpdate = array('update_date' => 'NOW()'); |
---|
162 | $col = 'customer_id, add_point, use_point, status'; |
---|
163 | |
---|
164 | $delflg = '1'; // 削除フラグ |
---|
165 | $message = ''; // ステータス変更後にポップアップするメッセージの内容 |
---|
166 | |
---|
167 | if ( $status_id == 'delete' ) { |
---|
168 | $arrUpdate['del_flg'] = $delflg; |
---|
169 | $message = '削除'; |
---|
170 | } |
---|
171 | // ステータスが発送済みの時は発送日を更新 |
---|
172 | elseif ( $status_id == ORDER_DELIV ) { |
---|
173 | $arrUpdate['status'] = $status_id; |
---|
174 | $arrUpdate['commit_date'] = 'NOW()'; |
---|
175 | $message = $arrORDERSTATUS[$status_id] . 'へ移動'; |
---|
176 | } |
---|
177 | else { |
---|
178 | $arrUpdate['status'] = $status_id; |
---|
179 | $message = $arrORDERSTATUS[$status_id] . 'へ移動'; |
---|
180 | } |
---|
181 | |
---|
182 | if ( isset($arrMove) ){ |
---|
183 | foreach ( $arrMove as $val ){ |
---|
184 | if ( $val != "" ) { |
---|
185 | if ( $status_id == ORDER_DELIV ) { |
---|
186 | $arrRet = $objQuery->select($col, $table, $where, array($val)); |
---|
187 | $customer_id = $arrRet[0]['customer_id']; |
---|
188 | $add_point = $arrRet[0]['add_point']; |
---|
189 | $status = $arrRet[0]['status']; |
---|
190 | if($customer_id != "" && $customer_id >= 1) { |
---|
191 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
192 | $arrRet[0]['point']+= $add_point; |
---|
193 | $sqlval['point'] = $arrRet[0]['point']; |
---|
194 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
195 | } |
---|
196 | } |
---|
197 | elseif ( $status_id == ORDER_CANCEL ) { |
---|
198 | $arrRet = $objQuery->select($col, $table, $where, array($val)); |
---|
199 | $customer_id = $arrRet[0]['customer_id']; |
---|
200 | $add_point = $arrRet[0]['add_point']; |
---|
201 | $use_point = $arrRet[0]['use_point']; |
---|
202 | $status = $arrRet[0]['status']; |
---|
203 | if($customer_id != "" && $customer_id >= 1) { |
---|
204 | if($status == 5) { |
---|
205 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
206 | $arrRet[0]['point']-= $add_point; |
---|
207 | $arrRet[0]['point']+= $use_point; |
---|
208 | $sqlval['point'] = $arrRet[0]['point']; |
---|
209 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
210 | } else { |
---|
211 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
212 | $arrRet[0]['point']+= $use_point; |
---|
213 | $sqlval['point'] = $arrRet[0]['point']; |
---|
214 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
215 | } |
---|
216 | } |
---|
217 | } |
---|
218 | else { |
---|
219 | $arrRet = $objQuery->select($col, $table, $where, array($val)); |
---|
220 | $customer_id = $arrRet[0]['customer_id']; |
---|
221 | $add_point = $arrRet[0]['add_point']; |
---|
222 | $use_point = $arrRet[0]['use_point']; |
---|
223 | $status = $arrRet[0]['status']; |
---|
224 | if($customer_id != "" && $customer_id >= 1) { |
---|
225 | if($status == 5) { |
---|
226 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
227 | $arrRet[0]['point']-= $add_point; |
---|
228 | $sqlval['point'] = $arrRet[0]['point']; |
---|
229 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
230 | } |
---|
231 | elseif($status == 3) { |
---|
232 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
233 | $arrRet[0]['point']-= $use_point; |
---|
234 | $sqlval['point'] = $arrRet[0]['point']; |
---|
235 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
236 | } |
---|
237 | else { |
---|
238 | $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id)); |
---|
239 | $sqlval['point'] = $arrRet[0]['point']; |
---|
240 | $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); |
---|
241 | } |
---|
242 | } |
---|
243 | } |
---|
244 | $objQuery->update($table, $arrUpdate, $where, array($val)); |
---|
245 | } |
---|
246 | |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | $this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');"; |
---|
251 | } |
---|
252 | } |
---|
253 | ?> |
---|