1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2014 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 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * お問い合わせ のページクラス. |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class LC_Page_Contact extends LC_Page_Ex |
---|
34 | { |
---|
35 | /** |
---|
36 | * Page を初期化する. |
---|
37 | * |
---|
38 | * @return void |
---|
39 | */ |
---|
40 | public function init() |
---|
41 | { |
---|
42 | parent::init(); |
---|
43 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
44 | $this->tpl_title = 'お問い合わせ'; |
---|
45 | } else { |
---|
46 | $this->tpl_title = 'お問い合わせ(入力ページ)'; |
---|
47 | } |
---|
48 | $this->httpCacheControl('nocache'); |
---|
49 | |
---|
50 | $masterData = new SC_DB_MasterData_Ex(); |
---|
51 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
52 | |
---|
53 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
54 | // @deprecated EC-CUBE 2.11 テンプレート互換用 |
---|
55 | $this->CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Page のプロセス. |
---|
61 | * |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | public function process() |
---|
65 | { |
---|
66 | parent::process(); |
---|
67 | $this->action(); |
---|
68 | $this->sendResponse(); |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * Page のアクション. |
---|
73 | * |
---|
74 | * @return void |
---|
75 | */ |
---|
76 | public function action() |
---|
77 | { |
---|
78 | $objFormParam = new SC_FormParam_Ex(); |
---|
79 | |
---|
80 | $this->arrData = isset($_SESSION['customer']) ? $_SESSION['customer'] : ''; |
---|
81 | |
---|
82 | switch ($this->getMode()) { |
---|
83 | case 'confirm': |
---|
84 | // エラーチェック |
---|
85 | $this->lfInitParam($objFormParam); |
---|
86 | $objFormParam->setParam($_POST); |
---|
87 | $objFormParam->convParam(); |
---|
88 | $objFormParam->toLower('email'); |
---|
89 | $objFormParam->toLower('email02'); |
---|
90 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
91 | // 入力値の取得 |
---|
92 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
93 | |
---|
94 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
95 | // エラー無しで完了画面 |
---|
96 | $this->tpl_mainpage = 'contact/confirm.tpl'; |
---|
97 | $this->tpl_title = 'お問い合わせ(確認ページ)'; |
---|
98 | } |
---|
99 | |
---|
100 | break; |
---|
101 | |
---|
102 | case 'return': |
---|
103 | $this->lfInitParam($objFormParam); |
---|
104 | $objFormParam->setParam($_POST); |
---|
105 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
106 | |
---|
107 | break; |
---|
108 | |
---|
109 | case 'complete': |
---|
110 | $this->lfInitParam($objFormParam); |
---|
111 | $objFormParam->setParam($_POST); |
---|
112 | $this->arrErr = $objFormParam->checkError(); |
---|
113 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
114 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
115 | $this->lfSendMail($this); |
---|
116 | |
---|
117 | // 完了ページへ移動する |
---|
118 | SC_Response_Ex::sendRedirect('complete.php'); |
---|
119 | SC_Response_Ex::actionExit(); |
---|
120 | } else { |
---|
121 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
122 | SC_Response_Ex::actionExit(); |
---|
123 | } |
---|
124 | break; |
---|
125 | |
---|
126 | default: |
---|
127 | break; |
---|
128 | } |
---|
129 | |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * お問い合わせ入力時のパラメーター情報の初期化を行う. |
---|
134 | * |
---|
135 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
136 | * @return void |
---|
137 | */ |
---|
138 | public function lfInitParam(&$objFormParam) |
---|
139 | { |
---|
140 | $objFormParam->addParam('お名前(姓)', 'name01', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
141 | $objFormParam->addParam('お名前(名)', 'name02', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
142 | $objFormParam->addParam('お名前(フリガナ・姓)', 'kana01', STEXT_LEN, 'KVCa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); |
---|
143 | $objFormParam->addParam('お名前(フリガナ・名)', 'kana02', STEXT_LEN, 'KVCa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); |
---|
144 | $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
145 | $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
146 | $objFormParam->addParam('都道府県', 'pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
147 | $objFormParam->addParam('住所1', 'addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
148 | $objFormParam->addParam('住所2', 'addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
149 | $objFormParam->addParam('お問い合わせ内容', 'contents', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
150 | $objFormParam->addParam('メールアドレス', 'email', null, 'KVa', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
151 | $objFormParam->addParam('メールアドレス(確認)', 'email02', null, 'KVa', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
152 | $objFormParam->addParam('お電話番号1', 'tel01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
153 | $objFormParam->addParam('お電話番号2', 'tel02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
154 | $objFormParam->addParam('お電話番号3', 'tel03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
155 | } |
---|
156 | |
---|
157 | /** |
---|
158 | * 入力内容のチェックを行なう. |
---|
159 | * |
---|
160 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
161 | * @return array 入力チェック結果の配列 |
---|
162 | */ |
---|
163 | public function lfCheckError(&$objFormParam) |
---|
164 | { |
---|
165 | // 入力データを渡す。 |
---|
166 | $arrForm = $objFormParam->getHashArray(); |
---|
167 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
168 | $objErr->arrErr = $objFormParam->checkError(); |
---|
169 | $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'email', 'email02'), array('EQUAL_CHECK')); |
---|
170 | |
---|
171 | return $objErr->arrErr; |
---|
172 | } |
---|
173 | |
---|
174 | /** |
---|
175 | * メールの送信を行う。 |
---|
176 | * |
---|
177 | * @param LC_Page_Contact $objPage |
---|
178 | * @return void |
---|
179 | */ |
---|
180 | public function lfSendMail(&$objPage) |
---|
181 | { |
---|
182 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
183 | $objPage->tpl_shopname = $CONF['shop_name']; |
---|
184 | $objPage->tpl_infoemail = $CONF['email02']; |
---|
185 | $helperMail = new SC_Helper_Mail_Ex(); |
---|
186 | $helperMail->setPage($this); |
---|
187 | $helperMail->sfSendTemplateMail( |
---|
188 | $objPage->arrForm['email']['value'], // to |
---|
189 | $objPage->arrForm['name01']['value'] .' 様', // to_name |
---|
190 | 5, // template_id |
---|
191 | $objPage, // objPage |
---|
192 | $CONF['email03'], // from_address |
---|
193 | $CONF['shop_name'], // from_name |
---|
194 | $CONF['email02'], // reply_to |
---|
195 | $CONF['email02'] // bcc |
---|
196 | ); |
---|
197 | } |
---|
198 | } |
---|