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

Revision 19805, 9.1 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部実装

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