#490 添加相关数据的查看功能

This commit is contained in:
Li Jianxuan 2013-05-22 09:13:50 +00:00
parent 00f0609eeb
commit 8234d6e625
4 changed files with 139 additions and 21 deletions

View File

@ -3836,19 +3836,19 @@ class AuthorController extends Zend_Controller_Action
if($ac == 'data') if($ac == 'data')
{ {
$this->_helper->viewRenderer('fund-data'); $this->_helper->viewRenderer('fund-data');
$uuid = $this->_getParam('uuid');
$this->view->q = $q = $this->_getParam('q'); $this->view->q = $q = $this->_getParam('q');
if(empty($uuid)) $rows = $fund->fetchFormData(true,$uid,$q);
{
$rows = $fund->fetchFormData($uid,$q);
view::addPaginator($rows,$this->view,$this->_request);
}else{
include('data/Metadata.php');
$md = new Metadata($this->db);
$this->view->md = $md->view($uuid);
$rows = $fund->fetch($uuid);
view::addPaginator($rows,$this->view,$this->_request); view::addPaginator($rows,$this->view,$this->_request);
return true;
} }
if($ac == 'dataview')
{
$this->_helper->viewRenderer('fund-data-view');
$this->view->q = $q = $this->_getParam('q');
$id = $this->_getParam('id');
$this->view->fund = $fund->view($id);
$rows = $fund->fetchFormData($id,$uid,$q);
view::addPaginator($rows,$this->view,$this->_request);
return true; return true;
} }

View File

@ -0,0 +1,100 @@
<?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="/author">数据作者</a>');
$this->headLink()->appendStylesheet('/css/author.css');
$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="span3">
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<div>
<ul class="nav nav-tabs">
<li><a href="/author/fund/ac/data">数据相关</a></li>
<li><a href="/author/fund/">所有项目</a></li>
<li><a href="/author/fund/ac/add">添加新项目</a></li>
<li class="active"><a href="javascript:void(0);">按项目查看</a></li>
</ul>
</div>
<?php if(!empty($this->fund)) { ?>
<div>
<h3><?= $this->fund['title'] ?> 的相关数据</h3>
<hr />
</div>
<?php } ?>
<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)) { ?>
<?php if(empty($this->AlertType)) $AlertType = "alert-error";else $AlertType = $this->AlertType;?>
<div class="alert alert-block fade in <?= $AlertType ?>" id="Alert-error-box">
<a class="close" data-dismiss="alert" href="#">×</a>
<?php if(!is_array($this->error)) { ?><h4 class="alert-heading"><?= $this->error ?></h4><?php } else { ?>
<ul>
<?php foreach($this->error as $v) { ?>
<li><?= $v ?></li>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<div class="alert <?= $this->AlertType;?>">
<a data-dismiss="alert" class="close">×</a>
<?php echo $this->msg ?>
</div>
<?php if(!empty($this->jump_url)) { ?>
<script language="javascript">setTimeout("self.location='<?php echo $this->jump_url ?>'",3000);</script>
<?php } ?>
<?php } else{ ?>
<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++;?>
<tr id="DataLine_<?= $item['mfid']?>">
<td><?= $item['mdtitle'] ?></td>
<td>
<a href="javascript:void(0);" onclick="onedel(<?= $item['mfid']?>)" id="delbtn_<?= $item['mfid']?>">移除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/author/fund/ac/mdfunddel/uuid/<?= $this->md['uuid'] ?>"
}
</script>

View File

@ -72,9 +72,10 @@ table thead tr th {background:#EBF2F6;}
<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>
<th>数据个数</th>
<th width="70">操作</th> <th width="70">操作</th>
</tr> </tr>
</thead> </thead>
@ -87,11 +88,12 @@ table thead tr th {background:#EBF2F6;}
<?php }else{?> <?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>"> <tr id="DataLine_<?= $item['mfid']?>">
<?php }?> <?php }?>
<td><?= $item['mdtitle'] ?></td>
<td><?= $item['title'] ?></td> <td><?= $item['title'] ?></td>
<td><?= $item['fund_id'] ?></td> <td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td>
<th><?= $item['mds'] ?></th>
<td> <td>
<a href="javascript:void(0);" onclick="onedel(<?= $item['mfid']?>)" id="delbtn_<?= $item['mfid']?>">移除</a> <a href="/author/fund/ac/dataview/id/<?= $item['id'] ?>">查看数据</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -95,7 +95,7 @@ class Fund extends Zend_Controller_Plugin_Abstract
} }
} }
function fetchFormData($uid,$keyword){ function fetchFormData($count = true,$uid,$keyword){
$wheresql = array(); $wheresql = array();
if(!empty($uid) && is_int($uid)) if(!empty($uid) && is_int($uid))
@ -112,6 +112,11 @@ class Fund extends Zend_Controller_Plugin_Abstract
$wheresql[] = " f.title LIKE '%$keyword%'"; $wheresql[] = " f.title LIKE '%$keyword%'";
} }
if($count !== true)
{
$wheresql[] = " f.id=$count ";
}
$wheresql[] = " md.title IS NOT NULL "; $wheresql[] = " md.title IS NOT NULL ";
if(count($wheresql)>0) if(count($wheresql)>0)
@ -121,11 +126,22 @@ class Fund extends Zend_Controller_Plugin_Abstract
$wheresql = ""; $wheresql = "";
} }
$sql = "SELECT f.*,mf.place,mf.id as mfid,md.title as mdtitle,md.uuid FROM ".$this->tbl_fund." f if($count === true)
{
$sql = "SELECT f.*,count(md.uuid) as mds FROM ".$this->tbl_fund." f
LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id
LEFT JOIN metadata md ON md.uuid=mf.uuid LEFT JOIN metadata md ON md.uuid=mf.uuid
$wheresql $wheresql
ORDER BY mf.place"; GROUP BY f.id";
}else{
$sql = "SELECT mf.id as mfid,md.title as mdtitle,md.uuid FROM ".$this->tbl_fund." f
LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id
LEFT JOIN metadata md ON md.uuid=mf.uuid
$wheresql
GROUP BY md.title,md.uuid,mf.id
";
}
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(PDO::FETCH_BOTH); $rows = $rs->fetchAll(PDO::FETCH_BOTH);