| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | // {{{ requires |
|---|
| 9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * MyPage のページクラス. |
|---|
| 13 | * |
|---|
| 14 | * @package Page |
|---|
| 15 | * @author LOCKON CO.,LTD. |
|---|
| 16 | * @version $Id$ |
|---|
| 17 | */ |
|---|
| 18 | class LC_Page_MyPage extends LC_Page { |
|---|
| 19 | |
|---|
| 20 | // {{{ properties |
|---|
| 21 | |
|---|
| 22 | /** ページナンバー */ |
|---|
| 23 | var $tpl_pageno; |
|---|
| 24 | |
|---|
| 25 | // }}} |
|---|
| 26 | // {{{ functions |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * Page を初期化する. |
|---|
| 30 | * |
|---|
| 31 | * @return void |
|---|
| 32 | */ |
|---|
| 33 | function init() { |
|---|
| 34 | parent::init(); |
|---|
| 35 | $this->tpl_mainpage = TEMPLATE_DIR .'mypage/index.tpl'; |
|---|
| 36 | $this->tpl_title = 'MYページ/購入履歴一覧'; |
|---|
| 37 | $this->tpl_navi = TEMPLATE_DIR . 'mypage/navi.tpl'; |
|---|
| 38 | $this->tpl_column_num = 1; |
|---|
| 39 | $this->tpl_mainno = 'mypage'; |
|---|
| 40 | $this->tpl_mypageno = 'index'; |
|---|
| 41 | $this->allowClientCache(); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | /** |
|---|
| 45 | * Page のプロセス. |
|---|
| 46 | * |
|---|
| 47 | * @return void |
|---|
| 48 | */ |
|---|
| 49 | function process() { |
|---|
| 50 | |
|---|
| 51 | $objView = new SC_SiteView(); |
|---|
| 52 | $objQuery = new SC_Query(); |
|---|
| 53 | $objCustomer = new SC_Customer(); |
|---|
| 54 | |
|---|
| 55 | // レイアウトデザインを取得 |
|---|
| 56 | $objLayout = new SC_Helper_PageLayout_Ex(); |
|---|
| 57 | $objLayout->sfGetPageLayout($this, false, "mypage/index.php"); |
|---|
| 58 | |
|---|
| 59 | // ログインチェック |
|---|
| 60 | if(!isset($_SESSION['customer'])) { |
|---|
| 61 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
|---|
| 62 | }else { |
|---|
| 63 | //マイページトップ顧客情報表示用 |
|---|
| 64 | $this->CustomerName1 = $objCustomer->getvalue('name01'); |
|---|
| 65 | $this->CustomerName2 = $objCustomer->getvalue('name02'); |
|---|
| 66 | $this->CustomerPoint = $objCustomer->getvalue('point'); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | //ページ送り用 |
|---|
| 70 | if (isset($_POST['pageno'])) { |
|---|
| 71 | $this->tpl_pageno = htmlspecialchars($_POST['pageno'], ENT_QUOTES, CHAR_CODE); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | $col = "order_id, create_date, payment_id, payment_total"; |
|---|
| 75 | $from = "dtb_order"; |
|---|
| 76 | $where = "del_flg = 0 AND customer_id=?"; |
|---|
| 77 | $arrval = array($objCustomer->getvalue('customer_id')); |
|---|
| 78 | $order = "order_id DESC"; |
|---|
| 79 | |
|---|
| 80 | $linemax = $objQuery->count($from, $where, $arrval); |
|---|
| 81 | $this->tpl_linemax = $linemax; |
|---|
| 82 | |
|---|
| 83 | // ページ送りの取得 |
|---|
| 84 | $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX); |
|---|
| 85 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
|---|
| 86 | $startno = $objNavi->start_row; |
|---|
| 87 | |
|---|
| 88 | // 取得範囲の指定(開始行番号、行数のセット) |
|---|
| 89 | $objQuery->setlimitoffset(SEARCH_PMAX, $startno); |
|---|
| 90 | // 表示順序 |
|---|
| 91 | $objQuery->setorder($order); |
|---|
| 92 | |
|---|
| 93 | //購入履歴の取得 |
|---|
| 94 | $this->arrOrder = $objQuery->select($col, $from, $where, $arrval); |
|---|
| 95 | |
|---|
| 96 | // 支払い方法の取得 |
|---|
| 97 | $objDb = new SC_Helper_DB_Ex(); |
|---|
| 98 | $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); |
|---|
| 99 | |
|---|
| 100 | $objView->assignobj($this); //$objpage内の全てのテンプレート変数をsmartyに格納 |
|---|
| 101 | $objView->display(SITE_FRAME); //パスとテンプレート変数の呼び出し、実行 |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | /** |
|---|
| 105 | * モバイルページを初期化する. |
|---|
| 106 | * |
|---|
| 107 | * @return void |
|---|
| 108 | */ |
|---|
| 109 | function mobileInit() { |
|---|
| 110 | $this->tpl_mainpage = 'mypage/index.tpl'; |
|---|
| 111 | $this->tpl_title = 'MYページ/購入履歴一覧'; |
|---|
| 112 | $this->allowClientCache(); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | /** |
|---|
| 116 | * Page のプロセス(モバイル). |
|---|
| 117 | * |
|---|
| 118 | * @return void |
|---|
| 119 | */ |
|---|
| 120 | function mobileProcess() { |
|---|
| 121 | $objView = new SC_MobileView(); |
|---|
| 122 | $objQuery = new SC_Query(); |
|---|
| 123 | $objCustomer = new SC_Customer(); |
|---|
| 124 | // クッキー管理クラス |
|---|
| 125 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
|---|
| 126 | // パラメータ管理クラス |
|---|
| 127 | $objFormParam = new SC_FormParam(); |
|---|
| 128 | // パラメータ情報の初期化 |
|---|
| 129 | $this->lfInitParam($objFormParam); |
|---|
| 130 | // POST値の取得 |
|---|
| 131 | $objFormParam->setParam($_POST); |
|---|
| 132 | |
|---|
| 133 | // 携帯端末IDが一致する会員が存在するかどうかをチェックする。 |
|---|
| 134 | $this->tpl_valid_phone_id = $objCustomer->checkMobilePhoneId(); |
|---|
| 135 | |
|---|
| 136 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
|---|
| 137 | |
|---|
| 138 | // ログイン処理 |
|---|
| 139 | if($_POST['mode'] == 'login') { |
|---|
| 140 | $objFormParam->toLower('login_email'); |
|---|
| 141 | $arrErr = $objFormParam->checkError(); |
|---|
| 142 | $arrForm = $objFormParam->getHashArray(); |
|---|
| 143 | |
|---|
| 144 | // クッキー保存判定 |
|---|
| 145 | if ($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") { |
|---|
| 146 | $objCookie->setCookie('login_email', $_POST['login_email']); |
|---|
| 147 | } else { |
|---|
| 148 | $objCookie->setCookie('login_email', ''); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | if (count($arrErr) == 0){ |
|---|
| 152 | if($objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) || |
|---|
| 153 | $objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { |
|---|
| 154 | // ログインが成功した場合は携帯端末IDを保存する。 |
|---|
| 155 | $objCustomer->updateMobilePhoneId(); |
|---|
| 156 | |
|---|
| 157 | // 携帯のメールアドレスをコピーする。 |
|---|
| 158 | $objCustomer->updateEmailMobile(); |
|---|
| 159 | |
|---|
| 160 | // XXX 動作しない時がある... |
|---|
| 161 | // 携帯のメールアドレスが登録されていない場合 |
|---|
| 162 | if (!$objCustomer->hasValue('email_mobile')) { |
|---|
| 163 | $this->sendRedirect($this->getLocation("../entry/email_mobile.php", array(session_name() => session_id()))); |
|---|
| 164 | exit; |
|---|
| 165 | } |
|---|
| 166 | } else { |
|---|
| 167 | $objQuery = new SC_Query; |
|---|
| 168 | $where = "email = ? AND status = 1 AND del_flg = 0"; |
|---|
| 169 | $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'])); |
|---|
| 170 | |
|---|
| 171 | if($ret > 0) { |
|---|
| 172 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR, "", false, "", true); |
|---|
| 173 | } else { |
|---|
| 174 | SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR, "", false, "", true); |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | } |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | // ログインチェック |
|---|
| 181 | if(!$objCustomer->isLoginSuccess()) { |
|---|
| 182 | $this->tpl_mainpage = 'mypage/login.tpl'; |
|---|
| 183 | $objView->assignArray($objFormParam->getHashArray()); |
|---|
| 184 | if (empty($arrErr)) $arrErr = array(); |
|---|
| 185 | $objView->assignArray(array("arrErr" => $arrErr)); |
|---|
| 186 | }else { |
|---|
| 187 | //マイページトップ顧客情報表示用 |
|---|
| 188 | $this->CustomerName1 = $objCustomer->getvalue('name01'); |
|---|
| 189 | $this->CustomerName2 = $objCustomer->getvalue('name02'); |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | $objView->assignobj($this); //$objpage内の全てのテンプレート変数をsmartyに格納 |
|---|
| 193 | $objView->display(SITE_FRAME); //パスとテンプレート変数の呼び出し、実行 |
|---|
| 194 | |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | /** |
|---|
| 198 | * デストラクタ. |
|---|
| 199 | * |
|---|
| 200 | * @return void |
|---|
| 201 | */ |
|---|
| 202 | function destroy() { |
|---|
| 203 | parent::destroy(); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | //エラーチェック |
|---|
| 207 | |
|---|
| 208 | function lfErrorCheck() { |
|---|
| 209 | $objErr = new SC_CheckError(); |
|---|
| 210 | $objErr->doFunc(array("メールアドレス", "login_email", STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","EMAIL_CHECK","MAX_LENGTH_CHECK")); |
|---|
| 211 | $objErr->dofunc(array("パスワード", "login_password", PASSWORD_LEN2), array("EXIST_CHECK","ALNUM_CHECK")); |
|---|
| 212 | return $objErr->arrErr; |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | /* パラメータ情報の初期化 */ |
|---|
| 216 | function lfInitParam(&$objFormParam) { |
|---|
| 217 | |
|---|
| 218 | $objFormParam->addParam("記憶する", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
|---|
| 219 | $objFormParam->addParam("メールアドレス", "login_email", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 220 | $objFormParam->addParam("パスワード", "login_pass", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | } |
|---|
| 224 | ?> |
|---|