Skip to content

Commit

Permalink
psis develop ok
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqing committed Aug 22, 2013
1 parent 8930b3b commit 07560fe
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 23 deletions.
5 changes: 5 additions & 0 deletions application/controllers/manage/node.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function get_node_name_json()
echo $this->Node_model->get_node_name_json();
}

public function get_node_name_api()
{
echo $this->Node_model->get_node_name_api();
}

public function get_parent_node_by_json()
{
echo $this->Node_model->get_parent_node_by_json();
Expand Down
20 changes: 20 additions & 0 deletions application/controllers/manage/relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,24 @@ public function get_tuopu_server()
echo json_encode($this->Relationship_model->get_tuopu_server($real_id));
}

public function rec_check()
{
$group_id = $this->uri->segment(4);
if($this->Relationship_model->rec_check($group_id)){
echo 1;
}
}

public function get_group_api()
{
$group_name = $this->uri->segment(4);
echo json_encode($this->Relationship_model->get_group_api($group_name));
}

public function get_relationship_api()
{
$group_name = $this->uri->segment(4);

echo json_encode($this->Relationship_model->get_relationship_api($group_name));
}
}
10 changes: 10 additions & 0 deletions application/models/node_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public function get_node_name($node_id)
}
}

public function get_node_name_api()
{
$query = $this->db->get('node');
$node =array();
foreach($query->result() as $v){
array_push($node,$v->node_name);
}
return json_encode($node);
}

public function get_node_id($node_name)
{
$this->db->where('node_name',$node_name);
Expand Down
66 changes: 66 additions & 0 deletions application/models/relationship_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,73 @@ public function get_tuopu_server($real_id)
return $servers;
}

public function rec_check($group_id)
{
$this->db->where('group_id',$group_id);
$query = $this->db->get('relationship_real');
if($this->db->affected_rows() >= 1){
return true;
}

return false ;
}

public function get_group_desc_by_id($group_id)
{
$this->db->select('group_desc');
$this->db->where('group_id',$group_id);
$query = $this->db->get('relationship');
foreach ($query->result() as $v) {
return $v->group_desc;
}

}

public function get_group_api($group_name)
{
$this->db->select('group_name,group_desc');
$this->db->like('group_name',$group_name);
$query = $this->db->get('relationship');

return $query->result_array();
}

public function get_relationship_api($group_name)
{
$servers = array();
$fscs = array();
$fc = array();
$group_id = '';
$this->db->select('group_id');
$this->db->where('group_name',$group_name);
$q = $this->db->get('relationship');
foreach($q->result() as $v){
$group_id = $v->group_id;
}
$this->db->select('server_ids');
$this->db->where('group_id',$group_id);
$query = $this->db->get('relationship_real');
$tmp1 = array();
$tmp2 = array();
foreach($query->result() as $s )
{
foreach(explode(',',$s->server_ids) as $v){

if($this->Server_model->is_fscs($v)){

$tmp1['server_name'] = $this->Server_model->get_server_by_id($v);
array_push($fscs,$tmp1);
}else if($this->Server_model->is_fc($v)){
$tmp2['server_name'] = $this->Server_model->get_server_by_id($v);
array_push($fc,$tmp2);
}
}
}

$servers['fscs'] =$fscs;
$servers['fc'] = $fc ;
return $servers;
}


}
30 changes: 12 additions & 18 deletions application/views/manage/relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
e.preventDefault();
var server_ids = $('#liOptionms2side__dx').val();
var group_id = $("input[name='node_id']").val();

if(! group_id ){
alert('你要选择一个设备组,亲!');
return false;
Expand All @@ -118,24 +119,17 @@
alert('你得往里面加点设备,亲!');
return false;
}
var url = '<?php echo base_url('manage/relationship/rec_add')?>';
$.post(
url,
{server_ids:server_ids,group_id:group_id},
function(data){
if(data){
$.messager.show({
msg:'添加成功',
title:'成功'
});
}else{
$.messager.show({
msg:'添加失败',
title:'失败'
});
}
}
);
var check_url = '<?php echo base_url('manage/relationship/rec_check')?>'+'/'+group_id;
$.get(
check_url,
function(data){
if(data){
$.messager.alert('出错啦','所选的组已经存在','error');
return false;
}
}
);

})
);
</script>
Expand Down
12 changes: 7 additions & 5 deletions application/views/manage/relationship_list_1.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
</ul>
</div>

<div class="span8">
<table class="table table-striped table-hover table-bordered">
<div class="span9">
<table class="table table-striped table-hover table-bordered" style="width: 100%;">
<thead>

<tr>
<th>关系id</th>
<th>关系组称</th>
<th>关系组名称</th>
<th>关系组描述</th>
<th>成员</th>
<th>操作</th>
</tr>
Expand All @@ -26,10 +27,11 @@
<tr>
<td><?php echo $item->real_id; ?></td>
<td><?php echo $this->Relationship_model->get_group_by_id($item->group_id); ?></td>
<td><?php echo $this->Relationship_model->get_group_desc_by_id($item->group_id); ?></td>
<td><?php $i = 0; foreach(explode(',',$item->server_ids) as $id ){
echo $this->Server_model->get_server_by_id($id)." ";
$i++ ;
if($i >3 ){
if($i >1 ){
echo ".....";
break;
}
Expand Down Expand Up @@ -84,7 +86,7 @@

</div>

</script>

<div id="groupShow" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
Expand Down

0 comments on commit 07560fe

Please sign in to comment.