source: branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_History.php @ 19912

Revision 19912, 9.6 KB checked in by nanasess, 13 years ago (diff)

#628(未使用処理・定義などの削除)

  • モジュール連携用のコードを削除

#843(複数配送先の指定)

  • 受注編集画面を修正

#642(共通ロジックの機能向上)

  • SC_Utils::sfIsPrePage(), SC_Utils::sfCheckNormalAccess() を削除

#631(テーブル定義の改良)

  • データ型を大文字に統一
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-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
25require_once(CLASS_REALDIR . "pages/LC_Page.php");
26
27/**
28 * 購入履歴 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class 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        $this->isMobile = Net_UserAgent_Mobile::isMobile();
56   }
57
58    /**
59     * Page のプロセス.
60     *
61     * @return void
62     */
63    function process() {
64        parent::process();
65        if ( $this->isMobile === false ){
66            $this->action();
67        } else {
68            $this->mobileAction();
69        }
70        $this->sendResponse();
71    }
72
73    /**
74     * Page のAction.
75     *
76     * @return void
77     */
78    function action() {
79        $objQuery = new SC_Query();
80        $objCustomer = new SC_Customer();
81        $objDb = new SC_Helper_DB_Ex();
82
83        // FIXME 他の画面と同様のバリデーションを行なう
84        if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
85            SC_Utils_Ex::sfDispException();
86        }
87
88        $orderId = $_GET['order_id'];
89
90        //不正アクセス判定
91        $from = "dtb_order";
92        $where = "del_flg = 0 AND customer_id = ? AND order_id = ? ";
93        $arrval = array($objCustomer->getValue('customer_id'), $orderId);
94        //DBに情報があるか判定
95        $cnt = $objQuery->count($from, $where, $arrval);
96        //ログインしていない、またはDBに情報が無い場合
97        if (!$objCustomer->isLoginSuccess() || $cnt == 0){
98            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
99        }
100
101        //受注詳細データの取得
102        $this->arrDisp = $this->lfGetOrderData($orderId);
103        $this->arrShipping = $this->lfGetShippingData($orderId);
104        $this->isMultiple = count($this->arrShipping) > 1;
105        // 支払い方法の取得
106        $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
107        // お届け時間の取得
108        $arrRet = $objDb->sfGetDelivTime($this->arrDisp['payment_id']);
109        $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
110
111        //マイページトップ顧客情報表示用
112        $this->tpl_login = true;
113        $this->CustomerName1 = $objCustomer->getvalue('name01');
114        $this->CustomerName2 = $objCustomer->getvalue('name02');
115        $this->CustomerPoint = $objCustomer->getvalue('point');
116
117        // 受注商品明細の取得
118        $this->tpl_arrOrderDetail = $this->lfGetOrderDetail($orderId);
119
120        // 受注メール送信履歴の取得
121        $this->tpl_arrMailHistory = $this->lfGetMailHistory($orderId);
122
123    }
124
125    /**
126     * デストラクタ.
127     *
128     * @return void
129     */
130    function destroy() {
131        parent::destroy();
132    }
133
134    /**
135     * Page のAction(モバイル).
136     *
137     * @return void
138     */
139    function mobileAction() {
140        define ("HISTORY_NUM", 5);
141
142        $objQuery = new SC_Query();
143        $objCustomer = new SC_Customer();
144        $pageNo = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 0; // TODO
145
146        // ログインチェック
147        if(!isset($_SESSION['customer'])) {
148            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
149        }
150
151        $col = "order_id, create_date, payment_id, payment_total";
152        $from = "dtb_order";
153        $where = "del_flg = 0 AND customer_id=?";
154        $arrval = array($objCustomer->getvalue('customer_id'));
155        $order = "order_id DESC";
156
157        $linemax = $objQuery->count($from, $where, $arrval);
158        $this->tpl_linemax = $linemax;
159
160        // 取得範囲の指定(開始行番号、行数のセット)
161        $objQuery->setLimitOffset(HISTORY_NUM, $pageNo);
162        // 表示順序
163        $objQuery->setOrder($order);
164
165        //購入履歴の取得
166        $this->arrOrder = $objQuery->select($col, $from, $where, $arrval);
167
168        // next
169        if ($pageNo + HISTORY_NUM < $linemax) {
170            $next = "<a href='history.php?pageno=" . ($pageNo + HISTORY_NUM) . "'>次へ→</a>";
171        } else {
172            $next = "";
173        }
174
175        // previous
176        if ($pageNo - HISTORY_NUM > 0) {
177            $previous = "<a href='history.php?pageno=" . ($pageNo - HISTORY_NUM) . "'>←前へ</a>";
178        } elseif ($pageNo == 0) {
179            $previous = "";
180        } else {
181            $previous = "<a href='history.php?pageno=0'>←前へ</a>";
182        }
183
184        // bar
185        if ($next != '' && $previous != '') {
186            $bar = " | ";
187        } else {
188            $bar = "";
189        }
190
191        $this->tpl_strnavi = $previous . $bar . $next;
192
193    }
194
195    /**
196     * 受注の取得
197     *
198     * @param integer $orderId 注文番号
199     * @return array 受注の内容
200     */
201    function lfGetOrderData($orderId) {
202        // DBから受注情報を読み込む
203        $objQuery = new SC_Query();
204        /*
205        $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, ";
206        $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, ";
207        $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date ";
208        */
209        $from = "dtb_order";
210        $where = "order_id = ?";
211        $arrRet = $objQuery->select("*", $from, $where, array($orderId));
212        return $arrRet[0];
213    }
214
215    /**
216     * 配送情報の取得.
217     * TODO リファクタリング
218     */
219    function lfGetShippingData($orderId) {
220        $objQuery =& SC_Query::getSingletonInstance();
221        $objProduct = new SC_Product();
222        $objQuery->setOrder('shipping_id');
223        $arrRet = $objQuery->select("*", "dtb_shipping", "order_id = ?", array($orderId));
224        foreach (array_keys($arrRet) as $key) {
225            $objQuery->setOrder('shipping_id');
226            $arrItems = $objQuery->select("*", "dtb_shipment_item", "order_id = ? AND shipping_id = ?",
227                                       array($orderId, $arrRet[$key]['shipping_id']));
228            foreach ($arrItems as $itemKey => $arrDetail) {
229                foreach ($arrDetail as $detailKey => $detailVal) {
230                    $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']][$detailKey] = $detailVal;
231                }
232
233                $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']]['productsClass'] =& $objProduct->getDetailAndProductsClass($arrDetail['product_class_id']);
234            }
235        }
236        return $arrRet;
237    }
238
239    /**
240     * 受注商品明細の取得
241     *
242     * @param integer $orderId 注文番号
243     * @return array 受注商品明細の内容
244     */
245    function lfGetOrderDetail($orderId) {
246        $objQuery = new SC_Query();
247        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
248
249        $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,";
250        $col .= "od.classcategory_name2 AS classcategory_name2, od.price AS price, od.quantity AS quantity, od.point_rate AS point_rate";
251        $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";
252        $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, ";
253        $col .= $dbFactory->getDownloadableDaysWhereSql();
254        $col .= " AS effective";
255        $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 = ?";
256        $arrRet = $objQuery->select($col, "dtb_products p, dtb_products_class pc, dtb_order_detail od, dtb_order o", $where,array($orderId));
257        return $arrRet;
258    }
259
260    /**
261     * 受注メール送信履歴の取得
262     *
263     * @param integer $orderId 注文番号
264     * @return array 受注メール送信履歴の内容
265     */
266    function lfGetMailHistory($orderId) {
267        $objQuery = new SC_Query();
268        $col = 'send_date, subject, template_id, send_id';
269        $where = 'order_id = ?';
270        $objQuery->setOrder('send_date DESC');
271        $this->arrMailHistory = $objQuery->select($col, 'dtb_mail_history', $where, array($orderId));
272    }
273}
274?>
Note: See TracBrowser for help on using the repository browser.