source: branches/dev/html/mobile/nonmember/deliv_addr.php @ 12798

Revision 12798, 12.2 KB checked in by nakanishi, 15 years ago (diff)
Line 
1<?php
2/**
3 *
4 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 * ÇÛÁ÷Àè¤ÎÄɲÃ
9 */
10require_once("../require.php");
11
12class LC_Page{
13    function LC_Page(){
14        $this->tpl_mainpage = 'nonmember/deliv_addr.tpl';
15        $this->tpl_title = "¾¤Î¤ªÆϤ±Àè¤ÎÅÐÏ¿";
16    }
17}
18
19$objPage = new LC_Page();
20$objView = new SC_MobileView(false);
21$objQuery = new SC_Query();
22$objCustomer = new SC_Customer();
23$objConn = new SC_DBConn();
24$objSiteSess = new SC_SiteSession();
25$objCartSess = new SC_CartSession();
26
27////¥í¥°¥¤¥óȽÄê
28//if (!$objCustomer->isLoginSuccess()){
29//  sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
30//}
31
32$objPage->arrForm = $_POST;
33$objPage->arrPref = $arrPref;
34
35//Ê̤ΤªÆϤ±Àè£Ä£ÂÅÐÏ¿ÍÑ¥«¥é¥àÇÛÎó
36$arrRegistColumn = array(
37                             array(  "column" => "name01",      "convert" => "aKV" ),
38                             array(  "column" => "name02",      "convert" => "aKV" ),
39                             array(  "column" => "kana01",      "convert" => "CKV" ),
40                             array(  "column" => "kana02",      "convert" => "CKV" ),
41                             array(  "column" => "zip01",       "convert" => "n" ),
42                             array(  "column" => "zip02",       "convert" => "n" ),
43                             array(  "column" => "pref",        "convert" => "n" ),
44                             array(  "column" => "addr01",      "convert" => "aKV" ),
45                             array(  "column" => "addr02",      "convert" => "aKV" ),
46                             array(  "column" => "tel01",       "convert" => "n" ),
47                             array(  "column" => "tel02",       "convert" => "n" ),
48                             array(  "column" => "tel03",       "convert" => "n" ),
49                        );
50
51//-- ¥Ç¡¼¥¿ÀßÄê
52foreach($_POST as $key => $val) {
53    if ($key != "mode" && $key != "return" && $key != "submit" && $key != session_name()) {
54        $objPage->list_data[ $key ] = $val;
55    }
56}
57
58
59
60// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
61$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
62
63print_r($objPage->arrForm);
64print("<br>");                       
65 //-- ÆþÎϥǡ¼¥¿¤ÎÊÑ´¹
66    $objPage->arrForm = lfConvertParam($objPage->arrForm, $arrRegistColumn);
67print_r($objPage->arrForm);
68print_r(lfErrorCheck1($objPage->arrForm));                       
69
70// Ìá¤ë¥Ü¥¿¥óÍѽèÍý
71if (!empty($_POST["return"])) {
72    switch ($_POST["mode"]) {
73    case 'complete':
74        $_POST["mode"] = "set2";
75        break;
76    case 'set2':
77        $_POST["mode"] = "set1";
78        break;
79    default:
80        header("Location: " . gfAddSessionId('index.php'));
81        exit;
82    }
83}
84
85switch ($_POST['mode']){
86    case 'set1':
87        $objPage->arrErr = lfErrorCheck1($objPage->arrForm);
88        if (count($objPage->arrErr) == 0 && empty($_POST["return"])) {
89            $objPage->tpl_mainpage = 'nonmember/set1.tpl';
90
91            $checkVal = array("pref", "addr01", "addr02", "addr03", "tel01", "tel02", "tel03");
92            foreach($checkVal as $key) {
93                unset($objPage->list_data[$key]);
94            }
95
96            // ͹ÊØÈֹ椫¤é½»½ê¤Î¼èÆÀ
97            if (@$objPage->arrForm['pref'] == "" && @$objPage->arrForm['addr01'] == "" && @$objPage->arrForm['addr02'] == "") {
98                $address = lfGetAddress($_REQUEST['zip01'].$_REQUEST['zip02']);
99
100                $objPage->arrForm['pref'] = @$address[0]['state'];
101                $objPage->arrForm['addr01'] = @$address[0]['city'] . @$address[0]['town'];
102            }
103        } else {
104            $checkVal = array("name01", "name02", "kana01", "kana02", "zip01", "zip02");
105            foreach($checkVal as $key) {
106                unset($objPage->list_data[$key]);
107            }
108        }
109        break;
110    case 'set2':
111        $objPage->arrErr = lfErrorCheck2($objPage->arrForm);
112        if (count($objPage->arrErr) == 0 && empty($_POST["return"])) {
113            $objPage->tpl_mainpage = 'nonmember/set2.tpl';
114        } else {
115            $objPage->tpl_mainpage = 'nonmember/set1.tpl';
116
117            $checkVal = array("pref", "addr01", "addr02", "addr03", "tel01", "tel02", "tel03");
118            foreach($checkVal as $key) {
119                unset($objPage->list_data[$key]);
120            }
121        }
122        break;
123    case 'complete':
124        $objPage->arrErr = lfErrorCheck($objPage->arrForm);
125        if (count($objPage->arrErr) == 0) {
126            // ÅÐÏ¿
127            $other_deliv_id = lfRegistData($_POST,$arrRegistColumn,$uniqid);
128
129            // ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
130            lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id);
131
132            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
133            $objSiteSess->setRegistFlag();
134            // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
135            header("Location: " . gfAddSessionId(MOBILE_URL_SHOP_PAYMENT));
136            exit;
137        } else {
138            sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
139        }
140        break;
141    default:
142        $deliv_count = $objQuery->count("dtb_other_deliv", "customer_id=?", array($objCustomer->getValue('customer_id')));
143        if ($deliv_count >= DELIV_ADDR_MAX){
144            sfDispSiteError(FREE_ERROR_MSG, "", false, "ºÇÂçÅÐÏ¿·ï¿ô¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£");
145        }
146}
147
148$objView->assignobj($objPage);
149$objView->display(SITE_FRAME);
150
151//-------------------------------------------------------------------------------------------------------------
152
153//----¡¡¼èÆÀʸ»úÎó¤ÎÊÑ´¹
154function lfConvertParam($array, $arrRegistColumn) {
155    /*
156     *  ʸ»úÎó¤ÎÊÑ´¹
157     *  K :  ¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
158     *  C :  ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
159     *  V :  ÂùÅÀÉÕ¤­¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹
160     *  n :  ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)¡×¤ËÊÑ´¹
161     *  a :  Á´³Ñ±Ñ¿ô»ú¤òȾ³Ñ±Ñ¿ô»ú¤ËÊÑ´¹¤¹¤ë
162     */
163    // ¥«¥é¥à̾¤È¥³¥ó¥Ð¡¼¥È¾ðÊó
164    print("251");   
165    foreach ($arrRegistColumn as $data) {
166        $arrConvList[ $data["column"] ] = $data["convert"];
167    }
168   
169    // ʸ»úÊÑ´¹
170    foreach ($arrConvList as $key => $val) {
171        // POST¤µ¤ì¤Æ¤­¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£
172        if(strlen(($array[$key])) > 0) {
173            $array[$key] = mb_convert_kana($array[$key] ,$val);
174        }
175    }
176    return $array;
177}
178
179/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
180function lfErrorCheck() {
181    $objErr = new SC_CheckError();
182   
183    $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", 'name01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
184    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", 'name02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK"));
185    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/À«¡Ë", 'kana01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
186    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/̾¡Ë", 'kana02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
187    $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
188    $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
189    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
190    $objErr->doFunc(array("ÅÔÆ»Éܸ©", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
191    $objErr->doFunc(array("»Ô¶èĮ¼", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
192    $objErr->doFunc(array("ÈÖÃÏ", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
193    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ1", 'tel01'), array("EXIST_CHECK","NUM_CHECK"));
194    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ2", 'tel02'), array("EXIST_CHECK","NUM_CHECK"));
195    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ3", 'tel03'), array("EXIST_CHECK","NUM_CHECK"));
196    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
197    return $objErr->arrErr;
198   
199}
200
201/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
202function lfErrorCheck1() {
203    $objErr = new SC_CheckError();
204   
205    $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", 'name01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
206    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", 'name02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK"));
207    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/À«¡Ë", 'kana01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
208    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/̾¡Ë", 'kana02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
209    $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
210    $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
211    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
212    return $objErr->arrErr;
213   
214}
215
216/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
217function lfErrorCheck2() {
218    $objErr = new SC_CheckError();
219   
220    $objErr->doFunc(array("ÅÔÆ»Éܸ©", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
221    $objErr->doFunc(array("»Ô¶èĮ¼", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
222    $objErr->doFunc(array("ÈÖÃÏ", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
223    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ1", 'tel01'), array("EXIST_CHECK","NUM_CHECK"));
224    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ2", 'tel02'), array("EXIST_CHECK","NUM_CHECK"));
225    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ3", 'tel03'), array("EXIST_CHECK","NUM_CHECK"));
226    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
227    return $objErr->arrErr;
228   
229}
230
231
232
233/* ÅÐÏ¿¼Â¹Ô Èó²ñ°÷¹ØÆþ¤Ç¤¢¤ë¤¿¤á¤Ë¹±µ×Ū¤ÊÅÐÏ¿¤Ï¤·¤Ê¤¤*/
234function lfRegistData($array, $arrRegistColumn,$uniqid) {
235    global $objConn;
236    global $objCustomer;
237   
238    $objQuery = new SC_Query();
239   
240    $sqlse = "SELECT customer_id FROM dtb_order_temp WHERE order_temp_id = ?";
241    $arrRegist['customer_id'] = $objConn->getOne($sqlse, array($uniqid));
242   
243    foreach ($arrRegistColumn as $data) {
244        if (strlen($array[ $data["column"] ]) > 0) {
245            $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
246        }
247    }
248   
249    //$arrRegist['customer_id'] = $objCustomer->getvalue('customer_id');
250   
251    //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô
252    $objConn->query("BEGIN");
253    if ($array['other_deliv_id'] != ""){
254        $objConn->autoExecute("dtb_other_deliv", $arrRegist, "other_deliv_id='" .addslashes($array["other_deliv_id"]). "'");
255    }else{
256        $objConn->autoExecute("dtb_other_deliv", $arrRegist);
257
258        $sqlse = "SELECT max(other_deliv_id) FROM dtb_other_deliv WHERE customer_id = ?";
259        $array['other_deliv_id'] = $objConn->getOne($sqlse, array($arrRegist['customer_id']));
260    }
261
262    $objConn->query("COMMIT");
263
264    return $array['other_deliv_id'];
265}
266
267
268
269// ͹ÊØÈֹ椫¤é½»½ê¤Î¼èÆÀ
270function lfGetAddress($zipcode) {
271    global $arrPref;
272
273    $conn = new SC_DBconn(ZIP_DSN);
274
275    // ͹ÊØÈֹ渡º÷ʸºîÀ®
276    $zipcode = mb_convert_kana($zipcode ,"n");
277    $sqlse = "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?";
278
279    $data_list = $conn->getAll($sqlse, array($zipcode));
280
281    // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÈÃͤòȿž¤µ¤»¤ë¡£
282    $arrREV_PREF = array_flip($arrPref);
283
284    /*
285        Áí̳¾Ê¤«¤é¥À¥¦¥ó¥í¡¼¥É¤·¤¿¥Ç¡¼¥¿¤ò¤½¤Î¤Þ¤Þ¥¤¥ó¥Ý¡¼¥È¤¹¤ë¤È
286        °Ê²¼¤Î¤è¤¦¤Êʸ»úÎó¤¬Æþ¤Ã¤Æ¤¤¤ë¤Î¤Ç  Âкö¤¹¤ë¡£
287        ¡¦¡Ê£±¡¦£±£¹ÃúÌÜ¡Ë
288        ¡¦°Ê²¼¤Ë·ÇºÜ¤¬¤Ê¤¤¾ì¹ç
289    */
290    $town =  $data_list[0]['town'];
291    $town = ereg_replace("¡Ê.*¡Ë$","",$town);
292    $town = ereg_replace("°Ê²¼¤Ë·ÇºÜ¤¬¤Ê¤¤¾ì¹ç","",$town);
293    $data_list[0]['town'] = $town;
294    $data_list[0]['state'] = $arrREV_PREF[$data_list[0]['state']];
295
296    return $data_list;
297}
298
299/* Ê̤ΤªÆϤ±Àè½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
300function lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id) {
301    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
302    $sqlval['order_temp_id'] = $uniqid;
303    $sqlval['update_date'] = 'Now()';
304    $sqlval['customer_id'] = '0';
305    //$sqlval['customer_id'] = $objCustomer->getValue('customer_id');
306    $sqlval['order_birth'] = $objCustomer->getValue('birth');
307
308    $objQuery = new SC_Query();
309    $where = "other_deliv_id = ?";
310    $arrRet = $objQuery->select("*", "dtb_other_deliv", $where, array($other_deliv_id));
311   
312    $sqlval['deliv_check'] = '1';
313    $sqlval['deliv_name01'] = $arrRet[0]['name01'];
314    $sqlval['deliv_name02'] = $arrRet[0]['name02'];
315    $sqlval['deliv_kana01'] = $arrRet[0]['kana01'];
316    $sqlval['deliv_kana02'] = $arrRet[0]['kana02'];
317    $sqlval['deliv_zip01'] = $arrRet[0]['zip01'];
318    $sqlval['deliv_zip02'] = $arrRet[0]['zip02'];
319    $sqlval['deliv_pref'] = $arrRet[0]['pref'];
320    $sqlval['deliv_addr01'] = $arrRet[0]['addr01'];
321    $sqlval['deliv_addr02'] = $arrRet[0]['addr02'];
322    $sqlval['deliv_tel01'] = $arrRet[0]['tel01'];
323    $sqlval['deliv_tel02'] = $arrRet[0]['tel02'];
324    $sqlval['deliv_tel03'] = $arrRet[0]['tel03'];
325    sfRegistTempOrder($uniqid, $sqlval);
326}
327
328?>
Note: See TracBrowser for help on using the repository browser.