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

157 lines
5.7 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 class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('user/left.phtml'); ?>
</div>
<?php if ($this->msg or $this->messages) :?>
<div id="message" class="alert alert-info">
<?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 class="col-md-10 col-sm-12">
<h4>所有数据中心用户 (共 <?= $this->count_users;?> 个)</h4>
<hr />
<div id="form">
<form id="mailconent" class="form-horizontal">
<div class="form-group">
<label class="col-md-2 col-sm-2 col-xs-3 control-label">邮件标题</label>
<div class="col-md-5 col-sm-5 col-xs-6">
<input type="text" name="title" value="<?php if(!empty($this->mailtemp['subject'])) echo $this->mailtemp['subject']; ?>" id="title" class="half form-control" />
</div>
</div>
<div class="form-group">
<label class="col-md-2 col-sm-2 col-xs-3 control-label">邮件内容</label>
<div class="col-md-5 col-sm-5 col-xs-6">
<textarea name="content" id="mail_content" class="form-control" row="6"><?php if(!empty($this->mailtemp['body'])) echo $this->mailtemp['body']; ?></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 col-sm-2 col-xs-3 control-label">支持标签:</label>
<div class="col-md-5 col-sm-5 col-xs-6">
<div class="alert alert-info">
<p>{username} => 用户名</p>
<p>{lastlogin} => 最后登录时间</p>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-7 col-sm-7 col-xs-9">
<button type="button" onclick="mail_send_start()" class="btn btn-success pull-right" id="send_button">发送祝贺邮件</button>
<label id="handle"></label>
</div>
</div>
<div class="form-group">
<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>
</div>
</form>
</div>
</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>