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

Revision 23605, 4.7 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • 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-2014 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
24require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php';
25
26/**
27 * お届け先編集 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Mypage_Delivery extends LC_Page_AbstractMypage_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    public function init()
41    {
42        parent::init();
43        $this->tpl_subtitle = 'お届け先追加・変更';
44        $this->tpl_mypageno = 'delivery';
45        $masterData         = new SC_DB_MasterData_Ex();
46        $this->arrPref      = $masterData->getMasterData('mtb_pref');
47        $this->arrCountry   = $masterData->getMasterData('mtb_country');
48        $this->httpCacheControl('nocache');
49    }
50
51    /**
52     * Page のプロセス.
53     *
54     * @return void
55     */
56    public function process()
57    {
58        parent::process();
59    }
60
61    /**
62     * Page のAction.
63     *
64     * @return void
65     */
66    public function action()
67    {
68        $objCustomer    = new SC_Customer_Ex();
69        $customer_id    = $objCustomer->getValue('customer_id');
70        $objAddress     = new SC_Helper_Address_Ex();
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            case 'delete':
80                if ($objFormParam->checkError()) {
81                    SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
82                    SC_Response_Ex::actionExit();
83                }
84
85                if (!$objAddress->deleteAddress($objFormParam->getValue('other_deliv_id'), $customer_id)) {
86                    SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先を削除できませんでした。');
87                    SC_Response_Ex::actionExit();
88                }
89                break;
90
91            // スマートフォン版のもっと見るボタン用
92            case 'getList':
93                $arrData = $objFormParam->getHashArray();
94                //別のお届け先情報
95                $arrOtherDeliv = $objAddress->getList($customer_id, (($arrData['pageno'] - 1) * SEARCH_PMAX));
96                //県名をセット
97                $arrOtherDeliv = $this->setPref($arrOtherDeliv, $this->arrPref);
98                $arrOtherDeliv['delivCount'] = count($arrOtherDeliv);
99                $this->arrOtherDeliv = $arrOtherDeliv;
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     * @param SC_FormParam_Ex $objFormParam
124     * @return SC_FormParam
125     */
126    public function lfInitParam(&$objFormParam)
127    {
128        $objFormParam->addParam('お届け先ID', 'other_deliv_id', INT_LEN, '', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
129        $objFormParam->addParam('現在ページ', 'pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false);
130    }
131
132    /**
133     * 県名をセット
134     *
135     * @param array $arrOtherDeliv
136     * @param array $arrPref
137     * return array
138     */
139    public function setPref($arrOtherDeliv, $arrPref)
140    {
141        if (is_array($arrOtherDeliv)) {
142            foreach ($arrOtherDeliv as $key => $arrDeliv) {
143                $arrOtherDeliv[$key]['prefname'] = $arrPref[$arrDeliv['pref']];
144            }
145        }
146
147        return $arrOtherDeliv;
148    }
149}
Note: See TracBrowser for help on using the repository browser.