source: branches/comu-ver2/data/class/pages/mypage/LC_Page_Mypage_History.php @ 17519

Revision 17519, 7.5 KB checked in by Seasoft, 16 years ago (diff)

MYページ画像の一部をテキストに。カスタマイズを容易にする試み。

  • 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
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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_column_num = 1;
51        $this->tpl_mainno = 'mypage';
52        $this->tpl_mypageno = 'index';
53        $this->allowClientCache();
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    function process() {
62        $objView = new SC_SiteView();
63        $objQuery = new SC_Query();
64        $objCustomer = new SC_Customer();
65        $objDb = new SC_Helper_DB_Ex();
66
67        // レイアウトデザインを取得
68        $objLayout = new SC_Helper_PageLayout_Ex();
69        $objLayout->sfGetPageLayout($this, false, "mypage/index.php");
70
71        //不正アクセス判定
72        $from = "dtb_order";
73        $where = "del_flg = 0 AND customer_id = ? AND order_id = ? ";
74        $arrval = array($objCustomer->getValue('customer_id'), $_POST['order_id']);
75        //DBに情報があるか判定
76        $cnt = $objQuery->count($from, $where, $arrval);
77        //ログインしていない、またはDBに情報が無い場合
78        if (!$objCustomer->isLoginSuccess() || $cnt == 0){
79            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
80        } else {
81            //受注詳細データの取得
82            $this->arrDisp = $this->lfGetOrderData($_POST['order_id']);
83            // 支払い方法の取得
84            $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
85            // 配送時間の取得
86            $arrRet = $objDb->sfGetDelivTime($this->arrDisp['payment_id']);
87            $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
88
89            //マイページトップ顧客情報表示用
90            $this->CustomerName1 = $objCustomer->getvalue('name01');
91            $this->CustomerName2 = $objCustomer->getvalue('name02');
92            $this->CustomerPoint = $objCustomer->getvalue('point');
93        }
94
95        $masterData = new SC_DB_MasterData_Ex();
96        $this->arrPref = $masterData->getMasterData("mtb_pref",
97                                 array("pref_id", "pref_name", "rank"));
98        $objView->assignobj($this);
99        $objView->display(SITE_FRAME);
100    }
101
102    /**
103     * デストラクタ.
104     *
105     * @return void
106     */
107    function destroy() {
108        parent::destroy();
109    }
110
111    /**
112     * モバイルページを初期化する.
113     *
114     * @return void
115     */
116    function mobileInit() {
117        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . 'mypage/history.tpl';
118        $this->tpl_title = 'MYページ/購入履歴一覧';
119        $this->allowClientCache();
120    }
121
122    /**
123     * Page のプロセス(モバイル).
124     *
125     * @return void
126     */
127    function mobileProcess() {
128        define ("HISTORY_NUM", 5);
129
130        $objView = new SC_MobileView();
131        $objQuery = new SC_Query();
132        $objCustomer = new SC_Customer();
133        $pageNo = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 0; // TODO
134
135        // ログインチェック
136        if(!isset($_SESSION['customer'])) {
137            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
138        }
139
140        $col = "order_id, create_date, payment_id, payment_total";
141        $from = "dtb_order";
142        $where = "del_flg = 0 AND customer_id=?";
143        $arrval = array($objCustomer->getvalue('customer_id'));
144        $order = "order_id DESC";
145
146        $linemax = $objQuery->count($from, $where, $arrval);
147        $this->tpl_linemax = $linemax;
148
149        // 取得範囲の指定(開始行番号、行数のセット)
150        $objQuery->setlimitoffset(HISTORY_NUM, $pageNo);
151        // 表示順序
152        $objQuery->setorder($order);
153
154        //購入履歴の取得
155        $this->arrOrder = $objQuery->select($col, $from, $where, $arrval);
156
157        // next
158        if ($pageNo + HISTORY_NUM < $linemax) {
159            $next = "<a href='history.php?pageno=" . ($pageNo + HISTORY_NUM) . "'>次へ→</a>";
160        } else {
161            $next = "";
162        }
163
164        // previous
165        if ($pageNo - HISTORY_NUM > 0) {
166            $previous = "<a href='history.php?pageno=" . ($pageNo - HISTORY_NUM) . "'>←前へ</a>";
167        } elseif ($pageNo == 0) {
168            $previous = "";
169        } else {
170            $previous = "<a href='history.php?pageno=0'>←前へ</a>";
171        }
172
173        // bar
174        if ($next != '' && $previous != '') {
175            $bar = " | ";
176        } else {
177            $bar = "";
178        }
179
180        $this->tpl_strnavi = $previous . $bar . $next;
181        $objView->assignobj($this);             //$objpage内の全てのテンプレート変数をsmartyに格納
182        $objView->display(SITE_FRAME);              //パスとテンプレート変数の呼び出し、実行
183    }
184
185    //受注詳細データの取得
186    function lfGetOrderData($order_id) {
187        //受注番号が数字であれば
188        if(SC_Utils_Ex::sfIsInt($order_id)) {
189            // DBから受注情報を読み込む
190            $objQuery = new SC_Query();
191            $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, ";
192            $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, ";
193            $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date ";
194            $from = "dtb_order";
195            $where = "order_id = ?";
196            $arrRet = $objQuery->select($col, $from, $where, array($order_id));
197            $arrOrder = $arrRet[0];
198            // 受注詳細データの取得
199            $arrRet = $this->lfGetOrderDetail($order_id);
200            $arrOrderDetail = SC_Utils_Ex::sfSwapArray($arrRet);
201            $arrData = array_merge($arrOrder, $arrOrderDetail);
202        }
203        return $arrData;
204    }
205
206    // 受注詳細データの取得
207    function lfGetOrderDetail($order_id) {
208        $objQuery = new SC_Query();
209        $col = "product_id, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
210        $where = "order_id = ?";
211        $objQuery->setorder("classcategory_id1, classcategory_id2");
212        $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
213        return $arrRet;
214    }
215}
216?>
Note: See TracBrowser for help on using the repository browser.