source: branches/rel/html/shopping/deliv.php @ 12157

Revision 12157, 10.3 KB checked in by uehara, 16 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 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 = URL_DIR.'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$objCampaignSess = new SC_CampaignSession();
36$objCustomer = new SC_Customer();
37// ¥¯¥Ã¥­¡¼´ÉÍý¥¯¥é¥¹
38$objCookie = new SC_Cookie(COOKIE_EXPIRE);
39// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
40$objFormParam = new SC_FormParam();
41// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
42lfInitParam();
43// POSTÃͤμèÆÀ
44$objFormParam->setParam($_POST);
45
46$objLoginFormParam = new SC_FormParam();    // ¥í¥°¥¤¥ó¥Õ¥©¡¼¥àÍÑ
47lfInitLoginFormParam();                     // ½é´üÀßÄê
48$objLoginFormParam->setParam($_POST);       // POSTÃͤμèÆÀ
49
50// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
51$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
52$objPage->tpl_uniqid = $uniqid;
53
54// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
55if($_POST['mode'] != 'login' && !$objCustomer->isLoginSuccess()) {
56    // ÉÔÀµ¥¢¥¯¥»¥¹¤È¤ß¤Ê¤¹
57    sfDispSiteError(CUSTOMER_ERROR);
58}
59
60switch($_POST['mode']) {
61case 'login':
62    $objLoginFormParam->toLower('login_email');
63    $objPage->arrErr = $objLoginFormParam->checkError();
64    $arrForm =  $objLoginFormParam->getHashArray();
65    // ¥¯¥Ã¥­¡¼ÊݸȽÄê
66    if($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
67        $objCookie->setCookie('login_email', $_POST['login_email']);
68    } else {
69        $objCookie->setCookie('login_email', '');
70    }
71
72    if(count($objPage->arrErr) == 0) {
73        // ¥í¥°¥¤¥óȽÄê
74        if(!$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: " . URL_SHOP_TOP);
89        exit;   
90    }
91    break;
92// ºï½ü
93case 'delete':
94    if (sfIsInt($_POST['other_deliv_id'])) {
95        $objQuery = new SC_Query();
96        $where = "other_deliv_id = ?";
97        $arrRet = $objQuery->delete("dtb_other_deliv", $where, array($_POST['other_deliv_id']));
98        $objFormParam->setValue('select_addr_id', '');
99    }
100    break;
101// ²ñ°÷ÅÐÏ¿½»½ê¤ËÁ÷¤ë
102case 'customer_addr':
103    // ²ñ°÷ÅÐÏ¿½»½ê¤¬¥Á¥§¥Ã¥¯¤µ¤ì¤Æ¤¤¤ë¾ì¹ç
104    if ($_POST['deliv_check'] == '-1') {
105        // ²ñ°÷¾ðÊó¤Î½»½ê¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
106        lfRegistDelivData($uniqid, $objCustomer);
107        // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
108        $objSiteSess->setRegistFlag();
109        // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
110        header("Location: " . URL_SHOP_PAYMENT);
111        exit;
112    // Ê̤ΤªÆϤ±À褬¥Á¥§¥Ã¥¯¤µ¤ì¤Æ¤¤¤ë¾ì¹ç
113    } elseif($_POST['deliv_check'] >= 1) {
114        if (sfIsInt($_POST['deliv_check'])) {
115            // ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
116            lfRegistOtherDelivData($uniqid, $objCustomer, $_POST['deliv_check']);
117            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
118            $objSiteSess->setRegistFlag();
119            // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
120            header("Location: " . URL_SHOP_PAYMENT);
121            exit;
122        }
123    }else{
124        // ¥¨¥é¡¼¤òÊÖ¤¹
125        $arrErr['deli'] = '¢¨ ¤ªÆϤ±Àè¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£';
126    }   
127    break;
128// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
129case 'return':
130    // ³Îǧ¥Ú¡¼¥¸¤Ø°ÜÆ°
131    header("Location: " . URL_CART_TOP);
132    exit;
133    break;
134default:
135    $objQuery = new SC_Query();
136    $where = "order_temp_id = ?";
137    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($uniqid));
138    $objFormParam->setParam($arrRet[0]);
139    break;
140}
141
142/** ɽ¼¨½èÍý **/
143
144// ²ñ°÷ÅÐÏ¿½»½ê¤Î¼èÆÀ
145$col = "name01, name02, pref, addr01, addr02";
146$where = "customer_id = ?";
147$objQuery = new SC_Query();
148$arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($_SESSION['customer']['customer_id']));
149// Ê̤ΤªÆϤ±Àè½»½ê¤Î¼èÆÀ
150$col = "other_deliv_id, name01, name02, pref, addr01, addr02";
151$objQuery->setorder("other_deliv_id DESC");
152$objOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($_SESSION['customer']['customer_id']));
153$objPage->arrAddr = $arrCustomerAddr;
154$objPage->tpl_addrmax = count($objOtherAddr);
155$cnt = 1;
156foreach($objOtherAddr as $val) {
157    $objPage->arrAddr[$cnt] = $val;
158    $cnt++;
159}
160
161// ÆþÎÏÃͤμèÆÀ
162$objPage->arrForm = $objFormParam->getFormParamList();
163$objPage->arrErr = $arrErr;
164
165$objView->assignobj($objPage);
166// ¥Õ¥ì¡¼¥à¤òÁªÂò(¥­¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹)
167$objCampaignSess->pageView($objView);
168//--------------------------------------------------------------------------------------------------------------------------
169/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
170function lfInitParam() {
171    global $objFormParam;
172    $objFormParam->addParam("¤ªÌ¾Á°1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
173    $objFormParam->addParam("¤ªÌ¾Á°2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
174    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
175    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
176    $objFormParam->addParam("͹ÊØÈÖ¹æ1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
177    $objFormParam->addParam("͹ÊØÈÖ¹æ2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
178    $objFormParam->addParam("ÅÔÆ»Éܸ©", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
179    $objFormParam->addParam("½»½ê1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
180    $objFormParam->addParam("½»½ê2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
181    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
182    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
183    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
184    $objFormParam->addParam("", "deliv_check");
185}
186
187function lfInitLoginFormParam() {
188    global $objLoginFormParam;
189    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
190    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
191    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
192}
193
194/* DB¤Ø¥Ç¡¼¥¿¤ÎÅÐÏ¿ */
195function lfRegistNewAddrData($uniqid, $objCustomer) {
196    global $objFormParam;
197    $arrRet = $objFormParam->getHashArray();
198    $sqlval = $objFormParam->getDbArray();
199    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
200    $sqlval['deliv_check'] = '1';
201    $sqlval['order_temp_id'] = $uniqid;
202    $sqlval['update_date'] = 'Now()';
203    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
204    $sqlval['order_birth'] = $objCustomer->getValue('birth');
205   
206    sfRegistTempOrder($uniqid, $sqlval);
207}
208
209/* ²ñ°÷¾ðÊó¤Î½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
210function lfRegistDelivData($uniqid, $objCustomer) {
211    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
212    $sqlval['order_temp_id'] = $uniqid;
213    $sqlval['update_date'] = 'Now()';
214    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
215    $sqlval['deliv_check'] = '-1';
216    $sqlval['deliv_name01'] = $objCustomer->getValue('name01');
217    $sqlval['deliv_name02'] = $objCustomer->getValue('name02');
218    $sqlval['deliv_kana01'] = $objCustomer->getValue('kana01');
219    $sqlval['deliv_kana02'] = $objCustomer->getValue('kana02');
220    $sqlval['deliv_zip01'] = $objCustomer->getValue('zip01');
221    $sqlval['deliv_zip02'] = $objCustomer->getValue('zip02');
222    $sqlval['deliv_pref'] = $objCustomer->getValue('pref');
223    $sqlval['deliv_addr01'] = $objCustomer->getValue('addr01');
224    $sqlval['deliv_addr02'] = $objCustomer->getValue('addr02');
225    $sqlval['deliv_tel01'] = $objCustomer->getValue('tel01');
226    $sqlval['deliv_tel02'] = $objCustomer->getValue('tel02');
227    $sqlval['deliv_tel03'] = $objCustomer->getValue('tel03');
228
229    $sqlval['deliv_fax01'] = $objCustomer->getValue('fax01');
230    $sqlval['deliv_fax02'] = $objCustomer->getValue('fax02');
231    $sqlval['deliv_fax03'] = $objCustomer->getValue('fax03');
232
233    sfRegistTempOrder($uniqid, $sqlval);
234}
235
236/* Ê̤ΤªÆϤ±Àè½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
237function lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id) {
238    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
239    $sqlval['order_temp_id'] = $uniqid;
240    $sqlval['update_date'] = 'Now()';
241    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
242    $sqlval['order_birth'] = $objCustomer->getValue('birth');
243       
244    $objQuery = new SC_Query();
245    $where = "other_deliv_id = ?";
246    $arrRet = $objQuery->select("*", "dtb_other_deliv", $where, array($other_deliv_id));
247   
248    $sqlval['deliv_check'] = $other_deliv_id;
249    $sqlval['deliv_name01'] = $arrRet[0]['name01'];
250    $sqlval['deliv_name02'] = $arrRet[0]['name02'];
251    $sqlval['deliv_kana01'] = $arrRet[0]['kana01'];
252    $sqlval['deliv_kana02'] = $arrRet[0]['kana02'];
253    $sqlval['deliv_zip01'] = $arrRet[0]['zip01'];
254    $sqlval['deliv_zip02'] = $arrRet[0]['zip02'];
255    $sqlval['deliv_pref'] = $arrRet[0]['pref'];
256    $sqlval['deliv_addr01'] = $arrRet[0]['addr01'];
257    $sqlval['deliv_addr02'] = $arrRet[0]['addr02'];
258    $sqlval['deliv_tel01'] = $arrRet[0]['tel01'];
259    $sqlval['deliv_tel02'] = $arrRet[0]['tel02'];
260    $sqlval['deliv_tel03'] = $arrRet[0]['tel03'];
261    sfRegistTempOrder($uniqid, $sqlval);
262}
263
264/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
265function lfCheckError() {
266    global $objFormParam;
267    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
268    $arrRet =  $objFormParam->getHashArray();
269    $objErr = new SC_CheckError($arrRet);
270    $objErr->arrErr = $objFormParam->checkError();
271    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
272    if ($_POST['mode'] == 'login'){
273    $objErr->doFunc(array("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN), array("EXIST_CHECK"));
274    $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN), array("EXIST_CHECK"));
275    }
276    $objErr->doFunc(array("TEL", "deliv_tel01", "deliv_tel02", "deliv_tel03", TEL_ITEM_LEN), array("TEL_CHECK"));
277    return $objErr->arrErr;
278}
279?>
Note: See TracBrowser for help on using the repository browser.