source: branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Status.php @ 21750

Revision 21750, 7.7 KB checked in by shutta, 12 years ago (diff)

#1579 SC_Query::getSingletonInstance()への置き換え

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_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 */
34class 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        $objDb = new SC_Helper_DB_Ex();
75
76        // パラメーター管理クラス
77        $objFormParam = new SC_FormParam_Ex();
78        // パラメーター情報の初期化
79        $this->lfInitParam($objFormParam);
80        $objFormParam->setParam($_POST);
81        // 入力値の変換
82        $objFormParam->convParam();
83
84        $this->arrForm = $objFormParam->getHashArray();
85        //        $this->arrForm = $_POST;
86
87        //支払方法の取得
88        $this->arrPayment = $objDb->sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method');
89
90        switch ($this->getMode()) {
91            case 'update':
92                switch ($objFormParam->getValue('change_status')) {
93                    case '':
94                        break;
95                        // 削除
96                    case 'delete':
97                        $this->lfDelete($objFormParam->getValue('move'));
98                        break;
99                        // 更新
100                    default:
101                        $this->lfStatusMove($objFormParam->getValue('change_status'), $objFormParam->getValue('move'));
102                        break;
103                }
104
105                // 対応状況
106                $status = !is_null($objFormParam->getValue('status')) ? $objFormParam->getValue('status') : '';
107                break;
108
109            case 'search':
110                // 対応状況
111                $status = !is_null($_POST['status']) ? $objFormParam->getValue('status') : '';
112                break;
113
114            default:
115                // 対応状況
116                //デフォルトで新規受付一覧表示
117                $status = ORDER_NEW;
118                break;
119        }
120
121        // 対応状況
122        $this->SelectedStatus = $status;
123        //検索結果の表示
124        $this->lfStatusDisp($status, $objFormParam->getValue('search_pageno'));
125
126    }
127
128    /**
129     *  パラメーター情報の初期化
130     *  @param SC_FormParam
131     */
132    function lfInitParam(&$objFormParam) {
133        $objFormParam->addParam('注文番号', 'order_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
134        $objFormParam->addParam('変更前対応状況', 'status', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
135        $objFormParam->addParam('変更後対応状況', 'change_status', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
136        $objFormParam->addParam('ページ番号', 'search_pageno', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
137        $objFormParam->addParam('移動注文番号', 'move', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
138    }
139
140    /**
141     *  入力内容のチェック
142     *  @param SC_FormParam
143     */
144    function lfCheckError(&$objFormParam) {
145        // 入力データを渡す。
146        $arrRet = $objFormParam->getHashArray();
147        $arrErr = $objFormParam->checkError();
148        if (is_null($objFormParam->getValue('search_pageno'))) {
149            $objFormParam->setValue('search_pageno', 1);
150        }
151
152        if ($this->getMode() == 'change') {
153            if (is_null($objFormParam->getValue('change_status'))) {
154                $objFormParam->setValue('change_status','');
155            }
156        }
157
158    }
159
160    /**
161     * デストラクタ.
162     *
163     * @return void
164     */
165    function destroy() {
166        parent::destroy();
167    }
168
169    // 対応状況一覧の表示
170    function lfStatusDisp($status,$pageno) {
171        $objQuery =& SC_Query_Ex::getSingletonInstance();
172
173        $select ='*';
174        $from = 'dtb_order';
175        $where = 'del_flg = 0 AND status = ?';
176        $arrWhereVal = array($status);
177        $order = 'order_id DESC';
178
179        $linemax = $objQuery->count($from, $where, $arrWhereVal);
180        $this->tpl_linemax = $linemax;
181
182        // ページ送りの処理
183        $page_max = ORDER_STATUS_MAX;
184
185        // ページ送りの取得
186        $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, 'fnNaviSearchOnlyPage', NAVI_PMAX);
187        $this->tpl_strnavi = $objNavi->strnavi;      // 表示文字列
188        $startno = $objNavi->start_row;
189
190        $this->tpl_pageno = $pageno;
191
192        // 取得範囲の指定(開始行番号、行数のセット)
193        $objQuery->setLimitOffset($page_max, $startno);
194
195        //表示順序
196        $objQuery->setOrder($order);
197
198        //検索結果の取得
199        $this->arrStatus = $objQuery->select($select, $from, $where, $arrWhereVal);
200    }
201
202    /**
203     * 対応状況の更新
204     */
205    function lfStatusMove($statusId, $arrOrderId) {
206        $objPurchase = new SC_Helper_Purchase_Ex();
207        $objQuery =& SC_Query_Ex::getSingletonInstance();
208
209        if (!isset($arrOrderId) || !is_array($arrOrderId)) {
210            return false;
211        }
212        $masterData = new SC_DB_MasterData_Ex();
213        $arrORDERSTATUS = $masterData->getMasterData('mtb_order_status');
214
215        $objQuery->begin();
216
217        foreach ($arrOrderId as $orderId) {
218            $objPurchase->sfUpdateOrderStatus($orderId, $statusId);
219        }
220
221        $objQuery->commit();
222
223        $this->tpl_onload = "window.alert('選択項目を" . $arrORDERSTATUS[$statusId] . "へ移動しました。');";
224        return true;
225    }
226
227    /**
228     * 受注テーブルの論理削除
229     */
230    function lfDelete($arrOrderId) {
231        $objQuery =& SC_Query_Ex::getSingletonInstance();
232
233        if (!isset($arrOrderId) || !is_array($arrOrderId)) {
234            return false;
235        }
236
237        $arrUpdate = array(
238            'del_flg'      => 1,
239            'update_date'  => 'CURRENT_TIMESTAMP',
240        );
241
242        $objQuery->begin();
243
244        foreach ($arrOrderId as $orderId) {
245            $objQuery->update('dtb_order', $arrUpdate, 'order_id = ?', array($orderId));
246        }
247
248        $objQuery->commit();
249
250        $this->tpl_onload = "window.alert('選択項目を削除しました。');";
251        return true;
252    }
253}
Note: See TracBrowser for help on using the repository browser.