source: branches/version-2_11-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Disp.php @ 21205

Revision 21205, 16.4 KB checked in by Ringo, 10 years ago (diff)

#1440 (ステータス管理のポップアップで複数のお届け先が正しく表示されない) 修正もれ

  • Property svn:eol-style set to native
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_REALDIR . 'pages/admin/order/LC_Page_Admin_Order_Edit.php';
26
27/**
28 * 受注情報表示 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id: LC_Page_Admin_Order_Disp.php 20767 2011-03-22 10:07:32Z nanasess $
33 */
34class LC_Page_Admin_Order_Disp extends LC_Page_Admin_Order_Ex {
35
36    var $arrShippingKeys = array(
37        'shipping_id',
38        'shipping_name01',
39        'shipping_name02',
40        'shipping_kana01',
41        'shipping_kana02',
42        'shipping_tel01',
43        'shipping_tel02',
44        'shipping_tel03',
45        'shipping_fax01',
46        'shipping_fax02',
47        'shipping_fax03',
48        'shipping_pref',
49        'shipping_zip01',
50        'shipping_zip02',
51        'shipping_addr01',
52        'shipping_addr02',
53        'shipping_date_year',
54        'shipping_date_month',
55        'shipping_date_day',
56        'time_id',
57    );
58
59    var $arrShipmentItemKeys = array(
60        'shipment_product_class_id',
61        'shipment_product_code',
62        'shipment_product_name',
63        'shipment_classcategory_name1',
64        'shipment_classcategory_name2',
65        'shipment_price',
66        'shipment_quantity',
67    );
68
69    // }}}
70    // {{{ functions
71
72    /**
73     * Page を初期化する.
74     *
75     * @return void
76     */
77    function init() {
78        parent::init();
79        $this->tpl_mainpage = 'order/disp.tpl';
80        $this->tpl_mainno = 'order';
81        $this->tpl_subnavi = '';
82        $this->tpl_subno = '';
83        $this->tpl_subtitle = '受注情報表示';
84
85        $masterData = new SC_DB_MasterData_Ex();
86        $this->arrPref = $masterData->getMasterData('mtb_pref');
87        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
88        $this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
89
90        // 支払い方法の取得
91        $this->arrPayment = SC_Helper_DB_Ex::sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
92
93        // 配送業者の取得
94        $this->arrDeliv = SC_Helper_DB_Ex::sfGetIDValueList("dtb_deliv", "deliv_id", 'name');
95    }
96
97    /**
98     * Page のプロセス.
99     *
100     * @return void
101     */
102    function process() {
103        $this->action();
104        $this->sendResponse();
105    }
106
107    /**
108     * Page のアクション.
109     *
110     * @return void
111     */
112    function action() {
113        $objPurchase = new SC_Helper_Purchase_Ex();
114        $objFormParam = new SC_FormParam_Ex();
115
116        // パラメータ情報の初期化
117        $this->lfInitParam($objFormParam);
118        $objFormParam->setParam($_REQUEST);
119        $objFormParam->convParam();
120        $order_id = $objFormParam->getValue('order_id');
121
122        // DBから受注情報を読み込む
123        $this->setOrderToFormParam($objFormParam, $order_id);
124
125        $this->arrForm = $objFormParam->getFormParamList();
126        $this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys));
127        $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
128        $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
129
130        $this->setTemplate($this->tpl_mainpage);
131    }
132
133    /**
134     * デストラクタ.
135     * @return void
136     */
137    function destroy() {
138        parent::destroy();
139    }
140
141    /**
142     * パラメータ情報の初期化を行う.
143     *
144     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
145     * @return void
146     */
147    function lfInitParam(&$objFormParam) {
148        // 検索条件のパラメータを初期化
149        parent::lfInitParam($objFormParam);
150
151        // お客様情報
152        $objFormParam->addParam("顧客名1", "order_name01", STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
153        $objFormParam->addParam("顧客名2", "order_name02", STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
154        $objFormParam->addParam("顧客名カナ1", "order_kana01", STEXT_LEN, 'KVCa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
155        $objFormParam->addParam("顧客名カナ2", "order_kana02", STEXT_LEN, 'KVCa', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
156        $objFormParam->addParam("メールアドレス", "order_email", null, 'KVCa', array("NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK"));
157        $objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, 'n', array("NUM_CHECK", "NUM_COUNT_CHECK"));
158        $objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, 'n', array("NUM_CHECK", "NUM_COUNT_CHECK"));
159        $objFormParam->addParam("都道府県", "order_pref", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
160        $objFormParam->addParam("住所1", "order_addr01", MTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
161        $objFormParam->addParam("住所2", "order_addr02", MTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
162        $objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
163        $objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
164        $objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
165
166        // 受注商品情報
167        $objFormParam->addParam("値引き", 'discount', INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
168        $objFormParam->addParam("送料", "deliv_fee", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
169        $objFormParam->addParam("手数料", 'charge', INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
170
171        // ポイント機能ON時のみ
172        if (USE_POINT !== false) {
173            $objFormParam->addParam("利用ポイント", "use_point", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
174        }
175
176        $objFormParam->addParam("配送業者", "deliv_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
177        $objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
178        $objFormParam->addParam("対応状況", 'status', INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
179        $objFormParam->addParam("お支払方法名称", "payment_method");
180
181        // 受注詳細情報
182        $objFormParam->addParam("商品項番", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
183        $objFormParam->addParam("商品種別ID", "product_type_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
184        $objFormParam->addParam("単価", 'price', INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
185        $objFormParam->addParam("数量", 'quantity', INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
186        $objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
187        $objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
188        $objFormParam->addParam("ポイント付与率", "point_rate");
189        $objFormParam->addParam("商品コード", "product_code");
190        $objFormParam->addParam("商品名", "product_name");
191        $objFormParam->addParam("規格名1", "classcategory_name1");
192        $objFormParam->addParam("規格名2", "classcategory_name2");
193        $objFormParam->addParam("メモ", 'note', MTEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK"));
194        $objFormParam->addParam("削除用項番", "delete_no", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
195
196        // DB読込用
197        $objFormParam->addParam("小計", 'subtotal');
198        $objFormParam->addParam("合計", 'total');
199        $objFormParam->addParam("支払い合計", "payment_total");
200        $objFormParam->addParam("加算ポイント", "add_point");
201        $objFormParam->addParam("お誕生日ポイント", "birth_point");
202        $objFormParam->addParam("消費税合計", 'tax');
203        $objFormParam->addParam("最終保持ポイント", "total_point");
204        $objFormParam->addParam("顧客ID", "customer_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
205        $objFormParam->addParam("顧客ID", "edit_customer_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
206        $objFormParam->addParam("現在のポイント", "customer_point");
207        $objFormParam->addParam("受注前ポイント", 'point');
208        $objFormParam->addParam("注文番号", "order_id");
209        $objFormParam->addParam("受注日", "create_date");
210        $objFormParam->addParam("発送日", "commit_date");
211        $objFormParam->addParam("備考", 'message');
212        $objFormParam->addParam("入金日", "payment_date");
213        $objFormParam->addParam("アクセス端末", "device_type_id");
214
215        // 複数情報
216        $objFormParam->addParam("配送数", "shipping_quantity", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), 1);
217        $objFormParam->addParam("配送ID", "shipping_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), 0);
218        $objFormParam->addParam("お名前1", "shipping_name01", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
219        $objFormParam->addParam("お名前2", "shipping_name02", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
220        $objFormParam->addParam("お名前(フリガナ・姓)", "shipping_kana01", STEXT_LEN, 'KVCa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
221        $objFormParam->addParam("お名前(フリガナ・名)", "shipping_kana02", STEXT_LEN, 'KVCa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
222        $objFormParam->addParam("郵便番号1", "shipping_zip01", ZIP01_LEN, 'n', array("NUM_CHECK", "NUM_COUNT_CHECK"));
223        $objFormParam->addParam("郵便番号2", "shipping_zip02", ZIP02_LEN, 'n', array("NUM_CHECK", "NUM_COUNT_CHECK"));
224        $objFormParam->addParam("都道府県", "shipping_pref", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
225        $objFormParam->addParam("住所1", "shipping_addr01", MTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
226        $objFormParam->addParam("住所2", "shipping_addr02", MTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
227        $objFormParam->addParam("電話番号1", "shipping_tel01", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
228        $objFormParam->addParam("電話番号2", "shipping_tel02", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
229        $objFormParam->addParam("電話番号3", "shipping_tel03", TEL_ITEM_LEN, 'n', array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
230        $objFormParam->addParam("お届け時間ID", "time_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
231        $objFormParam->addParam("お届け日(年)", "shipping_date_year", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
232        $objFormParam->addParam("お届け日(月)", "shipping_date_month", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
233        $objFormParam->addParam("お届け日(日)", "shipping_date_day", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
234        $objFormParam->addParam("お届け日", "shipping_date", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
235        $objFormParam->addParam("配送商品数量", "shipping_product_quantity", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
236
237        $objFormParam->addParam("商品規格ID", "shipment_product_class_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
238        $objFormParam->addParam("商品コード", "shipment_product_code");
239        $objFormParam->addParam("商品名", "shipment_product_name");
240        $objFormParam->addParam("規格名1", "shipment_classcategory_name1");
241        $objFormParam->addParam("規格名2", "shipment_classcategory_name2");
242        $objFormParam->addParam("単価", "shipment_price", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
243        $objFormParam->addParam("数量", "shipment_quantity", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
244
245        $objFormParam->addParam("商品項番", 'no', INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
246        $objFormParam->addParam("追加商品規格ID", "add_product_class_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
247        $objFormParam->addParam("修正商品規格ID", "edit_product_class_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK"));
248        $objFormParam->addParam("アンカーキー", "anchor_key", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
249    }
250
251    /**
252     * 受注データを取得して, SC_FormParam へ設定する.
253     *
254     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
255     * @param integer $order_id 取得元の受注ID
256     * @return void
257     */
258    function setOrderToFormParam(&$objFormParam, $order_id) {
259        $objPurchase = new SC_Helper_Purchase_Ex();
260
261        // 受注詳細を設定
262        $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false);
263        $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail));
264
265        $arrShippingsTmp = $objPurchase->getShippings($order_id);
266        $arrShippings = array();
267        foreach ($arrShippingsTmp as $row) {
268            // お届け日の処理
269            if (!SC_Utils_Ex::isBlank($row["shipping_date"])) {
270                $ts = strtotime($row["shipping_date"]);
271                $row['shipping_date_year'] = date('Y', $ts);
272                $row['shipping_date_month'] = date('n', $ts);
273                $row['shipping_date_day'] = date('j', $ts);
274            }
275            $arrShippings[$row['shipping_id']] = $row;
276        }
277        $objFormParam->setValue('shipping_quantity', count($arrShippings));
278        $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings));
279
280        /*
281         * 配送商品を設定
282         *
283         * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値
284         * $arrProductQuantity[$shipping_id] = 配送先ごとの配送商品数量
285         */
286        $arrProductQuantity = array();
287        $arrShipmentItem = array();
288        foreach ($arrShippings as $shipping_id => $arrShipping) {
289            $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']);
290            foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) {
291                foreach ($arrItem as $item_key => $item_val) {
292                    $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val;
293                }
294            }
295        }
296        $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity);
297        $objFormParam->setParam($arrShipmentItem);
298
299        /*
300         * 受注情報を設定
301         * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値
302         * が渡ってくるため, $arrOrder で上書きする.
303         */
304        $arrOrder = $objPurchase->getOrder($order_id);
305        $objFormParam->setParam($arrOrder);
306
307        // ポイントを設定
308        list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint(
309            $order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status']
310        );
311        $objFormParam->setValue('total_point', $db_point);
312        $objFormParam->setValue('point', $rollback_point);
313
314        if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) {
315            $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($objFormParam->getValue('customer_id'));
316            $objFormParam->setValue('customer_point', $arrCustomer['point']);
317        }
318    }
319
320}
321?>
Note: See TracBrowser for help on using the repository browser.