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

Revision 22065, 4.5 KB checked in by pineray, 11 years ago (diff)

#1958 別お届け先関連の処理をページクラスから分離

  • 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-2012 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_Delivery 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_subtitle = 'お届け先追加・変更';
47        $this->tpl_mypageno = 'delivery';
48        $masterData         = new SC_DB_MasterData_Ex();
49        $this->arrPref      = $masterData->getMasterData('mtb_pref');
50        $this->httpCacheControl('nocache');
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        parent::process();
60    }
61
62    /**
63     * Page のAction.
64     *
65     * @return void
66     */
67    function action() {
68
69        $objCustomer    = new SC_Customer_Ex();
70        $customer_id    = $objCustomer->getValue('customer_id');
71        $objAddress     = new SC_Helper_Address_Ex();
72        $objFormParam   = new SC_FormParam_Ex();
73
74        $this->lfInitParam($objFormParam);
75        $objFormParam->setParam($_POST);
76        $objFormParam->convParam();
77
78        switch ($this->getMode()) {
79
80            // お届け先の削除
81            case 'delete':
82                if ($objFormParam->checkError()) {
83                    SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
84                    SC_Response_Ex::actionExit();
85                }
86
87                $objAddress->deleteAddress($customer_id, $objFormParam->getValue('other_deliv_id'));
88                break;
89
90            // スマートフォン版のもっと見るボタン用
91            case 'getList':
92                    $arrData = $objFormParam->getHashArray();
93                    //別のお届け先情報
94                    $arrOtherDeliv = $objAddress->getList($customer_id, (($arrData['pageno'] - 1) * SEARCH_PMAX));
95                    //県名をセット
96                    $arrOtherDeliv = $this->setPref($arrOtherDeliv, $this->arrPref);
97                    $arrOtherDeliv['delivCount'] = count($arrOtherDeliv);
98                    $this->arrOtherDeliv = $arrOtherDeliv;
99
100
101                    echo SC_Utils_Ex::jsonEncode($this->arrOtherDeliv);
102                    SC_Response_Ex::actionExit();
103                    break;
104
105            // お届け先の表示
106            default:
107                break;
108        }
109
110        //別のお届け先情報
111        $this->arrOtherDeliv = $objAddress->getList($customer_id);
112
113        //お届け先登録数
114        $this->tpl_linemax = count($this->arrOtherDeliv);
115
116        // 1ページあたりの件数
117        $this->dispNumber = SEARCH_PMAX;
118
119
120    }
121
122    /**
123     * デストラクタ.
124     *
125     * @return void
126     */
127    function destroy() {
128        parent::destroy();
129    }
130
131    /**
132     * フォームパラメータの初期化
133     *
134     * @return SC_FormParam
135     */
136    function lfInitParam(&$objFormParam) {
137        $objFormParam->addParam('お届け先ID', 'other_deliv_id', INT_LEN, '', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
138        $objFormParam->addParam('現在ページ', 'pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false);
139    }
140
141    /**
142     * 県名をセット
143     *
144     * @param array $arrOtherDeliv
145     * @param array $arrPref
146     * return array
147     */
148    function setPref($arrOtherDeliv, $arrPref) {
149        if (is_array($arrOtherDeliv)) {
150            foreach ($arrOtherDeliv as $key => $arrDeliv) {
151                $arrOtherDeliv[$key]['prefname'] = $arrPref[$arrDeliv['pref']];
152            }
153        }
154        return $arrOtherDeliv;
155    }
156}
Note: See TracBrowser for help on using the repository browser.