source: branches/rel/html/admin/customer/edit.php @ 12157

Revision 12157, 12.5 KB checked in by uehara, 16 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9// ǧ¾Ú²ÄÈݤÎȽÄê
10$objSess = new SC_Session();
11sfIsSuccess($objSess);
12
13//---- ¥Ú¡¼¥¸É½¼¨ÍÑ¥¯¥é¥¹
14class LC_Page {
15    var $arrSession;
16    var $tpl_mode;
17    var $list_data;
18
19    var $arrErr;
20    var $arrYear;
21    var $arrMonth;
22    var $arrDay;
23    var $arrPref;
24    var $arrJob;
25    var $arrSex;
26    var $arrReminder;
27    var $count;
28   
29    var $tpl_strnavi;
30               
31    function LC_Page() {
32        $this->tpl_mainpage = 'customer/edit.tpl';
33        $this->tpl_mainno = 'customer';
34        $this->tpl_subnavi = 'customer/subnavi.tpl';
35        $this->tpl_subno = 'index';
36        $this->tpl_pager = DATA_PATH . 'Smarty/templates/admin/pager.tpl';
37        $this->tpl_subtitle = '¸ÜµÒ¥Þ¥¹¥¿';
38
39        global $arrPref;
40        $this->arrPref = $arrPref;
41        global $arrJob;
42        $this->arrJob = $arrJob;
43        global $arrSex;     
44        $this->arrSex = $arrSex;
45        global $arrReminder;
46        $this->arrReminder = $arrReminder;
47    }
48}
49$objQuery = new SC_Query();
50$objConn = new SC_DBConn();
51$objPage = new LC_Page();
52$objView = new SC_AdminView();
53$objDate = new SC_Date(1901);
54$objPage->arrYear = $objDate->getYear();    //¡¡ÆüÉÕ¥×¥ë¥À¥¦¥óÀßÄê
55$objPage->arrMonth = $objDate->getMonth();
56$objPage->arrDay = $objDate->getDay();
57
58//---- ÅÐÏ¿ÍÑ¥«¥é¥àÇÛÎó
59$arrRegistColumn = array(
60                             array(  "column" => "name01",      "convert" => "aKV" ),
61                             array(  "column" => "name02",      "convert" => "aKV" ),
62                             array(  "column" => "kana01",      "convert" => "CKV" ),
63                             array(  "column" => "kana02",      "convert" => "CKV" ),
64                             array(  "column" => "zip01",       "convert" => "n" ),
65                             array(  "column" => "zip02",       "convert" => "n" ),
66                             array(  "column" => "pref",        "convert" => "n" ),
67                             array(  "column" => "addr01",      "convert" => "aKV" ),
68                             array(  "column" => "addr02",      "convert" => "aKV" ),
69                             array(  "column" => "email",       "convert" => "a" ),
70                             array(  "column" => "email_mobile",    "convert" => "a" ),
71                             array(  "column" => "tel01",       "convert" => "n" ),
72                             array(  "column" => "tel02",       "convert" => "n" ),
73                             array(  "column" => "tel03",       "convert" => "n" ),
74                             array(  "column" => "fax01",       "convert" => "n" ),
75                             array(  "column" => "fax02",       "convert" => "n" ),
76                             array(  "column" => "fax03",       "convert" => "n" ),
77                             array(  "column" => "sex",         "convert" => "n" ),
78                             array(  "column" => "job",         "convert" => "n" ),
79                             array(  "column" => "birth",       "convert" => "n" ),
80                             array(  "column" => "password",    "convert" => "a" ),
81                             array(  "column" => "reminder",    "convert" => "n" ),
82                             array(  "column" => "reminder_answer", "convert" => "aKV" ),
83                             array(  "column" => "mailmaga_flg", "convert" => "n" ),                         
84                             array(  "column" => "note",        "convert" => "aKV" ),
85                             array(  "column" => "point",       "convert" => "n" ),
86                             array(  "column" => "status",      "convert" => "n" )
87                         );
88
89//---- ÅÐÏ¿½ü³°ÍÑ¥«¥é¥àÇÛÎó
90$arrRejectRegistColumn = array("year", "month", "day");
91
92// ¸¡º÷¾ò·ï¤òÊÝ»ý
93if ($_POST['mode'] == "edit_search") {
94    $arrSearch = $_POST;
95}else{
96    $arrSearch = $_POST['search_data'];
97}
98if(is_array($arrSearch)){
99    foreach($arrSearch as $key => $val){
100        $arrSearchData[$key] = $val;
101    }
102}
103
104$objPage->arrSearchData= $arrSearchData;
105
106//----¡¡¸ÜµÒÊÔ½¸¾ðÊó¼èÆÀ
107if (($_POST["mode"] == "edit" || $_POST["mode"] == "edit_search") && is_numeric($_POST["edit_customer_id"])) {
108
109    //--¡¡¸ÜµÒ¥Ç¡¼¥¿¼èÆÀ
110    $sql = "SELECT * FROM dtb_customer WHERE del_flg = 0 AND customer_id = ?";
111    $result = $objConn->getAll($sql, array($_POST["edit_customer_id"]));
112    $objPage->list_data = $result[0];
113   
114    $birth = split(" ", $objPage->list_data["birth"]);
115    $birth = split("-",$birth[0]);
116   
117    $objPage->list_data["year"] = $birth[0];
118    $objPage->list_data["month"] = $birth[1];
119    $objPage->list_data["day"] = $birth[2];
120   
121    $objPage->list_data["password"] = DEFAULT_PASSWORD;
122    //DBÅÐÏ¿¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤òÅϤ¹
123    $objPage->tpl_edit_email = $result[0]['email'];
124    //¹ØÆþÍúÎò¾ðÊó¤Î¼èÆÀ
125    $objPage->arrPurchaseHistory = lfPurchaseHistory($_POST['edit_customer_id']);
126    // »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ
127    $objPage->arrPayment = sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
128}
129
130//----¡¡¸ÜµÒ¾ðÊóÊÔ½¸
131if ( $_POST["mode"] != "edit" && $_POST["mode"] != "edit_search" && is_numeric($_POST["customer_id"])) {
132
133    //-- POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
134    $objPage->arrForm = $_POST;
135    $objPage->arrForm['email'] = strtolower($objPage->arrForm['email']);        // email¤Ï¤¹¤Ù¤Æ¾®Ê¸»ú¤Ç½èÍý
136
137    //-- ÆþÎϥǡ¼¥¿¤ÎÊÑ´¹
138    $objPage->arrForm = lfConvertParam($objPage->arrForm, $arrRegistColumn);
139    //-- ÆþÎÏ¥Á¥§¥Ã¥¯
140    $objPage->arrErr = lfErrorCheck($objPage->arrForm);
141
142    //-- ÆþÎÏ¥¨¥é¡¼È¯À¸ or ¥ê¥¿¡¼¥ó»þ
143    if ($objPage->arrErr || $_POST["mode"] == "return") {
144        foreach($objPage->arrForm as $key => $val) {
145            $objPage->list_data[ $key ] = $val;
146        }
147        //¹ØÆþÍúÎò¾ðÊó¤Î¼èÆÀ
148        $objPage->arrPurchaseHistory = lfPurchaseHistory($_POST['customer_id']);
149        // »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ
150        $objPage->arrPayment = sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
151       
152    } else {
153        //-- ³Îǧ
154        if ($_POST["mode"] == "confirm") {
155            $objPage->tpl_mainpage = 'customer/edit_confirm.tpl';
156            $passlen = strlen($objPage->arrForm['password']);
157            $objPage->passlen = lfPassLen($passlen);
158           
159        }
160        //--¡¡ÊÔ½¸
161        if($_POST["mode"] == "complete") {
162            $objPage->tpl_mainpage = 'customer/edit_complete.tpl';
163           
164            // ¸½ºß¤Î²ñ°÷¾ðÊó¤ò¼èÆÀ¤¹¤ë
165            $arrCusSts = $objQuery->getOne("SELECT status FROM dtb_customer WHERE customer_id = ?", array($_POST["customer_id"]));
166
167            // ²ñ°÷¾ðÊó¤¬Êѹ¹¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¥·¡¼¥¯¥ì¥Ã¥È¢ñ¤â¹¹¿·¤¹¤ë¡£
168            if ($arrCusSts != $_POST['status']){
169                $secret = sfGetUniqRandomId("r");
170                $objPage->arrForm['secret_key'] = $secret;
171                array_push($arrRegistColumn, array('column' => 'secret_key', 'convert' => 'n'));
172            }
173            //-- ÊÔ½¸ÅÐÏ¿
174            sfEditCustomerData($objPage->arrForm, $arrRegistColumn);
175        }
176    }
177}
178
179//----¡¡¥Ú¡¼¥¸É½¼¨
180$objView->assignobj($objPage);
181$objView->display(MAIN_FRAME);
182
183
184
185//-------------- function
186
187// ÊÔ½¸ÅÐÏ¿
188function lfRegisDatat($array, $arrRegistColumn) {
189    global $objConn;
190    global $objQuery;
191    foreach ($arrRegistColumn as $data) {
192        if($array[$data["column"]] != "") {
193            $arrRegist[$data["column"]] = $array[$data["column"]];
194        } else {
195            $arrRegist[$data["column"]] = NULL;
196        }
197    }
198    if (strlen($array["year"]) > 0) {
199        $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
200    }
201
202    //-- ¥Ñ¥¹¥ï¡¼¥É¤Î¹¹¿·¤¬¤¢¤ë¾ì¹ç¤Ï°Å¹æ²½¡£¡Ê¹¹¿·¤¬¤Ê¤¤¾ì¹ç¤ÏUPDATEʸ¤ò¹½À®¤·¤Ê¤¤¡Ë
203    if ($array["password"] != DEFAULT_PASSWORD) {
204        $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC);
205    } else {
206        unset($arrRegist['password']);
207    }
208
209    $arrRegist["update_date"] = "Now()";
210
211    //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô
212    $objConn->query("BEGIN");
213    $objQuery->Insert("dtb_customer", $arrRegist, "customer_id = '" .addslashes($array["customer_id"]). "'");
214
215    $objConn->query("COMMIT");
216}
217
218
219//----¡¡¼èÆÀʸ»úÎó¤ÎÊÑ´¹
220function 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//---- ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
244function lfErrorCheck($array) {
245
246    global $objConn;
247    $objErr = new SC_CheckError($array);
248
249    $objErr->doFunc(array("²ñ°÷¾õÂÖ", 'status'), array("EXIST_CHECK"));
250    $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", 'name01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
251    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", 'name02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
252    $objErr->doFunc(array("¥Õ¥ê¥¬¥Ê¡ÊÀ«¡Ë", 'kana01', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
253    $objErr->doFunc(array("¥Õ¥ê¥¬¥Ê¡Ê̾¡Ë", 'kana02', STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
254    $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
255    $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
256    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
257    $objErr->doFunc(array("ÅÔÆ»Éܸ©", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
258    $objErr->doFunc(array("¤´½»½ê¡Ê1¡Ë", "addr01", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
259    $objErr->doFunc(array("¤´½»½ê¡Ê2¡Ë", "addr02", MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
260    $objErr->doFunc(array('¥á¡¼¥ë¥¢¥É¥ì¥¹', "email", MTEXT_LEN) ,array("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
261   
262    //¸½²ñ°÷¤ÎȽÄê ¢ª¡¡¸½²ñ°÷¤â¤·¤¯¤Ï²¾ÅÐÏ¿Ãæ¤Ï¡¢¥á¥¢¥É°ì°Õ¤¬Á°Äó¤Ë¤Ê¤Ã¤Æ¤ë¤Î¤ÇƱ¤¸¥á¥¢¥É¤ÇÅÐÏ¿ÉÔ²Ä
263    if (strlen($array["email"]) > 0) {
264        $sql = "SELECT customer_id FROM dtb_customer WHERE email ILIKE ? escape '#' AND (status = 1 OR status = 2) AND del_flg = 0 AND customer_id <> ?";
265        $checkMail = ereg_replace( "_", "#_", $array["email"]);
266        $result = $objConn->getAll($sql, array($checkMail, $array["customer_id"]));
267        if (count($result) > 0) {
268            $objErr->arrErr["email"] .= "¢¨ ¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ç¤¹¡£";
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        $sql = "SELECT customer_id FROM dtb_customer WHERE email_mobile ILIKE ? escape '#' AND (status = 1 OR status = 2) AND del_flg = 0 AND customer_id <> ?";
276        $checkMail = ereg_replace( "_", "#_", $array["email_mobile"]);
277        $result = $objConn->getAll($sql, array($checkMail, $array["customer_id"]));
278        if (count($result) > 0) {
279            $objErr->arrErr["email_mobile"] .= "¢¨ ¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹(¥â¥Ð¥¤¥ë)¤Ç¤¹¡£";
280        }
281    }
282   
283   
284    $objErr->doFunc(array("¤ªÅÅÏÃÈÖ¹æ1", 'tel01'), array("EXIST_CHECK"));
285    $objErr->doFunc(array("¤ªÅÅÏÃÈÖ¹æ2", 'tel02'), array("EXIST_CHECK"));
286    $objErr->doFunc(array("¤ªÅÅÏÃÈÖ¹æ3", 'tel03'), array("EXIST_CHECK"));
287    $objErr->doFunc(array("¤ªÅÅÏÃÈÖ¹æ", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
288    $objErr->doFunc(array("FAXÈÖ¹æ", "fax01", "fax02", "fax03", TEL_LEN) ,array("TEL_CHECK"));
289    $objErr->doFunc(array("¤´À­ÊÌ", "sex") ,array("SELECT_CHECK", "NUM_CHECK"));
290    $objErr->doFunc(array("¤´¿¦¶È", "job") ,array("NUM_CHECK"));
291    if ($array["password"] != DEFAULT_PASSWORD) {
292        $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É", 'password', PASSWORD_LEN1, PASSWORD_LEN2), array("EXIST_CHECK", "ALNUM_CHECK", "NUM_RANGE_CHECK"));
293    }
294    $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É¤ò˺¤ì¤¿¤È¤­¤Î¥Ò¥ó¥È ¼ÁÌä", "reminder") ,array("SELECT_CHECK", "NUM_CHECK"));
295    $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É¤ò˺¤ì¤¿¤È¤­¤Î¥Ò¥ó¥È Åú¤¨", "reminder_answer", STEXT_LEN) ,array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
296    $objErr->doFunc(array("¥á¡¼¥ë¥Þ¥¬¥¸¥ó", "mailmaga_flg") ,array("SELECT_CHECK", "NUM_CHECK"));
297    $objErr->doFunc(array("À¸Ç¯·îÆü", "year", "month", "day"), array("CHECK_DATE"));
298    $objErr->doFunc(array("SHOPÍÑ¥á¥â", 'note', LTEXT_LEN), array("MAX_LENGTH_CHECK"));
299    $objErr->doFunc(array("½ê»ý¥Ý¥¤¥ó¥È", "point", TEL_LEN) ,array("MAX_LENGTH_CHECK", "NUM_CHECK"));
300    return $objErr->arrErr;
301   
302}
303
304//¹ØÆþÍúÎò¾ðÊó¤Î¼èÆÀ
305function lfPurchaseHistory($customer_id){
306        global $objQuery;
307        global $objPage;
308       
309        $objPage->tpl_pageno = $_POST['search_pageno'];
310        $objPage->edit_customer_id = $customer_id;
311
312        // ¥Ú¡¼¥¸Á÷¤ê¤Î½èÍý
313        $page_max = SEARCH_PMAX;
314        //¹ØÆþÍúÎò¤Î·ï¿ô¼èÆÀ
315        $objPage->tpl_linemax = $objQuery->count("dtb_order","customer_id=? AND del_flg = 0 ", array($customer_id));
316        $linemax = $objPage->tpl_linemax;
317       
318        // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ
319        $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchPage2", NAVI_PMAX);
320        $objPage->arrPagenavi = $objNavi->arrPagenavi;
321        $objPage->arrPagenavi['mode'] = 'edit';
322        $startno = $objNavi->start_row;
323       
324        // ¼èÆÀÈϰϤλØÄê(³«»Ï¹ÔÈֹ桢¹Ô¿ô¤Î¥»¥Ã¥È)
325        $objQuery->setlimitoffset($page_max, $startno);
326        // ɽ¼¨½ç½ø
327        $order = "order_id DESC";
328        $objQuery->setorder($order);
329        //¹ØÆþÍúÎò¾ðÊó¤Î¼èÆÀ
330        $arrPurchaseHistory = $objQuery->select("*", "dtb_order", "customer_id=? AND del_flg = 0 ", array($customer_id));
331       
332        return $arrPurchaseHistory;
333}
334
335//³Îǧ¥Ú¡¼¥¸Íѥѥ¹¥ï¡¼¥Éɽ¼¨ÍÑ
336
337function lfPassLen($passlen){
338    $ret = "";
339    for ($i=0;$i<$passlen;true){
340        $ret.="*";
341        $i++;
342    }
343    return $ret;
344}
345
346
347?>
Note: See TracBrowser for help on using the repository browser.