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