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

Revision 22856, 14.4 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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