source: branches/comu-ver2/data/class/pages/admin/order/LC_Page_Admin_Order_Status.php @ 17376

Revision 17376, 6.3 KB checked in by x41, 16 years ago (diff)

ステータスを発送済み後にポイントが付与されるように修正

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
Line 
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
25require_once(CLASS_PATH . "pages/LC_Page.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 {
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
51        $masterData = new SC_DB_MasterData_Ex();
52        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
53        $this->arrORDERSTATUS_COLOR = $masterData->getMasterData("mtb_order_status_color");
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    function process() {
62        $objView = new SC_AdminView();
63        $objSess = new SC_Session();
64        $objDb = new SC_Helper_DB_Ex();
65        $objQuery = new SC_Query();
66
67        // 認証可否の判定
68        $objSess = new SC_Session();
69        SC_Utils_Ex::sfIsSuccess($objSess);
70
71        $this->arrForm = $_POST;
72
73        //支払方法の取得
74        $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
75
76        if (!isset($_POST['mode'])) $_POST['mode'] = "";
77        if (!isset($_POST['search_pageno'])) $_POST['search_pageno'] = 1;
78
79        switch ($_POST['mode']){
80
81        case 'update':
82            if (!isset($_POST['change_status'])) $_POST['change_status'] = "";
83            if (!empty($_POST['change_status'])) {
84                $this->lfStatusMove($_POST['change_status'], $_POST['move']);
85            }
86            //ステータス情報
87            $status = isset($_POST['status']) ? $_POST['status'] : "";
88            break;
89
90        case 'search':
91            //ステータス情報
92            $status = isset($_POST['status']) ? $_POST['status'] : "";
93            break;
94
95        default:
96            //ステータス情報
97            //デフォルトで新規受付一覧表示
98            $status = ORDER_NEW;
99            break;
100        }
101
102        //ステータス情報
103        $this->SelectedStatus = $status;
104        //検索結果の表示
105        $this->lfStatusDisp($status, $_POST['search_pageno']);
106
107        $objView->assignobj($this);
108        $objView->display(MAIN_FRAME);
109    }
110    /**
111     * デストラクタ.
112     *
113     * @return void
114     */
115    function destroy() {
116        parent::destroy();
117    }
118
119    //ステータス一覧の表示
120    function lfStatusDisp($status,$pageno){
121        $objQuery = new SC_Query();
122
123        $select ="*";
124        $from = "dtb_order";
125        $where = "del_flg = 0 AND status = ?";
126        $arrval[] = $status;
127        $order = "order_id DESC";
128
129        $linemax = $objQuery->count($from, $where, $arrval);
130        $this->tpl_linemax = $linemax;
131
132        // ページ送りの処理
133        $page_max = ORDER_STATUS_MAX;
134
135        // ページ送りの取得
136        $objNavi = new SC_PageNavi($pageno, $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
137        $this->tpl_strnavi = $objNavi->strnavi;      // 表示文字列
138        $startno = $objNavi->start_row;
139
140        $this->tpl_pageno = $pageno;
141
142        // 取得範囲の指定(開始行番号、行数のセット)
143        $objQuery->setlimitoffset($page_max, $startno);
144
145        //表示順序
146        $objQuery->setorder($order);
147
148        //検索結果の取得
149        $this->arrStatus = $objQuery->select($select, $from, $where, $arrval);
150    }
151
152    //ステータス情報の更新(削除)
153    function lfStatusMove($status_id, $arrMove){
154        $objQuery = new SC_Query();
155        $masterData = new SC_DB_MasterData_Ex();
156        $arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
157
158        $table = 'dtb_order';
159        $where = 'order_id = ?';
160        $arrUpdate = array('update_date' => 'NOW()');
161    $col = 'customer_id, add_point';
162
163        $delflg  = '1'; // 削除フラグ
164        $message = '';  // ステータス変更後にポップアップするメッセージの内容
165
166        if ( $status_id == 'delete' ) {
167            $arrUpdate['del_flg'] = $delflg;
168            $message = '削除';
169        }
170        // ステータスが発送済みの時は発送日を更新
171        elseif ( $status_id == ORDER_DELIV ) {
172            $arrUpdate['status'] = $status_id;
173            $arrUpdate['commit_date'] = 'NOW()';
174            $message = $arrORDERSTATUS[$status_id] . 'へ移動';
175        }
176        else {
177            $arrUpdate['status'] = $status_id;
178            $message = $arrORDERSTATUS[$status_id] . 'へ移動';
179        }
180
181        if ( isset($arrMove) ){
182            foreach ( $arrMove as $val ){
183                if ( $val != "" ) {
184        if ( $status_id == ORDER_DELIV ) {
185        $arrRet = $objQuery->select($col, $table, $where, array($val));
186        $customer_id = $arrRet[0]['customer_id'];
187        $add_point = $arrRet[0]['add_point'];
188        if($customer_id != "" && $customer_id >= 1) {
189            $arrRet = $objQuery->select("point", 'dtb_customer', 'customer_id = ?', array($customer_id));
190            $arrRet[0]['point']+= $add_point;
191            $sqlval['point'] = $arrRet[0]['point'];
192            $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id));
193           }
194        }
195                    $objQuery->update($table, $arrUpdate, $where, array($val));
196                }
197
198            }
199        }
200
201        $this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');";
202    }
203}
204?>
Note: See TracBrowser for help on using the repository browser.