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

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