westdc-zf1/application/admin/views/scripts/data/visual-add.phtml

106 lines
4.6 KiB
PHTML

<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('同步GEONETWORK元数据</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div class="row">
<div class="span3">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span9">
<h3>添加可视化要素</h3>
<hr />
<?php if(!empty($this->error)) {?>
<div class="alert alert-error">
<?= $this->error ?>
</div>
<?php }?>
<form class="form-horizontal" method="post" action="">
<div class="control-group">
<label class="control-label" for="inputUUID">UUID</label>
<div class="controls">
<input type="text" id="inputUUID" placeholder="UUID" value="<?= $this->data['uuid'] ?>" class="input-block-level" name="uuid">
</div>
</div>
<div class="control-group">
<label class="control-label">状态</label>
<div class="controls">
<label class="radio inline">
<?php $checked = function(){
if(isset($this->info['status']))
{
if($this->info['status'] == 1)
{
return 'checked="checked"';
}
}else{
return 'checked="checked"';
}
}; ?>
<input type="radio" name="status" id="optionsRadios1" value="1" <?= $checked() ?>>
启用
</label>
<label class="radio inline">
<input type="radio" name="status" id="optionsRadios2" value="0"
<?= isset($this->info['status']) && $this->info['status'] == 0 ? 'checked="checked"':"" ?>>
禁用
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputData">数据读取SQL或表名</label>
<div class="controls">
<textarea name="data" rows="4" class="input-block-level" id="inputData"><?= !isset($this->info['data']) ? "":$this->info['data']?></textarea>
</div>
</div>
<?php if(empty($this->info['vars'])) { ?>
<div class="control-group">
<label class="control-label" for="inputVariable">可视化要素</label>
<div class="controls">
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]">
</div>
</div>
<?php }else{ ?>
<?php $vars = array() ?>
<?php $encoder = new \Westdc\Visual\VariableEncoder; ?>
<?php $vars = $encoder->decode($this->info['vars']);?>
<?php foreach($vars as $k=>$v) { ?>
<div class="control-group">
<label class="control-label" for="inputVariable">可视化要素 <small><a href="javascript:void(0);" onclick="delVar(this)">删除</a></small></label>
<div class="controls">
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]" value="<?= $v ?>">
</div>
</div>
<?php } ?>
<?php } ?>
<div class="control-group" id="last-control-group">
<div class="controls">
<input type="hidden" name="submit" value="1" />
<button type="button" class="btn btn-defualt" id="addVariable">添加要素</button>
<button type="submit" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
</div>
<script type="text/javascript">
$('#addVariable').click(function(e) {
html = '<div class="control-group">'
+ '<label class="control-label" for="inputVariable">可视化要素 <small><a href="javascript:void(0);" onclick="delVar(this)">删除</a></small></label>'
+ '<div class="controls">'
+ '<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]">'
+ '</div>'
+'</div>';
$('#last-control-group').prepend(html);
});
function delVar(dom){
$(dom).parent().parent().parent('.control-group').remove();
}
</script>