source: branches/comu-utf8/html/shopping/index.php @ 16016

Revision 16016, 12.7 KB checked in by adachi, 15 years ago (diff)

branches/comuをマージ

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: " . sfGetCurrentUri() . "/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.