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

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