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

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