1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 購入履歴 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Mypage_History 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_navi = TEMPLATE_REALDIR . 'mypage/navi.tpl'; |
---|
47 | $this->tpl_mainno = 'mypage'; |
---|
48 | $this->tpl_mypageno = 'index'; |
---|
49 | $this->tpl_subtitle = '購入履歴詳細'; |
---|
50 | $this->httpCacheControl('nocache'); |
---|
51 | $masterData = new SC_DB_MasterData_Ex(); |
---|
52 | $this->arrMAILTEMPLATE = $masterData->getMasterData("mtb_mail_template"); |
---|
53 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * Page のプロセス. |
---|
58 | * |
---|
59 | * @return void |
---|
60 | */ |
---|
61 | function process() { |
---|
62 | parent::process(); |
---|
63 | $this->action(); |
---|
64 | $this->sendResponse(); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * Page のAction. |
---|
69 | * |
---|
70 | * @return void |
---|
71 | */ |
---|
72 | function action() { |
---|
73 | $objQuery = new SC_Query(); |
---|
74 | $objCustomer = new SC_Customer(); |
---|
75 | $objDb = new SC_Helper_DB_Ex(); |
---|
76 | |
---|
77 | // FIXME 他の画面と同様のバリデーションを行なう |
---|
78 | if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) { |
---|
79 | SC_Utils_Ex::sfDispException(); |
---|
80 | } |
---|
81 | |
---|
82 | $orderId = $_GET['order_id']; |
---|
83 | |
---|
84 | //不正アクセス判定 |
---|
85 | $from = "dtb_order"; |
---|
86 | $where = "del_flg = 0 AND customer_id = ? AND order_id = ? "; |
---|
87 | $arrval = array($objCustomer->getValue('customer_id'), $orderId); |
---|
88 | //DBに情報があるか判定 |
---|
89 | $cnt = $objQuery->count($from, $where, $arrval); |
---|
90 | //ログインしていない、またはDBに情報が無い場合 |
---|
91 | if (!$objCustomer->isLoginSuccess() || $cnt == 0){ |
---|
92 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
93 | } |
---|
94 | |
---|
95 | //受注詳細データの取得 |
---|
96 | $this->arrDisp = $this->lfGetOrderData($orderId); |
---|
97 | $this->arrShipping = $this->lfGetShippingData($orderId); |
---|
98 | $this->isMultiple = count($this->arrShipping) > 1; |
---|
99 | // 支払い方法の取得 |
---|
100 | $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); |
---|
101 | // お届け時間の取得 |
---|
102 | $arrRet = $objDb->sfGetDelivTime($this->arrDisp['payment_id']); |
---|
103 | $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time'); |
---|
104 | |
---|
105 | //マイページトップ顧客情報表示用 |
---|
106 | $this->tpl_login = true; |
---|
107 | $this->CustomerName1 = $objCustomer->getvalue('name01'); |
---|
108 | $this->CustomerName2 = $objCustomer->getvalue('name02'); |
---|
109 | $this->CustomerPoint = $objCustomer->getvalue('point'); |
---|
110 | |
---|
111 | // 受注商品明細の取得 |
---|
112 | $this->tpl_arrOrderDetail = $this->lfGetOrderDetail($orderId); |
---|
113 | |
---|
114 | // 受注メール送信履歴の取得 |
---|
115 | $this->tpl_arrMailHistory = $this->lfGetMailHistory($orderId); |
---|
116 | |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * デストラクタ. |
---|
121 | * |
---|
122 | * @return void |
---|
123 | */ |
---|
124 | function destroy() { |
---|
125 | parent::destroy(); |
---|
126 | } |
---|
127 | |
---|
128 | /** |
---|
129 | * 受注の取得 |
---|
130 | * |
---|
131 | * @param integer $orderId 注文番号 |
---|
132 | * @return array 受注の内容 |
---|
133 | */ |
---|
134 | function lfGetOrderData($orderId) { |
---|
135 | // DBから受注情報を読み込む |
---|
136 | $objQuery = new SC_Query(); |
---|
137 | /* |
---|
138 | $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, "; |
---|
139 | $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, "; |
---|
140 | $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date "; |
---|
141 | */ |
---|
142 | $from = "dtb_order"; |
---|
143 | $where = "order_id = ?"; |
---|
144 | $arrRet = $objQuery->select("*", $from, $where, array($orderId)); |
---|
145 | return $arrRet[0]; |
---|
146 | } |
---|
147 | |
---|
148 | /** |
---|
149 | * 配送情報の取得. |
---|
150 | * TODO リファクタリング |
---|
151 | */ |
---|
152 | function lfGetShippingData($orderId) { |
---|
153 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
154 | $objProduct = new SC_Product(); |
---|
155 | $objQuery->setOrder('shipping_id'); |
---|
156 | $arrRet = $objQuery->select("*", "dtb_shipping", "order_id = ?", array($orderId)); |
---|
157 | foreach (array_keys($arrRet) as $key) { |
---|
158 | $objQuery->setOrder('shipping_id'); |
---|
159 | $arrItems = $objQuery->select("*", "dtb_shipment_item", "order_id = ? AND shipping_id = ?", |
---|
160 | array($orderId, $arrRet[$key]['shipping_id'])); |
---|
161 | foreach ($arrItems as $itemKey => $arrDetail) { |
---|
162 | foreach ($arrDetail as $detailKey => $detailVal) { |
---|
163 | $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']][$detailKey] = $detailVal; |
---|
164 | } |
---|
165 | |
---|
166 | $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']]['productsClass'] =& $objProduct->getDetailAndProductsClass($arrDetail['product_class_id']); |
---|
167 | } |
---|
168 | } |
---|
169 | return $arrRet; |
---|
170 | } |
---|
171 | |
---|
172 | /** |
---|
173 | * 受注商品明細の取得 |
---|
174 | * |
---|
175 | * @param integer $orderId 注文番号 |
---|
176 | * @return array 受注商品明細の内容 |
---|
177 | */ |
---|
178 | function lfGetOrderDetail($orderId) { |
---|
179 | $objQuery = new SC_Query(); |
---|
180 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
181 | |
---|
182 | $col = "od.product_id AS product_id, od.product_code AS product_code, od.product_name AS product_name, od.classcategory_name1 AS classcategory_name1,"; |
---|
183 | $col .= "od.classcategory_name2 AS classcategory_name2, od.price AS price, od.quantity AS quantity, od.point_rate AS point_rate"; |
---|
184 | $col .= ",CASE WHEN EXISTS(SELECT * FROM dtb_products WHERE product_id = od.product_id AND del_flg = 0 AND status = 1) THEN '1' ELSE '0' END AS enable"; |
---|
185 | $col .= ",o.status AS status, pc.product_type_id AS product_type_id, o.payment_date AS payment_date, od.product_class_id as product_class_id, "; |
---|
186 | $col .= $dbFactory->getDownloadableDaysWhereSql(); |
---|
187 | $col .= " AS effective"; |
---|
188 | $where = "p.product_id = od.product_id AND pc.product_id = od.product_id AND pc.product_class_id = od.product_class_id AND od.order_id = o.order_id AND od.order_id = ?"; |
---|
189 | $arrRet = $objQuery->select($col, "dtb_products p, dtb_products_class pc, dtb_order_detail od, dtb_order o", $where,array($orderId)); |
---|
190 | return $arrRet; |
---|
191 | } |
---|
192 | |
---|
193 | /** |
---|
194 | * 受注メール送信履歴の取得 |
---|
195 | * |
---|
196 | * @param integer $orderId 注文番号 |
---|
197 | * @return array 受注メール送信履歴の内容 |
---|
198 | */ |
---|
199 | function lfGetMailHistory($orderId) { |
---|
200 | $objQuery = new SC_Query(); |
---|
201 | $col = 'send_date, subject, template_id, send_id'; |
---|
202 | $where = 'order_id = ?'; |
---|
203 | $objQuery->setOrder('send_date DESC'); |
---|
204 | $this->arrMailHistory = $objQuery->select($col, 'dtb_mail_history', $where, array($orderId)); |
---|
205 | } |
---|
206 | } |
---|
207 | ?> |
---|