增加了数据信息统计功能

This commit is contained in:
Li Jianxuan 2012-05-25 09:23:46 +00:00
parent d53a234a26
commit 16b6bb0dd9
5 changed files with 288 additions and 9 deletions

View File

@ -2944,6 +2944,135 @@ class AuthorController extends Zend_Controller_Action
}//委托
/*
* staticsAction() 数据统计
*
*
*/
public function staticsAction(){
$ac = $this->_getParam('ac');
if(empty($ac))
{
$this->view->alldata = $this->getClick();
}
if($ac=="md")
{
$this->_helper->viewRenderer('statics-md');
$this->view->allorder = $this->getStatic("allorder");
$this->view->offlineorder = $this->getStatic("offline");
$this->view->onlineorder = $this->getStatic("online");
}
if($ac == "time")
{
$this->_helper->viewRenderer('statics-time');
$this->view->datas = $this->getStaticByYear("dataorder");
}
}//staticsAction() 数据统计
public function getClick(){
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$uid = $user->id;
}
$sql = "SELECT md.title,md.uuid,s.viewed,count(o.id) as down FROM metadata md
LEFT JOIN mdstat s ON md.uuid=s.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
LEFT JOIN dataorder o ON md.uuid=o.uuid
WHERE a.userid=? OR (o.status=0 or o.status=5)
GROUP BY md.title,md.uuid,s.viewed";
$sth = $this->db->prepare($sql);
$sth->execute(array($uid));
$rows = $sth->fetchAll();
return $rows;
}
/*
* getStaticByYear按月份获取统计数据
*/
public function getStaticByYear($ac,$year=0){
if(empty($year))
{
$year = date("Y",time());
}
if($ac == "dataorder")
{
$table = "dataorder";
$time_field = "ts_created";
$count_field = "id";
}
$sql = "select to_char(o.$time_field, 'YYYY-MM') as d , count(o.$count_field) as c from $table o
where o.ts_created between '$year-01-01' and '$year-12-12' group by d";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
return $rows;
}
public function getStatic($ac){
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$uid = $user->id;
}
if(empty($uid)){
return false;
}
if($ac == "allorder"){
$sql = " SELECT count(o.id) as c FROM metadata md
LEFT JOIN dataorder o ON md.uuid=o.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE a.userid=? AND a.status>0";
$sth = $this->db->prepare($sql);
$sth->execute(array($uid));
$row = $sth->fetch();
return $row['c'];
}
if($ac == "offline"){
$sql = " SELECT count(o.id) as c FROM metadata md
LEFT JOIN dataorder o ON md.uuid=o.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE o.offlineappid > 0 AND a.userid=? AND a.status>0";
$sth = $this->db->prepare($sql);
$sth->execute(array($uid));
$row = $sth->fetch();
return $row['c'];
}
if($ac == "online"){
$sql = " SELECT count(o.id) as c FROM metadata md
LEFT JOIN dataorder o ON md.uuid=o.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE o.onlineappid > 0 AND a.userid=? AND a.status>0";
$sth = $this->db->prepare($sql);
$sth->execute(array($uid));
$row = $sth->fetch();
return $row['c'];
}
}
public function getFileinfo($id){
$sql = "select * from attachments where id='$id'";
$re= $this->db->query($sql);

View File

@ -1,16 +1,16 @@
<ul>
<li><a href="/author/">介绍</a></li>
<li><a href="/author/">介绍</a></li>
<li><a href="/author/newdata">新建数据</a></li>
<li><a href="/author/apply">数据认证</a></li>
<li><a href="/author/accept">我的数据</a></li>
<li><a href="/author/inauthor">数据申请管理</a></li>
<li><a href="/author/comment">数据反馈管理</a></li>
<li><a href="/author/literature">数据文献管理</a></li>
<li><a href="/author/document">数据文档管理</a></li>
<li><a href="/author/news">数据新闻管理</a></li>
<li><a href="/author/version">数据版本管理</a></li>
<li><a href="/author/comment">数据反馈管理</a></li>
<li><a href="/author/literature">数据文献管理</a></li>
<li><a href="/author/document">数据文档管理</a></li>
<li><a href="/author/news">数据新闻管理</a></li>
<li><a href="/author/version">数据版本管理</a></li>
<!--
<li><a href="/author/survey">数据调查</a></li>
<li><a href="/author/qa">数据QA</a></li>
<li><a href="/author/statistics">信息统计</a></li> -->
<li><a href="/author/survey">数据调查</a></li>
<li><a href="/author/qa">数据QA</a></li> -->
<li><a href="/author/statics">信息统计</a></li>
</ul>

View File

@ -0,0 +1,52 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据申请管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow"><a class="text-shadow" href="/author/statics">数据统计</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/author/statics/ac/md">申请统计</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/statics/ac/time">按时间段统计</a></li>
</ul>
</div>
<div id="datalist">
<ul>
<?php
if(isset($this->allorder))
{
echo "<li><h1>申请总数量:".$this->allorder."</h1><a href='/author/inauthor'>【申请管理】</a></li>";
}
if(isset($this->offlineorder))
{
echo "<li><h1>离线申请总数量:".$this->offlineorder."</h1><a href='/author/inauthor/ac/offline'>【查看离线申请】</a></li>";
}
if(isset($this->onlineorder))
{
echo "<li><h1>在线申请总数量:".$this->onlineorder."</h1><a href='/author/inauthor/ac/online'>【查看在线申请】</a></li>";
}
?>
</ul>
</div>
</div>
<!-- //页面内容 -->
<script>
$('#wapper').width($('body').width()-300);
</script>

View File

@ -0,0 +1,47 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据申请管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow"><a class="text-shadow" href="/author/statics">数据统计</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/statics/ac/md">申请统计</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/author/statics/ac/time">按时间段统计</a></li>
</ul>
</div>
<div id="datalist">
<ul>
<?php
if(isset($this->datas))
{
foreach($this->datas as $k=>$v)
{
echo "<li>时间:{$v['d']}<br />申请数:{$v['c']}</li>";
}
}
?>
</ul>
</div>
</div>
<!-- //页面内容 -->
<script>
$('#wapper').width($('body').width()-300);
</script>

View File

@ -0,0 +1,51 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据申请管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow active"><a class="text-shadow" href="/author/statics">数据统计</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/statics/ac/md">申请统计</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/statics/ac/time">按时间段统计</a></li>
</ul>
</div>
<div id="datalist">
<ul>
<?php
if(isset($this->alldata))
{
foreach($this->alldata as $v)
{
echo "<li><p><a target='_blank' href='/data/".$v['uuid']."'>".$v['title']."</a></p><p>点击:".$v['viewed']." | 下载:".$v['down']."</p></li>";
}
}
?>
</ul>
</div>
</div>
<!-- //页面内容 -->
<script>
$('#wapper').width($('body').width()-300);
</script>