[15640] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15640] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15640] | 22 | */ |
---|
| 23 | |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15640] | 25 | |
---|
| 26 | /** |
---|
| 27 | * メルマガ管理 のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22856] | 33 | class LC_Page_Admin_Mail extends LC_Page_Admin_Ex |
---|
[22567] | 34 | { |
---|
[15640] | 35 | /** |
---|
| 36 | * Page を初期化する. |
---|
| 37 | * |
---|
| 38 | * @return void |
---|
| 39 | */ |
---|
[22567] | 40 | function init() |
---|
| 41 | { |
---|
[15640] | 42 | parent::init(); |
---|
| 43 | $this->tpl_mainpage = 'mail/index.tpl'; |
---|
| 44 | $this->tpl_mainno = 'mail'; |
---|
[20538] | 45 | $this->tpl_subno = 'index'; |
---|
[20128] | 46 | $this->tpl_pager = 'pager.tpl'; |
---|
[20911] | 47 | $this->tpl_maintitle = 'メルマガ管理'; |
---|
[15640] | 48 | $this->tpl_subtitle = '配信内容設定'; |
---|
| 49 | |
---|
| 50 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[19773] | 51 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[21481] | 52 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
[21514] | 53 | $this->arrJob['不明'] = '不明'; |
---|
[21481] | 54 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
| 55 | $this->arrPageRows = $masterData->getMasterData('mtb_page_max'); |
---|
[21514] | 56 | $this->arrHtmlmail = array('' => '両方', 1 => 'HTML', 2 => 'TEXT'); |
---|
[21481] | 57 | $this->arrMailType = $masterData->getMasterData('mtb_mail_type'); |
---|
[20540] | 58 | |
---|
[20283] | 59 | // 日付プルダウン設定 |
---|
[20499] | 60 | $objDate = new SC_Date_Ex(BIRTH_YEAR); |
---|
[21017] | 61 | $this->arrBirthYear = $objDate->getYear(); |
---|
| 62 | $this->arrRegistYear = $objDate->getYear(); |
---|
[20283] | 63 | $this->arrMonth = $objDate->getMonth(); |
---|
| 64 | $this->arrDay = $objDate->getDay(); |
---|
| 65 | $this->objDate = $objDate; |
---|
[15640] | 66 | |
---|
[20283] | 67 | // カテゴリ一覧設定 |
---|
| 68 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 69 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
[20540] | 70 | |
---|
[20343] | 71 | // テンプレート一覧設定 |
---|
[20357] | 72 | $this->arrTemplate = $this->lfGetMailTemplateList(SC_Helper_Mail_Ex::sfGetMailmagaTemplate()); |
---|
[20540] | 73 | |
---|
[18187] | 74 | $this->httpCacheControl('nocache'); |
---|
[15640] | 75 | } |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | * Page のプロセス. |
---|
| 79 | * |
---|
| 80 | * @return void |
---|
| 81 | */ |
---|
[22567] | 82 | function process() |
---|
| 83 | { |
---|
[19661] | 84 | $this->action(); |
---|
| 85 | $this->sendResponse(); |
---|
| 86 | } |
---|
[15640] | 87 | |
---|
[19661] | 88 | /** |
---|
| 89 | * Page のアクション. |
---|
| 90 | * |
---|
| 91 | * @return void |
---|
| 92 | */ |
---|
[22567] | 93 | function action() |
---|
| 94 | { |
---|
[20970] | 95 | // パラメーター管理クラス |
---|
[20501] | 96 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20283] | 97 | $this->lfInitParamSearchCustomer($objFormParam); |
---|
| 98 | $objFormParam->setParam($_POST); |
---|
| 99 | |
---|
| 100 | // パラメーター読み込み |
---|
| 101 | $this->arrHidden = $objFormParam->getSearchArray(); |
---|
| 102 | |
---|
| 103 | // 入力パラメーターチェック |
---|
[20343] | 104 | $this->arrErr = SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam); |
---|
| 105 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[21684] | 106 | if (!SC_Utils_Ex::isBlank($this->arrErr)) return; |
---|
[20540] | 107 | |
---|
[20283] | 108 | // モードによる処理切り替え |
---|
| 109 | switch ($this->getMode()) { |
---|
[21526] | 110 | // 配信先検索 |
---|
| 111 | case 'search': |
---|
| 112 | case 'back': |
---|
| 113 | list($this->tpl_linemax, $this->arrResults, $this->objNavi) = SC_Helper_Customer_Ex::sfGetSearchData($objFormParam->getHashArray()); |
---|
| 114 | $this->arrPagenavi = $this->objNavi->arrPagenavi; |
---|
| 115 | break; |
---|
| 116 | // input:検索結果画面「配信内容を設定する」押下後 |
---|
| 117 | case 'input': |
---|
| 118 | $this->tpl_mainpage = 'mail/input.tpl'; |
---|
| 119 | break; |
---|
| 120 | // template:テンプレート選択時 |
---|
| 121 | case 'template': |
---|
| 122 | case 'regist_back': |
---|
| 123 | $this->tpl_mainpage = 'mail/input.tpl'; |
---|
| 124 | if (SC_Utils_Ex::sfIsInt($_POST['template_id']) === true) { |
---|
| 125 | $this->lfAddParamSelectTemplate($objFormParam); |
---|
| 126 | $this->lfGetTemplateData($objFormParam, $_POST['template_id']); |
---|
| 127 | // regist_back時、subject,bodyにはテンプレートを読み込むのではなく、入力内容で上書き |
---|
[21684] | 128 | if ($this->getMode()=='regist_back') { |
---|
| 129 | $objFormParam->setParam($_POST); |
---|
| 130 | } |
---|
[21526] | 131 | } |
---|
| 132 | break; |
---|
| 133 | case 'regist_confirm': |
---|
| 134 | $this->tpl_mainpage = 'mail/input.tpl'; |
---|
[20343] | 135 | $this->lfAddParamSelectTemplate($objFormParam); |
---|
[21526] | 136 | $objFormParam->setParam($_POST); |
---|
| 137 | $this->arrErr = $objFormParam->checkError(); |
---|
| 138 | if (SC_Utils_Ex::isBlank($this->arrErr)) $this->tpl_mainpage = 'mail/input_confirm.tpl'; |
---|
| 139 | break; |
---|
| 140 | case 'regist_complete': |
---|
| 141 | $this->tpl_mainpage = 'mail/input.tpl'; |
---|
| 142 | $this->lfAddParamSelectTemplate($objFormParam); |
---|
| 143 | $objFormParam->setParam($_POST); |
---|
| 144 | $this->arrErr = $objFormParam->checkError(); |
---|
| 145 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 146 | $this->tpl_mainpage = 'mail/index.tpl'; |
---|
| 147 | SC_Helper_Mail_Ex::sfSendMailmagazine($this->lfRegisterData($objFormParam)); // DB登録・送信 |
---|
[21591] | 148 | |
---|
[21526] | 149 | SC_Response_Ex::sendRedirect('./history.php'); |
---|
| 150 | } |
---|
| 151 | break; |
---|
| 152 | // query:配信履歴から「確認」 |
---|
| 153 | case 'query': |
---|
| 154 | if (SC_Utils_Ex::sfIsInt($_GET['send_id'])) { |
---|
| 155 | $this->arrSearchData = $this->lfGetMailQuery(); |
---|
| 156 | } |
---|
| 157 | $this->setTemplate('mail/query.tpl'); |
---|
| 158 | break; |
---|
| 159 | // query:配信履歴から「再送信」 |
---|
| 160 | case 'retry': |
---|
| 161 | if (SC_Utils_Ex::sfIsInt($_GET['send_id'])) { |
---|
| 162 | SC_Helper_Mail_Ex::sfSendMailmagazine($_GET['send_id']); // DB登録・送信 |
---|
[21591] | 163 | |
---|
[21526] | 164 | SC_Response_Ex::sendRedirect('./history.php'); |
---|
| 165 | } else { |
---|
| 166 | $this->tpl_onload = "window.alert('メール送信IDが正しくありません');"; |
---|
| 167 | } |
---|
| 168 | break; |
---|
| 169 | default: |
---|
| 170 | break; |
---|
[15640] | 171 | } |
---|
[20343] | 172 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[15640] | 173 | } |
---|
| 174 | |
---|
| 175 | /** |
---|
[21419] | 176 | * パラメーター情報の初期化(初期会員検索時) |
---|
[20283] | 177 | * |
---|
| 178 | * @param array $objFormParam フォームパラメータークラス |
---|
| 179 | * @return void |
---|
| 180 | */ |
---|
[22567] | 181 | function lfInitParamSearchCustomer(&$objFormParam) |
---|
| 182 | { |
---|
[20283] | 183 | SC_Helper_Customer_Ex::sfSetSearchParam($objFormParam); |
---|
[21480] | 184 | $objFormParam->addParam('配信形式', 'search_htmlmail', INT_LEN, 'n', array('NUM_CHECK','MAX_LENGTH_CHECK')); |
---|
| 185 | $objFormParam->addParam('配信メールアドレス種別', 'search_mail_type', INT_LEN, 'n', array('NUM_CHECK','MAX_LENGTH_CHECK')); |
---|
[20283] | 186 | } |
---|
[20540] | 187 | |
---|
[20283] | 188 | /** |
---|
[20343] | 189 | * パラメーター情報の追加(テンプレート選択) |
---|
[20283] | 190 | * |
---|
| 191 | * @param array $objFormParam フォームパラメータークラス |
---|
[20343] | 192 | * @return void |
---|
[20283] | 193 | */ |
---|
[22567] | 194 | function lfAddParamSelectTemplate(&$objFormParam) |
---|
| 195 | { |
---|
[21514] | 196 | $objFormParam->addParam('メール形式', 'mail_method', INT_LEN, 'n', array('EXIST_CHECK','ALNUM_CHECK')); |
---|
[21480] | 197 | $objFormParam->addParam('Subject', 'subject', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); |
---|
[21514] | 198 | $objFormParam->addParam('本文', 'body', LLTEXT_LEN, 'KVCa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); |
---|
[21515] | 199 | $objFormParam->addParam('テンプレートID', 'template_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); |
---|
[20283] | 200 | } |
---|
[20540] | 201 | |
---|
[20283] | 202 | /** |
---|
[20357] | 203 | * メルマガテンプレート一覧情報の取得 |
---|
[20283] | 204 | * |
---|
[20357] | 205 | * @param array $arrTemplate SC_Helper_Mail_Ex::sfGetMailmagaTemplate()の戻り値 |
---|
[21017] | 206 | * @return array key:template_id value:サブジェクト【配信形式】 |
---|
[20283] | 207 | */ |
---|
[22567] | 208 | function lfGetMailTemplateList($arrTemplate) |
---|
| 209 | { |
---|
[21442] | 210 | if (is_array($arrTemplate)) { |
---|
| 211 | foreach ($arrTemplate as $line) { |
---|
[21515] | 212 | $return[$line['template_id']] = '【' . $this->arrHtmlmail[$line['mail_method']] . '】' . $line['subject']; |
---|
[15640] | 213 | } |
---|
| 214 | } |
---|
[22856] | 215 | |
---|
[20343] | 216 | return $return; |
---|
[15640] | 217 | } |
---|
[20540] | 218 | |
---|
[18631] | 219 | /** |
---|
[20343] | 220 | * テンプレートIDから情報の取得して$objFormParamにset_paramする |
---|
| 221 | * |
---|
| 222 | * @param array $objFormParam フォームパラメータークラス |
---|
| 223 | * @param array $template_id テンプレートID |
---|
| 224 | * @return void |
---|
| 225 | */ |
---|
[22567] | 226 | function lfGetTemplateData(&$objFormParam, $template_id) |
---|
| 227 | { |
---|
[20507] | 228 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[21514] | 229 | $objQuery->setOrder('template_id DESC'); |
---|
[20343] | 230 | $where = 'template_id = ?'; |
---|
| 231 | $arrResults = $objQuery->getRow('*', 'dtb_mailmaga_template', $where, array($template_id)); |
---|
| 232 | $objFormParam->setParam($arrResults); |
---|
| 233 | } |
---|
[20540] | 234 | |
---|
[20343] | 235 | /** |
---|
[18631] | 236 | * 配信内容と配信リストを書き込む |
---|
| 237 | * |
---|
[20357] | 238 | * @return integer 登録した行の dtb_send_history.send_id の値 |
---|
[18631] | 239 | */ |
---|
[22567] | 240 | function lfRegisterData(&$objFormParam) |
---|
| 241 | { |
---|
[20507] | 242 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20540] | 243 | |
---|
[21189] | 244 | list($linemax, $arrSendCustomer, $objNavi) = SC_Helper_Customer_Ex::sfGetSearchData($objFormParam->getHashArray(), 'All'); |
---|
[20343] | 245 | $send_customer_cnt = count($arrSendCustomer); |
---|
[15640] | 246 | |
---|
[20343] | 247 | $send_id = $objQuery->nextVal('dtb_send_history_send_id'); |
---|
[15640] | 248 | $dtb_send_history = array(); |
---|
[21481] | 249 | $dtb_send_history['mail_method'] = $objFormParam->getValue('mail_method'); |
---|
[20538] | 250 | $dtb_send_history['subject'] = $objFormParam->getValue('subject'); |
---|
| 251 | $dtb_send_history['body'] = $objFormParam->getValue('body'); |
---|
[21481] | 252 | $dtb_send_history['start_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 253 | $dtb_send_history['creator_id'] = $_SESSION['member_id']; |
---|
| 254 | $dtb_send_history['send_count'] = $send_customer_cnt; |
---|
| 255 | $dtb_send_history['search_data'] = serialize($objFormParam->getSearchArray()); |
---|
| 256 | $dtb_send_history['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 257 | $dtb_send_history['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20343] | 258 | $dtb_send_history['send_id'] = $send_id; |
---|
[21481] | 259 | $objQuery->insert('dtb_send_history', $dtb_send_history); |
---|
[21017] | 260 | // 「配信メールアドレス種別」に携帯メールアドレスが指定されている場合は、携帯メールアドレスに配信 |
---|
[21481] | 261 | $emailtype='email'; |
---|
[21017] | 262 | $searchmailtype = $objFormParam->getValue('search_mail_type'); |
---|
[21684] | 263 | if ($searchmailtype==2 || $searchmailtype==4) { |
---|
| 264 | $emailtype='email_mobile'; |
---|
| 265 | } |
---|
[21446] | 266 | if (is_array($arrSendCustomer)) { |
---|
[21442] | 267 | foreach ($arrSendCustomer as $line) { |
---|
[15640] | 268 | $dtb_send_customer = array(); |
---|
[21481] | 269 | $dtb_send_customer['customer_id'] = $line['customer_id']; |
---|
| 270 | $dtb_send_customer['send_id'] = $send_id; |
---|
[21017] | 271 | $dtb_send_customer['email'] = $line[$emailtype]; |
---|
[21515] | 272 | $dtb_send_customer['name'] = $line['name01'] . ' ' . $line['name02']; |
---|
[21481] | 273 | $objQuery->insert('dtb_send_customer', $dtb_send_customer); |
---|
[15640] | 274 | } |
---|
| 275 | } |
---|
[22856] | 276 | |
---|
[20357] | 277 | return $send_id; |
---|
[15640] | 278 | } |
---|
[20540] | 279 | |
---|
[20343] | 280 | /** |
---|
| 281 | * 配信履歴から条件を取得する |
---|
| 282 | * |
---|
| 283 | * @param integer $send_id 配信履歴番号 |
---|
[21017] | 284 | * @return array |
---|
[20343] | 285 | */ |
---|
[22567] | 286 | function lfGetMailQuery($send_id) |
---|
| 287 | { |
---|
[20507] | 288 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20540] | 289 | |
---|
[20343] | 290 | // 送信履歴より、送信条件確認画面 |
---|
[21514] | 291 | $sql = 'SELECT search_data FROM dtb_send_history WHERE send_id = ?'; |
---|
[21481] | 292 | $searchData = $objQuery->getOne($sql, array($_GET['send_id'])); |
---|
[22856] | 293 | |
---|
[20343] | 294 | return unserialize($searchData); |
---|
[15640] | 295 | } |
---|
| 296 | } |
---|