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

Revision 21864, 14.5 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新

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