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

Revision 22537, 14.4 KB checked in by pineray, 11 years ago (diff)

pageクラスからdtb_paymentテーブルを直接指定している箇所をなくす

以下のファイルが残っている.
LC_Page_Shopping_LoadPaymentModule.php
LC_Page_Admin_Home.php

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