修改离线申请表,增加wsn数据来源判定
This commit is contained in:
parent
a0c8be3a73
commit
77c95fde76
|
@ -1459,11 +1459,13 @@ class DataController extends Zend_Controller_Action
|
|||
$apply = $this->_request->getParam('apply');
|
||||
$finish = $this->_request->getParam('finish');
|
||||
$cancel = $this->_request->getParam('cancel');
|
||||
$wsn = $this->_request->getParam('wsn');
|
||||
$pdf = $this->_request->getParam('pdf');
|
||||
|
||||
//if (empty($uuid)) $this->_redirect('/data');
|
||||
$userid = view::User('id');
|
||||
|
||||
//添加到数据篮
|
||||
if ($uuid)
|
||||
{
|
||||
//存在历史遗留问题,原来的数据并不能保证唯一
|
||||
|
@ -1474,29 +1476,58 @@ class DataController extends Zend_Controller_Action
|
|||
$state = $order->addOrder($uuid);
|
||||
|
||||
if($state !== true)
|
||||
{
|
||||
if(!is_array($state))
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
}else{
|
||||
if($state['datetype'] == "wsn")
|
||||
{
|
||||
\view::Post($this,"此数据提供下载选择功能,请等待页面跳转至数据选择页面","/data/order/wsn/$uuid");
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-error',"无法申请:此元数据的数据类型未知");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表");
|
||||
}
|
||||
|
||||
if (empty($ac)) $ac='offline1';
|
||||
|
||||
} elseif ($del) {
|
||||
//删除数据申请
|
||||
$sql=$this->db->quoteInto("delete from dataorder where userid=".$userid." and status in (1,2) and id=?",$del);
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
//删除申请
|
||||
elseif ($del) {
|
||||
$order = new order\Order();
|
||||
$state = $order->del($del);
|
||||
if($state !== true)
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-success',"数据申请取消成功");
|
||||
}
|
||||
$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 ($apply) {
|
||||
if($apply == "all" || !is_numeric($apply))
|
||||
{
|
||||
$apply = -1;
|
||||
}
|
||||
$order = new order\Order();
|
||||
$state = $order->apply($apply);
|
||||
if($state !== true)
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-success',"提交成功,您可以点击“提交离线申请”来生成PDF申请表");
|
||||
}
|
||||
if (empty($ac)) $ac='offline2';
|
||||
} elseif ($finish) {
|
||||
}
|
||||
|
||||
//完成
|
||||
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);
|
||||
|
@ -1508,7 +1539,16 @@ class DataController extends Zend_Controller_Action
|
|||
$sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0";
|
||||
$this->db->query($sql,array($userid));
|
||||
}
|
||||
} elseif ($cancel) {
|
||||
}
|
||||
|
||||
elseif($wsn)
|
||||
{
|
||||
$this->_helper->viewRenderer('order-wsn');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -1521,33 +1561,37 @@ class DataController extends Zend_Controller_Action
|
|||
$this->db->query($sql,array($userid));
|
||||
}
|
||||
if (empty($ac)) $ac='offline2';
|
||||
} elseif ($pdf) {
|
||||
}
|
||||
|
||||
//生成PDF离线申请文件
|
||||
elseif ($pdf) {
|
||||
|
||||
//用户信息可以从SESSION中读取?离线申请信息
|
||||
//$sql="select * from users where id=?";
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,
|
||||
array_to_string(ARRAY(
|
||||
select r.reference from mdref mr left join reference r on mr.refid=r.id
|
||||
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,
|
||||
array_to_string(array(
|
||||
select fund.fund_type||':'||fund.title||'(编号:'||fund.fund_id||')'
|
||||
from fund left join mdfund on fund.id=mdfund.fid where mdfund.uuid=d.uuid),'\n'::text) as fund,
|
||||
doi.doi as datadoi,doi.authors,doi.publisher,doi.title as doititle,doi.author_en,doi.publisher_en,doi.title_en
|
||||
from dataorder d left join metadata m on d.uuid=m.uuid left join datadoi doi on doi.uuid=d.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();
|
||||
$order = new order\Order();
|
||||
$rows = $order->getOrderItemForPdf();
|
||||
$this->view->projectType = $order->projectType;
|
||||
|
||||
if ($rows) {
|
||||
$this->_helper->viewRenderer('pdf');
|
||||
|
||||
$this->view->data2 = $rows;
|
||||
|
||||
if ($this->_request->isPost()) {
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$this->view->formData = $formData = $this->_request->getPost();
|
||||
|
||||
if(empty($formData['title']))
|
||||
{
|
||||
$this->view->error = \view::Msg('alert-error',"");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$datalist='';
|
||||
foreach($rows as $i=>$row) $datalist.=($i+1).". ".$row['title'].";";
|
||||
$formData['datalist']=$datalist;
|
||||
if ($this->view->form->isValid($formData)) {
|
||||
$formData['datalist'] = $datalist;
|
||||
|
||||
if (@$formData['save']) {
|
||||
//保存
|
||||
//根据pdflink字段,以判断是否已经提交
|
||||
|
@ -1643,7 +1687,6 @@ where d.status=2 and d.userid=? order by d.ts_created desc
|
|||
if (empty($ac)) $ac='offline3';
|
||||
//$this->_redirect('/data/order');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql="select u.* from users u left join offlineapp o on u.id=o.userid where u.id=?";
|
||||
$row=$this->db->fetchRow($sql,array($userid));
|
||||
|
@ -1655,7 +1698,7 @@ where d.status=2 and d.userid=? order by d.ts_created desc
|
|||
$formData['address']=$row->address;
|
||||
$formData['purpose']=$row->project;
|
||||
$formData['id']=$row->id;*/
|
||||
$this->view->form->populate($row);
|
||||
$this->view->formData = $row;
|
||||
}
|
||||
} else
|
||||
$this->view->msg=view::Msg('alert-error',"错误:您还没有提交任何离线申请的数据,或您的数据申请已经提交(等待处理过程中)!",0);
|
||||
|
|
|
@ -36,6 +36,84 @@
|
|||
<?php if ($this->msg) : ?>
|
||||
<div class="alert"><p><?php echo $this->msg; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php echo $this->form;?>
|
||||
<form id="OfflinePdf" enctype="application/x-www-form-urlencoded" class="form-horizontal" action="" method="post">
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="realname">真实姓名</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="realname" id="realname" value="<?= empty($this->formData['realname']) ? "":$this->formData['realname']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="email">E-Mail</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="email" id="email" value="<?= empty($this->formData['email']) ? "":$this->formData['email']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="phone">电话</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="phone" id="phone" value="<?= empty($this->formData['phone']) ? "":$this->formData['phone']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="unit">单位</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="unit" id="unit" value="<?= empty($this->formData['unit']) ? "":$this->formData['unit']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="address">联系地址</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="address" id="address" value="<?= empty($this->formData['address']) ? "":$this->formData['address']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="postcode">邮编</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="postcode" id="postcode" value="<?= empty($this->formData['postcode']) ? "":$this->formData['postcode']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="project_id">项目编号</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="project_id" id="project_id" value="<?= empty($this->formData['project_id']) ? "":$this->formData['project_id']?>" helper="formText"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="project_type">项目类型</label>
|
||||
<div class="controls">
|
||||
<select name="project_type" id="project_type" helper="formSelect">
|
||||
<option value="" label="请选择项目类型" <?= empty($this->formData['project_type']) ? 'selected="selected"':"" ?>>请选择项目类型</option>
|
||||
<?php foreach($this->projectType as $k=>$v) {?>
|
||||
<option value="<?= $v ?>" <?= $this->formData['project_type'] == $v ? 'selected="selected"':"" ?>><?= $k ?></option>
|
||||
<?php }?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="project_title">项目名称</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="project_title" id="project_title" value="<?= empty($this->formData['project_title']) ? "":$this->formData['project_title']?>" helper="formText" class="input-block-level"> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" name="project">用途<br/>(请详细描述使用目的)</label>
|
||||
<div class="controls">
|
||||
<textarea name="project" id="project" helper="formTextarea" rows="3" class="input-block-level" cols="80">
|
||||
<?= empty($this->formData['project']) ? "":$this->formData['project']?>
|
||||
</textarea> </div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="hidden" name="id" value="8018" helper="formHidden" id="id">
|
||||
|
||||
<input type="submit" name="save" id="savebutton" value="预览PDF" class="btn">
|
||||
|
||||
<input type="submit" name="submit" id="submitbutton" value="提交申请到数据中心" class="btn btn-primary">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div><!--/span-->
|
||||
</div>
|
|
@ -9,6 +9,18 @@ class Order
|
|||
private $config;
|
||||
protected $events = NULL;
|
||||
|
||||
public $projectType = array(
|
||||
"国家973计划项目课题" => "国家973计划项目课题",
|
||||
"国家863计划课题"=>"国家863计划课题",
|
||||
"国家级科技支撑课题" => "国家级科技支撑课题",
|
||||
"国家级科技重大专项" => "国家级科技重大专项",
|
||||
"国家级国家重大工程" => "国家级国家重大工程",
|
||||
"国家级国家自然科学基金" => "国家级国家自然科学基金",
|
||||
"国际合作项目"=>"国际合作项目",
|
||||
"省部级项目" => "省部级项目",
|
||||
"其他项目工程" => "其他项目工程",
|
||||
); //申请中的项目类型
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
|
@ -53,6 +65,11 @@ class Order
|
|||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
if(!is_numeric($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||
{
|
||||
return "参数错误";
|
||||
|
@ -66,6 +83,14 @@ class Order
|
|||
return $data;
|
||||
}
|
||||
|
||||
$results = $this->events()->trigger('checksource', $this, compact('uuid'));
|
||||
$data = $results->bottom();
|
||||
|
||||
if($data !== true)
|
||||
{
|
||||
return array("datetype"=>$data,"uuid"=>$uuid);
|
||||
}
|
||||
|
||||
if($this->pushToDataorder($uuid,$uid) === true)
|
||||
{
|
||||
return true;
|
||||
|
@ -73,7 +98,7 @@ class Order
|
|||
return "操作中出现错误,请重试";
|
||||
}
|
||||
|
||||
}
|
||||
}//addOrder
|
||||
|
||||
//放到数据篮中
|
||||
public function pushToDataorder($uuid,$uid = 0)
|
||||
|
@ -92,8 +117,101 @@ class Order
|
|||
}else{
|
||||
return false;
|
||||
}
|
||||
}//pushToDataorder
|
||||
|
||||
//提交
|
||||
public function apply($id,$uid = 0)
|
||||
{
|
||||
if(!is_numeric($id) || !is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(empty($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
if($id == -1)
|
||||
{
|
||||
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$uid);
|
||||
if($this->db->exec($sql))
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return "处理中遇到问题,请重试";
|
||||
}
|
||||
}
|
||||
|
||||
if($id > 0)
|
||||
{
|
||||
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=$uid and id=?",$id);
|
||||
if($this->db->exec($sql))
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return "处理中遇到问题,请重试";
|
||||
}
|
||||
}
|
||||
|
||||
return "参数错误";
|
||||
}//apply()
|
||||
|
||||
//删除
|
||||
public function del($id,$uid = 0)
|
||||
{
|
||||
if(!is_numeric($id) || !is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(empty($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
if($id > 0)
|
||||
{
|
||||
$sql = $this->db->quoteInto("delete from dataorder where userid=$uid and status in (1,2) and id=?",$id);
|
||||
if($this->db->exec($sql))
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return "处理中遇到错误,请重试";
|
||||
}
|
||||
}
|
||||
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
//生成pdf
|
||||
public function pdf($uid = 0)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获得要生成pdf的信息
|
||||
public function getOrderItemForPdf($uid = 0)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
$sql = "select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,
|
||||
array_to_string(ARRAY(
|
||||
select r.reference from mdref mr left join reference r on mr.refid=r.id
|
||||
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,
|
||||
array_to_string(array(
|
||||
select fund.fund_type||':'||fund.title||'(编号:'||fund.fund_id||')'
|
||||
from fund left join mdfund on fund.id=mdfund.fid where mdfund.uuid=d.uuid),'\n'::text) as fund,
|
||||
doi.doi as datadoi,doi.authors,doi.publisher,doi.title as doititle,doi.author_en,doi.publisher_en,doi.title_en
|
||||
from dataorder d left join metadata m on d.uuid=m.uuid left join datadoi doi on doi.uuid=d.uuid
|
||||
where d.status=2 and d.userid=? order by d.ts_created desc
|
||||
";
|
||||
$rows = $this->db->fetchAll($sql,array($uid));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
|
@ -3,5 +3,12 @@ namespace order\listener;
|
|||
//接口 ,需要实现的Listener中的方法
|
||||
interface OrderEvents
|
||||
{
|
||||
public function submit($e);
|
||||
//申请提交事件
|
||||
public function submit(\Zend_EventManager_Event $e);
|
||||
|
||||
//检查数据来源事件
|
||||
//区别是直接下载的数据或是wsn来源的数据
|
||||
//wsn来源的数据需要用户在提交申请的时候选择要下载的内容
|
||||
public function checksource(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ class OrderListener implements \Zend_EventManager_ListenerAggregate
|
|||
{
|
||||
$mountedClass = new \order\mount\OrderOperate();
|
||||
$events->attach('submit', array($mountedClass, 'submit'), 100);
|
||||
$events->attach('checksource',array($mountedClass,'checksource'),100);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ class OrderOperate implements \order\listener\OrderEvents
|
|||
}
|
||||
|
||||
//提交申请
|
||||
public function submit($e)
|
||||
public function submit(\Zend_EventManager_Event $e)
|
||||
{
|
||||
$uuid = $e->getParam('uuid');
|
||||
$uid = $e->getParam('uid');
|
||||
|
@ -112,6 +112,23 @@ class OrderOperate implements \order\listener\OrderEvents
|
|||
}
|
||||
}//checkOrderNum
|
||||
|
||||
//检查数据来源
|
||||
public function checksource(\Zend_EventManager_Event $e)
|
||||
{
|
||||
$uuid = $e->getParam('uuid');
|
||||
|
||||
$sql = "SELECT * FROM wsn_metadata WHERE uuid='$uuid'";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
|
||||
$row = $rs->fetch();
|
||||
|
||||
if(isset($row['uuid']) && !empty($row['uuid']))
|
||||
{
|
||||
return "wsn";
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue