source: branches/version-2_13-dev/data/class/pages/admin/customer/LC_Page_Admin_Customer_Edit.php @ 23606

Revision 23606, 14.3 KB checked in by kimoto, 10 years ago (diff)

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

 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/e0f27994-b3c7-4fc6-ad70-55d3cd63769b/patches

  • 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/admin/LC_Page_Admin_Ex.php';
25
26/**
27 * 会員情報修正 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Admin_Customer_Edit extends LC_Page_Admin_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    public function init()
41    {
42        parent::init();
43        $this->tpl_mainpage = 'customer/edit.tpl';
44        $this->tpl_mainno = 'customer';
45        $this->tpl_subno = 'index';
46        $this->tpl_pager = 'pager.tpl';
47        $this->tpl_maintitle = '会員管理';
48        $this->tpl_subtitle = '会員登録';
49
50        $masterData = new SC_DB_MasterData_Ex();
51        $this->arrPref = $masterData->getMasterData('mtb_pref');
52        $this->arrCountry = $masterData->getMasterData('mtb_country');
53        $this->arrJob = $masterData->getMasterData('mtb_job');
54        $this->arrSex = $masterData->getMasterData('mtb_sex');
55        $this->arrReminder = $masterData->getMasterData('mtb_reminder');
56        $this->arrStatus = $masterData->getMasterData('mtb_customer_status');
57        $this->arrMailMagazineType = $masterData->getMasterData('mtb_mail_magazine_type');
58
59        // 日付プルダウン設定
60        $objDate = new SC_Date_Ex(BIRTH_YEAR);
61        $this->arrYear = $objDate->getYear();
62        $this->arrMonth = $objDate->getMonth();
63        $this->arrDay = $objDate->getDay();
64
65        // 支払い方法種別
66        $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList();
67    }
68
69    /**
70     * Page のプロセス.
71     *
72     * @return void
73     */
74    public function process()
75    {
76        $this->action();
77        $this->sendResponse();
78    }
79
80    /**
81     * Page のアクション.
82     *
83     * @return void
84     */
85    public function action()
86    {
87        // パラメーター管理クラス
88        $objFormParam = new SC_FormParam_Ex();
89        // 検索引き継ぎ用パラメーター管理クラス
90        $objFormSearchParam = new SC_FormParam_Ex();
91
92        // モードによる処理切り替え
93        switch ($this->getMode()) {
94            case 'edit_search':
95                // 検索引き継ぎ用パラメーター処理
96                $this->lfInitSearchParam($objFormSearchParam);
97                $objFormSearchParam->setParam($_REQUEST);
98                $this->arrErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
99                $this->arrSearchData = $objFormSearchParam->getSearchArray();
100                if (!SC_Utils_Ex::isBlank($this->arrErr)) {
101                    return;
102                }
103                // 指定会員の情報をセット
104                $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($objFormSearchParam->getValue('edit_customer_id'), true);
105                // 購入履歴情報の取得
106                list($this->tpl_linemax, $this->arrPurchaseHistory, $this->objNavi) = $this->lfPurchaseHistory($objFormSearchParam->getValue('edit_customer_id'));
107                $this->arrPagenavi = $this->objNavi->arrPagenavi;
108                $this->arrPagenavi['mode'] = 'return';
109                $this->tpl_pageno = '0';
110                break;
111            case 'confirm':
112                // パラメーター処理
113                $this->lfInitParam($objFormParam);
114                $objFormParam->setParam($_POST);
115                $objFormParam->convParam();
116                // 入力パラメーターチェック
117                $this->arrErr = $this->lfCheckError($objFormParam);
118                $this->arrForm = $objFormParam->getHashArray();
119                // 検索引き継ぎ用パラメーター処理
120                $this->lfInitSearchParam($objFormSearchParam);
121                $objFormSearchParam->setParam($objFormParam->getValue('search_data'));
122                $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
123                $this->arrSearchData = $objFormSearchParam->getSearchArray();
124                if (!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
125                    return;
126                }
127                // 確認画面テンプレートに切り替え
128                $this->tpl_mainpage = 'customer/edit_confirm.tpl';
129                break;
130            case 'return':
131                // パラメーター処理
132                $this->lfInitParam($objFormParam);
133                $objFormParam->setParam($_POST);
134                $objFormParam->convParam();
135                // 入力パラメーターチェック
136                $this->arrErr = $this->lfCheckError($objFormParam);
137                $this->arrForm = $objFormParam->getHashArray();
138                // 検索引き継ぎ用パラメーター処理
139                $this->lfInitSearchParam($objFormSearchParam);
140                $objFormSearchParam->setParam($objFormParam->getValue('search_data'));
141                $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
142                $this->arrSearchData = $objFormSearchParam->getSearchArray();
143                if (!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
144                    return;
145                }
146                // 購入履歴情報の取得
147                list($this->tpl_linemax, $this->arrPurchaseHistory, $this->objNavi) = $this->lfPurchaseHistory($objFormParam->getValue('customer_id'), $objFormParam->getValue('search_pageno'));
148                $this->arrPagenavi = $this->objNavi->arrPagenavi;
149                $this->arrPagenavi['mode'] = 'return';
150                $this->tpl_pageno = $objFormParam->getValue('search_pageno');
151
152                break;
153            case 'complete':
154                // 登録・保存処理
155                // パラメーター処理
156                $this->lfInitParam($objFormParam);
157                $objFormParam->setParam($_POST);
158                $objFormParam->convParam();
159                // 入力パラメーターチェック
160                $this->arrErr = $this->lfCheckError($objFormParam);
161                $this->arrForm = $objFormParam->getHashArray();
162                // 検索引き継ぎ用パラメーター処理
163                $this->lfInitSearchParam($objFormSearchParam);
164                $objFormSearchParam->setParam($objFormParam->getValue('search_data'));
165                $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
166                $this->arrSearchData = $objFormSearchParam->getSearchArray();
167                if (!SC_Utils_Ex::isBlank($this->arrErr) or !SC_Utils_Ex::isBlank($this->arrSearchErr)) {
168                    return;
169                }
170                $this->lfRegistData($objFormParam);
171                $this->tpl_mainpage = 'customer/edit_complete.tpl';
172                break;
173            case 'complete_return':
174                // 入力パラメーターチェック
175                $this->lfInitParam($objFormParam);
176                $objFormParam->setParam($_POST);
177                // 検索引き継ぎ用パラメーター処理
178                $this->lfInitSearchParam($objFormSearchParam);
179                $objFormSearchParam->setParam($objFormParam->getValue('search_data'));
180                $this->arrSearchErr = $this->lfCheckErrorSearchParam($objFormSearchParam);
181                $this->arrSearchData = $objFormSearchParam->getSearchArray();
182                if (!SC_Utils_Ex::isBlank($this->arrSearchErr)) {
183                    return;
184                }
185            default:
186                $this->lfInitParam($objFormParam);
187                $this->arrForm = $objFormParam->getHashArray();
188                break;
189        }
190
191    }
192
193    /**
194     * パラメーター情報の初期化
195     *
196     * @param  array $objFormParam フォームパラメータークラス
197     * @return void
198     */
199    public function lfInitParam(&$objFormParam)
200    {
201        // 会員項目のパラメーター取得
202        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam, true);
203        // 検索結果一覧画面への戻り用パラメーター
204        $objFormParam->addParam('検索用データ', 'search_data', '', '', array(), '', false);
205        // 会員購入履歴ページング用
206        $objFormParam->addParam('', 'search_pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false);
207    }
208
209    /**
210     * 検索パラメーター引き継ぎ用情報の初期化
211     *
212     * @param  SC_FormParam_Ex $objFormParam フォームパラメータークラス
213     * @return void
214     */
215    public function lfInitSearchParam(&$objFormParam)
216    {
217        SC_Helper_Customer_Ex::sfSetSearchParam($objFormParam);
218        // 初回受け入れ時用
219        $objFormParam->addParam('編集対象会員ID', 'edit_customer_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
220    }
221
222    /**
223     * 検索パラメーターエラーチェック
224     *
225     * @param  SC_FormParam_Ex $objFormParam フォームパラメータークラス
226     * @return array エラー配列
227     */
228    public function lfCheckErrorSearchParam(&$objFormParam)
229    {
230        return SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam);
231    }
232
233    /**
234     * フォーム入力パラメーターエラーチェック
235     *
236     * @param  array $objFormParam フォームパラメータークラス
237     * @return array エラー配列
238     */
239    public function lfCheckError(&$objFormParam)
240    {
241        $arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam, true);
242
243        // メアド重複チェック(共通ルーチンは使えない)
244        $objQuery   =& SC_Query_Ex::getSingletonInstance();
245        $col = 'email, email_mobile, customer_id';
246        $table = 'dtb_customer';
247        $where = 'del_flg <> 1 AND (email Like ? OR email_mobile Like ?)';
248        $arrVal = array($objFormParam->getValue('email'), $objFormParam->getValue('email_mobile'));
249        if ($objFormParam->getValue('customer_id')) {
250            $where .= ' AND customer_id <> ?';
251            $arrVal[] = $objFormParam->getValue('customer_id');
252        }
253        $arrData = $objQuery->getRow($col, $table, $where, $arrVal);
254        if (!SC_Utils_Ex::isBlank($arrData['email'])) {
255            if ($arrData['email'] == $objFormParam->getValue('email')) {
256                $arrErr['email'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
257            } elseif ($arrData['email'] == $objFormParam->getValue('email_mobile')) {
258                $arrErr['email_mobile'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
259            }
260        }
261        if (!SC_Utils_Ex::isBlank($arrData['email_mobile'])) {
262            if ($arrData['email_mobile'] == $objFormParam->getValue('email_mobile')) {
263                $arrErr['email_mobile'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
264            } elseif ($arrData['email_mobile'] == $objFormParam->getValue('email')) {
265                if ($arrErr['email'] == '') {
266                    $arrErr['email'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
267                }
268            }
269        }
270
271        return $arrErr;
272    }
273
274    /**
275     * 登録処理
276     *
277     * @param  array $objFormParam フォームパラメータークラス
278     * @return integer エラー配列
279     */
280    public function lfRegistData(&$objFormParam)
281    {
282        // 登録用データ取得
283        $arrData = $objFormParam->getDbArray();
284        // 足りないものを作る
285        if (!SC_Utils_Ex::isBlank($objFormParam->getValue('year'))) {
286            $arrData['birth'] = $objFormParam->getValue('year') . '/'
287                            . $objFormParam->getValue('month') . '/'
288                            . $objFormParam->getValue('day')
289                            . ' 00:00:00';
290        }
291
292        if (!is_numeric($arrData['customer_id'])) {
293            $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
294        } else {
295            $arrOldCustomerData = SC_Helper_Customer_Ex::sfGetCustomerData($arrData['customer_id']);
296            if ($arrOldCustomerData['status'] != $arrData['status']) {
297                $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
298            }
299        }
300
301        return SC_Helper_Customer_Ex::sfEditCustomerData($arrData, $arrData['customer_id']);
302    }
303
304    /**
305     * 購入履歴情報の取得
306     *
307     * @return array( integer 全体件数, mixed 会員データ一覧配列, mixed SC_PageNaviオブジェクト)
308     */
309    public function lfPurchaseHistory($customer_id, $pageno = 0)
310    {
311        if (SC_Utils_Ex::isBlank($customer_id)) {
312            return array('0', array(), NULL);
313        }
314        $objQuery =& SC_Query_Ex::getSingletonInstance();
315        $page_max = SEARCH_PMAX;
316        $table = 'dtb_order';
317        $where = 'customer_id = ? AND del_flg <> 1';
318        $arrVal = array($customer_id);
319        // 購入履歴の件数取得
320        $linemax = $objQuery->count($table, $where, $arrVal);
321        // ページ送りの取得
322        $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, 'eccube.moveSecondSearchPage', NAVI_PMAX);
323        // 取得範囲の指定(開始行番号、行数のセット)
324        $objQuery->setLimitOffset($page_max, $objNavi->start_row);
325        // 表示順序
326        $order = 'order_id DESC';
327        $objQuery->setOrder($order);
328        // 購入履歴情報の取得
329        $arrPurchaseHistory = $objQuery->select('*', $table, $where, $arrVal);
330
331        return array($linemax, $arrPurchaseHistory, $objNavi);
332    }
333}
Note: See TracBrowser for help on using the repository browser.