Ticket #174 增加了项目来源管理功能

This commit is contained in:
Li Jianxuan 2011-10-26 08:50:00 +00:00
parent 45abb67c08
commit 47089e9a57
3 changed files with 240 additions and 19 deletions

View File

@ -795,23 +795,117 @@ class Admin_DataController extends Zend_Controller_Action
function sourceAction() function sourceAction()
{ {
$do = $this->_request->getParam('do');
$uuid = $this->_request->getParam('uuid');
$id = $this->_request->getParam('id');
$q = $this->_request->getParam('q');
$search = $this->_request->getParam('search');
$add=(int)$this->_getParam('add'); if ($do == 'add') {
$edit=(int)$this->_getParam('edit');
$delete=(int)$this->_getParam('delete');
$search=$this->_getParam('search');
$keyword=$this->_getParam('keyword');
if ($add) { $redirect = "/admin/data/source/";
if(!empty($_POST['submit'])) if(!empty($_POST['submit']))
{ {
try{
$title = $this->_request->getParam('title');
$uuid = $this->_request->getParam('uuid');
$code = $this->_request->getParam('code');
$description = $this->_request->getParam('description');
$has_pages = $this->_request->getParam('has_pages');
$has_agreement = $this->_request->getParam('has_agreement');
$data = array(
'title' => $title,
'uuid' => $uuid,
'code' => $code,
'description' => $description,
'has_pages' => $has_pages,
'has_agreement' => $has_agreement
);
if($this->db->insert('source',$data))
{
$this->messenger->addMessage('添加来源信息成功');
$this->_redirect($redirect);
}
}catch(Exception $e){
$this->messenger->addMessage('添加来源信息失败:'.$e->getMessage());
$this->_redirect('/admin/data/source/do/add');
}
} }
$this->_helper->viewRenderer('sourceadd'); $this->_helper->viewRenderer('sourceadd');
}// 添加项目来源 }// 添加项目来源
else if($do == 'edit' && !empty($id))
{
if(!empty($_POST['submit']))
{
try{
$title = $this->_request->getParam('title');
$uuid = $this->_request->getParam('uuid');
$code = $this->_request->getParam('code');
$description = $this->_request->getParam('description');
$has_pages = $this->_request->getParam('has_pages');
$has_agreement = $this->_request->getParam('has_agreement');
$sql = "update source set title='$title',uuid='$uuid',code='$code',description='$description',has_pages='$has_pages',has_agreement='$has_agreement' where id='$id'";
if($this->db->exec($sql)>1)
{
$this->messenger->addMessage('修改来源信息成功');
$this->_redirect("/admin/data/source/do/edit/id/$id");
}
}catch(Exception $e){
$this->messenger->addMessage('修改来源信息失败:'.$e->getMessage());
$this->_redirect("/admin/data/source/do/edit/id/$id");
}
}
$sql = "select * from source where id='$id'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
$this->view->info = $row;
$this->_helper->viewRenderer('sourceadd');
}// 编辑单条信息
else
{
$wheresql = array();
if(!empty($q) && !empty($search))
{
$this->view->q = $q;
$wheresql[] = " title like '%$q%' ";
}
if(count($wheresql>0))$wheresql = join(' and ',$wheresql);
else $wheresql='';
if($wheresql!='')
{
$wheresql = 'where '.$wheresql;
}
$sql = "select * from source $wheresql order by id desc";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}// 项目来源管理
}//function sourceAction }//function sourceAction

View File

@ -0,0 +1,63 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('项目来源管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?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 class="ctrlplan">
<a href="/admin/data/source">项目来源管理</a>
<a href="/admin/data/source/do/add">添加项目来源</a>
</div>
<div class="search">
<form action="" method="get">
<input type="hidden" name="search" value='1' />
<input type="hidden" name="id" value='<?php echo $this->id;?>' />
<label>搜索关键字</label><input type="text" class="q" name="q" value="<?php echo $this->q; ?>" />
<input type="submit" class="btn" value="搜索" />
</form>
</div><!-- search DIV -->
<table class="stylized" width="700">
<thead>
<tr>
<td width='40%'>标题</td>
<td width='30%'>Code字符</td>
<td width='30%'>操作</td>
</tr>
</thead>
<?php if (count($this->paginator)): ?>
<tbody id="list">
<?php foreach ($this->paginator as $item): ?>
<tr>
<td><a href="/data/<?php echo $item['uuid'];?>"><?php echo $item['title']; ?></a></td>
<td><?php echo $item['code'];?></td>
<td><a href="/admin/data/source/do/edit/id/<?php echo $item['id']?>">查看编辑</a></td>
</tr>
<?php endforeach; ?>
</tbody>
<?php endif; ?>
</table>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<script>$("#list tr").mouseover(function(){$(this).addClass("high")}).mouseout(function(){$(this).removeClass("high")})</script>

View File

@ -0,0 +1,64 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('项目来源管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?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 class="ctrlplan">
<a href="/admin/data/source/">项目来源管理</a>
<a href="/admin/data/source/do/add">添加项目来源</a>
</div>
<form method="post" action="/admin/data/source">
<p>
<label>标题:</label><br />
<input type="text" name="title" value="<?php echo $this->info['title'];?>" />
</p>
<p>
<label class="required">uuid:</label><br />
<input type="text" name="uuid" value="<?php echo $this->info['uuid'];?>" />
</p>
<p>
<label class="required">Code:</label><br />
<input type="text" name="code" value="<?php echo $this->info['code'];?>" />
</p>
<p>
<label>描述</label><br />
<textarea id="description" class="samll half" name="description"><?php echo $this->info['description'];?></textarea>
</p>
<p>
<label>has_pages</label><br />
<input type="radio" name="has_pages" value="true" <?php if($this->info['has_pages']) echo 'checked="checked"';?> />True <input type="radio" name="has_pages" value="false" <?php if(!$this->info['has_pages']) echo 'checked="checked"';?> />False
</p>
<p>
<label>has_agreement</label><br />
<input type="radio" name="has_agreement" value="true" <?php if($this->info['has_agreement']) echo 'checked="checked"';?> />True <input type="radio" name="has_agreement" value="false" <?php if(!$this->info['has_agreement']) echo 'checked="checked"';?> />False
</p>
<p>
<input type="hidden" name="id" value="<?php echo $this->info['id'];?>" />
<input type="hidden" name="do" value="<?php if($this->info['uuid']!='') echo 'edit';else echo 'add';?>" />
<input type="hidden" name="submit" value="1" />
<input type="submit" value="提交" />
</p>
</form>
</div>