添加wsn数据选择弹窗控件和数据服务选择功能

This commit is contained in:
Li Jianxuan 2013-07-25 09:13:57 +00:00
parent eac0d60036
commit 53c820faa0
6 changed files with 201 additions and 7 deletions

View File

@ -668,6 +668,9 @@ class DataController extends Zend_Controller_Action
$fund = new Fund($this->db); $fund = new Fund($this->db);
$this->view->fund = $fund->fetch($uuid); $this->view->fund = $fund->fetch($uuid);
//判断特殊数据服务
$this->view->dataService= $this->checkDataService($uuid);
//自动跳转 //自动跳转
$sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?"; $sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?";
$row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid)); $row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
@ -679,6 +682,47 @@ class DataController extends Zend_Controller_Action
} }
} //viewAction } //viewAction
//检查特殊数据服务是否存在
private function checkDataService($uuid)
{
$order = new \order\mount\OrderOperate();
$service = $order->getDataService($uuid);
if(empty($service))
{
return NULL;
}else{
if($order->checkOrderHas($uuid))
{
return NULL;
}else{
return $service;
}
}
}//checkDataService
//特殊数据服务
public function dataserviceAction()
{
$uuid = $this->_getParam('uuid');
if(empty($uuid))
{
$this->jsonexit(array("error"=>"参数错误"));
}
$dataservice = new \data\DataService();
$info = $dataservice->get($uuid);
//暂时只有wsn
$data = array(
"type"=>"wsn", //服务类型
"info"=>$info, //信息 dataservice 表中的字段
"callback"=>"" //成功后的js回调函数
);
}
/* /*
getversionAction() 获取数据版本 getversionAction() 获取数据版本
*/ */

View File

@ -336,7 +336,11 @@ endforeach;
在线下载 在线下载
</a> </a>
<?php else: ?> <?php else: ?>
<?php if(!empty($this->dataService)) { ?>
<a href="javascript:void(0);" class="btn btn-primary btn-large btn-block" title="此数据需要选择要下载的子集" onclick="westdc.dataservice.choiceData('<?= $md->uuid ?>');">
<?php }else{ ?>
<a href="/data/order/uuid/<?php echo $md->uuid; ?>" class="btn btn-primary btn-large btn-block" title="免费!离线申请此数据(在线数据和离线数据都可申请)"> <a href="/data/order/uuid/<?php echo $md->uuid; ?>" class="btn btn-primary btn-large btn-block" title="免费!离线申请此数据(在线数据和离线数据都可申请)">
<?php } ?>
放入数据篮 放入数据篮
</a> </a>
<?php endif;endif; ?> <?php endif;endif; ?>

View File

@ -11,6 +11,9 @@
$this->headLink()->appendStylesheet('/css/water.css'); $this->headLink()->appendStylesheet('/css/water.css');
$this->theme->AppendPlus($this,'google_map_v3'); $this->theme->AppendPlus($this,'google_map_v3');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
if(!empty($this->dataService)) {
$this->theme->AppendModel($this,"dataservice");
}
?> ?>
<?= $this->render('breadcrumbs.phtml') ?> <?= $this->render('breadcrumbs.phtml') ?>
<style> <style>
@ -360,10 +363,18 @@ endforeach;
在线下载 在线下载
</a> </a>
<?php else: ?> <?php else: ?>
<?php
if(!empty($this->dataService)) { ?>
<a href="javascript:void(0);" class="btn btn-primary btn-large btn-block" title="此数据需要选择要下载的子集" onclick="westdc.dataservice.choiceData('<?= $md->uuid ?>');">
<?php }else{ ?>
<a href="/data/order/uuid/<?php echo $md->uuid; ?>" class="btn btn-primary btn-large btn-block" title="免费!离线申请此数据(在线数据和离线数据都可申请)"> <a href="/data/order/uuid/<?php echo $md->uuid; ?>" class="btn btn-primary btn-large btn-block" title="免费!离线申请此数据(在线数据和离线数据都可申请)">
<?php } ?>
放入数据篮 放入数据篮
</a> </a>
<?php endif;endif; ?> <?php endif;endif; ?>
<a href="javascript:void(0);" onclick="method.like('<?php echo $md->uuid; ?>',this)" class="btn btn-block" title="喜欢此数据可以将它放到收藏夹中下次浏览">
收藏此数据
</a>
</div> </div>
</div> </div>

View File

@ -0,0 +1,35 @@
<?php
namespace data;
class DataService
{
private $db; //传入PDO对象.
//使用到的公共变量
public $tbl_dataservice = "dataservice";
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
function Fetch()
{
$sql = "SELECT * FROM ".$this->tbl_dataservice."";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
function get($uuid)
{
$sql = "SELECT * FROM ".$this->tbl_dataservice." WHERE uuid='$uuid' LIMIT 1 START 0";
$rs = $this->db->query($sql);
return $rs->fetch();
}
}

View File

@ -77,7 +77,7 @@ class OrderOperate implements \order\listener\OrderEvents
} }
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=$uid and uuid=? and status in (1,2,3,4)"; $sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=$uid and uuid=? and status in (1,2,3,4)";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid)); $rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid),\PDO::FETCH_BOTH);
if($rs['datacount']>=1) if($rs['datacount']>=1)
{ {
@ -128,7 +128,7 @@ class OrderOperate implements \order\listener\OrderEvents
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch(\PDO::FETCH_BOTH);
if(isset($row['uuid']) && !empty($row['uuid'])) if(isset($row['uuid']) && !empty($row['uuid']))
{ {

View File

@ -0,0 +1,100 @@
var dataservice = {
//wsn 选择数据
choiceData : function(uuid)
{
this.uuid = uuid;
$.ajax({
'type':"POST",
'url':'/data/dataservice',
'data':'uuid=' + this.uuid,
'success':function(data){
if(typeof(data) == 'undefined')
{
alert("数据源错误,请联系管理员");
return false;
}
if(!$.isEmptyObject(data.error))
{
alert(data.error);
return false;
}
if(data.type == "wsn")
{
html = dataservice.wsn.dialog.site(data);
methods.creatWindow(id,html);
}
},
'timeout': 30000,
'error': function(){
alert('出现错误,请刷新后重试');
}
});
},
creatWindow : function(html){
$.colorbox({
initialHeight: '0',
initialWidth: '0',
html: html,
opacity: '0.3',
onComplete: function(){
$('.confirm_yes').click(function(e){
e.preventDefault();
});
$('.confirm_no').click(function(e){
e.preventDefault();
$.colorbox.close();
});
}
});
}
}
dataservice.wsn = {
request : function()
{
$.ajax({
'type':"POST",
'url':'/data/wsn/',
'data':$('#wsn-form').serialize(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{alert(data.error);}
if(typeof(data.success)!='undefined')
{
window.location.reload();
}
}
else{
alert('出现错误,请稍候再试');
}
},
'timeout': 30000,
'error': function(){
alert('出现错误,请刷新后重试');
}
});
},
dialog : {
site : function(data){
this.HTML = '<div class=""><div class="modal-header"><h3>选择观测点</h3></div>'
+ '<div class="modal-body"><form id="wsn-form">'
+ '<div></div>'
+ '<input type="hidden" name="uuid" value="'+data.uuid+'" />'
+ '</form></div>'
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>下一步</a>'
+ '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
return this.HTML;
},
var : function(data){
}
}
}