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

Revision 12157, 12.0 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 $tpl_login_email;
14    function LC_Page() {
15        $this->tpl_mainpage = 'shopping/index.tpl';
16        global $arrPref;
17        $this->arrPref = $arrPref;
18        global $arrSex;
19        $this->arrSex = $arrSex;
20        global $arrJob;
21        $this->arrJob = $arrJob;
22        $this->tpl_onload = 'fnCheckInputDeliv();';
23       
24        /*
25         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
26         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
27         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
28        */
29        session_cache_limiter('private-no-expire');             
30    }
31}
32
33$conn = new SC_DBConn();
34$objPage = new LC_Page();
35$objView = new SC_SiteView();
36$objSiteSess = new SC_SiteSession();
37$objCartSess = new SC_CartSession();
38$objCampaignSess = new SC_CampaignSession();
39$objCustomer = new SC_Customer();
40$objCookie = new SC_Cookie();
41$objFormParam = new SC_FormParam();         // ¥Õ¥©¡¼¥àÍÑ
42lfInitParam();                              // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
43$objFormParam->setParam($_POST);            // POSTÃͤμèÆÀ
44
45// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
46$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
47
48$objPage->tpl_uniqid = $uniqid;
49
50// ¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
51if($objCustomer->isLoginSuccess()) {
52    // ¤¹¤Ç¤Ë¥í¥°¥¤¥ó¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤ªÆϤ±ÀèÀßÄê²èÌ̤ËžÁ÷
53    header("Location: ./deliv.php");
54    exit;
55}
56
57switch($_POST['mode']) {
58case 'nonmember_confirm':
59    $objPage = lfSetNonMember($objPage);
60    // ¢¨break¤Ê¤·
61case 'confirm':
62    // ÆþÎÏÃͤÎÊÑ´¹
63    $objFormParam->convParam();
64    $objFormParam->toLower('order_mail');
65    $objFormParam->toLower('order_mail_check');
66   
67    $objPage->arrErr = lfCheckError();
68
69    // ÆþÎÏ¥¨¥é¡¼¤Ê¤·
70    if(count($objPage->arrErr) == 0) {
71        // DB¤Ø¤Î¥Ç¡¼¥¿ÅÐÏ¿
72        lfRegistData($uniqid);
73       
74        // ¤ªÆϤ±Àè¤Î¥³¥Ô¡¼
75        lfCopyDeliv($uniqid, $_POST);
76       
77        // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
78        $objSiteSess->setRegistFlag();
79        // ¤ª»Ùʧ¤¤ÊýË¡ÁªÂò¥Ú¡¼¥¸¤Ø°ÜÆ°
80        header("Location: " . URL_SHOP_PAYMENT);
81        exit;       
82    }
83   
84    break;
85// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
86case 'return':
87    // ³Îǧ¥Ú¡¼¥¸¤Ø°ÜÆ°
88    header("Location: " . URL_CART_TOP);
89    exit;
90    break;
91case 'nonmember':
92    $objPage = lfSetNonMember($objPage);
93    // ¢¨break¤Ê¤·
94default:
95    if($_GET['from'] == 'nonmember') {
96        $objPage = lfSetNonMember($objPage);
97    }
98    // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ
99    $uniqid = $objSiteSess->getUniqId();
100    $objQuery = new SC_Query();
101    $where = "order_temp_id = ?";
102    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($uniqid));
103    // DBÃͤμèÆÀ
104    $objFormParam->setParam($arrRet[0]);
105    $objFormParam->setValue('order_email_check', $arrRet[0]['order_email']);
106    $objFormParam->setDBDate($arrRet[0]['order_birth']);
107    break;
108}
109
110// ¥¯¥Ã¥­¡¼È½Äê
111$objPage->tpl_login_email = $objCookie->getCookie('login_email');
112if($objPage->tpl_login_email != "") {
113    $objPage->tpl_login_memory = "1";
114}
115
116// ÁªÂòÍÑÆüÉդμèÆÀ
117$objDate = new SC_Date(START_BIRTH_YEAR);
118$objPage->arrYear = $objDate->getYear('', 1950);    //¡¡ÆüÉÕ¥×¥ë¥À¥¦¥óÀßÄê
119$objPage->arrMonth = $objDate->getMonth();
120$objPage->arrDay = $objDate->getDay();
121
122if($objPage->year == '') {
123    $objPage->year = '----';
124}
125
126// ÆþÎÏÃͤμèÆÀ
127$objPage->arrForm = $objFormParam->getFormParamList();
128
129if($objPage->arrForm['year']['value'] == ""){
130    $objPage->arrForm['year']['value'] = '----';   
131}
132
133$objView->assignobj($objPage);
134// ¥Õ¥ì¡¼¥à¤òÁªÂò(¥­¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹)
135$objCampaignSess->pageView($objView);
136//--------------------------------------------------------------------------------------------------------------------------
137/* Èó²ñ°÷ÆþÎÏ¥Ú¡¼¥¸¤Î¥»¥Ã¥È */
138function lfSetNonMember($objPage) {
139    $objPage->tpl_mainpage = 'shopping/nonmember_input.tpl';
140    $objPage->tpl_css = array();
141    $objPage->tpl_css[] = URL_DIR.'css/layout/login/nonmember.css';
142    return $objPage;
143}
144
145/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
146function lfInitParam() {
147    global $objFormParam;
148    $objFormParam->addParam("¤ªÌ¾Á°¡ÊÀ«¡Ë", "order_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
149    $objFormParam->addParam("¤ªÌ¾Á°¡Ê̾¡Ë", "order_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
150    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê¡Ê¥»¥¤¡Ë", "order_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
151    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê¡Ê¥á¥¤¡Ë", "order_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
152    $objFormParam->addParam("͹ÊØÈÖ¹æ1", "order_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
153    $objFormParam->addParam("͹ÊØÈÖ¹æ2", "order_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
154    $objFormParam->addParam("ÅÔÆ»Éܸ©", "order_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
155    $objFormParam->addParam("½»½ê1", "order_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
156    $objFormParam->addParam("½»½ê2", "order_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
157    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ1", "order_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
158    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ2", "order_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
159    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ3", "order_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
160    $objFormParam->addParam("FAXÈÖ¹æ1", "order_fax01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
161    $objFormParam->addParam("FAXÈÖ¹æ2", "order_fax02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
162    $objFormParam->addParam("FAXÈÖ¹æ3", "order_fax03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
163    $objFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹", "order_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "NO_SPTAB", "MAX_LENGTH_CHECK", "EMAIL_CHECK", "EMAIL_CHAR_CHECK"));
164    $objFormParam->addParam("¥á¡¼¥ë¥¢¥É¥ì¥¹¡Ê³Îǧ¡Ë", "order_email_check", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "NO_SPTAB", "MAX_LENGTH_CHECK", "EMAIL_CHECK", "EMAIL_CHAR_CHECK"), "", false);
165    $objFormParam->addParam("ǯ", "year", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
166    $objFormParam->addParam("·î", "month", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
167    $objFormParam->addParam("Æü", "day", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
168    $objFormParam->addParam("À­ÊÌ", "order_sex", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
169    $objFormParam->addParam("¿¦¶È", "order_job", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
170    $objFormParam->addParam("Ê̤ΤªÆϤ±Àè", "deliv_check", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
171    $objFormParam->addParam("¤ªÌ¾Á°¡ÊÀ«¡Ë", "deliv_name01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
172    $objFormParam->addParam("¤ªÌ¾Á°¡Ê̾¡Ë", "deliv_name02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
173    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê¡Ê¥»¥¤¡Ë", "deliv_kana01", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
174    $objFormParam->addParam("¥Õ¥ê¥¬¥Ê¡Ê¥á¥¤¡Ë", "deliv_kana02", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
175    $objFormParam->addParam("͹ÊØÈÖ¹æ1", "deliv_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
176    $objFormParam->addParam("͹ÊØÈÖ¹æ2", "deliv_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
177    $objFormParam->addParam("ÅÔÆ»Éܸ©", "deliv_pref", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
178    $objFormParam->addParam("½»½ê1", "deliv_addr01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
179    $objFormParam->addParam("½»½ê2", "deliv_addr02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
180    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ1", "deliv_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
181    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ2", "deliv_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
182    $objFormParam->addParam("ÅÅÏÃÈÖ¹æ3", "deliv_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
183    $objFormParam->addParam("¥á¡¼¥ë¥Þ¥¬¥¸¥ó", "mail_flag", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), 1);
184}
185
186/* DB¤Ø¥Ç¡¼¥¿¤ÎÅÐÏ¿ */
187function lfRegistData($uniqid) {
188    global $objFormParam;
189    $arrRet = $objFormParam->getHashArray();
190    $sqlval = $objFormParam->getDbArray();
191    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
192    $sqlval['order_temp_id'] = $uniqid;
193    $sqlval['order_birth'] = sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
194    $sqlval['update_date'] = 'Now()';
195    $sqlval['customer_id'] = '0';
196   
197    // ´û¸¥Ç¡¼¥¿¤Î¥Á¥§¥Ã¥¯
198    $objQuery = new SC_Query();
199    $where = "order_temp_id = ?";
200    $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
201    // ´û¸¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç
202    if ($cnt == 0) {
203        $sqlval['create_date'] = 'Now()';
204        $objQuery->insert("dtb_order_temp", $sqlval);
205    } else {
206        $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
207    }
208   
209}
210
211/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
212function lfCheckError() {
213    global $objFormParam;
214    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
215    $arrRet =  $objFormParam->getHashArray();
216    $objErr = new SC_CheckError($arrRet);
217    $objErr->arrErr = $objFormParam->checkError();
218       
219    // Ê̤ΤªÆϤ±Àè¥Á¥§¥Ã¥¯
220    if($_POST['deliv_check'] == "1") {
221        $objErr->doFunc(array("¤ªÌ¾Á°¡ÊÀ«¡Ë", "deliv_name01"), array("EXIST_CHECK"));
222        $objErr->doFunc(array("¤ªÌ¾Á°¡Ê̾¡Ë", "deliv_name02"), array("EXIST_CHECK"));
223        $objErr->doFunc(array("¥Õ¥ê¥¬¥Ê¡Ê¥»¥¤¡Ë", "deliv_kana01"), array("EXIST_CHECK"));
224        $objErr->doFunc(array("¥Õ¥ê¥¬¥Ê¡Ê¥á¥¤¡Ë", "deliv_kana02"), array("EXIST_CHECK"));
225        $objErr->doFunc(array("͹ÊØÈÖ¹æ1", "deliv_zip01"), array("EXIST_CHECK"));
226        $objErr->doFunc(array("͹ÊØÈÖ¹æ2", "deliv_zip02"), array("EXIST_CHECK"));
227        $objErr->doFunc(array("ÅÔÆ»Éܸ©", "deliv_pref"), array("EXIST_CHECK"));
228        $objErr->doFunc(array("½»½ê1", "deliv_addr01"), array("EXIST_CHECK"));
229        $objErr->doFunc(array("½»½ê2", "deliv_addr02"), array("EXIST_CHECK"));
230        $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ1", "deliv_tel01"), array("EXIST_CHECK"));
231        $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ2", "deliv_tel02"), array("EXIST_CHECK"));
232        $objErr->doFunc(array("ÅÅÏÃÈÖ¹æ3", "deliv_tel03"), array("EXIST_CHECK"));
233    }
234   
235    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
236    $objErr->doFunc(array("TEL", "order_tel01", "order_tel02", "order_tel03", TEL_ITEM_LEN), array("TEL_CHECK"));
237    $objErr->doFunc(array("FAX", "order_fax01", "order_fax02", "order_fax03", TEL_ITEM_LEN), array("TEL_CHECK"));
238    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "order_zip01", "order_zip02"), array("ALL_EXIST_CHECK"));
239    $objErr->doFunc(array("TEL", "deliv_tel01", "deliv_tel02", "deliv_tel03", TEL_ITEM_LEN), array("TEL_CHECK"));
240    $objErr->doFunc(array("FAX", "deliv_fax01", "deliv_fax02", "deliv_fax03", TEL_ITEM_LEN), array("TEL_CHECK"));
241    $objErr->doFunc(array("͹ÊØÈÖ¹æ", "deliv_zip01", "deliv_zip02"), array("ALL_EXIST_CHECK"));
242    $objErr->doFunc(array("À¸Ç¯·îÆü", "year", "month", "day"), array("CHECK_DATE"));
243    $objErr->doFunc(array("¥á¡¼¥ë¥¢¥É¥ì¥¹", "¥á¡¼¥ë¥¢¥É¥ì¥¹¡Ê³Îǧ¡Ë", "order_email", "order_email_check"), array("EQUAL_CHECK"));
244   
245    // ¤¹¤Ç¤Ë¥á¥ë¥Þ¥¬¥Æ¡¼¥Ö¥ë¤Ë²ñ°÷¤È¤·¤Æ¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾ì¹ç
246    if(sfCheckCustomerMailMaga($arrRet['order_email'])) {
247        $objErr->arrErr['order_email'] = "¤³¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ï¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£<br />";
248    }
249       
250    return $objErr->arrErr;
251}
252
253// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¤ªÆϤ±Àè¤ò¥³¥Ô¡¼¤¹¤ë
254function lfCopyDeliv($uniqid, $arrData) {
255    $objQuery = new SC_Query();
256   
257    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
258    if($arrData["deliv_check"] != "1") {
259        $sqlval['deliv_name01'] = $arrData['order_name01'];
260        $sqlval['deliv_name02'] = $arrData['order_name02'];
261        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
262        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
263        $sqlval['deliv_pref'] = $arrData['order_pref'];
264        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
265        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
266        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
267        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
268        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
269        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
270        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
271        $where = "order_temp_id = ?";
272        $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
273    }
274}
275
276
277?>
Note: See TracBrowser for help on using the repository browser.