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

Revision 21693, 6.0 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_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        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
70        $objPlugin->doAction('LC_Page_Mypage_Delivery_action_before', array($this));
71
72        $objCustomer    = new SC_Customer_Ex();
73        $customer_id    = $objCustomer->getValue('customer_id');
74        $objFormParam   = new SC_FormParam_Ex();
75
76        $this->lfInitParam($objFormParam);
77        $objFormParam->setParam($_POST);
78        $objFormParam->convParam();
79
80        switch ($this->getMode()) {
81
82            // お届け先の削除
83            case 'delete':
84                if ($objFormParam->checkError()) {
85                    SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
86                    exit;
87                }
88
89                $this->deleteOtherDeliv($customer_id, $objFormParam->getValue('other_deliv_id'));
90                break;
91
92            // スマートフォン版のもっと見るボタン用
93            case 'getList':
94                    $arrData = $objFormParam->getHashArray();
95                    //別のお届け先情報
96                    $arrOtherDeliv = $this->getOtherDeliv($customer_id, (($arrData['pageno'] - 1) * SEARCH_PMAX));
97                    //県名をセット
98                    $arrOtherDeliv = $this->setPref($arrOtherDeliv, $this->arrPref);
99                    $arrOtherDeliv['delivCount'] = count($arrOtherDeliv);
100                    $this->arrOtherDeliv = $arrOtherDeliv;
101
102                    // フックポイント.
103                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
104                    $objPlugin->doAction('LC_Page_Mypage_Delivery_action_getList', array($this));
105
106                    echo SC_Utils_Ex::jsonEncode($this->arrOtherDeliv);
107                    exit;
108                    break;
109
110            // お届け先の表示
111            default:
112                break;
113        }
114
115        //別のお届け先情報
116        $this->arrOtherDeliv = $this->getOtherDeliv($customer_id);
117
118        //お届け先登録数
119        $this->tpl_linemax = count($this->arrOtherDeliv);
120
121        // 1ページあたりの件数
122        $this->dispNumber = SEARCH_PMAX;
123
124        // フックポイント.
125        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
126        $objPlugin->doAction('LC_Page_Mypage_Delivery_action_after', array($this));
127    }
128
129    /**
130     * デストラクタ.
131     *
132     * @return void
133     */
134    function destroy() {
135        parent::destroy();
136    }
137
138    /**
139     * フォームパラメータの初期化
140     *
141     * @return SC_FormParam
142     */
143    function lfInitParam(&$objFormParam) {
144        $objFormParam->addParam('お届け先ID', 'other_deliv_id', INT_LEN, '', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
145        $objFormParam->addParam('現在ページ', 'pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false);
146    }
147
148    /**
149     * お届け先の取得
150     *
151     * @param integer $customerId
152     * @param integer $startno
153     * @return array
154     */
155    function getOtherDeliv($customer_id, $startno = '') {
156        $objQuery   =& SC_Query_Ex::getSingletonInstance();
157        $objQuery->setOrder('other_deliv_id DESC');
158        //スマートフォン用の処理
159        if ($startno != '') {
160            $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
161        }
162        return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id));
163    }
164
165    /**
166     * お届け先の削除
167     *
168     * @param integer $customerId
169     * @param integer $delivId
170     */
171    function deleteOtherDeliv($customer_id, $deliv_id) {
172        $where      = 'customer_id = ? AND other_deliv_id = ?';
173        $objQuery   =& SC_Query_Ex::getSingletonInstance();
174        $objQuery->delete('dtb_other_deliv', $where, array($customer_id, $deliv_id));
175    }
176
177    /**
178     * 県名をセット
179     *
180     * @param array $arrOtherDeliv
181     * @param array $arrPref
182     * return array
183     */
184    function setPref($arrOtherDeliv, $arrPref) {
185        if (is_array($arrOtherDeliv)) {
186            foreach ($arrOtherDeliv as $key => $arrDeliv) {
187                $arrOtherDeliv[$key]['prefname'] = $arrPref[$arrDeliv['pref']];
188            }
189        }
190        return $arrOtherDeliv;
191    }
192}
Note: See TracBrowser for help on using the repository browser.