增加了邮件模板测试功能

修改了试图
This commit is contained in:
Li Jianxuan 2011-10-12 08:33:46 +00:00
parent 622d58391c
commit 64dcb7887d
5 changed files with 242 additions and 102 deletions

View File

@ -7,7 +7,7 @@ class Admin_SysController extends Zend_Controller_Action
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
$this->_helper->layout->setLayout('administry');//新UI
//$this->_helper->layout->setLayout('administry');//新UI
}
function postDispatch()
@ -28,6 +28,10 @@ class Admin_SysController extends Zend_Controller_Action
$submit = $this->_request->getParam('submit');
$id = $this->_request->getParam('id');
if($ac=='add' && empty($submit))
{
$this->_helper->viewRenderer('emailtextadd');
}
if($ac=='add' && !empty($submit))
{
@ -78,30 +82,75 @@ class Admin_SysController extends Zend_Controller_Action
$this->messenger->addMessage('模板编辑失败:'.$e->getMessage());
$this->_redirect('/admin/sys/emailtext');
}
}//模板编辑
else if($ac=='test'&& !empty($id))
{
if(!empty($submit))
{
$this->_helper->viewRenderer('emailtext_test');
}
}//模板测试
else
{
}else{
$sql = "select * from emailtext where id='$id'";
$rs = $this->db->query($sql);
$rows = $rs->fetch();
$this->view->info = $rows;
$this->_helper->viewRenderer('emailtext_edit');
}//模板列表
}
$this->_helper->viewRenderer('emailtextedit');
}
}//模板编辑
else if($ac=='test'&& !empty($id))
{
if(!empty($submit))
{
try{
$mailbody=new emailtext();
$mailbody->db = $this->db;
$mailbody->tmpid = $id;
$mailbody->data = array(
'user' => $this->_request->getParam('user')
);
$body=$mailbody->loadtmp();
if($body){
$body;
}else{
$this->messenger->addMessage('模板加载出错');
$this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id);
}
$subject = $this->_request->getParam('title');
$email = $this->_request->getParam('email');
if(empty($subject)||empty($email))
{
$this->messenger->addMessage('请填写测试邮件发送信息');
$this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id);
}
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setBodyText($body);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$body.=date("H:i:s",time());
$mail->addTo($email);
$mail->setSubject($subject);
if($mail->send()){
$this->messenger->addMessage('测试邮件发送成功');
$this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id);
}else{
$this->messenger->addMessage('测试邮件发送失败');
$this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id);
}
}catch(Exception $e){
$this->messenger->addMessage('测试邮件发送失败'.$e->getMessage());
$this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id);
}
}
else
{
$this->view->id = $id;
$this->_helper->viewRenderer('emailtexttest');
}
}//模板测试
else
{

View File

@ -2,31 +2,15 @@
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/static/js/jquery.dataTables.min.js');
$this->headLink()->appendStylesheet('/css/admin.css');
?>
<!-- Page title -->
<div id="pagetitle">
<div class="wrapper">
<h1>系统管理</h1>
<!-- Quick search box -->
<form action="" method="get"><input class="" type="text" id="q" name="q" /></form>
</div>
</div>
<!-- End of Page title -->
<!-- Page content -->
<div id="page">
<!-- Wrapper -->
<div class="wrapper">
<!-- Right column/section -->
<aside class="column width2 first">
<?= $this->partial('sys/left.phtml'); ?>
</aside>
<!-- End of Right column/section -->
<!-- Left column/section -->
<section class="column width6">
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('sys/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div class="box box-info">
@ -44,7 +28,7 @@
<div id="tabs">
<ul>
<li><a class="corner-tl" href="#tabs-1">邮件模板</a></li>
<li><a class="" href="#tabs-2">创建新模板</a></li>
<li><a class="" href="/admin/sys/emailtext/ac/add">创建新模板</a></li>
<li><a class="corner-tr" href="#tabs-3" id="showhelp">模板编辑说明</a></li>
</ul>
<div id="tabs-1">
@ -86,63 +70,8 @@
</table>
<div style="width:50%;text-align:left;">
<?= $this->paginator; ?></div>
</div>
<div id="tabs-2">
<h3>创建新邮件模板</h3>
<form name="form" method="post" action="/admin/sys/emailtext/">
<input type="hidden" name="ac" value="add" />
<input type="hidden" name="submit" value="1" />
<fieldset>
<p>
<label class="required" for="producttitle">标题</label><br/>
<input type="text" id="producttitle" class="half title" value="" name="title"/>
</p>
<p>
<label for="description">介绍</label><br/>
<textarea id="description" class="small half" name="description"></textarea>
</p>
<p>
<label for="body">模板内容</label><br/>
<textarea id="body" class="large full" name="body"></textarea>
<small><a href="javascript:showhelp();">查看说明?</a></small>
</p>
<p class="box"><input type="submit" id="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
</fieldset>
</form>
</div>
<div id="tabs-3">
<p>
</p>
</div>
</div>
</section>
<!-- End of Left column/section -->
</div>
<!-- End of Wrapper -->
</div>
<!-- End of Page content -->
<script type="text/javascript">
$(document).ready(function(){
/* setup navigation, content boxes, etc... */
Administry.setup();
/* expandable rows */
Administry.expandableRows();
/* nav */
$('#nav_sys').addClass("current");
/* tabs */
$("#tabs").tabs();
});
function showhelp(){$('#showhelp').click();}
</script>
</div>
</div>

View File

@ -0,0 +1,51 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('sys/left.phtml'); ?>
</div>
<div id="rightPanel">
<!-- Left column/section -->
<section class="column width6">
<h3>邮件模板添加</h3>
<form name="form" method="post" action="/admin/sys/emailtext/">
<input type="hidden" name="ac" value="add" />
<input type="hidden" name="submit" value="1" />
<fieldset>
<p>
<label class="required" for="producttitle">标题</label><br/>
<input type="text" id="producttitle" class="half title" value="" name="title"/>
</p>
<p>
<label for="description">介绍</label><br/>
<textarea id="description" class="small half" name="description" style="width:500px;height:80px;"></textarea>
</p>
<p>
<label for="body">模板内容</label><br/>
<textarea id="body" class="large full" style="width:500px;height:200px;" name="body"></textarea>
<small><a href="javascript:showhelp();">查看说明?</a></small>
</p>
<p class="box"><input type="submit" id="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
</fieldset>
</form>
</section>
<!-- End of Left column/section -->
</div>
</div>

View File

@ -0,0 +1,50 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('sys/left.phtml'); ?>
</div>
<div id="rightPanel">
<!-- Left column/section -->
<section class="column width6">
<h3>邮件模板编辑</h3>
<form name="form" method="post" action="/admin/sys/emailtext/">
<input type="hidden" name="ac" value="edit" />
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="id" value="<?php echo $this->info['id'];?>" />
<fieldset>
<p>
<label class="required" for="producttitle">标题</label><br/>
<input type="text" id="producttitle" class="half title" value="<?php echo $this->info['title'];?>" name="title"/>
</p>
<p>
<label for="description">介绍</label><br/>
<textarea id="description" class="small half" name="description" style="width:500px;height:80px;"><?php echo $this->info['description'];?></textarea>
</p>
<p>
<label for="body">模板内容</label><br/>
<textarea id="body" class="large full" name="body" style="width:500px;height:200px;"><?php echo $this->info['content'];?></textarea>
<small><a href="javascript:showhelp();">查看说明?</a></small>
</p>
<p class="box"><input type="submit" id="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
</fieldset>
</form>
</section>
<!-- End of Left column/section -->
</div>
</div>

View File

@ -0,0 +1,61 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
?>
<div id="divContent">
<div id="leftPanel">
<?= $this->partial('sys/left.phtml'); ?>
</div>
<div id="rightPanel">
<section class="column width6">
<?php if ($this->msg or $this->messages) :?>
<div class="box box-info">
<?php if ($this->msg) : ?>
<?php echo $this->msg; ?>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<?php echo $msg; ?>
<?php endforeach;endif; ?>
<script language="javascript">
setTimeout('$(".box-info").remove()',5000);
</script>
</div>
<?php endif; ?>
<h3>发送邮件发送测试</h3>
<form name="form" method="post" action="/admin/sys/emailtext/">
<input type="hidden" name="ac" value="test" />
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="id" value="<?php echo $this->id;?>" />
<fieldset>
<p>
<label for="email" class="required">测试的收信地址</label><br/>
<input type="text" id="producttitle" class="half title" value="" name="email"/>
</p>
<p>
<label class="required" for="producttitle">邮件标题</label><br/>
<input type="text" id="producttitle" class="half title" value="测试邮件标题" name="title"/>
</p>
<p>
<label for="user">收信用户名</label><br/>
<input type="text" id="user" class="half title" value="张测试" name="user"/>
</p>
<p class="box"><input type="submit" id="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
</fieldset>
</form>
</section>
</div>
</div>