westdc-zf1/application/admin/views/scripts/user/sendmail-holiday.phtml

148 lines
4.9 KiB
PHTML

<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/">后台首页</a>');
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<style>
.process {width:99%;height:20px;overflow:hidden;border:1px solid #6CF;}
.process .display { position:absolute;height:20px;color:#6CF; margin:0px; padding:0px;}
.process .np{display:block;height:20px;background-color:green;}
</style>
<div id="leftPanel">
<?= $this->partial('user/left.phtml'); ?>
</div>
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<div id="rightPanel">
<div style="font-size:16px;line-height:30px;">所有数据中心用户 (共 <?= $this->count_users;?> 个)</div>
<div id="form">
<form id="mailconent">
<p>
<label>邮件标题</label><br />
<input type="text" name="title" value="<?php if(!empty($this->mailtemp['subject'])) echo $this->mailtemp['subject']; ?>" id="title" class="half" />
</p>
<p>
<label>邮件内容</label><br />
<textarea name="content" id="mail_content" class="large half"><?php if(!empty($this->mailtemp['body'])) echo $this->mailtemp['body']; ?></textarea>
</p>
<p>
支持标签:
<pre>
{username} => 用户名
{lastlogin} => 最后登录时间
</pre>
</p>
<p>
<button type="button" onclick="mail_send_start()" class="btn btn-green" id="send_button">发送祝贺邮件</button>
<label id="handle"></label>
</p>
<p>
<div class="process" id="process_contorller" style="display:none;">
<div class="display" id="process_value"></div>
<div class="np" style="width:0%;" id="process_bar"></div>
</div>
</p>
</form>
</div>
</div>
<div id="test">
</div>
<script>
function mail_send_start(){
//按下发送按钮后将输入框和按钮锁死
var btn = '#send_button';
$(btn).attr('disabled',"disabled");
$('#title').attr('readonly',"readonly");
$('#mail_content').attr('readonly',"readonly");
//显示进度条
$('#process_contorller').show();
//收集数据并发送
var data = $('#mailconent').serialize();
send(data,"/admin/user/sendmail/ac/holidaymail");
}
function send(data,url){
var btn = '#send_button';
html = $(btn).html();
$.ajax({
'type': "POST",
'url': url,
'data': data,
'success': function(data){
if($.isEmptyObject(data)){Alert('遇到错误,请重试');return false;}
//脚本返回的错误提示
if($.isEmptyObject(data.error) === false)
{
$(btn).removeAttr('disabled');
$(btn).html('发送祝贺邮件');
$('#title').removeAttr('readonly');
$('#mail_content').removeAttr('readonly');
$('#handle').html('');
Alert(data.error);
return false;
}
//当状态为 1 时执行自调用,不传数据值
if(data.status==1){
$('#process_value').html(data.percent);
$('#process_bar').css('width',data.percent+'%');
$('#sended_count').html('此次发送:'+data.sended);
//$('#handle').html('<a href="javascript:;" onclick="send('+param+','+data.url+');">页面卡死请点击这里,不要随意点击</a>');
var param = 'title='+data.title+'&content='+data.content ;
send(param,data.url);
}
//其它情况就停止执行
else{
Alert('发送完成!');
//$(btn).removeAttr('disabled');
$('#process_value').html(data.percent);
$('#process_bar').css('width',data.percent+'%');
$(btn).html('发送已完成!');
$('#handle').html('');
}
},
'beforeSend':function(){
$(btn).html('<img src="/images/ajax-load-small.gif" />发送中');
},
'complete':function(){
//$(btn).html('发送已完成!');
},
'timeout': 20000,
'dataType': 'json',
'error': function(){
Alert('处理中出现问题,请重试');
$(btn).removeAttr('disabled');
$(btn).html('发送祝贺邮件');
$('#title').removeAttr('readonly');
$('#mail_content').removeAttr('readonly');
$('#handle').html('');
return false;
}
});
}
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
}
</script>