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

Revision 19892, 16.1 KB checked in by fukuda, 13 years ago (diff)

#880(mobile/sphoneディレクトリを削除)に対応。まずmobileのみ意図通りの動作になるように一部コミット(mypageディレクトリ)
・entryディレクトリと処理を共通化

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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 = TEMPLATE_REALDIR . 'admin/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    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process() {
66        $this->action();
67        $this->sendResponse();
68    }
69
70    /**
71     * Page のアクション.
72     *
73     * @return void
74     */
75    function action() {
76        // 認証可否の判定
77        $objSess = new SC_Session();
78        SC_Utils_Ex::sfIsSuccess($objSess);
79
80        $this->objQuery = new SC_Query();
81        $objDb = new SC_Helper_DB_Ex();
82        $objDate = new SC_Date(1901);
83        $objCustomerHelper = new SC_Helper_Customer_Ex();
84        $this->arrYear = $objDate->getYear();    // 日付プルダウン設定
85        $this->arrMonth = $objDate->getMonth();
86        $this->arrDay = $objDate->getDay();
87
88        //---- 登録用カラム配列
89        $arrRegistColumn = array(
90                                 array(  "column" => "name01",        "convert" => "aKV" ),
91                                 array(  "column" => "name02",        "convert" => "aKV" ),
92                                 array(  "column" => "kana01",        "convert" => "CKV" ),
93                                 array(  "column" => "kana02",        "convert" => "CKV" ),
94                                 array(  "column" => "zip01",        "convert" => "n" ),
95                                 array(  "column" => "zip02",        "convert" => "n" ),
96                                 array(  "column" => "pref",        "convert" => "n" ),
97                                 array(  "column" => "addr01",        "convert" => "aKV" ),
98                                 array(  "column" => "addr02",        "convert" => "aKV" ),
99                                 array(  "column" => "email",        "convert" => "a" ),
100                                 array(  "column" => "email_mobile",    "convert" => "a" ),
101                                 array(  "column" => "tel01",        "convert" => "n" ),
102                                 array(  "column" => "tel02",        "convert" => "n" ),
103                                 array(  "column" => "tel03",        "convert" => "n" ),
104                                 array(  "column" => "fax01",        "convert" => "n" ),
105                                 array(  "column" => "fax02",        "convert" => "n" ),
106                                 array(  "column" => "fax03",        "convert" => "n" ),
107                                 array(  "column" => "sex",            "convert" => "n" ),
108                                 array(  "column" => "job",            "convert" => "n" ),
109                                 array(  "column" => "birth",        "convert" => "n" ),
110                                 array(  "column" => "password",    "convert" => "a" ),
111                                 array(  "column" => "reminder",    "convert" => "n" ),
112                                 array(  "column" => "reminder_answer", "convert" => "aKV" ),
113                                 array(  "column" => "mailmaga_flg", "convert" => "n" ),
114                                 array(  "column" => "note",        "convert" => "aKV" ),
115                                 array(  "column" => "point",        "convert" => "n" ),
116                                 array(  "column" => "status",        "convert" => "n" )
117                                 );
118
119        //---- 登録除外用カラム配列
120        $arrRejectRegistColumn = array("year", "month", "day");
121
122        // 検索条件を保持
123        if ($_POST['mode'] == "edit_search") {
124            $arrSearch = $_POST;
125        }else{
126            $arrSearch = $_POST['search_data'];
127        }
128        if(is_array($arrSearch)){
129            foreach($arrSearch as $key => $val){
130                $arrSearchData[$key] = $val;
131            }
132        }
133
134        $this->arrSearchData= $arrSearchData;
135
136        //---- 顧客編集情報取得
137        if (($_POST["mode"] == "edit" || $_POST["mode"] == "edit_search") && is_numeric($_POST["edit_customer_id"])) {
138
139            //-- 顧客データ取得
140            $sql = "SELECT * FROM dtb_customer WHERE del_flg = 0 AND customer_id = ?";
141            $result = $this->objQuery->getAll($sql, array($_POST["edit_customer_id"]));
142            $this->list_data = $result[0];
143
144            $birth = split(" ", $this->list_data["birth"]);
145            $birth = split("-",$birth[0]);
146
147            $this->list_data["year"] = $birth[0];
148            $this->list_data["month"] = isset($birth[1]) ? $birth[1] : "";
149            $this->list_data["day"] = isset($birth[2]) ? $birth[2] : "";
150
151            $this->list_data["password"] = DEFAULT_PASSWORD;
152            //DB登録のメールアドレスを渡す
153            $this->tpl_edit_email = $result[0]['email'];
154            //購入履歴情報の取得
155            $this->arrPurchaseHistory = $this->lfPurchaseHistory($_POST['edit_customer_id']);
156            // 支払い方法の取得
157            $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
158        }
159
160        //---- 顧客情報編集
161        if ( $_POST["mode"] != "edit" && $_POST["mode"] != "edit_search" && is_numeric($_POST["customer_id"])) {
162
163            //-- POSTデータの引き継ぎ
164            $this->arrForm = $_POST;
165            $this->arrForm['email'] = strtolower($this->arrForm['email']);        // emailはすべて小文字で処理
166
167            //-- 入力データの変換
168            $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn);
169            //-- 入力チェック
170            $this->arrErr = $this->lfErrorCheck($this->arrForm);
171
172            //-- 入力エラー発生 or リターン時
173            if ($this->arrErr || $_POST["mode"] == "return") {
174                foreach($this->arrForm as $key => $val) {
175                    $this->list_data[ $key ] = $val;
176                }
177                //購入履歴情報の取得
178                $this->arrPurchaseHistory = $this->lfPurchaseHistory($_POST['customer_id']);
179                // 支払い方法の取得
180                $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
181
182            } else {
183                //-- 確認
184                if ($_POST["mode"] == "confirm") {
185                    $this->tpl_mainpage = 'customer/edit_confirm.tpl';
186                    $passlen = strlen($this->arrForm['password']);
187                    $this->passlen = SC_Utils_Ex::lfPassLen($passlen);
188
189                }
190                //-- 編集
191                if($_POST["mode"] == "complete") {
192                    $this->tpl_mainpage = 'customer/edit_complete.tpl';
193
194                    // 現在の会員情報を取得する
195                    $arrCusSts = $this->objQuery->getOne("SELECT status FROM dtb_customer WHERE customer_id = ?", array($_POST["customer_id"]));
196
197                    // 会員情報が変更されている場合にはシークレット№も更新する。
198                    if ($arrCusSts != $_POST['status']){
199                        $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
200                        $this->arrForm['secret_key'] = $secret;
201                        array_push($arrRegistColumn, array('column' => 'secret_key', 'convert' => 'n'));
202                    }
203                    //-- 編集登録
204                    $objCustomerHelper->sfEditCustomerDataAdmin($this->arrForm, $arrRegistColumn);
205                }
206            }
207        }
208    }
209
210    /**
211     * デストラクタ.
212     *
213     * @return void
214     */
215    function destroy() {
216        parent::destroy();
217    }
218
219    //---- 取得文字列の変換
220    function lfConvertParam($array, $arrRegistColumn) {
221        /*
222         *    文字列の変換
223         *    K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
224         *    C :  「全角ひら仮名」を「全角かた仮名」に変換
225         *    V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
226         *    n :  「全角」数字を「半角(ハンカク)」に変換
227         *  a :  全角英数字を半角英数字に変換する
228         */
229        // カラム名とコンバート情報
230        foreach ($arrRegistColumn as $data) {
231            $arrConvList[ $data["column"] ] = $data["convert"];
232        }
233        // 文字変換
234        foreach ($arrConvList as $key => $val) {
235            // POSTされてきた値のみ変換する。
236            if(strlen(($array[$key])) > 0) {
237                $array[$key] = mb_convert_kana($array[$key] ,$val);
238            }
239        }
240        return $array;
241    }
242
243    //---- 入力エラーチェック
244    function lfErrorCheck($array) {
245
246        $objErr = new SC_CheckError($array);
247
248        $objErr->doFunc(array("会員状態", 'status'), array("EXIST_CHECK"));
249        $objErr->doFunc(array("お名前(姓)", 'name01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
250        $objErr->doFunc(array("お名前(名)", 'name02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
251        $objErr->doFunc(array("お名前(フリガナ・姓)", 'kana01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
252        $objErr->doFunc(array("お名前(フリガナ・名)", 'kana02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
253        $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
254        $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
255        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
256        $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
257        $objErr->doFunc(array("住所(1)", "addr01", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
258        $objErr->doFunc(array("住所(2)", "addr02", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
259        $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
260
261        //現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
262        if (strlen($array["email"]) > 0) {
263            $array['email'] = strtolower($array['email']);
264            $sql = "SELECT customer_id FROM dtb_customer WHERE (email ILIKE ? escape '#' OR email_mobile ILIKE ? escape '#') AND (status = 1 OR status = 2) AND del_flg = 0 AND customer_id <> ?";
265            $checkMail = ereg_replace( "_", "#_", $array["email"]);
266            $result = $this->objQuery->getAll($sql, array($checkMail, $checkMail, $array["customer_id"]));
267            if (count($result) > 0) {
268                $objErr->arrErr["email"] .= "※ すでに登録されているメールアドレスです。<br />";
269            }
270        }
271
272        $objErr->doFunc(array('メールアドレス(モバイル)', "email_mobile", MTEXT_LEN) ,array("EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
273        //現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
274        if (strlen($array["email_mobile"]) > 0) {
275            $array['email_mobile'] = strtolower($array['email_mobile']);
276            $sql = "SELECT customer_id FROM dtb_customer WHERE (email ILIKE ? escape '#' OR email_mobile ILIKE ? escape '#') AND (status = 1 OR status = 2) AND del_flg = 0 AND customer_id <> ?";
277            $checkMail = ereg_replace( "_", "#_", $array["email_mobile"]);
278            $result = $this->objQuery->getAll($sql, array($checkMail, $checkMail, $array["customer_id"]));
279            if (count($result) > 0) {
280                $objErr->arrErr["email_mobile"] .= "※ すでに登録されているメールアドレス(モバイル)です。<br />";
281            }
282        }
283
284
285        $objErr->doFunc(array("お電話番号1", 'tel01'), array("EXIST_CHECK"));
286        $objErr->doFunc(array("お電話番号2", 'tel02'), array("EXIST_CHECK"));
287        $objErr->doFunc(array("お電話番号3", 'tel03'), array("EXIST_CHECK"));
288        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03") ,array("TEL_CHECK"));
289        $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
290        $objErr->doFunc(array("ご性別", "sex") ,array("SELECT_CHECK", "NUM_CHECK"));
291        $objErr->doFunc(array("ご職業", "job") ,array("NUM_CHECK"));
292        if ($array["password"] != DEFAULT_PASSWORD) {
293            $objErr->doFunc(array("パスワード", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK"));
294        }
295        $objErr->doFunc(array("パスワードを忘れたときのヒント 質問", "reminder") ,array("SELECT_CHECK", "NUM_CHECK"));
296        $objErr->doFunc(array("パスワードを忘れたときのヒント 答え", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
297        $objErr->doFunc(array("メールマガジン", "mailmaga_flg") ,array("SELECT_CHECK", "NUM_CHECK"));
298        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_DATE"));
299        $objErr->doFunc(array("SHOP用メモ", 'note', LTEXT_LEN), array("MAX_LENGTH_CHECK"));
300        $objErr->doFunc(array("所持ポイント", "point", TEL_LEN) ,array("MAX_LENGTH_CHECK", "NUM_CHECK"));
301        return $objErr->arrErr;
302
303    }
304
305    //購入履歴情報の取得
306    function lfPurchaseHistory($customer_id){
307        $this->tpl_pageno = $_POST['search_pageno'];
308        $this->edit_customer_id = $customer_id;
309
310        // ページ送りの処理
311        $page_max = SEARCH_PMAX;
312        //購入履歴の件数取得
313        $this->tpl_linemax = $this->objQuery->count("dtb_order","customer_id=? AND del_flg = 0 ", array($customer_id));
314        $linemax = $this->tpl_linemax;
315
316        // ページ送りの取得
317        $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchPage2", NAVI_PMAX);
318        $this->arrPagenavi = $objNavi->arrPagenavi;
319        $this->arrPagenavi['mode'] = 'edit';
320        $startno = $objNavi->start_row;
321
322        // 取得範囲の指定(開始行番号、行数のセット)
323        $this->objQuery->setLimitOffset($page_max, $startno);
324        // 表示順序
325        $order = "order_id DESC";
326        $this->objQuery->setOrder($order);
327        //購入履歴情報の取得
328        $arrPurchaseHistory = $this->objQuery->select("*", "dtb_order", "customer_id=? AND del_flg = 0 ", array($customer_id));
329
330        return $arrPurchaseHistory;
331    }
332
333}
334?>
Note: See TracBrowser for help on using the repository browser.