Ticket #150 增加了Onlineapp控制器和它的视图

This commit is contained in:
Li Jianxuan 2011-09-09 09:42:08 +00:00
parent 84e2b6d7db
commit b29d07988d
3 changed files with 267 additions and 51 deletions

View File

@ -0,0 +1,170 @@
<?php
class Admin_OnlineappController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
}
function postDispatch()
{
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
$select=$this->db->select();
$select->from('onlineapp as o',array('id','username','ts_created'))
//->where('usertype = ?', 'member')
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->order('o.id desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
$count="select count(id) as total from onlineapp";
$re=$this->db->query($count);
$t=$re->fetch();
$this->view->t=$t;
}//indexAction
function deleteAction()
{
$delete=(int)$this->_getParam('id');
if (isset($delete))
{
$sql="delete from onlineapp where id=?";
try {
$this->db->query($sql,array($delete));
$this->messenger->addMessage('该记录已删除');
} catch (Exception $e) {
$this->messenger->addMessage($e->getMessage());
}
$this->_redirect("/admin/onlineapp/");
}
}//deleteAction
function showAction()
{
$id = $this->_request->getParam('id');
if (!empty($id))
{
$sql ="select o.*,u.username as uname,u.id as uid,m.title,m.uuid
from onlineapp as o
left join users as u on u.id = o.userid
left join metadata as m on o.uuid = m.uuid
where o.id=?";
$result =$this->db->query($sql,$id);
$rows = $result->fetch();
$this->view->infos=$rows;
}
}//showAction
function datasAction()
{
$select=$this->db->select();
$select->from('onlineapp as o','count(o.id) as num')
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->where('o.uuid = m.uuid')
->group('m.title')
->group('m.uuid')
->order('num desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
/*$sql="select m.title,count(o.id) as num from onlineapp as o
left join metadata as m on m.uuid=o.uuid
where o.uuid=m.uuid
group by m.title";*/
}//datasAction
function showdataAction()
{
$uuid = $this->_request->getParam('uuid');
if(!empty($uuid))
{
$select=$this->db->select();
$select->from('onlineapp as o',array('id','username','ts_created'))
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->where('m.uuid = ?', $uuid)
->order('o.id desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
$sql="select title from metadata where uuid='$uuid'";
$re=$this->db->query($sql);
$t=$re->fetch();
$this->view->infos=$t;
}else {
$this->_redirect("/admin/onlineapp/");
}
}//showdataAction
function usersAction()
{
$select=$this->db->select();
$select->from('onlineapp as o','count(o.id) as num')
->join('users as u', 'u.id = o.userid', array('realname','id as uid'))
->where('o.userid = u.id')
->group('uid')
->group('realname')
->order('num desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
}//usersAction
function showuserAction()
{
$id = $this->_request->getParam('id');
if(!empty($id))
{
$select=$this->db->select();
$select->from('onlineapp as o',array('id','username','ts_created'))
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->where('o.userid = ?', $id)
->order('o.id desc');
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator;
$sql="select username,realname from users where id='$id'";
$re=$this->db->query($sql);
$t=$re->fetch();
$this->view->infos=$t;
}else {
$this->_redirect("/admin/onlineapp/");
}
}//showuserAction
}

View File

@ -4,23 +4,89 @@
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('后台管理首页');
$this->breadcrumb('<a href="/admin">后台管理首页</a>');
$this->breadcrumb('<a href="/admin/stat">统计</a>');
$this->breadcrumb('在线下载记录');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/prototype.js');
?>
<div id="divContent">
<div id="leftPanel">
用户管理工具:
<ul>
<li><a href="/admin/user/list">普通用户列表</a></li>
<li><a href="/admin/user/adminlist">管理员列表</a></li>
<li><a href="/admin/onlineapp">所有在线下载记录 <?php if(!empty($this->t['total'])) echo "(共".$this->t['total']."条)";?></a></li>
<li><a href="/admin/onlineapp/datas">数据下载记录统计</a></li>
<li><a href="/admin/onlineapp/users">用户下载记录统计</a></li>
</ul>
</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 id="rightPanel">
<div style="font-size:16px;line-height:30px;">共有 <?php echo $this->t['total'];?> 条在线下载记录</div>
<table>
<tr style="color:#FFF;background:#0a3e68;line-height:30px;">
<td width='80'>id</td>
<td width='100'>姓名</td>
<td width='350'>资料名称</td>
<td width='150'>下载时间</td>
<td width='150'>操作</td>
</tr>
<?php if (count($this->paginator)): ?>
<?php $autoindex=0;?>
<?php foreach ($this->paginator as $item): ?>
<?php $autoindex++;?>
<tr <?php if($autoindex%2 == 0) echo 'bgcolor="#CCCCCC"'; else echo 'bgcolor="#FFFFFF"'; ?>>
<td><?= $item['id']?></td>
<td><?= $item['username']?></td>
<td><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a></td>
<td><?php echo date('Y-m-d H:i:s', strtotime($item['ts_created'])); ?></td>
<td>
<a href='/admin/onlineapp/show/id/<?php echo $item['id'];?>'>查看详细</a>
<a href='/admin/onlineapp/delete/id/<?= $item['id'];?>/' onclick="return confirm('确定将此记录删除?')">删除</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
<div style="width:50%;text-align:left;">
<?= $this->paginator; ?>
</div>
</div>
</div>
<div id="oxbox" style="display:none;">
<div class="closeox"><a href="javascript:void(0);" onclick="$('oxbox').hide()">[关闭]</a></div>
<div id="loading">加载中...</div>
<div id="returninfo">
</div>
</div>
<script type="text/javascript">
function show(id)
{
var request_url = "/admin/onlineapp/show/";
request_pars = 'id='+id;
var myAjax = new Ajax.Updater('returninfo', request_url,{
method : 'get',
parameters : request_pars,
onFailure : reportError,
onLoading : loading,
onComplete : done,
evalScripts: true
});
}
function loading(){$('loading').style.display = 'block';}
function done(){$('loading').style.display = 'none';}
function reportError(request){alert('Sorry. There was an error.');}
</script>

View File

@ -5,17 +5,21 @@
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台管理首页</a>');
$this->breadcrumb('用户列表');
$this->breadcrumb('<a href="/admin/stat">统计</a>');
$this->breadcrumb('<a href="/admin/stat/onlineapp">在线下载记录</a>');
$this->breadcrumb('详细信息');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/prototype.js');
?>
<div id="divContent">
<div id="leftPanel">
用户管理工具:
<ul>
<li><a href="/admin/user/list">普通用户列表</a></li>
<li><a href="/admin/user/adminlist">管理员列表</a></li>
<li><a href="/admin/onlineapp">所有在线下载记录</a></li>
<li><a href="/admin/onlineapp/datas">数据下载记录统计</a></li>
<li><a href="/admin/onlineapp/users">用户下载记录统计</a></li>
</ul>
</div>
<?php if ($this->msg or $this->messages) :?>
@ -28,47 +32,23 @@
</div>
<?php endif; ?>
<div id="rightPanel">
<form name="form1" method="post" action="/admin/user/edit">
<table>
<tr><td>ID</td><td><?= $this->infos['id'];?></td></tr>
<tr><td>用户名</td><td><?= $this->infos['username'];?></td></tr>
<tr><td>真实姓名</td><td><?= $this->infos['realname'];?></td></tr>
<tr><td>电子邮箱</td><td><?= $this->infos['email'];?></td></tr>
<tr><td>注册时间</td><td><?=$this->infos['ts_created'];?></td></tr>
<tr><td>最后登陆时间</td><td><?= $this->infos['ts_last_login'];?></td></tr>
<tr><td>单位</td><td><?= $this->infos['unit'];?></td></tr>
<tr><td>地址</td><td><?= $this->infos['address'];?></td></tr>
<tr><td>电话</td><td><?= $this->infos['phone'];?></td></tr>
<tr><td>项目</td><td><?= $this->infos['project'];?></td></tr>
<tr><td>用户权限</td><td>
<select name="usertype">
<?php
if ($this->infos['usertype']=='member')
{ echo "
<option value='member' selected='selected'>普通会员</option>
<option value='administrator'>系统管理员</option>
";}
else if($this->infos['usertype']=='administrator')
{ echo "<option value='administrator' selected='selected'>系统管理员</option>
<option value='member'>普通会员</option>
";}
?>
</select>
</td></tr>
<tr><td>用户密码</td><td><input type='password' name="newpwd" /></td></tr>
<tr><td>确认用户密码</td><td><input type='password' name="cfnewpwd" /></td></tr>
<tr><td width="80">记录ID</td><td><?php echo $this->infos['id'];?></td></tr>
<tr><td>用户名</td><td><?php echo $this->infos['uname'];?> > <a href="/admin/user/show/id/<?php echo $this->infos['uid'];?>">察看用户</a></td></tr>
<tr><td>姓名</td><td><?php echo $this->infos['username'];?></td></tr>
<tr><td>单位</td><td><?php echo $this->infos['unit'];?></td></tr>
<tr><td>电话</td><td><?php echo $this->infos['phone'];?></td></tr>
<tr><td>地址</td><td><?php echo $this->infos['address'];?></td></tr>
<tr><td>邮编</td><td><?php echo $this->infos['postcode'];?></td></tr>
<tr><td>电话</td><td><?php echo $this->infos['phone'];?></td></tr>
<tr><td>Email</td><td><?php echo $this->infos['email'];?></td></tr>
<tr><td>项目</td><td><textarea style="width:500px;height:200px;font-size:12px;"><?php echo $this->infos['project'];?></textarea></td></tr>
<tr><td>下载时间</td><td><?php echo date('Y-m-d H:i:s', strtotime($this->infos['ts_created']));?></td></tr>
<tr><td>项目名称</td><td><?php echo $this->infos['title'];?> > <a href="/data/<?php echo $this->infos['uuid'];?>">查看项目</a></td></tr>
</table>
<input type='hidden' value="<?php echo $this->infos['id'];?>" name='id' />
<input type="submit" value="提交" />
</form>
<form name="lostpwd" action="/admin/user/fetchpwd">
<input type="hidden" name="id" value="<?= $this->infos['id'];?>" />
<input type="hidden" name="email" value="<?= $this->infos['email'];?>" />
<input type="submit" value="为他执行重置密码"/>
</form>
<div style="width:50%;text-align:left;">
<?= $this->paginator; ?>
</div>
</div>