source: branches/feature-module-update/data/class/pages/mypage/LC_Page_Mypage_History.php @ 16234

Revision 16234, 6.7 KB checked in by nanasess, 17 years ago (diff)

クラス化対応

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