更新数据的PDF生成功能,更改添加到数据篮的后台处理
This commit is contained in:
parent
7fe66c8b4b
commit
eac0d60036
|
@ -1461,6 +1461,7 @@ class DataController extends Zend_Controller_Action
|
|||
$cancel = $this->_request->getParam('cancel');
|
||||
$wsn = $this->_request->getParam('wsn');
|
||||
$pdf = $this->_request->getParam('pdf');
|
||||
$selections = $this->_request->getParam('data');
|
||||
|
||||
//if (empty($uuid)) $this->_redirect('/data');
|
||||
$userid = view::User('id');
|
||||
|
@ -1481,9 +1482,10 @@ class DataController extends Zend_Controller_Action
|
|||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
}else{
|
||||
if($state['datetype'] == "wsn")
|
||||
$service_type = $order->serviceTypeTest($state['service_type']);
|
||||
if($service_type !== false)
|
||||
{
|
||||
\view::Post($this,"此数据提供下载选择功能,请等待页面跳转至数据选择页面","/data/order/wsn/$uuid");
|
||||
\view::Post($this,$service_type,$state['service_url']."?href=".urlencode(\view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid);
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-error',"无法申请:此元数据的数据类型未知");
|
||||
}
|
||||
|
@ -1496,6 +1498,28 @@ class DataController extends Zend_Controller_Action
|
|||
|
||||
}
|
||||
|
||||
elseif ($selections)
|
||||
{
|
||||
if(empty($uuid))
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',"无法申请:参数出错,请通过正确的途径访问");
|
||||
}
|
||||
|
||||
$order = new order\Order();
|
||||
$orderListener = new order\listener\OrderListener();
|
||||
@$order->events()->attachAggregate($orderListener);
|
||||
$state = $order->addOrder($uuid,$selections);
|
||||
|
||||
if($state !== true)
|
||||
{
|
||||
$this->view->msg = \view::Msg('alert-error',$state);
|
||||
}else{
|
||||
$this->view->msg = \view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表");
|
||||
}
|
||||
|
||||
if (empty($ac)) $ac='offline1';
|
||||
}
|
||||
|
||||
//删除申请
|
||||
elseif ($del) {
|
||||
$order = new order\Order();
|
||||
|
@ -1581,14 +1605,6 @@ class DataController extends Zend_Controller_Action
|
|||
|
||||
$this->view->formData = $formData = $this->_request->getPost();
|
||||
|
||||
$s = $order->checkPdfOrderField($formData);
|
||||
|
||||
if($s !== true)
|
||||
{
|
||||
$this->view->error = \view::Msg('alert-error',$s);
|
||||
return true;
|
||||
}
|
||||
|
||||
$datalist='';
|
||||
foreach($rows as $i=>$row)
|
||||
{
|
||||
|
@ -1597,42 +1613,26 @@ class DataController extends Zend_Controller_Action
|
|||
$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']));
|
||||
|
||||
$orderListener = new order\listener\OrderListener();
|
||||
|
||||
@$order->events()->attachAggregate($orderListener);
|
||||
|
||||
$order->setPdfData($rows);
|
||||
|
||||
$s = $order->SaveOrder($formData);
|
||||
|
||||
if($s !== true)
|
||||
{
|
||||
$this->view->error = \view::Msg('alert-error',$s);
|
||||
return true;
|
||||
}
|
||||
|
||||
//不能修改顺序
|
||||
$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;
|
||||
|
||||
return true;
|
||||
} elseif ($formData['submit']) {
|
||||
//提交
|
||||
//生成PDF
|
||||
|
@ -1761,6 +1761,7 @@ class DataController extends Zend_Controller_Action
|
|||
@$this->view->dataorder2=$dataorder2;
|
||||
@$this->view->dataorder3=$dataorder3;*/
|
||||
}
|
||||
|
||||
/*
|
||||
* 查看数据缩略图
|
||||
*/
|
||||
|
|
|
@ -103,9 +103,7 @@
|
|||
<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>
|
||||
<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">
|
||||
|
|
|
@ -340,6 +340,9 @@ endforeach;
|
|||
放入数据篮
|
||||
</a>
|
||||
<?php endif;endif; ?>
|
||||
<a href="javascript:void(0);" class="btn btn-block" title="喜欢此数据可以将它放到收藏夹中下次浏览">
|
||||
收藏此数据
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
|
|
@ -19,7 +19,9 @@ class Order
|
|||
"国际合作项目"=>"国际合作项目",
|
||||
"省部级项目" => "省部级项目",
|
||||
"其他项目工程" => "其他项目工程",
|
||||
); //申请中的项目类型
|
||||
);//申请中的项目类型
|
||||
|
||||
public $pdfData;
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
|
@ -58,7 +60,7 @@ class Order
|
|||
**************/
|
||||
|
||||
//添加到数据篮
|
||||
public function addOrder($uuid,$uid = 0){
|
||||
public function addOrder($uuid,$selection = NULL,$uid = 0){
|
||||
|
||||
if(empty($uid))
|
||||
{
|
||||
|
@ -83,12 +85,13 @@ class Order
|
|||
return $data;
|
||||
}
|
||||
|
||||
if(empty($selection))
|
||||
{
|
||||
$results = $this->events()->trigger('checksource', $this, compact('uuid'));
|
||||
$data = $results->bottom();
|
||||
|
||||
if($data !== true)
|
||||
if(!empty($data))
|
||||
{
|
||||
return array("datetype"=>$data,"uuid"=>$uuid);
|
||||
return $data;
|
||||
}
|
||||
|
||||
if($this->pushToDataorder($uuid,$uid) === true)
|
||||
|
@ -97,19 +100,32 @@ class Order
|
|||
}else{
|
||||
return "操作中出现错误,请重试";
|
||||
}
|
||||
|
||||
}else{
|
||||
if($this->pushToDataorder($uuid,$uid) === true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return "操作中出现错误,请重试";
|
||||
}
|
||||
}
|
||||
}//addOrder
|
||||
|
||||
//放到数据篮中
|
||||
public function pushToDataorder($uuid,$uid = 0)
|
||||
public function pushToDataorder($uuid,$uid = 0,$selection = NULL)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
if(empty($selection))
|
||||
{
|
||||
$sql="insert into dataorder (uuid,ts_created,userid,status) values(?,now(),?,?)";
|
||||
$rs = $this->db->query($sql,array($uuid,$uid,1));
|
||||
}else{
|
||||
$sql="insert into dataorder (uuid,ts_created,userid,status,selection) values(?,now(),?,?,?)";
|
||||
$rs = $this->db->query($sql,array($uuid,$uid,1,$selection));
|
||||
}
|
||||
|
||||
if($rs)
|
||||
{
|
||||
|
@ -184,16 +200,89 @@ class Order
|
|||
return "参数错误";
|
||||
}
|
||||
|
||||
|
||||
//设置PDF上显示的内容 getOrderItemForPdf() 的返回结果
|
||||
public function setPdfData($data)
|
||||
{
|
||||
$this->pdfData = $data;
|
||||
}
|
||||
|
||||
//保存预览
|
||||
public function SaveOrder($formData,$uid = 0)
|
||||
{
|
||||
if(empty($uid) || !is_numeric($uid))
|
||||
{
|
||||
$uid = \view::User('id');
|
||||
}
|
||||
|
||||
$results = $this->events()->trigger('order.formcheck', $this, compact('formData'));
|
||||
$data = $results->bottom();
|
||||
|
||||
if($data !== true)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
$results = $this->events()->trigger('order.onUpdate', $this, compact('formData','uid'));
|
||||
$data = $results->bottom();
|
||||
|
||||
if($data !== true)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
$this->pdfPrint($formData,$uid);
|
||||
|
||||
return true;
|
||||
|
||||
}//SaveOrder
|
||||
|
||||
//发送邮件
|
||||
public function SendEmail(){
|
||||
public function SendOrderEmail(){
|
||||
|
||||
}
|
||||
|
||||
//生成pdf
|
||||
public function pdf($uid = 0)
|
||||
public function pdfPrint($formData,$userid = 0)
|
||||
{
|
||||
$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->config->offline->template;
|
||||
|
||||
$pdf->heihetemplate = $this->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($this->pdfData);
|
||||
|
||||
$pdf->addSecurity($this->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');
|
||||
}
|
||||
|
||||
//获得要生成pdf的信息
|
||||
|
@ -220,74 +309,39 @@ class Order
|
|||
return $rows;
|
||||
}
|
||||
|
||||
public function makePdf($formData,$userid = 0)
|
||||
//service_type 选择
|
||||
public function serviceTypeTest($type)
|
||||
{
|
||||
|
||||
if(empty($type) || !is_numeric($type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function PdfOrderSave($formData,$uid = 0)
|
||||
switch($type)
|
||||
{
|
||||
|
||||
case 0:
|
||||
return "此数据为在线查看数据";
|
||||
break;
|
||||
case 1:
|
||||
return "此数据有可以选择的子集";
|
||||
break;
|
||||
case 2:
|
||||
return "此数据有多个子集供选择";
|
||||
break;
|
||||
case 3:
|
||||
return "";
|
||||
break;
|
||||
case 4:
|
||||
return "";
|
||||
break;
|
||||
case 5:
|
||||
return "";
|
||||
break;
|
||||
case 6:
|
||||
return "";
|
||||
break;
|
||||
}
|
||||
|
||||
//checkPdfOrderField 检查PDF申请表的信息
|
||||
public function checkPdfOrderField($formData)
|
||||
{
|
||||
if(empty($formData['realname']))
|
||||
{
|
||||
return "请输入真实姓名";
|
||||
}
|
||||
|
||||
if(empty($formData['email']))
|
||||
{
|
||||
return "请输入Email";
|
||||
}
|
||||
|
||||
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$formData['email']))
|
||||
{
|
||||
return "请输入正确的电子邮件地址";
|
||||
}
|
||||
|
||||
if(empty($formData['phone']))
|
||||
{
|
||||
return "请输入联系电话";
|
||||
}
|
||||
|
||||
if(empty($formData['unit']))
|
||||
{
|
||||
return "请输入单位";
|
||||
}
|
||||
|
||||
if(empty($formData['address']))
|
||||
{
|
||||
return "请输入地址";
|
||||
}
|
||||
|
||||
if(empty($formData['postcode']) || !is_numeric($formData['postcode']))
|
||||
{
|
||||
return "请输入邮政编码";
|
||||
}
|
||||
|
||||
if(empty($formData['project_id']))
|
||||
{
|
||||
return "请输入项目编号";
|
||||
}
|
||||
|
||||
if(empty($formData['project_type']))
|
||||
{
|
||||
return "请选择项目类型";
|
||||
}
|
||||
|
||||
if(empty($formData['project_title']))
|
||||
{
|
||||
return "请填写项目标题";
|
||||
}
|
||||
|
||||
if(empty($formData['project']))
|
||||
{
|
||||
return "请填写用途";
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkPdfOrderField
|
||||
return false;
|
||||
}//serviceTypeTest
|
||||
}
|
|
@ -20,6 +20,7 @@ class OrderListener implements \Zend_EventManager_ListenerAggregate
|
|||
public function attach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$this->attachOnOrder($events);
|
||||
$this->attachOnPdf($events);
|
||||
}
|
||||
|
||||
public function detach(\Zend_EventManager_EventCollection $events)
|
||||
|
@ -34,4 +35,13 @@ class OrderListener implements \Zend_EventManager_ListenerAggregate
|
|||
$events->attach('checksource',array($mountedClass,'checksource'),100);
|
||||
}
|
||||
|
||||
public function attachOnPdf(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$PdfFormClass = new \order\mount\PdfForm();
|
||||
$events->attach('order.formcheck', array($PdfFormClass, 'checkPdfOrderField'), 100);
|
||||
|
||||
$PdfClass = new \order\mount\PdfOperate();
|
||||
$events->attach('order.onUpdate', array($PdfClass, 'updateUserInfo'), 100);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace order\listener;
|
||||
//接口 ,需要实现的Listener中的方法
|
||||
interface PdfEvents
|
||||
{
|
||||
//检查该填写的字段
|
||||
public function updateUserInfo(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace order\listener;
|
||||
//接口 ,需要实现的Listener中的方法
|
||||
interface PdfFormEvents
|
||||
{
|
||||
//检查该填写的字段
|
||||
public function checkPdfOrderField(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -117,7 +117,14 @@ class OrderOperate implements \order\listener\OrderEvents
|
|||
{
|
||||
$uuid = $e->getParam('uuid');
|
||||
|
||||
$sql = "SELECT * FROM wsn_metadata WHERE uuid='$uuid'";
|
||||
return $this->getDataService($uuid);
|
||||
|
||||
}
|
||||
|
||||
//获得数据服务类型
|
||||
public function getDataService($uuid){
|
||||
|
||||
$sql = "SELECT * FROM dataservice WHERE uuid='$uuid'";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
|
||||
|
@ -125,10 +132,11 @@ class OrderOperate implements \order\listener\OrderEvents
|
|||
|
||||
if(isset($row['uuid']) && !empty($row['uuid']))
|
||||
{
|
||||
return "wsn";
|
||||
return $row;
|
||||
}else{
|
||||
return true;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
namespace order\mount;
|
||||
include_once("helper/view.php");
|
||||
|
||||
//事件中存在的操作
|
||||
class PdfForm implements \order\listener\PdfFormEvents
|
||||
{
|
||||
private $db;
|
||||
private $config;
|
||||
|
||||
//!!!!!!important!!!!!
|
||||
//不同项目使用时是否要修改此项??
|
||||
public $tbl_metadata = "heihemetadata";
|
||||
public $tbl_dataorder = "dataorder";
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
//提交申请
|
||||
public function submit(\Zend_EventManager_Event $e)
|
||||
{
|
||||
$uuid = $e->getParam('uuid');
|
||||
$uid = $e->getParam('uid');
|
||||
|
||||
try{
|
||||
if($this->checkOrderUUID($uuid) !== false)
|
||||
{
|
||||
return "此数据尚未正式发布,还不能申请";
|
||||
}
|
||||
|
||||
if($this->checkOrderNum(true,$uid) === false)
|
||||
{
|
||||
return "您的数据篮中存放的数据已达到可申请的数量";
|
||||
}
|
||||
|
||||
if($this->checkOrderHas($uuid,$uid))
|
||||
{
|
||||
return "此数据已经在数据篮中";
|
||||
}
|
||||
}catch(Exception $e)
|
||||
{
|
||||
\view::Dump($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//checkPdfOrderField 检查PDF申请表的信息
|
||||
public function checkPdfOrderField(\Zend_EventManager_Event $e)
|
||||
{
|
||||
$formData = $e->getParam('formData');
|
||||
|
||||
if(empty($formData['realname']))
|
||||
{
|
||||
return "请输入真实姓名";
|
||||
}
|
||||
|
||||
if(empty($formData['email']))
|
||||
{
|
||||
return "请输入Email";
|
||||
}
|
||||
|
||||
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$formData['email']))
|
||||
{
|
||||
return "请输入正确的电子邮件地址";
|
||||
}
|
||||
|
||||
if(empty($formData['phone']))
|
||||
{
|
||||
return "请输入联系电话";
|
||||
}
|
||||
|
||||
if(empty($formData['unit']))
|
||||
{
|
||||
return "请输入单位";
|
||||
}
|
||||
|
||||
if(empty($formData['address']))
|
||||
{
|
||||
return "请输入地址";
|
||||
}
|
||||
|
||||
if(empty($formData['postcode']) || !is_numeric($formData['postcode']))
|
||||
{
|
||||
return "请输入邮政编码";
|
||||
}
|
||||
|
||||
if(empty($formData['project_id']))
|
||||
{
|
||||
return "请输入项目编号";
|
||||
}
|
||||
|
||||
if(empty($formData['project_type']))
|
||||
{
|
||||
return "请选择项目类型";
|
||||
}
|
||||
|
||||
if(empty($formData['project_title']))
|
||||
{
|
||||
return "请填写项目标题";
|
||||
}
|
||||
|
||||
if(empty($formData['project']))
|
||||
{
|
||||
return "请填写用途";
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkPdfOrderField
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
namespace order\mount;
|
||||
include_once("helper/view.php");
|
||||
|
||||
//事件中存在的操作
|
||||
class PdfOperate implements \order\listener\PdfEvents
|
||||
{
|
||||
private $db;
|
||||
private $config;
|
||||
|
||||
//!!!!!!important!!!!!
|
||||
//不同项目使用时是否要修改此项??
|
||||
public $tbl_metadata = "heihemetadata";
|
||||
public $tbl_dataorder = "dataorder";
|
||||
public $tbl_offlineapp = "offlineapp";
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
//提交申请
|
||||
public function updateUserInfo(\Zend_EventManager_Event $e)
|
||||
{
|
||||
//根据pdflink字段,以判断是否已经提交
|
||||
//在数据库中创建rules,在更新offlineapp表时同时更新users表中对应的信息
|
||||
$formData = $e->getParam('formData');
|
||||
$uid = $e->getParam('uid');
|
||||
|
||||
try{
|
||||
|
||||
$sql="SELECT id FROM ".$this->tbl_offlineapp."
|
||||
WHERE userid=? AND (pdflink IS null OR pdflink='') AND (ts_approved IS null)";
|
||||
$row = $this->db->fetchRow($sql,array($uid));
|
||||
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new \dbh($this->db);
|
||||
$formData['username'] = $formData['realname'];
|
||||
unset($formData['realname']);
|
||||
unset($formData['save']);
|
||||
if ($row) {
|
||||
$s = $dbh->update($this->tbl_offlineapp,$formData," id={$row['id']} ");
|
||||
return $s;
|
||||
} else {
|
||||
$s = $dbh->insert($this->tbl_offlineapp,$formData);
|
||||
return $s;
|
||||
}
|
||||
|
||||
}catch(Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue