source: branches/feature-module-update/html/shopping/deliv.php @ 15080

Revision 15080, 10.9 KB checked in by nanasess, 15 years ago (diff)

svn properties 設定

  • svn:mime-type - application/x-httpd-php; charset=UTF-8
  • svn:keywords - Id
  • Property svn:keywords set to Id
  • Property svn:mime-type set to application/x-httpd-php; charset=UTF-8
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.