source: temp/branches/mobile/html/mobile/shopping/deliv.php @ 11409

Revision 11409, 10.9 KB checked in by rebelt, 16 years ago (diff)

以下のモバイルサイト用ページ・機能を作成いたしました。

  • 会員登録
  • 注文
  • イプシロン決済
  • Property svn:eol-style set to native
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8require_once("../require.php");
9
10class LC_Page {
11    var $arrSession;
12    var $tpl_mode;
13    var $arrAddr;
14    function LC_Page() {
15        $this->tpl_mainpage = 'shopping/deliv.tpl';
16        $this->tpl_css = '/css/layout/shopping/index.css';
17        global $arrPref;
18        $this->arrPref = $arrPref;
19        $this->tpl_title = "¤ªÆϤ±Àè»ØÄê";      // ¥¿¥¤¥È¥ë
20
21        /*
22         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
23         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
24         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
25        */
26        session_cache_limiter('private-no-expire');     
27
28    }
29}
30
31$objPage = new LC_Page();
32$objView = new SC_SiteView();
33$objSiteSess = new SC_SiteSession();
34$objCartSess = new SC_CartSession();
35$objCustomer = new SC_Customer();
36// ¥¯¥Ã¥­¡¼´ÉÍý¥¯¥é¥¹
37$objCookie = new SC_Cookie(COOKIE_EXPIRE);
38// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
39$objFormParam = new SC_FormParam();
40// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
41lfInitParam();
42// POSTÃͤμèÆÀ
43$objFormParam->setParam($_POST);
44
45$objLoginFormParam = new SC_FormParam();    // ¥í¥°¥¤¥ó¥Õ¥©¡¼¥àÍÑ
46lfInitLoginFormParam();                     // ½é´üÀßÄê
47$objLoginFormParam->setParam($_POST);       // POSTÃͤμèÆÀ
48
49// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
50$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
51$objPage->tpl_uniqid = $uniqid;
52
53// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
54if($_POST['mode'] != 'login' && !$objCustomer->isLoginSuccess()) {
55    // ÉÔÀµ¥¢¥¯¥»¥¹¤È¤ß¤Ê¤¹
56    sfDispSiteError(CUSTOMER_ERROR);
57}
58
59switch($_POST['mode']) {
60case 'login':
61    $objLoginFormParam->toLower('login_email');
62    $objPage->arrErr = $objLoginFormParam->checkError();
63    $arrForm =  $objLoginFormParam->getHashArray();
64    // ¥¯¥Ã¥­¡¼ÊݸȽÄê
65    if($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
66        $objCookie->setCookie('login_email', $_POST['login_email']);
67    } else {
68        $objCookie->setCookie('login_email', '');
69    }
70
71    if(count($objPage->arrErr) == 0) {
72        // ¥í¥°¥¤¥óȽÄê
73        if(!$objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) &&
74           !$objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'])) {
75            // ²¾ÅÐÏ¿¤ÎȽÄê
76            $objQuery = new SC_Query;
77            $where = "email = ? AND status = 1 AND del_flg = 0";
78            $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email']));
79           
80            if($ret > 0) {
81                sfDispSiteError(TEMP_LOGIN_ERROR);
82            } else {
83                sfDispSiteError(SITE_LOGIN_ERROR);
84            }
85        }
86    } else {
87        // ¥í¥°¥¤¥ó¥Ú¡¼¥¸¤ËÌá¤ë
88        header("Location: " . gfAddSessionId(URL_SHOP_TOP));
89        exit;
90    }
91
92    // ¥í¥°¥¤¥ó¤¬À®¸ù¤·¤¿¾ì¹ç¤Ï·ÈÂÓüËöID¤òÊݸ¤¹¤ë¡£
93    $objCustomer->updateMobilePhoneId();
94    break;
95// ºï½ü
96case 'delete':
97    if (sfIsInt($_POST['other_deliv_id'])) {
98        $objQuery = new SC_Query();
99        $where = "other_deliv_id = ?";
100        $arrRet = $objQuery->delete("dtb_other_deliv", $where, array($_POST['other_deliv_id']));
101        $objFormParam->setValue('select_addr_id', '');
102    }
103    break;
104// ²ñ°÷ÅÐÏ¿½»½ê¤ËÁ÷¤ë
105case 'customer_addr':
106    // ¤ªÆϤ±À褬¥Á¥§¥Ã¥¯¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¹¹¿·½èÍý¤ò¹Ô¤¦
107    if ($_POST['deli'] != "") {
108        // ²ñ°÷¾ðÊó¤Î½»½ê¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
109        lfRegistDelivData($uniqid, $objCustomer);
110        // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
111        $objSiteSess->setRegistFlag();
112        // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
113        header("Location: " . gfAddSessionId(URL_SHOP_PAYMENT));
114        exit;
115    }else{
116        // ¥¨¥é¡¼¤òÊÖ¤¹
117        $arrErr['deli'] = '¢¨ ¤ªÆϤ±Àè¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£';
118    }
119    break;
120   
121// ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ËÁ÷¤ë
122case 'other_addr':
123    // ¤ªÆϤ±À褬¥Á¥§¥Ã¥¯¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¹¹¿·½èÍý¤ò¹Ô¤¦
124    if ($_POST['deli'] != "") {
125        if (sfIsInt($_POST['other_deliv_id'])) {
126            // ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
127            lfRegistOtherDelivData($uniqid, $objCustomer, $_POST['other_deliv_id']);
128            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
129            $objSiteSess->setRegistFlag();
130            // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
131            header("Location: " . gfAddSessionId(URL_SHOP_PAYMENT));
132            exit;
133        }
134    }else{
135        // ¥¨¥é¡¼¤òÊÖ¤¹
136        $arrErr['deli'] = '¢¨ ¤ªÆϤ±Àè¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£';
137    }
138    break;
139
140/*
141// Ê̤ΤªÆϤ±Àè¤ò»ØÄê
142case 'new_addr':
143    // ÆþÎÏÃͤÎÊÑ´¹
144    $objFormParam->convParam();
145    $objPage->arrErr = lfCheckError($arrRet);
146    // ÆþÎÏ¥¨¥é¡¼¤Ê¤·
147    if(count($objPage->arrErr) == 0) {
148        // DB¤Ø¤ªÆϤ±Àè¤òÅÐÏ¿
149        lfRegistNewAddrData($uniqid, $objCustomer);
150        // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
151        $objSiteSess->setRegistFlag();
152        // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
153        header("Location: " . URL_SHOP_PAYMENT);
154        exit;
155    }
156    break;
157*/
158
159// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
160case 'return':
161    // ³Îǧ¥Ú¡¼¥¸¤Ø°ÜÆ°
162    header("Location: " . URL_CART_TOP);
163    exit;
164    break;
165default:
166    $objQuery = new SC_Query();
167    $where = "order_temp_id = ?";
168    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($uniqid));
169    $objFormParam->setParam($arrRet[0]);
170    break;
171}
172
173/** ɽ¼¨½èÍý **/
174
175// ²ñ°÷ÅÐÏ¿½»½ê¤Î¼èÆÀ
176$col = "name01, name02, pref, addr01, addr02, zip01, zip02";
177$where = "customer_id = ?";
178$objQuery = new SC_Query();
179$arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($_SESSION['customer']['customer_id']));
180// Ê̤ΤªÆϤ±Àè½»½ê¤Î¼èÆÀ
181$col = "other_deliv_id, name01, name02, pref, addr01, addr02, zip01, zip02";
182$objQuery->setorder("other_deliv_id DESC");
183$objOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($_SESSION['customer']['customer_id']));
184$objPage->arrAddr = $arrCustomerAddr;
185$cnt = 1;
186foreach($objOtherAddr as $val) {
187    $objPage->arrAddr[$cnt] = $val;
188    $cnt++;
189}
190
191// ÆþÎÏÃͤμèÆÀ
192$objPage->arrForm = $objFormParam->getFormParamList();
193$objPage->arrErr = $arrErr;
194$objView->assignobj($objPage);
195$objView->display(SITE_FRAME);
196//--------------------------------------------------------------------------------------------------------------------------
197/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
198function lfInitParam() {
199    global $objFormParam;
200    $objFormParam->addParam("¤ªÌ¾Á°1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
201    $objFormParam->addParam("¤ªÌ¾Á°2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
202    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
203    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
204    $objFormParam->addParam("͹ÊØÈÖ¹æ1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
205    $objFormParam->addParam("͹ÊØÈÖ¹æ2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
206    $objFormParam->addParam("ÅÔÆ»Éܸ©", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
207    $objFormParam->addParam("½»½ê1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
208    $objFormParam->addParam("½»½ê2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
209    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
210    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
211    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
212}
213
214function lfInitLoginFormParam() {
215    global $objLoginFormParam;
216    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
217    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
218    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
219}
220
221/* DB¤Ø¥Ç¡¼¥¿¤ÎÅÐÏ¿ */
222function lfRegistNewAddrData($uniqid, $objCustomer) {
223    global $objFormParam;
224    $arrRet = $objFormParam->getHashArray();
225    $sqlval = $objFormParam->getDbArray();
226    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
227    $sqlval['deliv_check'] = '1';
228    $sqlval['order_temp_id'] = $uniqid;
229    $sqlval['update_date'] = 'Now()';
230    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
231    $sqlval['order_birth'] = $objCustomer->getValue('birth');
232   
233    sfRegistTempOrder($uniqid, $sqlval);
234}
235
236/* ²ñ°÷¾ðÊó¤Î½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
237function lfRegistDelivData($uniqid, $objCustomer) {
238    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
239    $sqlval['order_temp_id'] = $uniqid;
240    $sqlval['update_date'] = 'Now()';
241    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
242    $sqlval['deliv_check'] = '1';
243    $sqlval['deliv_name01'] = $objCustomer->getValue('name01');
244    $sqlval['deliv_name02'] = $objCustomer->getValue('name02');
245    $sqlval['deliv_kana01'] = $objCustomer->getValue('kana01');
246    $sqlval['deliv_kana02'] = $objCustomer->getValue('kana02');
247    $sqlval['deliv_zip01'] = $objCustomer->getValue('zip01');
248    $sqlval['deliv_zip02'] = $objCustomer->getValue('zip02');
249    $sqlval['deliv_pref'] = $objCustomer->getValue('pref');
250    $sqlval['deliv_addr01'] = $objCustomer->getValue('addr01');
251    $sqlval['deliv_addr02'] = $objCustomer->getValue('addr02');
252    $sqlval['deliv_tel01'] = $objCustomer->getValue('tel01');
253    $sqlval['deliv_tel02'] = $objCustomer->getValue('tel02');
254    $sqlval['deliv_tel03'] = $objCustomer->getValue('tel03');
255
256    $sqlval['deliv_fax01'] = $objCustomer->getValue('fax01');
257    $sqlval['deliv_fax02'] = $objCustomer->getValue('fax02');
258    $sqlval['deliv_fax03'] = $objCustomer->getValue('fax03');
259
260    sfRegistTempOrder($uniqid, $sqlval);
261}
262
263/* Ê̤ΤªÆϤ±Àè½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
264function lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id) {
265    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
266    $sqlval['order_temp_id'] = $uniqid;
267    $sqlval['update_date'] = 'Now()';
268    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
269    $sqlval['order_birth'] = $objCustomer->getValue('birth');
270       
271    $objQuery = new SC_Query();
272    $where = "other_deliv_id = ?";
273    $arrRet = $objQuery->select("*", "dtb_other_deliv", $where, array($other_deliv_id));
274   
275    $sqlval['deliv_check'] = '1';
276    $sqlval['deliv_name01'] = $arrRet[0]['name01'];
277    $sqlval['deliv_name02'] = $arrRet[0]['name02'];
278    $sqlval['deliv_kana01'] = $arrRet[0]['kana01'];
279    $sqlval['deliv_kana02'] = $arrRet[0]['kana02'];
280    $sqlval['deliv_zip01'] = $arrRet[0]['zip01'];
281    $sqlval['deliv_zip02'] = $arrRet[0]['zip02'];
282    $sqlval['deliv_pref'] = $arrRet[0]['pref'];
283    $sqlval['deliv_addr01'] = $arrRet[0]['addr01'];
284    $sqlval['deliv_addr02'] = $arrRet[0]['addr02'];
285    $sqlval['deliv_tel01'] = $arrRet[0]['tel01'];
286    $sqlval['deliv_tel02'] = $arrRet[0]['tel02'];
287    $sqlval['deliv_tel03'] = $arrRet[0]['tel03'];
288    sfRegistTempOrder($uniqid, $sqlval);
289}
290
291/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
292function lfCheckError() {
293    global $objFormParam;
294    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
295    $arrRet =  $objFormParam->getHashArray();
296    $objErr = new SC_CheckError($arrRet);
297    $objErr->arrErr = $objFormParam->checkError();
298    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
299    if ($_POST['mode'] == 'login'){
300    $objErr->doFunc(array("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN), array("EXIST_CHECK"));
301    $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN), array("EXIST_CHECK"));
302    }
303    $objErr->doFunc(array("TEL", "deliv_tel01", "deliv_tel02", "deliv_tel03", TEL_ITEM_LEN), array("TEL_CHECK"));
304    return $objErr->arrErr;
305}
306?>
Note: See TracBrowser for help on using the repository browser.