[16102] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 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 |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php'; |
---|
[16102] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 購入履歴 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[22567] | 34 | class LC_Page_Mypage_History extends LC_Page_AbstractMypage_Ex |
---|
| 35 | { |
---|
[16102] | 36 | |
---|
| 37 | // }}} |
---|
| 38 | // {{{ functions |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * Page を初期化する. |
---|
| 42 | * |
---|
| 43 | * @return void |
---|
| 44 | */ |
---|
[22567] | 45 | function init() |
---|
| 46 | { |
---|
[16102] | 47 | parent::init(); |
---|
[20144] | 48 | $this->tpl_mypageno = 'index'; |
---|
| 49 | $this->tpl_subtitle = '購入履歴詳細'; |
---|
[18187] | 50 | $this->httpCacheControl('nocache'); |
---|
[20144] | 51 | |
---|
| 52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[21481] | 53 | $this->arrMAILTEMPLATE = $masterData->getMasterData('mtb_mail_template'); |
---|
[20144] | 54 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[21481] | 55 | $this->arrWDAY = $masterData->getMasterData('mtb_wday'); |
---|
| 56 | $this->arrProductType = $masterData->getMasterData('mtb_product_type'); |
---|
[21527] | 57 | } |
---|
[16102] | 58 | |
---|
| 59 | /** |
---|
| 60 | * Page のプロセス. |
---|
| 61 | * |
---|
| 62 | * @return void |
---|
| 63 | */ |
---|
[22567] | 64 | function process() |
---|
| 65 | { |
---|
[19661] | 66 | parent::process(); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * Page のAction. |
---|
| 71 | * |
---|
| 72 | * @return void |
---|
| 73 | */ |
---|
[22567] | 74 | function action() |
---|
| 75 | { |
---|
[21596] | 76 | |
---|
[20490] | 77 | $objCustomer = new SC_Customer_Ex(); |
---|
[20144] | 78 | $objDb = new SC_Helper_DB_Ex(); |
---|
[20167] | 79 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[22271] | 80 | $objProduct = new SC_Product(); |
---|
[16102] | 81 | |
---|
[18399] | 82 | if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) { |
---|
[20144] | 83 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
[18399] | 84 | } |
---|
| 85 | |
---|
[22271] | 86 | $order_id = $_GET['order_id']; |
---|
| 87 | $this->is_price_change = false; |
---|
[18399] | 88 | |
---|
[20167] | 89 | //受注データの取得 |
---|
| 90 | $this->tpl_arrOrderData = $objPurchase->getOrder($order_id, $objCustomer->getValue('customer_id')); |
---|
| 91 | |
---|
[21441] | 92 | if (empty($this->tpl_arrOrderData)) { |
---|
[16102] | 93 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
| 94 | } |
---|
| 95 | |
---|
[20694] | 96 | $this->arrShipping = $this->lfGetShippingDate($objPurchase, $order_id, $this->arrWDAY); |
---|
[20144] | 97 | |
---|
| 98 | $this->isMultiple = count($this->arrShipping) > 1; |
---|
[18399] | 99 | // 支払い方法の取得 |
---|
[22537] | 100 | $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList(); |
---|
[18399] | 101 | // 受注商品明細の取得 |
---|
[20167] | 102 | $this->tpl_arrOrderDetail = $objPurchase->getOrderDetail($order_id); |
---|
[22271] | 103 | foreach ($this->tpl_arrOrderDetail as $product_index => $arrOrderProductDetail) { |
---|
| 104 | //必要なのは商品の販売金額のみなので、遅い場合は、別途SQL作成した方が良い |
---|
| 105 | $arrTempProductDetail = $objProduct->getProductsClass($arrOrderProductDetail['product_class_id']); |
---|
| 106 | if($this->tpl_arrOrderDetail[$product_index]['price'] != $arrTempProductDetail['price02']) { |
---|
| 107 | $this->is_price_change = true; |
---|
| 108 | } |
---|
| 109 | $this->tpl_arrOrderDetail[$product_index]['product_price'] = ($arrTempProductDetail['price02'])?$arrTempProductDetail['price02']:0; |
---|
| 110 | } |
---|
| 111 | |
---|
[21046] | 112 | $this->tpl_arrOrderDetail = $this->setMainListImage($this->tpl_arrOrderDetail); |
---|
[20888] | 113 | $objPurchase->setDownloadableFlgTo($this->tpl_arrOrderDetail); |
---|
[21354] | 114 | // モバイルダウンロード対応処理 |
---|
| 115 | $this->lfSetAU($this->tpl_arrOrderDetail); |
---|
[18399] | 116 | // 受注メール送信履歴の取得 |
---|
[20144] | 117 | $this->tpl_arrMailHistory = $this->lfGetMailHistory($order_id); |
---|
[21596] | 118 | |
---|
[18399] | 119 | |
---|
[16102] | 120 | } |
---|
| 121 | |
---|
| 122 | /** |
---|
| 123 | * デストラクタ. |
---|
| 124 | * |
---|
| 125 | * @return void |
---|
| 126 | */ |
---|
[22567] | 127 | function destroy() |
---|
| 128 | { |
---|
[16102] | 129 | parent::destroy(); |
---|
| 130 | } |
---|
| 131 | |
---|
[16234] | 132 | /** |
---|
[18399] | 133 | * 受注メール送信履歴の取得 |
---|
| 134 | * |
---|
[20144] | 135 | * @param integer $order_id 注文番号 |
---|
[18399] | 136 | * @return array 受注メール送信履歴の内容 |
---|
| 137 | */ |
---|
[22567] | 138 | function lfGetMailHistory($order_id) |
---|
| 139 | { |
---|
[20507] | 140 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20144] | 141 | $col = 'send_date, subject, template_id, send_id'; |
---|
| 142 | $where = 'order_id = ?'; |
---|
[18675] | 143 | $objQuery->setOrder('send_date DESC'); |
---|
[20144] | 144 | return $objQuery->select($col, 'dtb_mail_history', $where, array($order_id)); |
---|
[18399] | 145 | } |
---|
[20583] | 146 | |
---|
| 147 | /** |
---|
| 148 | * 受注お届け先情報の取得 |
---|
| 149 | * |
---|
| 150 | * @param $objPurchase object SC_Helper_Purchaseクラス |
---|
| 151 | * @param $order_id integer 注文番号 |
---|
| 152 | * @param $arrWDAY array 曜日データの配列 |
---|
| 153 | * @return array お届け先情報 |
---|
| 154 | */ |
---|
[22567] | 155 | function lfGetShippingDate(&$objPurchase, $order_id, $arrWDAY) |
---|
| 156 | { |
---|
[20583] | 157 | $arrShipping = $objPurchase->getShippings($order_id); |
---|
| 158 | |
---|
[21441] | 159 | foreach ($arrShipping as $shipping_index => $shippingData) { |
---|
| 160 | foreach ($shippingData as $key => $val) { |
---|
| 161 | if ($key == 'shipping_date' && SC_Utils_Ex::isBlank($val) == false) { |
---|
[20583] | 162 | // お届け日を整形 |
---|
[21514] | 163 | list($y, $m, $d, $w) = explode(' ', date('Y m d w' , strtotime($val))); |
---|
| 164 | $arrShipping[$shipping_index]['shipping_date'] = sprintf('%04d/%02d/%02d(%s)', $y, $m, $d, $arrWDAY[$w]); |
---|
[20583] | 165 | } |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | return $arrShipping; |
---|
| 170 | } |
---|
[21420] | 171 | |
---|
[21046] | 172 | /** |
---|
| 173 | * 購入履歴商品に画像をセット |
---|
| 174 | * |
---|
| 175 | * @param $arrOrderDetail 購入履歴の配列 |
---|
| 176 | * @return array 画像をセットした購入履歴の配列 |
---|
| 177 | */ |
---|
[22567] | 178 | function setMainListImage($arrOrderDetails) |
---|
| 179 | { |
---|
[21046] | 180 | $i = 0; |
---|
| 181 | foreach ($arrOrderDetails as $arrOrderDetail) { |
---|
| 182 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 183 | $arrProduct = $objQuery->select('main_list_image', 'dtb_products', 'product_id = ?', array($arrOrderDetail['product_id'])); |
---|
| 184 | $arrOrderDetails[$i]['main_list_image'] = $arrProduct[0]['main_list_image']; |
---|
[21071] | 185 | $i++; |
---|
[21046] | 186 | } |
---|
| 187 | return $arrOrderDetails; |
---|
| 188 | } |
---|
[21354] | 189 | |
---|
| 190 | /** |
---|
| 191 | * 購入履歴商品にMIMETYPE、ファイル名をセット |
---|
| 192 | * |
---|
| 193 | * @param $arrOrderDetail 購入履歴の配列 |
---|
| 194 | * @return array MIMETYPE、ファイル名をセットした購入履歴の配列 |
---|
| 195 | */ |
---|
[22567] | 196 | function lfSetMimetype($arrOrderDetails) |
---|
| 197 | { |
---|
[21354] | 198 | $objHelperMobile = new SC_Helper_Mobile_Ex(); |
---|
| 199 | $i = 0; |
---|
| 200 | foreach ($arrOrderDetails as $arrOrderDetail) { |
---|
| 201 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
| 202 | $arrProduct = $objQuery->select('down_realfilename,down_filename', 'dtb_products_class', 'product_id = ? AND product_class_id = ?', array($arrOrderDetail['product_id'],$arrOrderDetail['product_class_id'])); |
---|
| 203 | $arrOrderDetails[$i]['mime_type'] = $objHelperMobile->getMimeType($arrProduct[0]['down_realfilename']); |
---|
| 204 | $arrOrderDetails[$i]['down_filename'] = $arrProduct[0]['down_filename']; |
---|
| 205 | $i++; |
---|
| 206 | } |
---|
| 207 | return $arrOrderDetails; |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | /** |
---|
| 211 | * 特定キャリア(AU)モバイルダウンロード処理 |
---|
| 212 | * キャリアがAUのモバイル端末からダウンロードする場合は単純に |
---|
| 213 | * Aタグでダウンロードできないケースがある為、対応する。 |
---|
| 214 | * |
---|
| 215 | * @param integer $order_id 注文番号 |
---|
| 216 | * @param $arrOrderDetail 購入履歴の配列 |
---|
| 217 | */ |
---|
[22567] | 218 | function lfSetAU($arrOrderDetails) |
---|
| 219 | { |
---|
[21354] | 220 | $this->isAU = false; |
---|
| 221 | // モバイル端末かつ、キャリアがAUの場合に処理を行う |
---|
[21441] | 222 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && SC_MobileUserAgent::getCarrier() == 'ezweb') { |
---|
[21354] | 223 | // MIMETYPE、ファイル名のセット |
---|
| 224 | $this->tpl_arrOrderDetail = $this->lfSetMimetype($arrOrderDetails); |
---|
[21636] | 225 | |
---|
| 226 | // @deprecated 2.12.0 PHP 定数 SID を使うこと |
---|
[21354] | 227 | $this->phpsessid = $_GET['PHPSESSID']; |
---|
[21636] | 228 | |
---|
[21354] | 229 | $this->isAU = true; |
---|
| 230 | } |
---|
| 231 | } |
---|
[16102] | 232 | } |
---|