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

Revision 20285, 14.3 KB checked in by AMUAMU, 13 years ago (diff)

#965 (リファクタリング [管理画面]顧客管理)に関する修正 LC_Page_Admin_Customer.php LC_Page_Admin_Customer_Edit.php
#963 (リファクタリング [管理画面]メルマガ管理)の検索処理共通化修正で正常に動くように動作を合わせた。
SC_Helper_Customer_Ex::sfGetSearchData()を追加。
顧客一覧検索系はSC_Customer_Helperに共通機能多数なので利用を。
検索処理の共通化にあわせて LC_Page_Admin_Mail.php側も修正。

#850 (顧客CSV 列追加時にロジックの変更を不要に)の修正
#870 (CSVアップロードにおいて、CSV項目の種類・数を自由に変更出来る機能)に関連した修正
#657 (CSVダウンロードの改善)に関連した修正
#1024 (「顧客検索→編集→完了→続けて登録→検索に戻る」と遷移した場合に検索条件を引き継がない問題)の改修

予定より時間かかった・・・

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