쿠폰생성 대 sms 이메일알림 기능 추가

This commit is contained in:
chicpro
2014-03-11 13:05:00 +09:00
parent c6161454cf
commit 01cfe50260
3 changed files with 146 additions and 0 deletions

View File

@ -136,6 +136,17 @@ include_once(G5_PLUGIN_PATH.'/jquery-ui/datepicker.php');
<input type="text" name="cp_maximum" value="<?php echo stripslashes($cp['cp_maximum']); ?>" id="cp_maximum" class="frm_input"> 원
</td>
</tr>
<?php if($w == '') { ?>
<tr>
<th scope="row">쿠폰발행알림</th>
<td>
<label for="cp_sms_send">SMS발송</label>
<input type="checkbox" name="cp_sms_send" value="1" id="cp_sms_send" checked="checked">
<label for="cp_email_send">이메일발송</label>
<input type="checkbox" name="cp_email_send" value="1" id="cp_email_send" checked="checked">
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
@ -257,6 +268,12 @@ function form_check(f)
return false;
}
// 전체회원일 때 쿠폰알림 체크되어 있으면 확인창
if(f.chk_all_mb.checked && (f.cp_sms_send.checked || f.cp_email_send.checked)) {
if(!confirm("전체회원에게 쿠폰발행알림을 발송하시겠습니까?"))
return false;
}
return true;
}
</script>

View File

@ -109,5 +109,98 @@ if($w == '') {
sql_query($sql);
}
// 쿠폰생성알림 발송
if($w == '' && ($_POST['cp_sms_send'] || $_POST['cp_email_send'])) {
include_once(G5_LIB_PATH.'/mailer.lib.php');
include_once(G5_LIB_PATH.'/icode.sms.lib.php');
$sms_count = 0;
if($config['cf_sms_use'] == 'icode' && $_POST['cp_sms_send'])
{
$SMS = new SMS;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
}
$arr_send_list = array();
if($_POST['chk_all_mb']) {
$sql = " select mb_id, mb_name, mb_hp, mb_email, mb_mailling, mb_sms
from {$g5['member_table']}
where mb_leave_date = ''
and mb_intercept_date = ''
and ( mb_mailling = '1' or mb_sms = '1' )
and mb_id <> '{$config['cf_admin']}' ";
} else {
$sql = " select mb_id, mb_name, mb_hp, mb_email, mb_mailling, mb_sms
from {$g5['member_table']}
where mb_id = '$mb_id' ";
}
$result = sql_query($sql);
for($i=0; $row = sql_fetch_array($result); $i++) {
$arr_send_list[] = $row;
}
$count = count($arr_send_list);
$admin = get_admin('super');
for($i=0; $i<$count; $i++) {
if(!$arr_send_list[$i]['mb_id'])
continue;
// SMS
if($config['cf_sms_use'] == 'icode' && $_POST['cp_sms_send'] && $arr_send_list[$i]['mb_hp'] && $arr_send_list[$i]['mb_sms']) {
$sms_contents = $cp_subject.' 쿠폰이 '.$arr_send_list[$i]['mb_name'].'님께 발행됐습니다. 쿠폰만료 : '.$cp_end.' '.str_replace('http://', '', G5_URL);
$sms_contents = iconv_euckr($sms_contents);
if($sms_contents) {
$receive_number = preg_replace("/[^0-9]/", "", $arr_send_list[$i]['mb_hp']); // 수신자번호
$send_number = preg_replace("/[^0-9]/", "", $default['de_admin_company_tel']); // 발신자번호
if($receive_number && $send_number) {
$SMS->Add($receive_number, $send_number, $config['cf_icode_id'], $sms_contents, "");
$sms_count++;
}
}
}
// E-MAIL
if($config['cf_email_use'] && $_POST['cp_email_send'] && $arr_send_list[$i]['mb_email'] && $arr_send_list[$i]['mb_mailling']) {
$mb_name = $arr_send_list[$i]['mb_name'];
switch($cp_method) {
case 2:
$coupon_method = '결제금액할인';
break;
case 3:
$coupon_method = '배송비할인';
break;
default:
$coupon_method = '개별상품할인';
break;
}
$contents = '쿠폰명 : '.$cp_subject.'<br>';
$contents .= '적용대상 : '.$coupon_method.'<br>';
$contents .= '쿠폰만료 : '.$cp_end;
$title = $config['cf_title'].' - 쿠폰발행알림 메일';
$email = $arr_send_list[$i]['mb_email'];
ob_start();
include G5_SHOP_PATH.'/mail/couponmail.mail.php';
$content = ob_get_contents();
ob_end_clean();
mailer($config['cf_title'], $admin['mb_email'], $email, $title, $content, 1);
}
}
// SMS발송
if($config['cf_sms_use'] == 'icode' && $_POST['cp_sms_send'] && $sms_count)
{
$SMS->Send();
}
}
goto_url('./couponlist.php');
?>

View File

@ -0,0 +1,36 @@
<?php //쿠폰발행알림 ?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title><?php echo $config['cf_title']; ?> - 쿠폰발행알림 메일</title>
</head>
<?php
$cont_st = 'margin:0 auto 20px;width:94%;border:0';
$caption_st = 'padding:0 0 5px;font-weight:bold';
$th_st = 'padding:5px;border-top:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9;background:#f5f6fa;text-align:left';
$td_st = 'padding:5px;border-top:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9';
$empty_st = 'padding:30px;border-top:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9;text-align:center';
$ft_a_st = 'display:block;padding:30px 0;background:#484848;color:#fff;text-align:center;text-decoration:none';
?>
<body>
<div style="margin:30px auto;width:600px;border:10px solid #f7f7f7">
<div style="border:1px solid #dedede">
<h1 style="margin:0 0 20px;padding:30px 30px 20px;background:#f7f7f7;color:#555;font-size:1.4em">
<?php echo $config['cf_title'];?> - 쿠폰발행알림 메일
</h1>
<p style="<?php echo $cont_st; ?>"><b><?php echo $mb_name; ?></b> 님께 발행된 쿠폰입니다.</p>
<p style="<?php echo $cont_st; ?>"><?php echo $contents; ?></p>
<a href="<?php echo G5_URL; ?>" target="_blank" style="<?php echo $ft_a_st; ?>"><?php echo $config['cf_title']; ?> 방문</a>
</div>
</div>
</body>
</html>