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

Revision 19881, 8.3 KB checked in by fukuda, 13 years ago (diff)

#880(mobile/sphoneディレクトリを削除)に対応。まずmobileのみ意図通りの動作になるように一部コミット(mypageディレクトリ) changeは作業中

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