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

Revision 21867, 5.4 KB checked in by nakanishi, 9 years ago (diff)

#1831 Copyright Update

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