Changeset 20343 for branches/version-2_5-dev/data/class
- Timestamp:
- 2011/02/23 16:23:39 (15 years ago)
- Location:
- branches/version-2_5-dev/data/class/pages/admin/mail
- Files:
-
- 2 edited
-
LC_Page_Admin_Mail.php (modified) (7 diffs)
-
LC_Page_Admin_Mail_Preview.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail.php
r20335 r20343 71 71 $this->arrCatList = $objDb->sfGetCategoryList(); 72 72 73 // テンプレート一覧設定 74 $this->arrTemplate = $this->lfGetMailTemplateList(SC_Helper_Mail_Ex::sfGetMailTemplate()); 75 73 76 $this->httpCacheControl('nocache'); 74 77 } … … 90 93 */ 91 94 function action() { 95 92 96 // パラメータ管理クラス 93 97 $objFormParam = new SC_FormParam(); … … 97 101 // パラメーター読み込み 98 102 $this->arrHidden = $objFormParam->getSearchArray(); 103 104 // 入力パラメーターチェック 105 $this->arrErr = SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam); 99 106 $this->arrForm = $objFormParam->getFormParamList(); 100 101 // 入力パラメーターチェック 102 $this->arrErr = $this->lfCheckError($objFormParam); 103 if(!SC_Utils_Ex::isBlank($this->arrErr)) { 104 return; 105 } 106 107 if(!SC_Utils_Ex::isBlank($this->arrErr)) return; 108 107 109 // モードによる処理切り替え 108 110 switch ($this->getMode()) { 109 case 'search': 110 list($this->tpl_linemax, $this->arrResults, $this->objNavi) = $this->lfDoSearch($objFormParam->getHashArray()); 111 $this->arrPagenavi = $this->objNavi->arrPagenavi; 112 break; 113 default: 114 break; 115 } 116 117 118 /* 119 // ページ初期設定 120 $objDate = new SC_Date(); 121 $objQuery = new SC_Query(); 122 $objDb = new SC_Helper_DB_Ex(); 123 $this->objDate = $objDate; 124 $this->arrTemplate = $this->getTemplateList($objQuery); 125 126 $objSess = new SC_Session(); 127 128 // 認証可否の判定 129 SC_Utils_Ex::sfIsSuccess($objSess); 130 131 switch($this->getMode()) { 132 case 'query': 133 // query:配信履歴「確認」 134 if (SC_Utils_Ex::sfIsInt($_GET["send_id"])) { 135 // 送信履歴より、送信条件確認画面 136 $sql = "SELECT search_data FROM dtb_send_history WHERE send_id = ?"; 137 $result = $objQuery->getOne($sql, array($_GET["send_id"])); 138 $tpl_path = "mail/query.tpl"; 139 140 $list_data = unserialize($result); 141 142 // 都道府県を変換 143 $list_data['pref_disp'] = $this->arrPref[$list_data['pref']]; 144 145 // 配信形式 146 $list_data['htmlmail_disp'] = $this->arrHtmlmail[$list_data['htmlmail']]; 147 148 // 性別の変換 149 if (count($list_data['sex']) > 0) { 150 foreach($list_data['sex'] as $key => $val){ 151 $list_data['sex'][$key] = $this->arrSex[$val]; 152 $sex_disp .= $list_data['sex'][$key] . " "; 153 } 154 $list_data['sex_disp'] = $sex_disp; 155 } 156 157 // 職業の変換 158 if (count($list_data['job']) > 0) { 159 foreach($list_data['job'] as $key => $val){ 160 $list_data['job'][$key] = $this->arrJob[$val]; 161 $job_disp .= $list_data['job'][$key] . " "; 162 } 163 $list_data['job_disp'] = $job_disp; 164 } 165 166 // カテゴリ変換 167 $arrCatList = $objDb->sfGetCategoryList(); 168 $list_data['category_name'] = $arrCatList[$list_data['category_id']]; 169 170 $this->list_data = $list_data; 171 $this->setTemplate('mail/query.tpl'); 172 return; 173 } 174 break; 175 //search:「検索」ボタン 176 //back:検索結果画面「戻る」ボタン 111 // 配信先検索 177 112 case 'search': 178 113 case 'back': 179 // 入力値コンバート 180 $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 181 182 // 入力エラーのチェック 183 $this->arrErr = $this->lfErrorCheck($this->list_data); 184 185 // 検索開始 186 if (empty($this->arrErr)) { 187 $this->list_data['name'] = isset($this->list_data['name']) 188 ? $this->list_data['name'] : ""; 189 // hidden要素作成 190 $this->arrHidden = $this->lfGetHidden($this->list_data); 191 192 // 検索データ取得 193 $objSelect = new SC_CustomerList($this->list_data, "magazine"); 194 // 生成されたWHERE文を取得する 195 list($where, $arrval) = $objSelect->getWhere(); 196 197 // 「WHERE」部分を削除する。 198 $where = ereg_replace("^WHERE", "", $where); 199 200 // 検索結果の取得 201 $from = "dtb_customer"; 202 203 // 行数の取得 204 $linemax = $objQuery->count($from, $where, $arrval); 205 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 206 207 // ページ送りの取得 208 $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnResultPageNavi", NAVI_PMAX); 209 $this->arrPagenavi = $objNavi->arrPagenavi; 210 $startno = $objNavi->start_row; 211 212 // 取得範囲の指定(開始行番号、行数のセット) 213 $objQuery->setLimitOffset(SEARCH_PMAX, $startno); 214 // 表示順序 215 $objQuery->setOrder("customer_id DESC"); 216 217 // 検索結果の取得 218 $col = $objSelect->getMailMagazineColumn($this->lfGetIsMobile($_POST['mail_type'])); 219 $this->arrResults = $objQuery->select($col, $from, $where, $arrval); 220 // 現在時刻の取得 221 $this->arrNowDate = $this->lfGetNowDate(); 222 } 223 break; 224 // input:検索結果画面「htmlmail内容設定」ボタン 114 list($this->tpl_linemax, $this->arrResults, $this->objNavi) = SC_Helper_Customer_Ex::sfGetSearchData($objFormParam->getHashArray()); 115 $this->arrPagenavi = $this->objNavi->arrPagenavi; 116 break; 117 // input:検索結果画面「配信内容を設定する」押下後 225 118 case 'input': 226 // 入力値コンバート 227 $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 228 // 入力エラーのチェック 229 $this->arrErr = $this->lfErrorCheck($this->list_data); 230 // エラーなし 231 if (empty($this->arrErr)) { 232 // 現在時刻の取得 233 $this->arrNowDate = $this->lfGetNowDate(); 234 $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成 235 $this->tpl_mainpage = 'mail/input.tpl'; 236 } 237 break; 238 // template:テンプレート選択 119 $this->tpl_mainpage = 'mail/input.tpl'; 120 break; 121 // template:テンプレート選択時 239 122 case 'template': 240 // 入力値コンバート 241 $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn); 242 243 // 時刻設定の取得 244 $this->arrNowDate['year'] = isset($_POST['send_year']) ? $_POST['send_year'] : ""; 245 $this->arrNowDate['month'] = isset($_POST['send_month']) ? $_POST['send_month'] : ""; 246 $this->arrNowDate['day'] = isset($_POST['send_day']) ? $_POST['send_day'] : ""; 247 $this->arrNowDate['hour'] = isset($_POST['send_hour']) ? $_POST['send_hour'] : ""; 248 $this->arrNowDate['minutes'] = isset($_POST['send_minutes']) ? $_POST['send_minutes'] : ""; 249 250 // 入力エラーのチェック 251 $this->arrErr = $this->lfErrorCheck($this->list_data); 252 253 // 検索開始 254 if (empty($this->arrErr)) { 255 $this->list_data['name'] = isset($this->list_data['name']) ? $this->list_data['name'] : ""; 256 $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成 257 258 $this->tpl_mainpage = 'mail/input.tpl'; 259 $template_data = $this->getTemplateData($objQuery, $_POST['template_id']); 260 if ( $template_data ){ 261 foreach( $template_data as $key=>$val ){ 262 $this->list_data[$key] = $val; 263 } 264 } 265 266 } 267 break; 268 // regist_confirm:「入力内容を確認」 269 // regist_back:「テンプレート設定画面へ戻る」 270 // regist_complete:「登録」 123 case 'regist_back': 124 $this->tpl_mainpage = 'mail/input.tpl'; 125 if (SC_Utils_Ex::sfIsInt($_POST['template_id']) === true) { 126 $this->lfAddParamSelectTemplate($objFormParam); 127 $this->lfGetTemplateData($objFormParam, $_POST['template_id']); 128 // regist_back時、subject,bodyにはテンプレートを読み込むのではなく、入力内容で上書き 129 if($this->getMode()=='regist_back') $objFormParam->setParam($_POST); 130 } 131 break; 271 132 case 'regist_confirm': 272 case 'regist_back': 133 $this->tpl_mainpage = 'mail/input.tpl'; 134 $this->lfAddParamSelectTemplate($objFormParam); 135 $objFormParam->setParam($_POST); 136 $this->arrErr = $objFormParam->checkError(); 137 if (SC_Utils_Ex::isBlank($this->arrErr)) $this->tpl_mainpage = 'mail/input_confirm.tpl'; 138 break; 273 139 case 'regist_complete': 274 // 入力値コンバート 275 $this->arrCheckColumn = array_merge( $this->arrSearchColumn, $this->arrRegistColumn ); 276 $this->list_data = $this->lfConvertParam($_POST, $this->arrCheckColumn); 277 278 // 現在時刻の取得 279 $this->arrNowDate = $this->lfGetNowDate(); 280 281 // 入力エラーのチェック 282 $this->arrErr = $this->lfErrorCheck($this->list_data, 1); 283 $this->tpl_mainpage = 'mail/input.tpl'; 284 $this->arrHidden = $this->lfGetHidden($this->list_data); // hidden要素作成 285 286 // 検索開始 287 if (empty($this->arrErr)) { 288 $this->list_data['name'] = 289 isset($this->list_data['name']) 290 ? $this->list_data['name'] : ""; 291 //TODO 要リファクタリング(MODE if利用) 292 if ( $this->getMode() == 'regist_confirm'){ 293 $this->tpl_mainpage = 'mail/input_confirm.tpl'; 294 } else if( $this->getMode() == 'regist_complete' ){ 295 $sendId = $this->lfRegistData($objQuery, $this->list_data); 296 SC_Response_Ex::sendRedirectFromUrlPath(ADMIN_DIR . 'mail/sendmail.php', array('mode' => 'now', 'send_id' => $sendId)); 297 exit; 298 } 299 } 140 $this->tpl_mainpage = 'mail/input.tpl'; 141 $this->lfAddParamSelectTemplate($objFormParam); 142 $objFormParam->setParam($_POST); 143 $this->arrErr = $objFormParam->checkError(); 144 if (SC_Utils_Ex::isBlank($this->arrErr)){ 145 $this->lfRegisterData($objFormParam); 146 $this->tpl_mainpage = 'mail/index.tpl'; 147 //SC_Helper_Mail_Ex::hogehoge(); //送信処理 148 $this->tpl_onload = "window.alert('メール送信が完了しました。配信履歴画面から確認してください。');"; 149 } 150 break; 151 // query:配信履歴「確認」 152 case 'query': 153 if (SC_Utils_Ex::sfIsInt($_GET["send_id"])) { 154 $this->arrSearchData = $this->lfGetMailQuery(); 155 } 156 $this->setTemplate('mail/query.tpl'); 300 157 break; 301 158 default: 159 break; 302 160 } 303 */161 $this->arrForm = $objFormParam->getFormParamList(); 304 162 } 305 163 … … 314 172 315 173 /** 316 * パラメーター情報の初期化 174 * パラメーター情報の初期化(初期顧客検索時) 317 175 * 318 176 * @param array $objFormParam フォームパラメータークラス … … 328 186 329 187 /** 330 * エラーチェック188 * パラメーター情報の追加(テンプレート選択) 331 189 * 332 190 * @param array $objFormParam フォームパラメータークラス 333 * @return array エラー配列 334 */ 335 function lfCheckError(&$objFormParam) { 336 return SC_Helper_Customer_Ex::sfCheckErrorSearchParam($objFormParam); 337 } 338 339 /** 340 * 顧客一覧を検索する処理 341 * 342 * @param array $arrParam 検索パラメーター連想配列 343 * @return array( integer 全体件数, mixed 顧客データ一覧配列, mixed SC_PageNaviオブジェクト) 344 */ 345 function lfDoSearch($arrParam) { 346 return SC_Helper_Customer_Ex::sfGetSearchData($arrParam); 347 } 348 349 // 現在時刻の取得(配信時間デフォルト値) 350 function lfGetNowDate(){ 351 $nowdate = date("Y/n/j/G/i"); 352 list($year, $month, $day, $hour, $minute) = split("[/]", $nowdate); 353 $arrNowDate = array( 'year' => $year, 'month' => $month, 'day' => $day, 'hour' => $hour, 'minutes' => $minute); 354 foreach ($arrNowDate as $key => $val){ 355 switch ($key){ 356 case 'minutes': 357 $val = ereg_replace('^[0]','', $val); 358 if ($val < 30){ 359 $list_date[$key] = '30'; 360 }else{ 361 $list_date[$key] = '00'; 362 } 363 break; 364 case 'year': 365 case 'month': 366 case 'day': 367 $list_date[$key] = $val; 368 break; 191 * @return void 192 */ 193 function lfAddParamSelectTemplate(&$objFormParam) { 194 $objFormParam->addParam("メール形式", 'mail_method', INT_LEN, "n", array("EXIST_CHECK","ALNUM_CHECK")); 195 $objFormParam->addParam("Subject", 'subject', STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 196 $objFormParam->addParam("本文", 'body', LLTEXT_LEN, "KVCa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 197 $objFormParam->addParam("テンプレートID", "template_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"), "", false); 198 } 199 200 /** 201 * テンプレート一覧情報の取得 202 * 203 * @param array $arrTemplate SC_Helper_Mail_Ex::sfGetMailTemplate()の戻り値 204 * @return array key:template_id value:サブジェクト【配信形式】 205 */ 206 function lfGetMailTemplateList($arrTemplate){ 207 if ( is_array($arrTemplate) ){ 208 foreach( $arrTemplate as $line ){ 209 $return[$line['template_id']] = "【" . $this->arrHtmlmail[$line['mail_method']] . "】" . $line['subject']; 369 210 } 370 211 } 371 if ($arrNowDate['minutes'] < 30){ 372 $list_date['hour'] = $hour; 373 }else{ 374 $list_date['hour'] = $hour + 1; 375 } 376 return $list_date; 377 } 378 212 return $return; 213 } 214 215 /** 216 * テンプレートIDから情報の取得して$objFormParamにset_paramする 217 * 218 * @param array $objFormParam フォームパラメータークラス 219 * @param array $template_id テンプレートID 220 * @return void 221 */ 222 function lfGetTemplateData(&$objFormParam, $template_id){ 223 $objQuery =& SC_Query::getSingletonInstance(); 224 $objQuery->setOrder("template_id DESC"); 225 $where = 'template_id = ?'; 226 $arrResults = $objQuery->getRow('*', 'dtb_mailmaga_template', $where, array($template_id)); 227 $objFormParam->setParam($arrResults); 228 } 229 379 230 /** 380 231 * 配信内容と配信リストを書き込む … … 382 233 * @return string 登録した行の dtb_send_history.send_id の値 383 234 */ 384 function lfRegist Data(&$objQuery, $arrData){385 386 $objSelect = new SC_CustomerList($this->lfConvertParam($arrData, $this->arrSearchColumn), "magazine" );387 388 $se arch_data = $objQuery->getAll($objSelect->getListMailMagazine($this->lfGetIsMobile($_POST['mail_type'])), $objSelect->arrVal);389 $dataCnt = count($search_data); 390 235 function lfRegisterData(&$objFormParam){ 236 $objQuery =& SC_Query::getSingletonInstance(); 237 238 list($linemax, $arrSendCustomer, $objNavi) = SC_Helper_Customer_Ex::sfGetSearchData($objFormParam->getHashArray()); 239 $send_customer_cnt = count($arrSendCustomer); 240 241 $send_id = $objQuery->nextVal('dtb_send_history_send_id'); 391 242 $dtb_send_history = array(); 392 $dtb_send_history["mail_method"] = $arrData['mail_method']; 393 $dtb_send_history["subject"] = $arrData['subject']; 394 $dtb_send_history["body"] = $arrData['body']; 395 if(MELMAGA_BATCH_MODE) { 396 $dtb_send_history["start_date"] = $arrData['send_year'] ."/".$arrData['send_month']."/".$arrData['send_day']." ".$arrData['send_hour'].":".$arrData['send_minutes']; 397 } else { 398 $dtb_send_history["start_date"] = "now()"; 399 } 243 $dtb_send_history["mail_method"] = $objFormParam->getValue('mail_method'); 244 $dtb_send_history["subject"] = $objFormParam->getValue('subject'); 245 $dtb_send_history["body"] = $objFormParam->getValue('body'); 246 $dtb_send_history["start_date"] = "now()"; 400 247 $dtb_send_history["creator_id"] = $_SESSION['member_id']; 401 $dtb_send_history["send_count"] = $dataCnt; 402 $arrData['body'] = ""; 403 $dtb_send_history["search_data"] = serialize($arrData); 248 $dtb_send_history["send_count"] = $send_customer_cnt; 249 $dtb_send_history["search_data"] = serialize($objFormParam->getSearchArray()); 404 250 $dtb_send_history["update_date"] = "now()"; 405 251 $dtb_send_history["create_date"] = "now()"; 406 $dtb_send_history['send_id'] = $ objQuery->nextVal('dtb_send_history_send_id');252 $dtb_send_history['send_id'] = $send_id; 407 253 $objQuery->insert("dtb_send_history", $dtb_send_history ); 408 254 409 $sendId = $objQuery->currval('dtb_send_history_send_id'); 410 411 if ( is_array( $search_data ) ){ 412 foreach( $search_data as $line ){ 255 if ( is_array( $arrSendCustomer ) ){ 256 foreach( $arrSendCustomer as $line ){ 413 257 $dtb_send_customer = array(); 414 258 $dtb_send_customer["customer_id"] = $line["customer_id"]; 415 $dtb_send_customer["send_id"] = $send Id;259 $dtb_send_customer["send_id"] = $send_id; 416 260 $dtb_send_customer["email"] = $line["email"]; 417 261 $dtb_send_customer["name"] = $line["name01"] . " " . $line["name02"]; … … 419 263 } 420 264 } 421 422 return $sendId; 423 } 424 425 function lfGetIsMobile($mail_type) { 426 // 検索結果の取得 427 $is_mobile = false; 428 switch($mail_type) { 429 case 1: 430 $is_mobile = false; 431 break; 432 case 2: 433 $is_mobile = true; 434 break; 435 default: 436 $is_mobile = false; 437 break; 438 } 439 440 return $is_mobile; 441 } 442 443 // hidden要素出力用配列の作成 444 function lfGetHidden( $array ){ 445 if ( is_array($array) ){ 446 foreach( $array as $key => $val ){ 447 if ( is_array( $val )){ 448 for ( $i=0; $i<count($val); $i++){ 449 $return[ $key.'['.$i.']'] = $val[$i]; 450 } 451 } else { 452 $return[$key] = $val; 453 } 454 } 455 } 456 return $return; 457 } 458 459 // 取得文字列の変換 460 function lfConvertParam($array, $arrSearchColumn) { 461 462 // 文字変換 463 foreach ($arrSearchColumn as $data) { 464 $arrConvList[ $data["column"] ] = $data["convert"]; 465 } 466 467 $new_array = array(); 468 foreach ($arrConvList as $key => $val) { 469 if (isset($array[$key]) && strlen($array[$key]) > 0 ){ // データのあるものだけ返す 470 $new_array[$key] = $array[$key]; 471 if( strlen($val) > 0) { 472 $new_array[$key] = mb_convert_kana($new_array[$key] ,$val); 473 } 474 } 475 } 476 return $new_array; 477 478 } 479 480 481 // 入力エラーチェック 482 function lfErrorCheck($array, $flag = '') { 483 484 // flag は登録時用 485 486 $objErr = new SC_CheckError($array); 487 488 if ( $flag ){ 489 $objErr->doFunc(array("テンプレート", "template_id"), array("EXIST_CHECK", "NUM_CHECK")); 490 $objErr->doFunc(array("メール送信法法", "mail_method"), array("EXIST_CHECK", "NUM_CHECK")); 491 $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); 492 $objErr->doFunc(array("本文", 'body', LLTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); // HTMLテンプレートを使用しない場合 493 } 494 495 return $objErr->arrErr; 496 } 497 498 /* テンプレートIDとsubjectの配列を返す */ 499 function getTemplateList(&$objQuery){ 500 $return = ""; 501 $sql = "SELECT template_id, subject, mail_method FROM dtb_mailmaga_template WHERE del_flg = 0 "; 502 if ($_POST["htmlmail"] == 2 || $_POST['mail_type'] == 2) { 503 $sql .= " AND mail_method = 2 "; // TEXT希望者へのTESTメールテンプレートリスト 504 } 505 $sql .= " ORDER BY template_id DESC"; 506 $result = $objQuery->getAll($sql); 507 508 if ( is_array($result) ){ 509 foreach( $result as $line ){ 510 $return[$line['template_id']] = "【" . $this->arrMagazineTypeAll[$line['mail_method']] . "】" . $line['subject']; 511 } 512 } 513 514 return $return; 515 } 516 517 /* テンプレートIDからテンプレートデータを取得 */ 518 function getTemplateData(&$objQuery, $id){ 519 520 if ( SC_Utils_Ex::sfIsInt($id) ){ 521 $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? ORDER BY template_id DESC"; 522 $result = $objQuery->getAll( $sql, array($id) ); 523 if ( is_array($result) ) { 524 $return = $result[0]; 525 } 526 } 527 return $return; 528 } 529 265 } 266 267 /** 268 * 配信履歴から条件を取得する 269 * 270 * @param integer $send_id 配信履歴番号 271 * @return array 272 */ 273 function lfGetMailQuery($send_id){ 274 275 $objQuery =& SC_Query::getSingletonInstance(); 276 277 // 送信履歴より、送信条件確認画面 278 $sql = "SELECT search_data FROM dtb_send_history WHERE send_id = ?"; 279 $searchData = $objQuery->getOne($sql, array($_GET["send_id"])); 280 return unserialize($searchData); 281 } 530 282 } 531 283 ?> -
branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_Preview.php
r20335 r20343 70 70 if (SC_Utils_Ex::sfIsInt($_GET['template_id'])){ 71 71 $arrMail = $objMailHelper->sfGetMailTemplate($_GET['template_id']); 72 $this->mail = $arrMail[0]; 72 73 } 73 74 break; … … 75 76 if (SC_Utils_Ex::sfIsInt($_GET['send_id'])){ 76 77 $arrMail = $objMailHelper->sfGetSendHistory($_GET['send_id']); 78 $this->mail = $arrMail[0]; 77 79 } 78 80 break; 81 case 'presend'; 82 $this->mail['body'] = $_POST['body']; 79 83 default: 80 84 } 81 85 82 $this->mail = $arrMail[0];86 83 87 $this->setTemplate($this->tpl_mainpage); 84 88 }
Note: See TracChangeset
for help on using the changeset viewer.
