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

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