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