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