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

Revision 19783, 9.2 KB checked in by nanasess, 13 years ago (diff)

#748(モバイル/スマートフォンのデザイン管理)

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