修改离线申请表,增加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)
|
||||
{
|
||||
//存在历史遗留问题,原来的数据并不能保证唯一
|
||||
|
@ -1475,28 +1477,57 @@ class DataController extends Zend_Controller_Action
|
|||
|
||||
if($state !== true)
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
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);
|
||||
|
@ -1504,11 +1535,20 @@ class DataController extends Zend_Controller_Action
|
|||
$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));
|
||||
$this->db->query($sql,array($userid,(int)$finish));
|
||||
$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,128 +1561,131 @@ class DataController extends Zend_Controller_Action
|
|||
$this->db->query($sql,array($userid));
|
||||
}
|
||||
if (empty($ac)) $ac='offline2';
|
||||
} elseif ($pdf) {
|
||||
//生成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));
|
||||
$order = new order\Order();
|
||||
$rows = $order->getOrderItemForPdf();
|
||||
$this->view->projectType = $order->projectType;
|
||||
|
||||
if ($rows) {
|
||||
$this->view->data2=$rows;
|
||||
$this->view->form=new OfflinePdfForm();
|
||||
|
||||
$this->_helper->viewRenderer('pdf');
|
||||
$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)) {
|
||||
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(),project_type=?,project_id=?,project_title=? where id=?";
|
||||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$formData['project_type'],$formData['project_id'],$formData['project_title'],$row['id']));
|
||||
} else {
|
||||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist,project_type,project_id,project_title) values(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$formData['project_type'],$formData['project_id'],$formData['project_title']));
|
||||
}
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
//生成PDF
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join heihemetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from heihemetadata) and d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
|
||||
$pdf = new ApplicantPDF();
|
||||
$pdf->template=$this->view->config->offline->template;
|
||||
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
|
||||
$formData['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
|
||||
$pdf->data = $formData;
|
||||
if (isset($formData['westdclist'])) $pdf->drawWestdc();
|
||||
if (isset($formData['heihelist'])) $pdf->drawHeihe();
|
||||
$pdf->addRef($rows);
|
||||
$pdf->addSecurity($this->view->config->offline->security);
|
||||
header("Content-Disposition: inline; filename=westdc-data-apply.pdf");
|
||||
header("Content-Type:application/pdf");
|
||||
//header("Content-Length: " . strlen($pdfstring));
|
||||
echo $pdf->Output('westdc-data-apply.pdf','S');
|
||||
die();
|
||||
//exit;
|
||||
} elseif ($formData['submit']) {
|
||||
//提交
|
||||
//生成PDF
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join heihemetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from heihemetadata) and d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
|
||||
$pdf = new ApplicantPDF();
|
||||
$pdf->template=$this->view->config->offline->template;
|
||||
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
|
||||
$pdf->data = $formData;
|
||||
$pdf->data['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
|
||||
if (isset($formData['westdclist'])) $pdf->drawWestdc();
|
||||
if (isset($formData['heihelist'])) $pdf->drawHeihe();
|
||||
$pdf->addRef($rows);
|
||||
$pdf->addSecurity($this->view->config->offline->security);
|
||||
$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=?,project_type=?,project_id=?,project_title=? where id=?";
|
||||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn,$formData['project_type'],$formData['project_id'],$formData['project_title'],$row['id']));
|
||||
} else {
|
||||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist,pdflink,project_type,project_id,project_title) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn,$formData['project_type'],$formData['project_id'],$formData['project_title']));
|
||||
$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');
|
||||
$data = array(
|
||||
"user"=>$formData['realname'],
|
||||
"datalist"=>str_replace(";","\n",$datalist)
|
||||
);
|
||||
$mailtp=new EmailText($this->db,'offline-email',$data);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addTo($formData['email']);
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$attach=$mail->createAttachment($pdf->Output('applicant','S'));
|
||||
$attach->filename='数据申请-'.$formData['realname'].'.pdf';
|
||||
$mail->send();
|
||||
$this->_helper->viewRenderer('order');
|
||||
|
||||
//跳转到/data/order,并提示帮助信息,告知用户已经发送EMAIL
|
||||
$this->view->msg=view::Msg('alert-success',"提示信息:您的离线申请已经提交,系统已经发送一封邮件给您,请打印出申请表、签字后扫描为pdf并email给数据中心服务组(仍可以采用邮寄方式),具体信息请参考邮件说明。",0);
|
||||
if (empty($ac)) $ac='offline3';
|
||||
//$this->_redirect('/data/order');
|
||||
$formData['datalist'] = $datalist;
|
||||
|
||||
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(),project_type=?,project_id=?,project_title=? where id=?";
|
||||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$formData['project_type'],$formData['project_id'],$formData['project_title'],$row['id']));
|
||||
} else {
|
||||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist,project_type,project_id,project_title) values(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$formData['project_type'],$formData['project_id'],$formData['project_title']));
|
||||
}
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
//生成PDF
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join heihemetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from heihemetadata) and d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
|
||||
$pdf = new ApplicantPDF();
|
||||
$pdf->template=$this->view->config->offline->template;
|
||||
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
|
||||
$formData['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
|
||||
$pdf->data = $formData;
|
||||
if (isset($formData['westdclist'])) $pdf->drawWestdc();
|
||||
if (isset($formData['heihelist'])) $pdf->drawHeihe();
|
||||
$pdf->addRef($rows);
|
||||
$pdf->addSecurity($this->view->config->offline->security);
|
||||
header("Content-Disposition: inline; filename=westdc-data-apply.pdf");
|
||||
header("Content-Type:application/pdf");
|
||||
//header("Content-Length: " . strlen($pdfstring));
|
||||
echo $pdf->Output('westdc-data-apply.pdf','S');
|
||||
die();
|
||||
//exit;
|
||||
} elseif ($formData['submit']) {
|
||||
//提交
|
||||
//生成PDF
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join heihemetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
|
||||
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from heihemetadata) and d.status=2 and d.userid=?";
|
||||
$list=$this->db->fetchAll($sql,array($userid));
|
||||
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
|
||||
$pdf = new ApplicantPDF();
|
||||
$pdf->template=$this->view->config->offline->template;
|
||||
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
|
||||
$pdf->data = $formData;
|
||||
$pdf->data['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
|
||||
if (isset($formData['westdclist'])) $pdf->drawWestdc();
|
||||
if (isset($formData['heihelist'])) $pdf->drawHeihe();
|
||||
$pdf->addRef($rows);
|
||||
$pdf->addSecurity($this->view->config->offline->security);
|
||||
$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=?,project_type=?,project_id=?,project_title=? where id=?";
|
||||
$this->db->query($sql,array($formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn,$formData['project_type'],$formData['project_id'],$formData['project_title'],$row['id']));
|
||||
} else {
|
||||
$sql="insert into offlineapp (userid,username,email,phone,address,postcode,project,unit,datalist,pdflink,project_type,project_id,project_title) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
$this->db->query($sql,array($userid,$formData['realname'],$formData['email'],$formData['phone'],$formData['address'],$formData['postcode'],$formData['project'],$formData['unit'],$datalist,$fn,$formData['project_type'],$formData['project_id'],$formData['project_title']));
|
||||
$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');
|
||||
$data = array(
|
||||
"user"=>$formData['realname'],
|
||||
"datalist"=>str_replace(";","\n",$datalist)
|
||||
);
|
||||
$mailtp=new EmailText($this->db,'offline-email',$data);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addTo($formData['email']);
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$attach=$mail->createAttachment($pdf->Output('applicant','S'));
|
||||
$attach->filename='数据申请-'.$formData['realname'].'.pdf';
|
||||
$mail->send();
|
||||
$this->_helper->viewRenderer('order');
|
||||
|
||||
//跳转到/data/order,并提示帮助信息,告知用户已经发送EMAIL
|
||||
$this->view->msg=view::Msg('alert-success',"提示信息:您的离线申请已经提交,系统已经发送一封邮件给您,请打印出申请表、签字后扫描为pdf并email给数据中心服务组(仍可以采用邮寄方式),具体信息请参考邮件说明。",0);
|
||||
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=?";
|
||||
|
@ -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);
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
</div><!--/span-->
|
||||
<div class="span9">
|
||||
<h3>离线申请提交</h3>
|
||||
<h4>数据清单</h4>
|
||||
<h4>数据清单</h4>
|
||||
<blockquote>
|
||||
<ul class="unstyled">
|
||||
<?php foreach ($this->data2 as $i=>$md) : ?>
|
||||
<li><?php echo ($i+1).". ".$md['title']; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul></blockquote>
|
||||
<hr />
|
||||
<h4>申请表填写说明</h4>
|
||||
<hr />
|
||||
<h4>申请表填写说明</h4>
|
||||
<blockquote>
|
||||
<p class="text-info">其中用途部分,请填写您的详细使用目的;项目类型请从列表中选择,若无对应的项目支持,请选择其他项目工程;如项目无编号信息,则填写“无”;硕博论文请在用途中注明。</p>
|
||||
<p class="text-info">其中用途部分,请填写您的详细使用目的;项目类型请从列表中选择,若无对应的项目支持,请选择其他项目工程;如项目无编号信息,则填写“无”;硕博论文请在用途中注明。</p>
|
||||
<p class="text-success">详细准确的信息能使您更快通过申请。(数据提供者会根据您提供的信息来进行决策判断)</p></blockquote>
|
||||
<h4>申请表(请务必填写真实信息以便审核通过)</h4>
|
||||
<?php if ($this->messages): foreach($this->messages as $msg): ?>
|
||||
|
@ -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>
|
||||
</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