source: branches/version-1/html/shopping/deliv.php @ 17686

Revision 17686, 10.6 KB checked in by takegami, 14 years ago (diff)

#389 表示されていないお届け先を指定できる

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            $deliv_count = $objQuery->count("dtb_other_deliv","customer_id=? and other_deliv_id = ?" ,array($objCustomer->getValue('customer_id'), $_POST['deliv_check']));
116            if ($deliv_count != 1) {
117                sfDispSiteError(CUSTOMER_ERROR);
118            }
119            // ÅÐÏ¿ºÑ¤ß¤ÎÊ̤ΤªÆϤ±Àè¤ò¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤à
120            lfRegistOtherDelivData($uniqid, $objCustomer, $_POST['deliv_check']);
121            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
122            $objSiteSess->setRegistFlag();
123            // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
124            header("Location: " . URL_SHOP_PAYMENT);
125            exit;
126
127        }
128    }else{
129        // ¥¨¥é¡¼¤òÊÖ¤¹
130        $arrErr['deli'] = '¢¨ ¤ªÆϤ±Àè¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£';
131    }   
132    break;
133// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
134case 'return':
135    // ³Îǧ¥Ú¡¼¥¸¤Ø°ÜÆ°
136    header("Location: " . URL_CART_TOP);
137    exit;
138    break;
139default:
140    $objQuery = new SC_Query();
141    $where = "order_temp_id = ?";
142    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($uniqid));
143    $objFormParam->setParam($arrRet[0]);
144    break;
145}
146
147/** ɽ¼¨½èÍý **/
148
149// ²ñ°÷ÅÐÏ¿½»½ê¤Î¼èÆÀ
150$col = "name01, name02, pref, addr01, addr02";
151$where = "customer_id = ?";
152$objQuery = new SC_Query();
153$arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($_SESSION['customer']['customer_id']));
154// Ê̤ΤªÆϤ±Àè½»½ê¤Î¼èÆÀ
155$col = "other_deliv_id, name01, name02, pref, addr01, addr02";
156$objQuery->setorder("other_deliv_id DESC");
157$objOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($_SESSION['customer']['customer_id']));
158$objPage->arrAddr = $arrCustomerAddr;
159$objPage->tpl_addrmax = count($objOtherAddr);
160$cnt = 1;
161foreach($objOtherAddr as $val) {
162    $objPage->arrAddr[$cnt] = $val;
163    $cnt++;
164}
165
166// ÆþÎÏÃͤμèÆÀ
167$objPage->arrForm = $objFormParam->getFormParamList();
168$objPage->arrErr = $arrErr;
169
170$objView->assignobj($objPage);
171// ¥Õ¥ì¡¼¥à¤òÁªÂò(¥­¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹)
172$objCampaignSess->pageView($objView);
173//--------------------------------------------------------------------------------------------------------------------------
174/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
175function lfInitParam() {
176    global $objFormParam;
177    $objFormParam->addParam("¤ªÌ¾Á°1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
178    $objFormParam->addParam("¤ªÌ¾Á°2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
179    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
180    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
181    $objFormParam->addParam("͹ÊØÈÖ¹æ1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
182    $objFormParam->addParam("͹ÊØÈÖ¹æ2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
183    $objFormParam->addParam("ÅÔÆ»Éܸ©", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
184    $objFormParam->addParam("½»½ê1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
185    $objFormParam->addParam("½»½ê2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
186    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
187    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
188    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
189    $objFormParam->addParam("", "deliv_check");
190}
191
192function lfInitLoginFormParam() {
193    global $objLoginFormParam;
194    $objLoginFormParam->addParam("µ­²±¤¹¤ë", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
195    $objLoginFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
196    $objLoginFormParam->addParam("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
197}
198
199/* DB¤Ø¥Ç¡¼¥¿¤ÎÅÐÏ¿ */
200function lfRegistNewAddrData($uniqid, $objCustomer) {
201    global $objFormParam;
202    $arrRet = $objFormParam->getHashArray();
203    $sqlval = $objFormParam->getDbArray();
204    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
205    $sqlval['deliv_check'] = '1';
206    $sqlval['order_temp_id'] = $uniqid;
207    $sqlval['update_date'] = 'Now()';
208    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
209    $sqlval['order_birth'] = $objCustomer->getValue('birth');
210   
211    sfRegistTempOrder($uniqid, $sqlval);
212}
213
214/* ²ñ°÷¾ðÊó¤Î½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
215function lfRegistDelivData($uniqid, $objCustomer) {
216    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
217    $sqlval['order_temp_id'] = $uniqid;
218    $sqlval['update_date'] = 'Now()';
219    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
220    $sqlval['deliv_check'] = '-1';
221    $sqlval['deliv_name01'] = $objCustomer->getValue('name01');
222    $sqlval['deliv_name02'] = $objCustomer->getValue('name02');
223    $sqlval['deliv_kana01'] = $objCustomer->getValue('kana01');
224    $sqlval['deliv_kana02'] = $objCustomer->getValue('kana02');
225    $sqlval['deliv_zip01'] = $objCustomer->getValue('zip01');
226    $sqlval['deliv_zip02'] = $objCustomer->getValue('zip02');
227    $sqlval['deliv_pref'] = $objCustomer->getValue('pref');
228    $sqlval['deliv_addr01'] = $objCustomer->getValue('addr01');
229    $sqlval['deliv_addr02'] = $objCustomer->getValue('addr02');
230    $sqlval['deliv_tel01'] = $objCustomer->getValue('tel01');
231    $sqlval['deliv_tel02'] = $objCustomer->getValue('tel02');
232    $sqlval['deliv_tel03'] = $objCustomer->getValue('tel03');
233
234    $sqlval['deliv_fax01'] = $objCustomer->getValue('fax01');
235    $sqlval['deliv_fax02'] = $objCustomer->getValue('fax02');
236    $sqlval['deliv_fax03'] = $objCustomer->getValue('fax03');
237
238    sfRegistTempOrder($uniqid, $sqlval);
239}
240
241/* Ê̤ΤªÆϤ±Àè½»½ê¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
242function lfRegistOtherDelivData($uniqid, $objCustomer, $other_deliv_id) {
243    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
244    $sqlval['order_temp_id'] = $uniqid;
245    $sqlval['update_date'] = 'Now()';
246    $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
247    $sqlval['order_birth'] = $objCustomer->getValue('birth');
248       
249    $objQuery = new SC_Query();
250    $where = "other_deliv_id = ?";
251    $arrRet = $objQuery->select("*", "dtb_other_deliv", $where, array($other_deliv_id));
252   
253    $sqlval['deliv_check'] = $other_deliv_id;
254    $sqlval['deliv_name01'] = $arrRet[0]['name01'];
255    $sqlval['deliv_name02'] = $arrRet[0]['name02'];
256    $sqlval['deliv_kana01'] = $arrRet[0]['kana01'];
257    $sqlval['deliv_kana02'] = $arrRet[0]['kana02'];
258    $sqlval['deliv_zip01'] = $arrRet[0]['zip01'];
259    $sqlval['deliv_zip02'] = $arrRet[0]['zip02'];
260    $sqlval['deliv_pref'] = $arrRet[0]['pref'];
261    $sqlval['deliv_addr01'] = $arrRet[0]['addr01'];
262    $sqlval['deliv_addr02'] = $arrRet[0]['addr02'];
263    $sqlval['deliv_tel01'] = $arrRet[0]['tel01'];
264    $sqlval['deliv_tel02'] = $arrRet[0]['tel02'];
265    $sqlval['deliv_tel03'] = $arrRet[0]['tel03'];
266    sfRegistTempOrder($uniqid, $sqlval);
267}
268
269/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
270function lfCheckError() {
271    global $objFormParam;
272    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
273    $arrRet =  $objFormParam->getHashArray();
274    $objErr = new SC_CheckError($arrRet);
275    $objErr->arrErr = $objFormParam->checkError();
276    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
277    if ($_POST['mode'] == 'login'){
278    $objErr->doFunc(array("¥á¡¼¥ë¥¢¥É¥ì¥¹", "login_email", STEXT_LEN), array("EXIST_CHECK"));
279    $objErr->doFunc(array("¥Ñ¥¹¥ï¡¼¥É", "login_pass", STEXT_LEN), array("EXIST_CHECK"));
280    }
281    $objErr->doFunc(array("TEL", "deliv_tel01", "deliv_tel02", "deliv_tel03", TEL_ITEM_LEN), array("TEL_CHECK"));
282    return $objErr->arrErr;
283}
284?>
Note: See TracBrowser for help on using the repository browser.