为支持项目添加相关数据的查看和关系删除功能

This commit is contained in:
Li Jianxuan 2013-05-16 08:47:29 +00:00
parent 7712a0f910
commit 48f2358599
4 changed files with 284 additions and 176 deletions

View File

@ -3379,7 +3379,9 @@ class Admin_DataController extends Zend_Controller_Action
$this->_helper->layout->setLayout('administry'); $this->_helper->layout->setLayout('administry');
$ac = $this->_getParam('ac'); $ac = $this->_getParam('ac');
$submit = $this->_getParam('submit'); $submit = $this->_getParam('submit');
$this->view->q = $keyword = $this->_getParam('q');
include_once("helper/view.php");
include_once("data/Fund.php"); include_once("data/Fund.php");
$fund = new Fund($this->db); $fund = new Fund($this->db);
@ -3396,13 +3398,13 @@ class Admin_DataController extends Zend_Controller_Action
if(empty($uuid)) if(empty($uuid))
{ {
$rows = $fund->fetch(); $rows = $fund->fetch();
$fund->addPaginator($rows,$this->view,$this->_request); view::addPaginator($rows,$this->view,$this->_request);
}else{ }else{
include('data/Metadata.php'); include('data/Metadata.php');
$md = new Metadata($this->db); $md = new Metadata($this->db);
$this->view->md = $md->view($uuid); $this->view->md = $md->view($uuid);
$rows = $fund->fetch($uuid); $rows = $fund->fetch($uuid);
$fund->addPaginator($rows,$this->view,$this->_request); view::addPaginator($rows,$this->view,$this->_request);
} }
return true; return true;
} }
@ -3535,7 +3537,7 @@ class Admin_DataController extends Zend_Controller_Action
$md = new Metadata($this->db); $md = new Metadata($this->db);
$this->view->md = $md->view($uuid); $this->view->md = $md->view($uuid);
$fund->addPaginator($rows,$this->view,$this->_request); view::addPaginator($rows,$this->view,$this->_request);
return true; return true;
}//formd }//formd
@ -3563,6 +3565,29 @@ class Admin_DataController extends Zend_Controller_Action
} }
}//mdfunddel }//mdfunddel
if($ac == "data")
{
$this->_helper->viewRenderer('fund-data');
$id = $this->_getParam('id');
$del = $this->_getParam('del');
$this->view->info = $fund->view($id);
if(!empty($del))
{
$s = $fund->dataRelationDelete($del);
if($s)
{
$this->view->error = view::Error("删除成功!","alert-sccuess");
}else{
$this->view->error = view::Error("删除失败!","alert-error");
}
}
$rows = $fund->getData($id,$keyword);
view::addPaginator($rows,$this->view,$this->_request);
}
}//fund }//fund
public function doiAction() public function doiAction()

View File

@ -0,0 +1,78 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('支持项目');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin');
?>
<style>
table thead tr th {background:#EBF2F6;}
</style>
<div class="row-fluid">
<div class="span2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span10">
<div>
<ul class="nav nav-tabs">
<li><a href="/admin/data/fund/">所有项目</a></li>
<li><a href="/admin/data/fund/ac/add">添加新项目</a></li>
<li class="active"><a href="/admin/data/fund/ac/data/id/<?= $this->id ?>">相关数据</a></li>
</ul>
</div>
<div>
<div class="input-append">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<h3><?= $this->info['title'] ?> 的相关数据</h3>
<hr />
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>名称</th>
<th width="70">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>">
<?php }?>
<td><?= $item['title'] ?></td>
<td>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
</div>
</div>
<!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/fund/ac/mdfunddel/"
}
</script>

View File

@ -1,164 +1,165 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author); $this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>'); $this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('支持项目'); $this->breadcrumb('支持项目');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin'); $this->theme->AppendPlus($this,'admin_plugin');
?> ?>
<style> <style>
table thead tr th {background:#EBF2F6;} table thead tr th {background:#EBF2F6;}
</style> </style>
<div class="row-fluid"> <div class="row-fluid">
<div class="span2"> <div class="span2">
<?= $this->partial('data/left.phtml'); ?> <?= $this->partial('data/left.phtml'); ?>
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="/admin/data/fund/">所有项目</a></li> <li class="active"><a href="/admin/data/fund/">所有项目</a></li>
<li><a href="/admin/data/fund/ac/add">添加新项目</a></li> <li><a href="/admin/data/fund/ac/add">添加新项目</a></li>
</ul> </ul>
</div> </div>
<?php if(!empty($this->md)) { ?> <?php if(!empty($this->md)) { ?>
<div> <div>
<?php if(empty($this->ct)) { ?> <?php if(empty($this->ct)) { ?>
<a class="btn btn-primary pull-right" href="/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>"><i class="icon-plus"></i>为此数据添加项目</a> <a class="btn btn-primary pull-right" href="/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>"><i class="icon-plus"></i>为此数据添加项目</a>
<?php }else{ ?> <?php }else{ ?>
<a class="pull-right btn" href="/admin/data/fund/uuid/<?= $this->md['uuid'] ?>">返回</a> <a class="pull-right btn" href="/admin/data/fund/uuid/<?= $this->md['uuid'] ?>">返回</a>
<div class="pull-right label label-info">点击“添加此项目”即可将项目添加到元数据</div> <div class="pull-right label label-info">点击“添加此项目”即可将项目添加到元数据</div>
<?php } ?> <?php } ?>
<h3><?= $this->md['title'] ?>》 的支持项目</h3> <h3><?= $this->md['title'] ?>》 的支持项目</h3>
<hr /> <hr />
</div> </div>
<?php } ?> <?php } ?>
<div> <div>
<div class="input-append"> <div class="input-append">
<form id="datasearch" class="search_form" action=""> <form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" /> <input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button> <button type="submit" class="btn" id="search_btn">搜索</button>
</form> </form>
</div> </div>
</div> </div>
<?php if(!empty($this->error)) { ?> <?php if(!empty($this->error)) { ?>
<?php if(empty($this->AlertType)) $AlertType = "alert-error";else $AlertType = $this->AlertType;?> <?php if(empty($this->AlertType)) $AlertType = "alert-error";else $AlertType = $this->AlertType;?>
<div class="alert alert-block fade in <?= $AlertType ?>" id="Alert-error-box"> <div class="alert alert-block fade in <?= $AlertType ?>" id="Alert-error-box">
<a class="close" data-dismiss="alert" href="#">×</a> <a class="close" data-dismiss="alert" href="#">×</a>
<?php if(!is_array($this->error)) { ?><h4 class="alert-heading"><?= $this->error ?></h4><?php } else { ?> <?php if(!is_array($this->error)) { ?><h4 class="alert-heading"><?= $this->error ?></h4><?php } else { ?>
<ul> <ul>
<?php foreach($this->error as $v) { ?> <?php foreach($this->error as $v) { ?>
<li><?= $v ?></li> <li><?= $v ?></li>
<?php } ?> <?php } ?>
</ul> </ul>
<?php } ?> <?php } ?>
</div> </div>
<?php } ?> <?php } ?>
<?php if(!empty($this->msg)) { ?> <?php if(!empty($this->msg)) { ?>
<div class="alert <?= $this->AlertType;?>"> <div class="alert <?= $this->AlertType;?>">
<a data-dismiss="alert" class="close">×</a> <a data-dismiss="alert" class="close">×</a>
<?php echo $this->msg ?> <?php echo $this->msg ?>
</div> </div>
<?php if(!empty($this->jump_url)) { ?> <?php if(!empty($this->jump_url)) { ?>
<script language="javascript">setTimeout("self.location='<?php echo $this->jump_url ?>'",3000);</script> <script language="javascript">setTimeout("self.location='<?php echo $this->jump_url ?>'",3000);</script>
<?php } ?> <?php } ?>
<?php } else{ ?> <?php } else{ ?>
<div id="datalist"> <div id="datalist">
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>名称</th> <th>名称</th>
<th>编号</th> <th>编号</th>
<th>类型</th> <th>类型</th>
<?php if($this->md) { ?> <?php if($this->md) { ?>
<th width="80">排序</th> <th width="80">排序</th>
<?php }else{ ?> <?php }else{ ?>
<th>英文标题</th> <th>英文标题</th>
<th>英文类型</th> <th>英文类型</th>
<?php } ?> <?php } ?>
<?php if($this->ct) { ?> <?php if($this->ct) { ?>
<th>添加</th> <th>添加</th>
<?php } ?> <?php } ?>
<th width="70">操作</th> <th width="100">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $autoindex=0; <?php $autoindex=0;
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<?php if(empty($this->md)) { ?> <?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>"> <tr id="DataLine_<?= $item['id']?>">
<?php }else{?> <?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>"> <tr id="DataLine_<?= $item['mfid']?>">
<?php }?> <?php }?>
<td><?= $item['title'] ?></td> <td><?= $item['title'] ?></td>
<td><?= $item['fund_id'] ?></td> <td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td> <td><?= $item['fund_type'] ?></td>
<?php if($this->md) { ?> <?php if($this->md) { ?>
<?php if($this->ct) { ?> <?php if($this->ct) { ?>
<td><input type="text" name="order" id="order_<?= $item['id']?>" class="span12" /></td> <td><input type="text" name="order" id="order_<?= $item['id']?>" class="span12" /></td>
<?php }else{ ?> <?php }else{ ?>
<td><input type="text" name="order" id="order_<?= $item['mfid']?>" class="span12" value="<?= $item['place'] ?>" /></td> <td><input type="text" name="order" id="order_<?= $item['mfid']?>" class="span12" value="<?= $item['place'] ?>" /></td>
<?php }?> <?php }?>
<?php }else{ ?> <?php }else{ ?>
<td><?= $item['title_en'] ?></td> <td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td> <td><?= $item['fund_type_en'] ?></td>
<?php } ?> <?php } ?>
<?php if($this->ct) { ?> <?php if($this->ct) { ?>
<td><a href="javascript:void(0);" class="addtomd" rel="<?= $item['id']?>">添加此项目</a></td> <td><a href="javascript:void(0);" class="addtomd" rel="<?= $item['id']?>">添加此项目</a></td>
<?php } ?> <?php } ?>
<td> <td>
<?php if(empty($this->md)) { ?> <?php if(empty($this->md)) { ?>
<a href="/admin/data/fund/ac/edit/id/<?= $item['id']?>">编辑</a> <a href="/admin/data/fund/ac/data/id/<?= $item['id']?>">数据</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a> <a href="/admin/data/fund/ac/edit/id/<?= $item['id']?>">编辑</a>
<?php }else{ ?> <a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<?php if(empty($this->ct)) { ?><a href="javascript:void(0);" class="changeorder" rel="<?= $item['mfid']?>">排序</a> <?php } ?> <?php }else{ ?>
<a href="javascript:void(0);" onclick="onedel(<?= $item['mfid']?>)" id="delbtn_<?= $item['mfid']?>">移除</a> <?php if(empty($this->ct)) { ?><a href="javascript:void(0);" class="changeorder" rel="<?= $item['mfid']?>">排序</a> <?php } ?>
<?php } ?> <a href="javascript:void(0);" onclick="onedel(<?= $item['mfid']?>)" id="delbtn_<?= $item['mfid']?>">移除</a>
</td> <?php } ?>
</tr> </td>
<?php endforeach; ?> </tr>
</tbody> <?php endforeach; ?>
</table> </tbody>
<?php endif; ?> </table>
<div class="pagenavi"><?= $this->paginator; ?></div> <?php endif; ?>
</div> <div class="pagenavi"><?= $this->paginator; ?></div>
<?php } ?> </div>
</div> <?php } ?>
</div> </div>
<!-- //页面内容 --> </div>
<script> <!-- //页面内容 -->
<?php if(!empty($this->ct)) { ?> <script>
$('.addtomd').each(function(index, element) { <?php if(!empty($this->ct)) { ?>
$(this).click(function(){ $('.addtomd').each(function(index, element) {
id = $(this).attr('rel'); $(this).click(function(){
order = $('#order_'+id).val(); id = $(this).attr('rel');
self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/id/'+id+'/order/'+ order order = $('#order_'+id).val();
}); self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/id/'+id+'/order/'+ order
}); });
<?php }else{ ?> });
$('.changeorder').each(function(index, element) { <?php }else{ ?>
$(this).click(function(){ $('.changeorder').each(function(index, element) {
id = $(this).attr('rel'); $(this).click(function(){
order = $('#order_'+id).val(); id = $(this).attr('rel');
self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/mfid/'+id+'/order/'+ order order = $('#order_'+id).val();
}); self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/mfid/'+id+'/order/'+ order
}); });
<?php } ?> });
<?php if(empty($this->md)) { ?> <?php } ?>
var info = { <?php if(empty($this->md)) { ?>
btn_prefix : "delbtn_", var info = {
item_prefix : "DataLine_", btn_prefix : "delbtn_",
url : "/admin/data/fund/ac/del" item_prefix : "DataLine_",
} url : "/admin/data/fund/ac/del"
<?php }else{ ?> }
var info = { <?php }else{ ?>
btn_prefix : "delbtn_", var info = {
item_prefix : "DataLine_", btn_prefix : "delbtn_",
url : "/admin/data/fund/ac/mdfunddel/uuid/<?= $this->md['uuid'] ?>" item_prefix : "DataLine_",
} url : "/admin/data/fund/ac/mdfunddel/uuid/<?= $this->md['uuid'] ?>"
<?php } ?> }
</script> <?php } ?>
</script>

View File

@ -200,16 +200,20 @@ class Fund extends Zend_Controller_Plugin_Abstract
} }
} }
function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request) function getData($id,$keyword="")
{ {
$page = $request->getParam('page'); $search = "";
if(!empty($keyword))
$paginator = Zend_Paginator::factory($data); {
$paginator->setCurrentPageNumber($page); $search = " AND md.title LIKE '%$keyword%' ";
$paginator->setItemCountPerPage(12); }
$paginator->setView($ctl); $sql = "SELECT md.title,mf.id FROM ".$this->tbl_mdfund." mf
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); LEFT JOIN ".$this->tbl_fund." f ON mf.fid=f.id
$ctl->paginator = $paginator; LEFT JOIN metadata md ON md.uuid=mf.uuid
WHERE f.id=$id $search";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
} }
function _getParams(Zend_Controller_Request_Abstract $request) function _getParams(Zend_Controller_Request_Abstract $request)