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 |
---|
25 | require_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 | */ |
---|
34 | class LC_Page_Admin_Customer_Customer 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/customer.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 | $objDate = new SC_Date(1901); |
---|
82 | $this->arrYear = $objDate->getYear(); // 日付プルダウン設定 |
---|
83 | $this->arrMonth = $objDate->getMonth(); |
---|
84 | $this->arrDay = $objDate->getDay(); |
---|
85 | |
---|
86 | //---- 登録用カラム配列 |
---|
87 | $arrRegistColumn = array( |
---|
88 | array( "column" => "name01", "convert" => "aKV" ), |
---|
89 | array( "column" => "name02", "convert" => "aKV" ), |
---|
90 | array( "column" => "kana01", "convert" => "CKV" ), |
---|
91 | array( "column" => "kana02", "convert" => "CKV" ), |
---|
92 | array( "column" => "zip01", "convert" => "n" ), |
---|
93 | array( "column" => "zip02", "convert" => "n" ), |
---|
94 | array( "column" => "pref", "convert" => "n" ), |
---|
95 | array( "column" => "addr01", "convert" => "aKV" ), |
---|
96 | array( "column" => "addr02", "convert" => "aKV" ), |
---|
97 | array( "column" => "email", "convert" => "a" ), |
---|
98 | array( "column" => "email_mobile", "convert" => "a" ), |
---|
99 | array( "column" => "tel01", "convert" => "n" ), |
---|
100 | array( "column" => "tel02", "convert" => "n" ), |
---|
101 | array( "column" => "tel03", "convert" => "n" ), |
---|
102 | array( "column" => "fax01", "convert" => "n" ), |
---|
103 | array( "column" => "fax02", "convert" => "n" ), |
---|
104 | array( "column" => "fax03", "convert" => "n" ), |
---|
105 | array( "column" => "sex", "convert" => "n" ), |
---|
106 | array( "column" => "job", "convert" => "n" ), |
---|
107 | array( "column" => "birth", "convert" => "n" ), |
---|
108 | array( "column" => "password", "convert" => "a" ), |
---|
109 | array( "column" => "reminder", "convert" => "n" ), |
---|
110 | array( "column" => "reminder_answer", "convert" => "aKV" ), |
---|
111 | array( "column" => "mailmaga_flg", "convert" => "n" ), |
---|
112 | array( "column" => "note", "convert" => "aKV" ), |
---|
113 | array( "column" => "point", "convert" => "n" ), |
---|
114 | array( "column" => "status", "convert" => "n" ) |
---|
115 | ); |
---|
116 | |
---|
117 | //---- 登録除外用カラム配列 |
---|
118 | $arrRejectRegistColumn = array("year", "month", "day"); |
---|
119 | |
---|
120 | //---- 顧客情報編集 |
---|
121 | if ($_POST["mode"] == "confirm" || $_POST["mode"] == "complete" || $_POST["mode"] == "return") { |
---|
122 | |
---|
123 | //-- POSTデータの引き継ぎ |
---|
124 | $this->arrForm = $_POST; |
---|
125 | $this->arrForm['email'] = strtolower($this->arrForm['email']); // emailはすべて小文字で処理 |
---|
126 | |
---|
127 | //-- 入力データの変換 |
---|
128 | $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn); |
---|
129 | //-- 入力チェック |
---|
130 | $this->arrErr = $this->lfErrorCheck($this->arrForm); |
---|
131 | |
---|
132 | //-- 入力エラー発生 or リターン時 |
---|
133 | if ($this->arrErr || $_POST["mode"] == "return") { |
---|
134 | foreach($this->arrForm as $key => $val) { |
---|
135 | $this->list_data[ $key ] = $val; |
---|
136 | } |
---|
137 | |
---|
138 | } else { |
---|
139 | //-- 確認 |
---|
140 | if ($_POST["mode"] == "confirm") { |
---|
141 | $this->tpl_mainpage = 'customer/customer_confirm.tpl'; |
---|
142 | $passlen = strlen($this->arrForm['password']); |
---|
143 | $this->passlen = $this->lfPassLen($passlen); |
---|
144 | |
---|
145 | } |
---|
146 | //-- 登録 |
---|
147 | if($_POST["mode"] == "complete") { |
---|
148 | $this->tpl_mainpage = 'customer/customer_complete.tpl'; |
---|
149 | |
---|
150 | // シークレット№も登録する。 |
---|
151 | $secret = SC_Utils_Ex::sfGetUniqRandomId("r"); |
---|
152 | $this->arrForm['secret_key'] = $secret; |
---|
153 | array_push($arrRegistColumn, array('column' => 'secret_key', 'convert' => 'n')); |
---|
154 | |
---|
155 | //-- 登録 |
---|
156 | $this->lfRegisData($this->arrForm, $arrRegistColumn); |
---|
157 | } |
---|
158 | } |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | /** |
---|
163 | * デストラクタ. |
---|
164 | * |
---|
165 | * @return void |
---|
166 | */ |
---|
167 | function destroy() { |
---|
168 | parent::destroy(); |
---|
169 | } |
---|
170 | |
---|
171 | // 編集登録 |
---|
172 | function lfRegisData($array, $arrRegistColumn) { |
---|
173 | |
---|
174 | foreach ($arrRegistColumn as $data) { |
---|
175 | if($array[$data["column"]] != "") { |
---|
176 | $arrRegist[$data["column"]] = $array[$data["column"]]; |
---|
177 | } else { |
---|
178 | $arrRegist[$data["column"]] = NULL; |
---|
179 | } |
---|
180 | } |
---|
181 | if (strlen($array["year"]) > 0) { |
---|
182 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
---|
183 | } |
---|
184 | |
---|
185 | //-- パスワードの更新がある場合は暗号化。(更新がない場合はUPDATE文を構成しない) |
---|
186 | if ($array["password"] != DEFAULT_PASSWORD) { |
---|
187 | $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
---|
188 | } else { |
---|
189 | unset($arrRegist['password']); |
---|
190 | } |
---|
191 | |
---|
192 | $arrRegist["update_date"] = "Now()"; |
---|
193 | |
---|
194 | //-- 編集登録実行 |
---|
195 | $this->objQuery->begin(); |
---|
196 | $arrRegist['customer_id'] = $this->objQuery->nextVal('dtb_customer_customer_id'); |
---|
197 | $this->objQuery->Insert("dtb_customer", $arrRegist); |
---|
198 | $this->objQuery->commit(); |
---|
199 | } |
---|
200 | |
---|
201 | |
---|
202 | //---- 取得文字列の変換 |
---|
203 | function lfConvertParam($array, $arrRegistColumn) { |
---|
204 | /* |
---|
205 | * 文字列の変換 |
---|
206 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
207 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
208 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
209 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
210 | * a : 全角英数字を半角英数字に変換する |
---|
211 | */ |
---|
212 | // カラム名とコンバート情報 |
---|
213 | foreach ($arrRegistColumn as $data) { |
---|
214 | $arrConvList[ $data["column"] ] = $data["convert"]; |
---|
215 | } |
---|
216 | // 文字変換 |
---|
217 | foreach ($arrConvList as $key => $val) { |
---|
218 | // POSTされてきた値のみ変換する。 |
---|
219 | if(strlen(($array[$key])) > 0) { |
---|
220 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
221 | } |
---|
222 | } |
---|
223 | return $array; |
---|
224 | } |
---|
225 | |
---|
226 | //---- 入力エラーチェック |
---|
227 | function lfErrorCheck($array) { |
---|
228 | |
---|
229 | $objErr = new SC_CheckError($array); |
---|
230 | |
---|
231 | $objErr->doFunc(array("会員状態", 'status'), array("EXIST_CHECK")); |
---|
232 | $objErr->doFunc(array("お名前(姓)", 'name01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
233 | $objErr->doFunc(array("お名前(名)", 'name02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
234 | $objErr->doFunc(array("お名前(フリガナ・姓)", 'kana01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
235 | $objErr->doFunc(array("お名前(フリガナ・名)", 'kana02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
236 | $objErr->doFunc(array("郵便番号1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
237 | $objErr->doFunc(array("郵便番号2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
238 | $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK")); |
---|
239 | $objErr->doFunc(array("都道府県", 'pref'), array("SELECT_CHECK","NUM_CHECK")); |
---|
240 | $objErr->doFunc(array("住所(1)", "addr01", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
241 | $objErr->doFunc(array("住所(2)", "addr02", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
242 | $objErr->doFunc(array('メールアドレス', "email", MTEXT_LEN) ,array("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); |
---|
243 | |
---|
244 | //現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可 |
---|
245 | if (strlen($array["email"]) > 0) { |
---|
246 | $array['email'] = strtolower($array['email']); |
---|
247 | $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 <> ?"; |
---|
248 | $checkMail = ereg_replace( "_", "#_", $array["email"]); |
---|
249 | $result = $this->objQuery->getAll($sql, array($checkMail, $checkMail, $array["customer_id"])); |
---|
250 | if (count($result) > 0) { |
---|
251 | $objErr->arrErr["email"] .= "※ すでに登録されているメールアドレスです。<br />"; |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | $objErr->doFunc(array('メールアドレス(モバイル)', "email_mobile", MTEXT_LEN) ,array("EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); |
---|
256 | //現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可 |
---|
257 | if (strlen($array["email_mobile"]) > 0) { |
---|
258 | $array['email_mobile'] = strtolower($array['email_mobile']); |
---|
259 | $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 <> ?"; |
---|
260 | $checkMail = ereg_replace( "_", "#_", $array["email_mobile"]); |
---|
261 | $result = $this->objQuery->getAll($sql, array($checkMail, $checkMail, $array["customer_id"])); |
---|
262 | if (count($result) > 0) { |
---|
263 | $objErr->arrErr["email_mobile"] .= "※ すでに登録されているメールアドレス(モバイル)です。<br />"; |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | |
---|
268 | $objErr->doFunc(array("お電話番号1", 'tel01'), array("EXIST_CHECK")); |
---|
269 | $objErr->doFunc(array("お電話番号2", 'tel02'), array("EXIST_CHECK")); |
---|
270 | $objErr->doFunc(array("お電話番号3", 'tel03'), array("EXIST_CHECK")); |
---|
271 | $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03") ,array("TEL_CHECK")); |
---|
272 | $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK")); |
---|
273 | $objErr->doFunc(array("ご性別", "sex") ,array("SELECT_CHECK", "NUM_CHECK")); |
---|
274 | $objErr->doFunc(array("ご職業", "job") ,array("NUM_CHECK")); |
---|
275 | if ($array["password"] != DEFAULT_PASSWORD) { |
---|
276 | $objErr->doFunc(array("パスワード", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK")); |
---|
277 | } |
---|
278 | $objErr->doFunc(array("パスワードを忘れたときのヒント 質問", "reminder") ,array("SELECT_CHECK", "NUM_CHECK")); |
---|
279 | $objErr->doFunc(array("パスワードを忘れたときのヒント 答え", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
280 | $objErr->doFunc(array("メールマガジン", "mailmaga_flg") ,array("SELECT_CHECK", "NUM_CHECK")); |
---|
281 | $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_DATE")); |
---|
282 | $objErr->doFunc(array("SHOP用メモ", 'note', LTEXT_LEN), array("MAX_LENGTH_CHECK")); |
---|
283 | $objErr->doFunc(array("所持ポイント", "point", TEL_LEN) ,array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
284 | return $objErr->arrErr; |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | |
---|
289 | //確認ページ用パスワード表示用 |
---|
290 | function lfPassLen($passlen){ |
---|
291 | $ret = ""; |
---|
292 | for ($i=0;$i<$passlen;true){ |
---|
293 | $ret.="*"; |
---|
294 | $i++; |
---|
295 | } |
---|
296 | return $ret; |
---|
297 | } |
---|
298 | |
---|
299 | } |
---|
300 | ?> |
---|