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

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