517 lines
24 KiB
PHP
517 lines
24 KiB
PHP
<?php
|
||
class WaterController extends DataController
|
||
{
|
||
private $limit=20;
|
||
function indexAction()
|
||
{
|
||
}
|
||
function documentAction()
|
||
{
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d'))");
|
||
$sum=$row[0]['count'];
|
||
$sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d')) order by reference limit ? offset ?";
|
||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
function surveystdAction()
|
||
{
|
||
}
|
||
function coldAction()
|
||
{
|
||
$this->getmd('上游寒区水文试验区');
|
||
}
|
||
function bgAction()
|
||
{
|
||
$this->getmd('冰沟流域加密观测区');
|
||
}
|
||
function arAction()
|
||
{
|
||
$this->getmd('阿柔加密观测区');
|
||
}
|
||
function bdkAction()
|
||
{
|
||
$this->getmd('扁都口加密观测区');
|
||
}
|
||
function ebAction()
|
||
{
|
||
$this->getmd('峨堡加密观测区');
|
||
}
|
||
function forestAction()
|
||
{
|
||
$this->getmd('森林水文试验区');
|
||
}
|
||
function dykAction()
|
||
{
|
||
$this->getmd('大野口流域加密观测区');
|
||
}
|
||
function plgAction()
|
||
{
|
||
$this->getmd('排露沟流域加密观测区');
|
||
}
|
||
function aridAction()
|
||
{
|
||
$this->getmd('中游干旱区水文试验区');
|
||
}
|
||
function hzzAction()
|
||
{
|
||
$this->getmd('花寨子荒漠加密观测区');
|
||
}
|
||
function ykAction()
|
||
{
|
||
$this->getmd('盈科绿洲加密观测区');
|
||
}
|
||
function zyAction()
|
||
{
|
||
$this->getmd('张掖市加密观测区');
|
||
}
|
||
function zynocAction()
|
||
{
|
||
$this->getmd('观象台加密观测区');
|
||
}
|
||
function lzgAction()
|
||
{
|
||
$this->getmd('临泽草地加密观测区');
|
||
}
|
||
function lzsAction()
|
||
{
|
||
$this->getmd('临泽站加密观测区');
|
||
}
|
||
function meteoAction()
|
||
{
|
||
$this->getmd('气象水文','theme');
|
||
}
|
||
function autometeoAction()
|
||
{
|
||
$this->getmd('气象观测','theme');
|
||
}
|
||
function mobilemeteoAction()
|
||
{
|
||
$this->getmd('移动气象观测','theme');
|
||
}
|
||
function ecAction()
|
||
{
|
||
$this->getmd('涡动相关','theme');
|
||
}
|
||
function lasAction()
|
||
{
|
||
$this->getmd('大孔径闪烁仪','theme');
|
||
}
|
||
function normalmeteoAction()
|
||
{
|
||
$this->getmd('常规气象观测','theme');
|
||
}
|
||
function regionalmeteoAction()
|
||
{
|
||
$this->getmd('区域气象观测','theme');
|
||
}
|
||
function dopplerAction()
|
||
{
|
||
$this->getmd('降雨','theme');
|
||
}
|
||
function hydroAction()
|
||
{
|
||
$this->getmd('水文','theme');
|
||
}
|
||
function airsoundingAction()
|
||
{
|
||
$this->getmd('大气廓线','theme');
|
||
}
|
||
function aireboneAction()
|
||
{
|
||
$this->getmd('航空遥感','theme');
|
||
}
|
||
function radiometerAction()
|
||
{
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$state=$this->db->query("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword ilike '%波段机载微波辐射计') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')");
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword ilike '%波段机载微波辐射计') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
function lidarAction()
|
||
{
|
||
//$this->getmd('激光雷达','theme');
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$state=$this->db->query("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='激光雷达') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')");
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='激光雷达') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
function widasAction()
|
||
{
|
||
//$this->getmd('WiDAS','theme');
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$state=$this->db->query("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='红外广角双模式成像仪WiDAS') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')");
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='红外广角双模式成像仪WiDAS') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
function asdAction()
|
||
{
|
||
//$this->getmd('成像光谱仪OMIS-II','theme');
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$state=$this->db->query("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='成像光谱仪OMIS-II') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')");
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='theme' and keyword='成像光谱仪OMIS-II') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
function satelliteAction()
|
||
{
|
||
$this->getmd('卫星遥感','theme');
|
||
}
|
||
|
||
function tagAction()
|
||
{
|
||
$key = $this->_request->getParam('key');
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
if (!empty($key)) {
|
||
$this->view->codename=$key;
|
||
$sql=$this->db->quoteInto('select count(id) from keyword where keyword=?',$key);
|
||
$state=$this->db->query($sql);
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title,id,description from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keyword='".$key."') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
} else {
|
||
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join metadata on keyword.id=metadata.id where keyword.keytype='place' and metadata.source='0595169a-279e-4b95-819f-129d0ba4280d' group by keyword.keyword order by count desc");
|
||
$k1=$state->fetchAll();
|
||
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join metadata m on k.id=m.id where k.keytype='theme' and m.source='0595169a-279e-4b95-819f-129d0ba4280d' group by k.keyword order by k.keyword");
|
||
$k2=$state->fetchAll();
|
||
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join metadata on keyword.id=metadata.id where keyword.keytype='temporal' and metadata.source='0595169a-279e-4b95-819f-129d0ba4280d' group by keyword.keyword order by keyword.keyword");
|
||
$k5=$state->fetchAll();
|
||
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
|
||
}
|
||
}
|
||
|
||
function searchAction()
|
||
{
|
||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||
$form=new SearchForm();
|
||
$this->view->form=$form;
|
||
//$form->submit->setLabel('快速搜索');
|
||
$key=$this->_request->getParam('q');
|
||
if (!empty($key)) {
|
||
$search=new Search($key);
|
||
$where=$search->sql_expr(array("title","description"));
|
||
$page=@(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$row=$this->db->fetchAll("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and ".$where);
|
||
$sum=$row[0]['count'];
|
||
$sql="select uuid,title,id,description from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and ".$where." order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->key=$key;
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
}
|
||
|
||
function timemapAction()
|
||
{
|
||
$sql="select id,uuid,west,south,north,east,title,timebegin,timeend from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and timebegin is not null and timebegin::date>date('2007-01-01')";
|
||
$this->view->rows=$this->db->fetchAll($sql);
|
||
}
|
||
|
||
function timelineAction()
|
||
{
|
||
$fn="watertime.xml";
|
||
$rows=$this->db->fetchAll("select ts_created from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' order by ts_created desc limit 1");
|
||
$last_update=strtotime($rows[0]['ts_created']);
|
||
if (!file_exists($fn) || (filemtime($fn)<$last_update))
|
||
{
|
||
$dateformat="M j Y";
|
||
$rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and timebegin is not null order by timebegin,title");
|
||
$timexml='<data>';
|
||
foreach($rows as $row) {
|
||
$timexml.='<event start="'.date($dateformat,strtotime($row['timebegin'])).' GMT+0800" ';
|
||
if ($row['timeend']!='' && $row['timeend']!=$row['timebegin']) $timexml.=' end="'.date($dateformat,strtotime($row['timeend'])).'" isDuration="true"';
|
||
$timexml.= ' title="'.htmlspecialchars(mb_substr($row['title'],11,mb_strlen($row['title'],'UTF-8')-10,'UTF-8')).'" image="/images/westdc_40w.gif" link="/water/'.$row['uuid'].'">';
|
||
$desc_length=mb_strlen($row['description'],"UTF-8");
|
||
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
|
||
if ($desc_length>300) $desc.=" ...";
|
||
$timexml.=htmlspecialchars($desc);
|
||
$timexml.="</event>\n";
|
||
}
|
||
$timexml.='</data>';
|
||
$fp=fopen($fn,'w');
|
||
fwrite($fp,$timexml);
|
||
fclose($fp);
|
||
}
|
||
}
|
||
|
||
function categoryAction()
|
||
{
|
||
$code = (int)$this->_request->getParam('code');
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$row=$this->db->fetchAll("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from category where code=".$code.")");
|
||
$sum=$row[0]['count'];
|
||
|
||
$this->view->category=$this->db->fetchAll('select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh');
|
||
if ($code>0 && $code<20) {
|
||
$sql="select uuid,title,description,id from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select distinct id from category where code=".$code.") order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
|
||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
||
} else {
|
||
//提供全部分类列表
|
||
}
|
||
}
|
||
/*
|
||
* 离线申请(可以包括在线数据),在无数据参数时,则显示已有列表
|
||
*/
|
||
function orderAction()
|
||
{
|
||
$uuid=$this->_request->getParam('uuid');
|
||
$del = $this->_request->getParam('del');
|
||
$apply = $this->_request->getParam('apply');
|
||
$finish = $this->_request->getParam('finish');
|
||
$cancel = $this->_request->getParam('cancel');
|
||
$pdf = $this->_request->getParam('pdf');
|
||
//if (empty($uuid)) $this->_redirect('/data');
|
||
$userid=Zend_Auth::getInstance()->getIdentity()->id;
|
||
if ($uuid)
|
||
{
|
||
//处理数据入库
|
||
//离线申请的数据不应该重复,因此需要在数据库限制?还是在WEB端限制?
|
||
//在数据库中控制,只保证uuid,userid,status唯一就可以?
|
||
//存在历史遗留问题,原来的数据并不能保证唯一
|
||
//status: 1 开始进入离线申请申请程序中
|
||
// 2 填写并提交离线申请表
|
||
// 3 邮寄离线申请表
|
||
// 4 收到离线申请表
|
||
// 5 处理离线申请表
|
||
// 10:离线申请完成?
|
||
// -1: 取消了在线下载进程
|
||
//首先判断离线申请的数据数量是否超过系统限制
|
||
$sql="select count(*) as datacount from dataorder where (ts_approved is null) and userid=? and status>0 and status<5";
|
||
$r=$this->db->fetchRow($sql,array($userid));
|
||
//保证添加的离线数据申请未申请
|
||
$sql="select count(*) as datacount from dataorder where (ts_approved is null) and userid=? and uuid=? and status=1";
|
||
$r1=$this->db->fetchRow($sql,array($userid,$uuid));
|
||
if ($r['datacount']<$this->view->config->download->max && $r1['datacount']<1) {
|
||
$sql="insert into dataorder (uuid,ts_created,userid,status) values(?,now(),?,?)";
|
||
$this->db->query($sql,array($uuid,$userid,1));
|
||
//成功信息提示
|
||
$sql=$this->db->quoteInto("select title,uuid from metadata where uuid=?",$uuid);
|
||
$this->view->md=$this->db->fetchRow($sql);
|
||
} else {
|
||
if ($r1['datacount']>=1)
|
||
$this->view->msg="错误:您申请的数据已经在数据蓝中!";
|
||
else
|
||
$this->view->msg="错误:您正在进行的离线申请的数据数已经超过系统允许的最大值,请在完成本次离线申请后再进行操作!";
|
||
}
|
||
} elseif ($del) {
|
||
//删除数据申请
|
||
$sql=$this->db->quoteInto("delete from dataorder where id=?",$del);
|
||
$this->db->query($sql);
|
||
$this->_redirect('/data/order');
|
||
} elseif ($apply) {
|
||
if ($apply=='all') {
|
||
$sql=$this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$userid);
|
||
$this->db->query($sql);
|
||
} else {
|
||
$sql="update dataorder set status=2 where status=1 and userid=? and id=?";
|
||
$this->db->query($sql,array($userid,(int)$apply));
|
||
}
|
||
} elseif ($finish) {
|
||
if ($finish=='all') {
|
||
$sql=$this->db->quoteInto("update dataorder set ts_approved=now() where status=0 and userid=?",$userid);
|
||
$this->db->query($sql);
|
||
$sql="update ftpuser set datacount=0 where userid=?";
|
||
$this->db->query($sql,array($userid));
|
||
} else {
|
||
$sql="update dataorder set ts_approved=now() where status=0 and userid=? and id=?";
|
||
$this->db->query($sql,array($userid,(int)$finish));
|
||
$sql="update ftpuser set datacount=datacount-1 where userid=?";
|
||
$this->db->query($sql,array($userid));
|
||
}
|
||
} elseif ($cancel) {
|
||
if ($cancel=='all') {
|
||
$sql=$this->db->quoteInto("update dataorder set ts_approved=now(),status=-1 where status=0 and userid=?",$userid);
|
||
$this->db->query($sql);
|
||
$sql="update ftpuser set datacount=0 where userid=?";
|
||
$this->db->query($sql,array($userid));
|
||
} else {
|
||
$sql="update dataorder set ts_approved=now(),status=-1 where status=0 and userid=? and id=?";
|
||
$this->db->query($sql,array($userid,(int)$cancel));
|
||
$sql="update ftpuser set datacount=datacount-1 where userid=?";
|
||
$this->db->query($sql,array($userid));
|
||
}
|
||
} elseif ($pdf) {
|
||
//生成PDF离线申请文件
|
||
//用户信息可以从SESSION中读取?离线申请信息
|
||
//$sql="select * from users where id=?";
|
||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d left join metadata m on d.uuid=m.uuid where d.status=2 and d.userid=? order by d.ts_created desc";
|
||
$rows=$this->db->fetchAll($sql,array($userid));
|
||
if ($rows) {
|
||
$this->view->data2=$rows;
|
||
$this->view->form=new OfflinePdfForm();
|
||
|
||
$this->_helper->viewRenderer('pdf');
|
||
if ($this->_request->isPost()) {
|
||
$formData = $this->_request->getPost();
|
||
$datalist='';
|
||
foreach($rows as $i=>$row) $datalist.=($i+1).". ".$row['title'].";";
|
||
$formData['datalist']=$datalist;
|
||
if ($this->view->form->isValid($formData)) {
|
||
if (@$formData['save']) {
|
||
//保存
|
||
//根据pdflink字段,以判断是否已经提交
|
||
//在数据库中创建rules,在更新offlineapp表时同时更新users表中对应的信息
|
||
$sql="select id from offlineapp where userid=? and (pdflink is null or pdflink='') and (ts_approved is null)";
|
||
$row=$this->db->fetchRow($sql,array($userid));
|
||
if ($row) {
|
||
$sql="update offlineapp set username=?,email=?,phone=?,address=?,postcode=?,project=?,unit=?,datalist=?,ts_created=now() where id=?";
|
||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$row['id']));
|
||
} else {
|
||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist) values(?,?,?,?,?,?,?,?,?)";
|
||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist));
|
||
}
|
||
$this->_helper->layout->disableLayout();
|
||
$this->_helper->viewRenderer->setNoRender();
|
||
//生成PDF
|
||
$pdf = new ApplicantWaterPDF();
|
||
$pdf->template=$this->view->config->offline->water_template;
|
||
$pdf->data = $formData;
|
||
$pdf->drawWestdc();
|
||
header("Content-Disposition: inline; filename=water-data-apply.pdf");
|
||
header("Content-Type:application/pdf");
|
||
//header("Content-Length: " . strlen($pdfstring));
|
||
echo $pdf->Output('water-data-apply.pdf','S');
|
||
die();
|
||
//exit;
|
||
} elseif ($formData['submit']) {
|
||
//提交
|
||
//生成PDF
|
||
$pdf = new ApplicantWaterPDF();
|
||
$pdf->template=$this->view->config->offline->water_template;
|
||
$pdf->data = $formData;
|
||
$pdf->drawWestdc();
|
||
|
||
$fn=$formData['realname'].date('YmdHis').".pdf";
|
||
$pdf->Output($this->view->config->offline->savepath."/".$fn, 'F');
|
||
|
||
//保存到数据库
|
||
$sql="select id from offlineapp where userid=? and pdflink is null and (ts_approved is null)";
|
||
$row=$this->db->fetchRow($sql,array($userid));
|
||
if ($row) {
|
||
$sql="update offlineapp set username=?,email=?,phone=?,address=?,postcode=?,project=?,unit=?,datalist=?,ts_created=now(),pdflink=? where id=?";
|
||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn,$row['id']));
|
||
} else {
|
||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist,pdflink) values(?,?,?,?,?,?,?,?,?,?)";
|
||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn));
|
||
$sql="select id from offlineapp where userid=? and pdflink=?";
|
||
$row=$this->db->fetchRow($sql,array($userid,$fn));
|
||
}
|
||
$sql="update dataorder set status=3, offlineappid=? where status=2 and userid=?";
|
||
$this->db->query($sql,array($row['id'],$userid));
|
||
|
||
//发送用户邮件进行信息提示和说明
|
||
//$mail = new Zend_Mail('utf-8');
|
||
$mail = new WestdcMailer($this->view->config->smtp);
|
||
$body=file_get_contents($this->view->config->offline->email->template);
|
||
$body=str_replace("[username]",$formData['realname'],$body);
|
||
$body=str_replace("[datalist]",str_replace(";","\n",$datalist),$body);
|
||
$mail->setBodyText($body);
|
||
$mail->addTo($formData['email']);
|
||
$mail->setSubject('您在西部数据中心进行的离线申请');
|
||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||
$attach=$mail->createAttachment($pdf->Output('applicant','S'));
|
||
$attach->filename='数据申请-'.$formData['realname'].'.pdf';
|
||
$mail->send();
|
||
|
||
//跳转到/data/order,并提示帮助信息,告知用户已经发送EMAIL
|
||
$this->messenger->addMessage('提示信息:您的离线申请已经提交,系统已经发送一封邮件给您,请打印出申请表并签字后邮寄给西部数据中心服务组,具体信息请参考邮件说明。');
|
||
$this->_redirect('/data/order');
|
||
}
|
||
}
|
||
} else {
|
||
$sql="select u.*,o.postcode from users u left join offlineapp o on u.id=o.userid where u.id=?";
|
||
$row=$this->db->fetchRow($sql,array($userid));
|
||
/*$row=$ut->fetchRow('id='.$userid);
|
||
$formData['email']=$row->email;
|
||
$formData['phone']=$row->phone;
|
||
$formData['realname']=$row->realname;
|
||
$formData['unit']=$row->unit;
|
||
$formData['address']=$row->address;
|
||
$formData['purpose']=$row->project;
|
||
$formData['id']=$row->id;*/
|
||
$this->view->form->populate($row);
|
||
}
|
||
} else
|
||
$this->view->msg="错误:您还没有提交任何离线申请的数据,或您的数据申请已经正式提交(等待处理过程中)!";
|
||
}
|
||
//显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载
|
||
$sql="select d.*,m.title,m.datatype from dataorder d left join metadata m on d.uuid=m.uuid where (d.status>0 or (d.status=0 and (d.ts_approved is null))) and d.userid=? order by d.status,d.ts_created desc";
|
||
$rows=$this->db->fetchAll($sql,array($userid));
|
||
foreach($rows as $row) {
|
||
switch ($row['status']){
|
||
case 0:
|
||
$dataorder0[]=$row;
|
||
break;
|
||
case 1:
|
||
$dataorder1[]=$row;
|
||
break;
|
||
case 2:
|
||
case 3:
|
||
case 4:
|
||
case 5:
|
||
$dataorder2[]=$row;
|
||
break;
|
||
default:
|
||
$dataorder3[]=$row;
|
||
break;
|
||
}
|
||
}
|
||
@$this->view->dataorder0=$dataorder0;
|
||
@$this->view->dataorder1=$dataorder1;
|
||
@$this->view->dataorder2=$dataorder2;
|
||
@$this->view->dataorder3=$dataorder3;
|
||
}
|
||
|
||
private function getmd($keyword,$type='place')
|
||
{
|
||
$page=(int)$this->_request->getParam('page');
|
||
if (empty($page)) $page=1;
|
||
$offset=$this->limit*($page-1);
|
||
$state=$this->db->query("select count(*) from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')");
|
||
$row=$state->fetchAll();
|
||
$sum=$row[0]['count'];
|
||
//@todo: add order with title
|
||
$sql="select uuid,title from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,title limit ? offset ?";
|
||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||
$this->view->offset=$offset+1;
|
||
}
|
||
} |