diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 2c5a5d6d..b02606cd 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -1,4 +1,9 @@ _getParam('uuid'); if(empty($uuid)) @@ -717,6 +723,9 @@ class DataController extends Zend_Controller_Action //暂时只有wsn { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $data = array( "type"=>"wsn", //服务类型 "info"=>$info, //信息 dataservice 表中的字段 @@ -728,11 +737,13 @@ class DataController extends Zend_Controller_Action if(empty($data['data'])) { $this->jsonexit(array("error"=>'数据接口错误,请联系管理员')); + return true; } if(!is_array($data['data'])) { $this->jsonexit(array("error"=>$data['data'])); + return true; } $this->_helper->layout->disableLayout(); @@ -748,35 +759,84 @@ class DataController extends Zend_Controller_Action { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - + + $type = $this->_getParam('type'); $uuid = $this->_getParam("uuid"); - $sites = array("chk"=>$this->_getParam("siteid")); - $dataservice = new \data\DataService(); - $info = $dataservice->get($uuid); + $dataservice = new DataService(); - $dataservice = new \data\DataService(); - - $data = array( - "type"=>"wsn", //服务类型 - "info"=>$info, //信息 dataservice 表中的字段 - "callback"=>"alert('ok')", //成功后的js回调函数 - ); - - $data['data'] = $dataservice->getWsnData("var",$uuid,$sites); - - if(empty($data['data'])) + if($type == 'var') { - $this->jsonexit(array("error"=>'数据接口错误,请联系管理员')); - } - - if(!is_array($data['data'])) - { - $this->jsonexit(array("error"=>$data['data'])); - } + $sites = array( + "chk"=>$this->_getParam("siteid") + ); - $this->jsonexit($data); - return true; + $info = $dataservice->get($uuid); + + $data = array( + "type"=>"wsn", //服务类型 + "info"=>$info, //信息 dataservice 表中的字段 + "callback"=>"westdc.dataservice.wsn.Submit()", //成功后的js回调函数 + ); + + $data['data'] = $dataservice->getWsnData("var",$uuid,$sites); + + if(empty($data['data'])) + { + $this->jsonexit(array("error"=>'数据接口错误,请联系管理员')); + return true; + } + + if(!is_array($data['data'])) + { + $this->jsonexit(array("error"=>$data['data'])); + return true; + } + + $this->jsonexit($data); + return true; + } + + if($type == "submit") + { + $info = $dataservice->get($uuid); + $param = array( + "site" => $this->_getParam("site"), + ); + + $data = array( + "type"=>"wsn", //服务类型 + "info"=>$info, //信息 dataservice 表中的字段 + "callback"=>"westdc.dataservice.wsn.Submited()", //成功后的js回调函数 + ); + + $data['data'] = $dataservice->getWsnData("submit",$uuid,$param); + + if(empty($data['data'])) + { + $this->jsonexit(array("error"=>'数据接口错误,请联系管理员')); + return true; + } + + if(!is_array($data['data'])) + { + $this->jsonexit(array("error"=>$data['data'])); + return true; + } + + $order = new Order(); + $orderListener = new OrderListener(); + @$order->events()->attachAggregate($orderListener); + $status = $order->addOrder($uuid,json_encode($data['data']['site'],JSON_NUMERIC_CHECK)); + if($status !== true) + { + $this->jsonexit(array("error"=>$status)); + return true; + } + + $this->jsonexit($data); + return true; + } } @@ -1553,7 +1613,6 @@ class DataController extends Zend_Controller_Action { $this->view->pageID = "account-dataorder"; $ac = $this->_request->getParam('ac'); - include_once("helper/view.php"); $uuid = $this->_request->getParam('uuid'); @@ -1573,8 +1632,8 @@ class DataController extends Zend_Controller_Action { //存在历史遗留问题,原来的数据并不能保证唯一 - $order = new order\Order(); - $orderListener = new order\listener\OrderListener(); + $order = new Order(); + $orderListener = new OrderListener(); @$order->events()->attachAggregate($orderListener); $state = $order->addOrder($uuid); @@ -1582,18 +1641,18 @@ class DataController extends Zend_Controller_Action { if(!is_array($state)) { - $this->view->msg = \view::Msg('alert-error',$state); + $this->view->msg = view::Msg('alert-error',$state); }else{ $service_type = $order->serviceTypeTest($state['service_type']); if($service_type !== false) { - \view::Post($this,$service_type,$state['service_url']."?href=".urlencode(\view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid); + 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',"无法申请:此元数据的数据类型未知"); + $this->view->msg = view::Msg('alert-error',"无法申请:此元数据的数据类型未知"); } } }else{ - $this->view->msg = \view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); + $this->view->msg = view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); } if (empty($ac)) $ac='offline1'; @@ -1604,19 +1663,19 @@ class DataController extends Zend_Controller_Action { if(empty($uuid)) { - $this->view->msg = \view::Msg('alert-error',"无法申请:参数出错,请通过正确的途径访问"); + $this->view->msg = view::Msg('alert-error',"无法申请:参数出错,请通过正确的途径访问"); } - $order = new order\Order(); - $orderListener = new order\listener\OrderListener(); + $order = new Order(); + $orderListener = new OrderListener(); @$order->events()->attachAggregate($orderListener); $state = $order->addOrder($uuid,$selections); if($state !== true) { - $this->view->msg = \view::Msg('alert-error',$state); + $this->view->msg = view::Msg('alert-error',$state); }else{ - $this->view->msg = \view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); + $this->view->msg = view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); } if (empty($ac)) $ac='offline1'; @@ -1624,13 +1683,13 @@ class DataController extends Zend_Controller_Action //删除申请 elseif ($del) { - $order = new order\Order(); + $order = new Order(); $state = $order->del($del); if($state !== true) { - $this->view->msg = \view::Msg('alert-error',$state); + $this->view->msg = view::Msg('alert-error',$state); }else{ - $this->view->msg = \view::Msg('alert-success',"数据申请取消成功"); + $this->view->msg = view::Msg('alert-success',"数据申请取消成功"); } $this->_redirect('/data/order'); } @@ -1641,13 +1700,13 @@ class DataController extends Zend_Controller_Action { $apply = -1; } - $order = new order\Order(); + $order = new Order(); $state = $order->apply($apply); if($state !== true) { - $this->view->msg = \view::Msg('alert-error',$state); + $this->view->msg = view::Msg('alert-error',$state); }else{ - $this->view->msg = \view::Msg('alert-success',"提交成功,您可以点击“提交离线申请”来生成PDF申请表"); + $this->view->msg = view::Msg('alert-success',"提交成功,您可以点击“提交离线申请”来生成PDF申请表"); } if (empty($ac)) $ac='offline2'; } @@ -1694,7 +1753,7 @@ class DataController extends Zend_Controller_Action //用户信息可以从SESSION中读取?离线申请信息 //$sql="select * from users where id=?"; - $order = new order\Order(); + $order = new Order(); $rows = $order->getOrderItemForPdf(); $this->view->projectType = $order->projectType; @@ -1716,7 +1775,7 @@ class DataController extends Zend_Controller_Action if (@$formData['save']) { - $orderListener = new order\listener\OrderListener(); + $orderListener = new OrderListener(); @$order->events()->attachAggregate($orderListener); @@ -1726,7 +1785,7 @@ class DataController extends Zend_Controller_Action if($s !== true) { - $this->view->error = \view::Msg('alert-error',$s); + $this->view->error = view::Msg('alert-error',$s); return true; } diff --git a/application/default/views/scripts/data/order-wsn.phtml b/application/default/views/scripts/data/order-wsn.phtml new file mode 100644 index 00000000..81d58662 --- /dev/null +++ b/application/default/views/scripts/data/order-wsn.phtml @@ -0,0 +1,33 @@ +headTitle($this->config->title->site); + $this->headTitle($this->config->title->data); + $this->headTitle('离线申请'); + $this->headTitle()->setSeparator(' - '); + $this->breadcrumb('首页'); + $this->breadcrumb(''.$this->config->title->data.''); + $this->breadcrumb('离线申请'); + $this->breadcrumb()->setSeparator(' > '); +$this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝'); +?> + = $this->render('breadcrumbs.phtml') ?> +
没有找到对应的元数据。
- \ No newline at end of file + \ No newline at end of file diff --git a/application/models/data/DataService.php b/application/models/data/DataService.php index 37ea50d5..108b1011 100644 --- a/application/models/data/DataService.php +++ b/application/models/data/DataService.php @@ -1,5 +1,9 @@ get($uuid); + + $info = $this->get($uuid); - $curl = new \helper\Curl(); + $curl = new Curl(); if($type == 'site') { $param = array( - //'uuid'=>$uuid, - 'uuid'=>'78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST - 'uid'=>\view::User('id') + 'uuid'=>$uuid, + //'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST + 'uid'=> view::User('id') ); $data = $curl->request($info['service_url']."site/",$param,"POST"); $data = json_decode($data['response'],TRUE); @@ -55,15 +57,27 @@ class DataService if($type == 'var') { $param_temp = array( - //'uuid'=>$uuid, - 'uuid'=>'78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST - 'uid'=>\view::User('id'), + 'uuid'=>$uuid, + //'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST + 'uid'=> view::User('id'), ); $param = array_merge($param,$param_temp); $data = $curl->request($info['service_url']."var/",$param,"POST"); $data = json_decode($data['response'],TRUE); } + if($type == 'submit') + { + $param_temp = array( + 'uuid'=>$uuid, + //'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST + 'uid'=> view::User('id'), + ); + $param = array_merge($param,$param_temp); + $data = $curl->request($info['service_url']."insert/",$param,"POST"); + $data = json_decode($data['response'],TRUE); + } + if($data['status'] == 0) { return $data['error']; diff --git a/htdocs/js/lib/custom/models/dataservice.js b/htdocs/js/lib/custom/models/dataservice.js index 6e64a602..675e5011 100644 --- a/htdocs/js/lib/custom/models/dataservice.js +++ b/htdocs/js/lib/custom/models/dataservice.js @@ -54,6 +54,7 @@ westdc.dataservice = { $.colorbox({ initialHeight: '0', initialWidth: '0', + maxWidth : '80%', html: html, opacity: '0.3', onComplete: function(){ @@ -91,6 +92,7 @@ westdc.dataservice.wsn = { html = westdc.dataservice.wsn.dialog.vars(data); westdc.dataservice.creatWindow(html); + westdc.dataservice.wsn._init.vars(); }, 'timeout': 30000, @@ -99,6 +101,45 @@ westdc.dataservice.wsn = { } }); }, + Submit : function(){ + $.ajax({ + 'type':"POST", + 'url':'/data/wsn/', + 'data':$('#dataservice-wsn-form').serialize(), + 'success':function(data){ + if(typeof(data) == 'undefined') + { + alert("数据源错误,请联系管理员"); + return false; + } + + if(!$.isEmptyObject(data.error)) + { + alert(data.error); + return false; + } + + if($.isEmptyObject(data.data)) + { + alert("提交失败,可能是服务器通信错误,请联系管理员"); + return false; + } + + if(data.data.success == 1) + { + window.location = '/data/order/ac/offline1'; + return true; + }else{ + alert('提交失败,请重试'); + return false; + } + }, + 'timeout': 30000, + 'error': function(){ + alert('出现错误,请刷新后重试'); + } + }); + }, dialog : { site : function(data){ this.input = new Array(); @@ -124,29 +165,67 @@ westdc.dataservice.wsn = { return this.HTML; }, vars : function(data){ - this.input = new Array(); + this.selects = ""; + + this.uls = new Array(); for(i in data.data) { - for(i in data.data) - this.li = '