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

Revision 14821, 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$_SESSION["test"]= "test";
28sfprintr($_SESSION);
29
30$objPage->arrForm = $_POST;
31$objPage->arrPref = $arrPref;
32
33//Ê̤ΤªÆϤ±Àè£Ä£ÂÅÐÏ¿ÍÑ¥«¥é¥àÇÛÎó
34$arrRegistColumn = array(
35                             array(  "column" => "name01",      "convert" => "aKV" ),
36                             array(  "column" => "name02",      "convert" => "aKV" ),
37                             array(  "column" => "kana01",      "convert" => "CKV" ),
38                             array(  "column" => "kana02",      "convert" => "CKV" ),
39                             array(  "column" => "zip01",       "convert" => "n" ),
40                             array(  "column" => "zip02",       "convert" => "n" ),
41                             array(  "column" => "pref",        "convert" => "n" ),
42                             array(  "column" => "addr01",      "convert" => "aKV" ),
43                             array(  "column" => "addr02",      "convert" => "aKV" ),
44                             array(  "column" => "tel01",       "convert" => "n" ),
45                             array(  "column" => "tel02",       "convert" => "n" ),
46                             array(  "column" => "tel03",       "convert" => "n" ),
47                        );
48
49//-- ¥Ç¡¼¥¿ÀßÄê
50foreach($_POST as $key => $val) {
51    if ($key != "mode" && $key != "return" && $key != "submit" && $key != session_name()) {
52        $objPage->list_data[ $key ] = $val;
53    }
54}
55
56// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
57$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
58                     
59 //-- ÆþÎϥǡ¼¥¿¤ÎÊÑ´¹
60    $objPage->arrForm = lfConvertParam($objPage->arrForm, $arrRegistColumn);                       
61// Ìá¤ë¥Ü¥¿¥óÍѽèÍý
62if (!empty($_POST["return"])) {
63    switch ($_POST["mode"]) {
64    case 'complete':
65        $_POST["mode"] = "set2";
66        break;
67    case 'set2':
68        $_POST["mode"] = "set1";
69        break;
70    default:
71        header("Location: " . gfAddSessionId('index.php'));
72        exit;
73
74    }
75}else{
76   
77}
78
79switch ($_POST['mode']){
80    case 'set1':
81        $objPage->arrErr = lfErrorCheck1($objPage->arrForm);
82        if (count($objPage->arrErr) == 0 && empty($_POST["return"])) {
83            $objPage->tpl_mainpage = 'nonmember/set1.tpl';
84
85            $checkVal = array("pref", "addr01", "addr02", "addr03", "tel01", "tel02", "tel03");
86            foreach($checkVal as $key) {
87                unset($objPage->list_data[$key]);
88            }
89
90            // ͹ÊØÈֹ椫¤é½»½ê¤Î¼èÆÀ
91            if (@$objPage->arrForm['pref'] == "" && @$objPage->arrForm['addr01'] == "" && @$objPage->arrForm['addr02'] == "") {
92                $address = lfGetAddress($_REQUEST['zip01'].$_REQUEST['zip02']);
93
94                $objPage->arrForm['pref'] = @$address[0]['state'];
95                $objPage->arrForm['addr01'] = @$address[0]['city'] . @$address[0]['town'];
96            }
97        } else {
98            $checkVal = array("name01", "name02", "kana01", "kana02", "zip01", "zip02");
99            foreach($checkVal as $key) {
100                unset($objPage->list_data[$key]);
101            }
102        }
103        break;
104    case 'set2':
105        $objPage->arrErr = lfErrorCheck2($objPage->arrForm);
106        if (count($objPage->arrErr) == 0 && empty($_POST["return"])) {
107            $objPage->tpl_mainpage = 'nonmember/set2.tpl';
108        } else {
109            $objPage->tpl_mainpage = 'nonmember/set1.tpl';
110
111            $checkVal = array("pref", "addr01", "addr02", "addr03", "tel01", "tel02", "tel03");
112            foreach($checkVal as $key) {
113                unset($objPage->list_data[$key]);
114            }
115        }
116        break;
117    case 'complete':
118        $objPage->arrErr = lfErrorCheck($objPage->arrForm);
119        if (count($objPage->arrErr) == 0) {
120            // ÅÐÏ¿
121            $other_deliv_id = lfRegistData($_POST,$arrRegistColumn,$uniqid);
122           
123            // ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
124            lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id);
125
126            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
127            $objSiteSess->setRegistFlag();
128            // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
129            header("Location: " . gfAddSessionId('./payment.php'));
130            exit;
131        } else {
132            sfDispSiteError(CUSTOMER_ERROR, "", false, "", true);
133        }
134        break;
135    default:
136        $deliv_count = $objQuery->count("dtb_other_deliv", "customer_id=?", array($objCustomer->getValue('customer_id')));
137        if ($deliv_count >= DELIV_ADDR_MAX){
138            sfDispSiteError(FREE_ERROR_MSG, "", false, "ºÇÂçÅÐÏ¿·ï¿ô¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£");
139        }
140}
141
142$objView->assignobj($objPage);
143$objView->display(SITE_FRAME);
144
145//-------------------------------------------------------------------------------------------------------------
146
147//----¡¡¼èÆÀʸ»úÎó¤ÎÊÑ´¹
148function lfConvertParam($array, $arrRegistColumn) {
149    /*
150     *  ʸ»úÎó¤ÎÊÑ´¹
151     *  K :  ¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
152     *  C :  ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
153     *  V :  ÂùÅÀÉÕ¤­¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹
154     *  n :  ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)¡×¤ËÊÑ´¹
155     *  a :  Á´³Ñ±Ñ¿ô»ú¤òȾ³Ñ±Ñ¿ô»ú¤ËÊÑ´¹¤¹¤ë
156     */
157    // ¥«¥é¥à̾¤È¥³¥ó¥Ð¡¼¥È¾ðÊó   
158    foreach ($arrRegistColumn as $data) {
159        $arrConvList[ $data["column"] ] = $data["convert"];
160    }
161   
162    // ʸ»úÊÑ´¹
163    foreach ($arrConvList as $key => $val) {
164        // POST¤µ¤ì¤Æ¤­¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£
165        if(strlen(($array[$key])) > 0) {
166            $array[$key] = mb_convert_kana($array[$key] ,$val);
167        }
168    }
169    return $array;
170}
171
172/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
173function lfErrorCheck() {
174    $objErr = new SC_CheckError();
175   
176    $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", 'name01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
177    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", 'name02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK"));
178    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/À«¡Ë", 'kana01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
179    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/̾¡Ë", 'kana02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
180    $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
181    $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
182    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
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/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
195function lfErrorCheck1() {
196    $objErr = new SC_CheckError();
197   
198    $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", 'name01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
199    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", 'name02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK"));
200    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/À«¡Ë", 'kana01', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
201    $objErr->doFunc(array("¤ªÌ¾Á°¡Ê¥«¥Ê/̾¡Ë", 'kana02', STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK", "MAX_LENGTH_CHECK", "KANA_CHECK"));
202    $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "zip01", ZIP01_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
203    $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "zip02", ZIP02_LEN ) ,array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
204    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
205    return $objErr->arrErr;
206   
207}
208
209/* ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */
210function lfErrorCheck2() {
211    $objErr = new SC_CheckError();
212   
213    $objErr->doFunc(array("ÅÔÆ»Éܸ©", 'pref'), array("SELECT_CHECK","NUM_CHECK"));
214    $objErr->doFunc(array("»Ô¶èĮ¼", "addr01", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
215    $objErr->doFunc(array("ÈÖÃÏ", "addr02", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
216    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ1", 'tel01'), array("EXIST_CHECK","NUM_CHECK"));
217    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ2", 'tel02'), array("EXIST_CHECK","NUM_CHECK"));
218    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ3", 'tel03'), array("EXIST_CHECK","NUM_CHECK"));
219    $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ", "tel01", "tel02", "tel03", TEL_LEN) ,array("TEL_CHECK"));
220    return $objErr->arrErr;
221   
222}
223
224
225
226/* ÅÐÏ¿¼Â¹Ô Èó²ñ°÷¹ØÆþ¤Ç¤¢¤ë¤¿¤á¤Ë¹±µ×Ū¤ÊÅÐÏ¿¤Ï¤·¤Ê¤¤*/
227function lfRegistData($array, $arrRegistColumn,$uniqid) {
228    global $objConn;
229    global $objCustomer;
230   
231    $objQuery = new SC_Query();
232   
233    $sqlse = "SELECT customer_id FROM dtb_order_temp WHERE order_temp_id = ?";
234    $arrRegist['customer_id'] = $objConn->getOne($sqlse, array($uniqid));
235   
236    foreach ($arrRegistColumn as $data) {
237        if (strlen($array[ $data["column"] ]) > 0) {
238            $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
239        }
240    }
241   
242    //$arrRegist['customer_id'] = $objCustomer->getvalue('customer_id');
243   
244    //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô
245    $objConn->query("BEGIN");
246    if ($array['other_deliv_id'] != ""){
247        $objConn->autoExecute("dtb_other_deliv", $arrRegist, "other_deliv_id='" .addslashes($array["other_deliv_id"]). "'");
248    }else{
249        $objConn->autoExecute("dtb_other_deliv", $arrRegist);
250
251        $sqlse = "SELECT max(other_deliv_id) FROM dtb_other_deliv WHERE customer_id = ?";
252        $array['other_deliv_id'] = $objConn->getOne($sqlse, array($arrRegist['customer_id']));
253    }
254
255    $objConn->query("COMMIT");
256
257    return $array['other_deliv_id'];
258}
259
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.