添加黑河数据汇交计划相关控制器、视图,以及一部分功能

This commit is contained in:
Li Jianxuan 2012-11-09 09:58:33 +00:00
parent 1dd158475f
commit 9b20bab70e
10 changed files with 716 additions and 11 deletions

View File

@ -0,0 +1,370 @@
<?php
class Admin_HeiheController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
}
function postDispatch()
{
}
function indexAction()
{
}
/*
* projectsAction() 数据汇交计划
*
*
*
*
*/
function projectAction()
{
$this->view->input_NameDefaultVal = "专家姓名";
$this->view->input_EmailDefaultVal = "专家email";
$projectTable = "heiheproject";
$ac = $this->_getParam('ac');
if(empty($ac) || $ac == "index")
{
$this->_helper->viewRenderer('project');
//Search Link
$this->view->searchLink = "/admin/heihe/project/ac/index/";
$q = $this->_getParam('q');
$wheresql = array();
if(!empty($q))
{
$wheresql[] = " (title LIKE '%$q%' OR
code LIKE '%$q%' OR
name LIKE '%$q%' OR
email LIKE '%$q%')";
$this->view->searchKeyword = $q;
}
if(count($wheresql)>0)
{
$wheresql = join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(!empty($wheresql))
{
$wheresql = " WHERE ".$wheresql;
}
$sql = "SELECT * FROM $projectTable $wheresql
ORDER BY id ASC";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll();
foreach ($rows as $k=>$v)
{
$rows[$k]['status'] = $this->replacestatus($v['status']);
}
$this->view->Count = count($rows);
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}//ac == index
//邀请专家
if($ac == "invite")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$pid = $this->_getParam('id');
$name = $this->_getParam('name');
$email = $this->_getParam('email');
if(!is_numeric($pid))
{
$this->jsonexit(array("error"=>"参数错误"));
return true;
}
if(empty($name) || $name == $this->view->input_NameDefaultVal)
{
$this->jsonexit(array("error"=>"请输入专家姓名"));
return true;
}
if(empty($email) || $email == $this->view->input_EmailDefaultVal)
{
$this->jsonexit(array("error"=>"请输入专家Email"));
return true;
}
$sql = "SELECT * FROM $projectTable WHERE id=$pid";
$sth = $this->db->query($sql);
$row = $sth->fetch();
$expert_name = $this->getArray($row['expert_name']);
$expert_email = $this->getArray($row['expert_email']);
$name_list = array();
$email_list = array();
if(is_array($expert_name) && count($expert_name)>0)
{
if(in_array($name,$expert_name))
{
$this->jsonexit(array("error"=>"该专家的姓名已经存在"));
return true;
}
}
if(is_array($expert_email) && count($expert_email)>0)
{
if(in_array($email,$expert_email))
{
$this->jsonexit(array("error"=>"该专家的Email已经存在"));
return true;
}
}
$expert_name[] = $name;
$expert_email[] = $email;
$name_list = $this->mkArray($expert_name);
$email_list = $this->mkArray($expert_email);
$update = array("expert_name"=>$name_list,"expert_email"=>$email_list);
$where = "id=$pid";
if($this->db->update($projectTable,$update,$where))
{
$this->sendMailToExpert($email);
$this->jsonexit(array("msg"=>"专家邀请成功!","invited"=>1));
return true;
}else{
$this->jsonexit(array("error"=>"邀请失败,请重试"));
return true;
}
return true;
}// 邀请专家
if($ac == "showexpert")
{
$del = $this->_getParam('del');
if(isset($del))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}else{
$this->_helper->layout->setLayout('layout-iframe');
$this->_helper->viewRenderer('project-showexpert');
}
$pid = $this->_getParam('id');
if(empty($pid) || !is_numeric($pid))
{
$this->view->error = "参数错误";
return true;
}
$this->view->pid = $pid;
$sql = "SELECT * FROM $projectTable WHERE id=$pid";
$sth = $this->db->query($sql);
$row = $sth->fetch();
if(empty($row['expert_name']))
{
$this->view->error = "此项目还没有添加跟踪专家";
return true;
}
$names = $this->getArray($row['expert_name']);
$emails = $this->getArray($row['expert_email']);
$experts = array();
foreach($names as $k=>$v)
{
$experts[$k] = array("name"=>$names[$k],"email"=>$emails[$k]);
}
$this->view->experts = $experts;
$del = $this->_getParam('del');
if(isset($del))
{
if(!is_numeric($del))
{
$this->jsonexit(array("error"=>"参数错误"));
return true;
}
unset($names[$del]);
unset($emails[$del]);
$update = array(
"expert_name"=>$this->mkArray($names),
"expert_email"=>$this->mkArray($emails)
);
$where = "id=$pid";
if($this->db->update($projectTable,$update,$where))
{
$this->jsonexit(array("deleted"=>1));
return true;
}else{
$this->jsonexit(array("error"=>"邀请失败,请重试"));
return true;
}
}
return true;
}//ac == showexpert 查看跟踪专家
if($ac == "unsubmit")
{
}//ac == unsubmit 未提交
if($ac == "submit")
{
}//ac == submit 已提交
}//projectsAction()
function replacestatus($status)
{
if($status == 0)
{
return "计划未提交";
}
if($status == 1)
{
return "计划未审核";
}
if($status == 2)
{
return "跟踪专家审核";
}
if($status == 3)
{
return "跟踪专家通过";
}
if($status == 4)
{
return "数据委员会通过";
}
}
//从pgsql读取数组并拆分为php数组
function getArray($str){
if(strlen($str)>3)
{
return explode(",",substr($str,1,-1));
}else{
return NULL;
}
}
//将php数组组装成pgsql中的数组
function mkArray($array){
if(!is_array($array))
{
return "{".$array."}";
}
if(count($array)==1)
{
$key = max(array_keys($array));
return "{".$array[$key]."}";
}
if(count($array)>1)
{
return "{".join(",",$array)."}";
}
}
//发送邀请专家的邮件
function sendMailToExpert($name,$email)
{
$http_base = "http://".$_SERVER ['HTTP_HOST'];
$code = substr(md5($email),5,12);
$url = $http_base."/heihe/projects/invite/".$code;
include_once("EmailText.php");
$mailtp=new EmailText($this->db,"expert_invite",array(
'name' => $name,
'url' => $url,
));
//Email test code
$mail_config = array(
'ssl' => 'ssl',
'port' => 465,
'auth' => 'login',
'username' => 'liujin834@gmail.com',
'password' => 'hhagecysbgispqoz'
);
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $mail_config);
Zend_Mail::setDefaultTransport($transport);
$mail=new Zend_Mail();
$body="aaa";
$mail->setBodyText($body);
$mail->setFrom('liujin834@gmail.com','liujin834');
$mail->addTo($email);
$mail->setSubject('数据跟踪专家邀请');
$mail->send();
/*
include_once("EmailText.php");
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mailtp=new EmailText($this->db,"author-new",array(
'user' => $row['realname'],
'uuid' => $row['uuid'],
'title'=> $row['title'],
'email'=> $row['email'],
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
$mail->addTo($this->debug_email);
$mail->send();
*/
}
public function jsonexit($data){
$this->getResponse()
->setHeader('Content-Type', 'application/json')
->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
return true;
}
}

View File

@ -0,0 +1,16 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('黑河数据集');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('heihe/left.phtml'); ?>
</div>
<div id="rightPanel">
</div>

View File

@ -0,0 +1,4 @@
<ul>
<li class="title">黑河数据集</li>
<li><a href="/admin/heihe/project">项目</a></li>
</ul>

View File

@ -0,0 +1,68 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/heihe">黑河数据集</a>');
$this->breadcrumb('黑河数据集');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->headLink()->appendStylesheet('/css/author.css');
?>
<?php
if(!empty($this->error))
{
echo $this->error;
echo "<script>setTimeout('parent.$.fn.colorbox.close();',2000);</script>";
}else{?>
<div class="content" id="datalist">
<ul>
<?php
foreach($this->experts as $k=>$v)
{
echo '<li id="item_'.$k.'">'.$v['name'] ." - ".$v['email'].' <lable id="delBtn_'.$k.'"><a href="javascript:void(0);" onclick="del(\''.$k.'\')">删除</a></lable></li>';
}
?>
</ul>
</div>
<script>
function del(id){
var dom = "#delBtn_"+id;
var html = $(dom).html();
$.ajax({
'type':"POST",
'url':'/admin/heihe/project/ac/showexpert',
'data':'id=<?= $this->pid;?>&del='+id,
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(typeof(data.msg)!='undefined')
{Alert(data.msg);}
if(typeof(data.deleted)!='undefined')
{$('#item_'+id).fadeOut(function(){$(this).remove();});}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){Alert('处理中出现错误,请刷新页面后重试');},
'beforeSend':function(){$(dom).html('<img src="/images/ajax-load-small.gif" />');$(dom).attr("disabled","disabled")},
'complete':function(){$(dom).html(html);$(dom).removeAttr("disabled");dom = null;}
});
}
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
}
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
</script>
<?php
}
?>

View File

@ -0,0 +1,93 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/heihe">黑河数据集</a>');
$this->breadcrumb('黑河数据集');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->headLink()->appendStylesheet('/css/author.css');
?>
<div id="leftPanel">
<?= $this->partial('heihe/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if(!empty($this->searchLink)){ ?>
<div>
<form id="datasearch" class="search_form" action="<?= $this->searchLink ?>">
<input type="text" id="keyword" name="q" value="<?= $this->searchKeyword; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
<?php }?>
<div>
<?= $this->Count; ?> 条记录
</div>
<div id="datalist">
<?php
if (count($this->paginator)):
echo "<ul>";
$autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;
?>
<li>
<p><span class="title"><?php echo $item['title'];?></span></p>
<p>编号:<label><?= $item['code'];?></label> | 负责人:<?= $item['name'];?> | 开始时间:<?= $item['pstart'];?> | 状态:<?= $item['status'];?></p>
<p>
<a href="javascript:void(0);" onclick="$('#inviteFrom_<?= $item['id'];?>').toggle();">邀请跟踪专家</a> | 
<a class="iframe" href="/admin/heihe/project/ac/showexpert/id/<?= $item['id'];?>">查看跟踪专家</a>
</p>
<p id="inviteFrom_<?= $item['id'];?>" style="display:none;">
<input type="text" id="expert_name_<?= $item['id'];?>" value="<?= $this->input_NameDefaultVal ?>"
onfocus="if(this.value=='<?= $this->input_NameDefaultVal ?>'){this.value=''}" onblur="if(this.value==''){this.value='<?= $this->input_NameDefaultVal ?>'}" />
<input type="text" id="expert_email_<?= $item['id'];?>" value="<?= $this->input_EmailDefaultVal ?>"
onfocus="if(this.value=='<?= $this->input_EmailDefaultVal ?>'){this.value=''}" onblur="if(this.value==''){this.value='<?= $this->input_EmailDefaultVal ?>'}" />
<button type="button" class="btn btn-green" onclick="invite(<?= $item['id'];?>)" id="inviteBtn_<?= $item['id'];?>">邀请</button>
</p>
</li>
<?php
endforeach;
echo "</ul>";
endif; ?>
</div>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<script>
function invite(id){
var dom = "#inviteBtn_"+id;
var html = $(dom).html();
$.ajax({
'type':"POST",
'url':'/admin/heihe/project/ac/invite',
'data':'id='+id+'&name='+$('#expert_name_'+id).val()+'&email='+$('#expert_email_'+id).val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(typeof(data.msg)!='undefined')
{Alert(data.msg);}
if(typeof(data.invited)!='undefined')
{$('#expert_name_'+id).val('');$('#expert_email_'+id).val('');}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){Alert('处理中出现错误,请刷新页面后重试');},
'beforeSend':function(){$(dom).html('<img src="/images/ajax-load-small.gif" />');$(dom).attr("disabled","disabled")},
'complete':function(){$(dom).html(html);$(dom).removeAttr("disabled");dom = null;}
});
}
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
}
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
</script>

View File

@ -730,6 +730,81 @@ class HeiheController extends DataController
}//function submitAction()
/*
* projectsAction() 数据汇交计划
*
*
*
*
*/
function projectsAction()
{
$ac = $this->_getParam('ac');
if(empty($ac) || $ac == "index")
{
$this->_helper->viewRenderer('project-index');
$sql = "SELECT * FROM heiheproject";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll();
foreach ($rows as $k=>$v)
{
$rows[$k]['status'] = $this->replacestatus($v['status']);
}
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}//ac == index
if($ac == "submitting")
{
}//ac == submitting 正在提交
if($ac == "unsubmit")
{
}//ac == unsubmit 未提交
if($ac == "submit")
{
}//ac == submit 已提交
}//projectsAction()
function replacestatus($status)
{
if($status == 0)
{
return "计划未提交";
}
if($status == 1)
{
return "计划未审核";
}
if($status == 2)
{
return "跟踪专家审核";
}
if($status == 3)
{
return "跟踪专家通过";
}
if($status == 4)
{
return "数据委员会通过";
}
}
function genRandomString($len)
{
$chars = array(

View File

@ -34,6 +34,7 @@
<li>黑河计划数据汇交</li>
<li>数据使用协议</li> -->
<li class="bigtitle text-shadow"><a href="/heihe/submit">数据汇交</a></li>
<li class="bigtitle text-shadow"><a href="/heihe/projects">数据汇交计划</a></li>
</ul>
<form id="search" enctype="application/x-www-form-urlencoded" action="/heihe/search" method="post">
<input type="text" name="q" id="q" value="<?php echo (empty($this->key))?'回车搜索标题和摘要':$this->key; ?>" onfocus="myfocus(this);" onblur="myblur(this);">

View File

@ -0,0 +1,59 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/water.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
$this->breadcrumb('<a href="/heihe/">'.$this->config->title->heihe.'</a>');
$this->breadcrumb('数据汇交计划');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
?>
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('heihe/navi.phtml'); ?>
</div>
</div>
<div id='right'>
<div class="clear">&nbsp;</div>
<?php if(!empty($this->error)) {?>
<div id="intro"><?php echo $this->error;?></div>
<?php }else{?>
<div style="overflow:hidden;">
<div id="tabs-controller">
<ul>
<li class="box-shadow"><a class="text-shadow" href="/heihe/submit/ac/newdata">正在提交</a></li>
<li class="box-shadow"><a class="text-shadow" href="/heihe/submit/ac/newdata/do/add">未提交</a></li>
<li class="box-shadow"><a class="text-shadow" href="/heihe/project/ac/commited">已提交</a></li>
</ul>
</div>
<div id="datalist">
<?php
if (count($this->paginator)):
echo "<ul>";
$autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;
?>
<li>
<p><span class="title"><?php echo $item['title'];?></span></p>
<p>编号:<label><?= $item['code'];?></label> | 负责人:<?= $item['name'];?> | 开始时间:<?= $item['pstart'];?> | 状态:<?= $item['status'];?></p>
</li>
<?php
endforeach;
echo "</ul>";
endif; ?>
</div>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
});
</script>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen"
href="/css/default.css" />
<script src='/js/navi.js' type="text/javascript"></script>
<link rel="shortcut icon" href="/favicon_64.png" />
<link rel="alternate" type="application/rss+xml" title="WestDC RSS Feed" href="/data/feed" />
<link rel="pingback" href="http://westdc.westgis.ac.cn/data/pingback" />
<?= $this->headTitle() ?>
<?= $this->headScript() ?>
<?= $this->headLink() ?>
<?= $this->headStyle() ?>
</head>
<body>
<?= $this->layout()->content ?>
</body>
</html>

View File

@ -14,7 +14,7 @@ class news
function getAllCategory($hide = 0){
$sql = "SELECT c.* FROM news_category c
WHERE display>0
WHERE display>$hide
ORDER BY displayorder asc";
$re = $this->db->query($sql);
$categorys = $re->fetchAll();