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
RevLine 
[15568]1<?php
2/*
[16582]3 * This file is part of EC-CUBE
4 *
[22206]5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
[15568]6 *
7 * http://www.lockon.co.jp/
[16582]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.
[15568]22 */
23
24// {{{ requires
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[15568]26
27/**
[21419]28 * 会員情報修正 のページクラス.
[15568]29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
[20345]34class LC_Page_Admin_Customer_Edit extends LC_Page_Admin_Ex {
[15568]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';
[16183]47        $this->tpl_mainno = 'customer';
48        $this->tpl_subno = 'index';
[20128]49        $this->tpl_pager = 'pager.tpl';
[21419]50        $this->tpl_maintitle = '会員管理';
51        $this->tpl_subtitle = '会員登録';
[15568]52
53        $masterData = new SC_DB_MasterData_Ex();
[19773]54        $this->arrPref = $masterData->getMasterData('mtb_pref');
[21481]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');
[20232]60
61        // 日付プルダウン設定
[20499]62        $objDate = new SC_Date_Ex(BIRTH_YEAR);
[20819]63        $this->arrYear = $objDate->getYear();
[20232]64        $this->arrMonth = $objDate->getMonth();
65        $this->arrDay = $objDate->getDay();
[20540]66
[20232]67        // 支払い方法種別
[22537]68        $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList();
[15568]69    }
70
71    /**
72     * Page のプロセス.
73     *
74     * @return void
75     */
76    function process() {
[19661]77        $this->action();
78        $this->sendResponse();
79    }
[15568]80
[19661]81    /**
82     * Page のアクション.
83     *
84     * @return void
85     */
86    function action() {
[21591]87
[20970]88        // パラメーター管理クラス
[20501]89        $objFormParam = new SC_FormParam_Ex();
[20232]90        // 検索引き継ぎ用パラメーター管理クラス
[20501]91        $objFormSearchParam = new SC_FormParam_Ex();
[15568]92
[20232]93        // モードによる処理切り替え
[20044]94        switch ($this->getMode()) {
[21526]95            case 'edit_search':
[21653]96                // 検索引き継ぎ用パラメーター処理
[21526]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                }
[21653]104                // 指定会員の情報をセット
[21526]105                $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($objFormSearchParam->getValue('edit_customer_id'), true);
[21653]106                // 購入履歴情報の取得
[21526]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':
[21653]113                // パラメーター処理
[21526]114                $this->lfInitParam($objFormParam);
115                $objFormParam->setParam($_POST);
116                $objFormParam->convParam();
117                // 入力パラメーターチェック
118                $this->arrErr = $this->lfCheckError($objFormParam);
119                $this->arrForm = $objFormParam->getHashArray();
[21653]120                // 検索引き継ぎ用パラメーター処理
[21526]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':
[21653]132                // パラメーター処理
[21526]133                $this->lfInitParam($objFormParam);
134                $objFormParam->setParam($_POST);
135                $objFormParam->convParam();
136                // 入力パラメーターチェック
137                $this->arrErr = $this->lfCheckError($objFormParam);
138                $this->arrForm = $objFormParam->getHashArray();
[21653]139                // 検索引き継ぎ用パラメーター処理
[21526]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                }
[21653]147                // 購入履歴情報の取得
[21526]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');
[20540]152
[21526]153                break;
154            case 'complete':
[21653]155                // 登録・保存処理
156                // パラメーター処理
[21526]157                $this->lfInitParam($objFormParam);
158                $objFormParam->setParam($_POST);
159                $objFormParam->convParam();
160                // 入力パラメーターチェック
161                $this->arrErr = $this->lfCheckError($objFormParam);
162                $this->arrForm = $objFormParam->getHashArray();
[21653]163                // 検索引き継ぎ用パラメーター処理
[21526]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':
[21653]175                // 入力パラメーターチェック
[21526]176                $this->lfInitParam($objFormParam);
177                $objFormParam->setParam($_POST);
[21653]178                // 検索引き継ぎ用パラメーター処理
[21526]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:
[21653]187                $this->lfInitParam($objFormParam);
188                $this->arrForm = $objFormParam->getHashArray();
[21526]189                break;
[15568]190        }
[21743]191
[15568]192    }
193
194    /**
195     * デストラクタ.
196     *
197     * @return void
198     */
199    function destroy() {
200        parent::destroy();
201    }
202
[20232]203    /**
204     * パラメーター情報の初期化
205     *
206     * @param array $objFormParam フォームパラメータークラス
207     * @return void
208     */
209    function lfInitParam(&$objFormParam) {
[21419]210        // 会員項目のパラメーター取得
[20232]211        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam, true);
212        // 検索結果一覧画面への戻り用パラメーター
[21515]213        $objFormParam->addParam('検索用データ', 'search_data', '', '', array(), '', false);
[21419]214        // 会員購入履歴ページング用
[21515]215        $objFormParam->addParam('', 'search_pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false);
[15568]216    }
217
[20232]218    /**
219     * 検索パラメーター引き継ぎ用情報の初期化
220     *
221     * @param array $objFormParam フォームパラメータークラス
222     * @return void
223     */
224    function lfInitSearchParam(&$objFormParam) {
225        SC_Helper_Customer_Ex::sfSetSearchParam($objFormParam);
226        // 初回受け入れ時用
[21514]227        $objFormParam->addParam('編集対象会員ID', 'edit_customer_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
[20232]228    }
[15568]229
[20232]230    /**
231     * 検索パラメーターエラーチェック
232     *
233     * @param array $objFormParam フォームパラメータークラス
234     * @return array エラー配列
235     */
236    function lfCheckErrorSearchParam(&$objFormParam) {
237        return SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam);
238    }
[20540]239
[20232]240    /**
241     * フォーム入力パラメーターエラーチェック
242     *
243     * @param array $objFormParam フォームパラメータークラス
244     * @return array エラー配列
245     */
246    function lfCheckError(&$objFormParam) {
247        $arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam, true);
[20540]248
[21653]249        // メアド重複チェック(共通ルーチンは使えない)
[20507]250        $objQuery   =& SC_Query_Ex::getSingletonInstance();
[21514]251        $col = 'email, email_mobile, customer_id';
[21481]252        $table = 'dtb_customer';
[21514]253        $where = 'del_flg <> 1 AND (email Like ? OR email_mobile Like ?)';
[20232]254        $arrVal = array($objFormParam->getValue('email'), $objFormParam->getValue('email_mobile'));
[21481]255        if ($objFormParam->getValue('customer_id')) {
[21514]256            $where .= ' AND customer_id <> ?';
[21481]257            $arrVal[] = $objFormParam->getValue('customer_id');
[20232]258        }
259        $arrData = $objQuery->getRow($col, $table, $where, $arrVal);
[21441]260        if (!SC_Utils_Ex::isBlank($arrData['email'])) {
261            if ($arrData['email'] == $objFormParam->getValue('email')) {
[21419]262                $arrErr['email'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
[21686]263            } else if ($arrData['email'] == $objFormParam->getValue('email_mobile')) {
[21419]264                $arrErr['email_mobile'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用しているアドレスです。';
[15568]265            }
266        }
[21441]267        if (!SC_Utils_Ex::isBlank($arrData['email_mobile'])) {
268            if ($arrData['email_mobile'] == $objFormParam->getValue('email_mobile')) {
[21419]269                $arrErr['email_mobile'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
[21686]270            } else if ($arrData['email_mobile'] == $objFormParam->getValue('email')) {
[21514]271    if ($arrErr['email'] == '') {
[21419]272                    $arrErr['email'] = '※ すでに他の会員(ID:' . $arrData['customer_id'] . ')が使用している携帯アドレスです。';
[20819]273                }
[15568]274            }
275        }
[20232]276        return $arrErr;
277    }
[15568]278
[20232]279    /**
280     * 登録処理
281     *
282     * @param array $objFormParam フォームパラメータークラス
283     * @return array エラー配列
284     */
285    function lfRegistData(&$objFormParam) {
[20507]286        $objQuery   =& SC_Query_Ex::getSingletonInstance();
[20232]287        // 登録用データ取得
288        $arrData = $objFormParam->getDbArray();
289        // 足りないものを作る
[21441]290        if (!SC_Utils_Ex::isBlank($objFormParam->getValue('year'))) {
[20232]291            $arrData['birth'] = $objFormParam->getValue('year') . '/'
292                            . $objFormParam->getValue('month') . '/'
[20819]293                            . $objFormParam->getValue('day')
[20232]294                            . ' 00:00:00';
295        }
[15568]296
[21441]297        if (!is_numeric($arrData['customer_id'])) {
[20538]298            $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
[21441]299        } else {
[20232]300            $arrOldCustomerData = SC_Helper_Customer_Ex::sfGetCustomerData($arrData['customer_id']);
[21441]301            if ($arrOldCustomerData['status'] != $arrData['status']) {
[20538]302                $arrData['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
[20232]303            }
[15568]304        }
[20232]305        return SC_Helper_Customer_Ex::sfEditCustomerData($arrData, $arrData['customer_id']);
[15568]306    }
307
[20237]308    /**
309     * 購入履歴情報の取得
310     *
311     * @param array $arrParam 検索パラメーター連想配列
[21419]312     * @return array( integer 全体件数, mixed 会員データ一覧配列, mixed SC_PageNaviオブジェクト)
[20237]313     */
[21479]314    function lfPurchaseHistory($customer_id, $pageno = 0) {
[21441]315        if (SC_Utils_Ex::isBlank($customer_id)) {
[20237]316            return array('0', array(), NULL);
317        }
[20507]318        $objQuery =& SC_Query_Ex::getSingletonInstance();
[16183]319        $page_max = SEARCH_PMAX;
[21481]320        $table = 'dtb_order';
[21514]321        $where = 'customer_id = ? AND del_flg <> 1';
[20237]322        $arrVal = array($customer_id);
[21653]323        // 購入履歴の件数取得
[20237]324        $linemax = $objQuery->count($table, $where, $arrVal);
[16183]325        // ページ送りの取得
[21481]326        $objNavi = new SC_PageNavi_Ex($pageno, $linemax, $page_max, 'fnNaviSearchPage2', NAVI_PMAX);
[16183]327        // 取得範囲の指定(開始行番号、行数のセット)
[20237]328        $objQuery->setLimitOffset($page_max, $objNavi->start_row);
[16183]329        // 表示順序
[21514]330        $order = 'order_id DESC';
[20237]331        $objQuery->setOrder($order);
[21653]332        // 購入履歴情報の取得
[21514]333        $arrPurchaseHistory = $objQuery->select('*', $table, $where, $arrVal);
[15568]334
[20237]335        return array($linemax, $arrPurchaseHistory, $objNavi);
[15568]336    }
337}
Note: See TracBrowser for help on using the repository browser.