source: branches/version-2_12-dev/data/class/pages/mypage/LC_Page_Mypage_History.php @ 21693

Revision 21693, 7.8 KB checked in by h_yoshimoto, 12 years ago (diff)

#1692 フックポイント名を変更

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 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_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.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_AbstractMypage_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mypageno     = 'index';
47        $this->tpl_subtitle     = '購入履歴詳細';
48        $this->httpCacheControl('nocache');
49
50        $masterData             = new SC_DB_MasterData_Ex();
51        $this->arrMAILTEMPLATE  = $masterData->getMasterData('mtb_mail_template');
52        $this->arrPref          = $masterData->getMasterData('mtb_pref');
53        $this->arrWDAY          = $masterData->getMasterData('mtb_wday');
54        $this->arrProductType   = $masterData->getMasterData('mtb_product_type');
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        parent::process();
64    }
65
66    /**
67     * Page のAction.
68     *
69     * @return void
70     */
71    function action() {
72        // フックポイント.
73        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
74        $objPlugin->doAction('LC_Page_Mypage_History_action_before', array($this));
75
76        $objCustomer    = new SC_Customer_Ex();
77        $objDb          = new SC_Helper_DB_Ex();
78        $objPurchase = new SC_Helper_Purchase_Ex();
79
80        if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
81            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
82        }
83
84        $order_id        = $_GET['order_id'];
85
86        //受注データの取得
87        $this->tpl_arrOrderData = $objPurchase->getOrder($order_id, $objCustomer->getValue('customer_id'));
88
89        if (empty($this->tpl_arrOrderData)) {
90            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
91        }
92
93        $this->arrShipping      = $this->lfGetShippingDate($objPurchase, $order_id, $this->arrWDAY);
94
95        $this->isMultiple       = count($this->arrShipping) > 1;
96        // 支払い方法の取得
97        $this->arrPayment       = $objDb->sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method');
98        // 受注商品明細の取得
99        $this->tpl_arrOrderDetail = $objPurchase->getOrderDetail($order_id);
100        $this->tpl_arrOrderDetail = $this->setMainListImage($this->tpl_arrOrderDetail);
101        $objPurchase->setDownloadableFlgTo($this->tpl_arrOrderDetail);
102        // モバイルダウンロード対応処理
103        $this->lfSetAU($this->tpl_arrOrderDetail);
104        // 受注メール送信履歴の取得
105        $this->tpl_arrMailHistory = $this->lfGetMailHistory($order_id);
106
107        // フックポイント.
108        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
109        $objPlugin->doAction('LC_Page_Mypage_History_action_after', array($this));
110
111    }
112
113    /**
114     * デストラクタ.
115     *
116     * @return void
117     */
118    function destroy() {
119        parent::destroy();
120    }
121
122    /**
123     * 受注メール送信履歴の取得
124     *
125     * @param integer $order_id 注文番号
126     * @return array 受注メール送信履歴の内容
127     */
128    function lfGetMailHistory($order_id) {
129        $objQuery   =& SC_Query_Ex::getSingletonInstance();
130        $col        = 'send_date, subject, template_id, send_id';
131        $where      = 'order_id = ?';
132        $objQuery->setOrder('send_date DESC');
133        return $objQuery->select($col, 'dtb_mail_history', $where, array($order_id));
134    }
135
136    /**
137     * 受注お届け先情報の取得
138     *
139     * @param $objPurchase object SC_Helper_Purchaseクラス
140     * @param $order_id integer 注文番号
141     * @param $arrWDAY array 曜日データの配列
142     * @return array お届け先情報
143     */
144    function lfGetShippingDate(&$objPurchase, $order_id, $arrWDAY) {
145        $arrShipping = $objPurchase->getShippings($order_id);
146
147        foreach ($arrShipping as $shipping_index => $shippingData) {
148            foreach ($shippingData as $key => $val) {
149                if ($key == 'shipping_date' && SC_Utils_Ex::isBlank($val) == false) {
150                    // お届け日を整形
151                    list($y, $m, $d, $w) = explode(' ', date('Y m d w' , strtotime($val)));
152                    $arrShipping[$shipping_index]['shipping_date'] = sprintf('%04d/%02d/%02d(%s)', $y, $m, $d, $arrWDAY[$w]);
153                }
154            }
155        }
156
157        return $arrShipping;
158    }
159
160    /**
161     * 購入履歴商品に画像をセット
162     *
163     * @param $arrOrderDetail 購入履歴の配列
164     * @return array 画像をセットした購入履歴の配列
165     */
166    function setMainListImage($arrOrderDetails) {
167        $i = 0;
168        foreach ($arrOrderDetails as $arrOrderDetail) {
169            $objQuery =& SC_Query_Ex::getSingletonInstance();
170            $arrProduct = $objQuery->select('main_list_image', 'dtb_products', 'product_id = ?', array($arrOrderDetail['product_id']));
171            $arrOrderDetails[$i]['main_list_image'] = $arrProduct[0]['main_list_image'];
172            $i++;
173        }
174        return $arrOrderDetails;
175    }
176
177    /**
178     * 購入履歴商品にMIMETYPE、ファイル名をセット
179     *
180     * @param $arrOrderDetail 購入履歴の配列
181     * @return array MIMETYPE、ファイル名をセットした購入履歴の配列
182     */
183    function lfSetMimetype($arrOrderDetails) {
184        $objHelperMobile = new SC_Helper_Mobile_Ex();
185        $i = 0;
186        foreach ($arrOrderDetails as $arrOrderDetail) {
187            $objQuery =& SC_Query_Ex::getSingletonInstance();
188            $arrProduct = $objQuery->select('down_realfilename,down_filename', 'dtb_products_class', 'product_id = ? AND product_class_id = ?', array($arrOrderDetail['product_id'],$arrOrderDetail['product_class_id']));
189            $arrOrderDetails[$i]['mime_type'] = $objHelperMobile->getMimeType($arrProduct[0]['down_realfilename']);
190            $arrOrderDetails[$i]['down_filename'] = $arrProduct[0]['down_filename'];
191            $i++;
192        }
193        return $arrOrderDetails;
194    }
195
196    /**
197     * 特定キャリア(AU)モバイルダウンロード処理
198     * キャリアがAUのモバイル端末からダウンロードする場合は単純に
199     * Aタグでダウンロードできないケースがある為、対応する。
200     *
201     * @param integer $order_id 注文番号
202     * @param $arrOrderDetail 購入履歴の配列
203     */
204    function lfSetAU($arrOrderDetails) {
205        $this->isAU = false;
206        // モバイル端末かつ、キャリアがAUの場合に処理を行う
207        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && SC_MobileUserAgent::getCarrier() == 'ezweb') {
208            // MIMETYPE、ファイル名のセット
209            $this->tpl_arrOrderDetail = $this->lfSetMimetype($arrOrderDetails);
210
211            // @deprecated 2.12.0 PHP 定数 SID を使うこと
212            $this->phpsessid = $_GET['PHPSESSID'];
213
214            $this->isAU = true;
215        }
216    }
217}
Note: See TracBrowser for help on using the repository browser.