Skip to content

Commit

Permalink
Merge pull request #56 from lqmcn/master
Browse files Browse the repository at this point in the history
优化
  • Loading branch information
jiangbianwanghai committed May 20, 2016
2 parents c229f18 + 1d2b541 commit d45c37f
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 48 deletions.
47 changes: 47 additions & 0 deletions application/controllers/bug.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,21 @@ public function coment_add_ajax() {
}
$this->load->helper('friendlydate');
if ($feedback['status']) {
if ($row['add_user'] == $this->input->cookie('uids')) {
$role = 'BUG反馈人';
} elseif (
$row['accept_user'] == $this->input->cookie('uids')) {
$role = 'BUG受理人';
} else {
$role = '路人甲';
}
$callBack = array(
'status' => true,
'message' => array(
'content'=>html_entity_decode($this->input->post('content')),
'username'=>$users[$this->input->cookie('uids')]['username'],
'realname'=>$users[$this->input->cookie('uids')]['realname'],
'role' => $role,
'addtime' => friendlydate(time())
)
);
Expand Down Expand Up @@ -447,6 +456,44 @@ public function del() {
echo json_encode($callBack);
}

public function close() {
$bugId = $this->uri->segment(3, 0);
$this->load->model('Model_bug', 'bug', TRUE);
$flag = $this->bug->close($bugId);
if ($flag) {
$callBack = array(
'status' => true,
'message' => '关闭成功'
);
} else {
$callBack = array(
'status' => false,
'message' => '关闭失败'
);
}

echo json_encode($callBack);
}

public function open() {
$bugId = $this->uri->segment(3, 0);
$this->load->model('Model_bug', 'bug', TRUE);
$flag = $this->bug->open($bugId);
if ($flag) {
$callBack = array(
'status' => true,
'message' => '操作成功'
);
} else {
$callBack = array(
'status' => false,
'message' => '操作失败'
);
}

echo json_encode($callBack);
}

public function star_ajax() {
$bugId = $this->uri->segment(3, 0);
$this->load->model('Model_bug', 'bug', TRUE);
Expand Down
15 changes: 15 additions & 0 deletions application/controllers/issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,21 @@ public function change_flow() {
exit();
}*/

//验证是否还存在激活的BUG
if ($flow == 'wait') {
$this->load->model('Model_bug', 'bug', TRUE);
$bugAct = $this->bug->getBugAct($id);
if ($bugAct) {
$callBack = array(
'status' => false,
'message' => '还有正常开启的BUG需要解决',
'url' => '/issue/view/'.$row['id']
);
echo json_encode($callBack);
exit();
}
}

//更改工作流
$user = $this->input->cookie('uids');
if ($flow == 'fixed') {
Expand Down
24 changes: 21 additions & 3 deletions application/models/model_bug.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function add($data) {

public function listByIssueId($id) {
$rows = array('total' => 0, 'data' => false);
$this->db->select('id, subject, state, level, add_user, add_time, accept_user, accept_time');
$this->db->select('id, subject, state, level, add_user, add_time, accept_user, accept_time,status');
$this->db->where('issue_id', $id);
$db = clone($this->db);
$rows['total'] = $this->db->count_all_results($this->_table);
Expand Down Expand Up @@ -108,11 +108,19 @@ public function checkin($id, $level) {
}

public function checkout($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'state' => '-1', 'check_time' => time()), array('id' => $id));
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'state' => '-1', 'check_time' => time(), 'status' => '0'), array('id' => $id));
}

public function close($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'check_time' => time(), 'status' => '0'), array('id' => $id));
}

public function open($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'check_time' => time(), 'status' => '1', 'state' => '0'), array('id' => $id));
}

public function over($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'state' => '3'), array('id' => $id));
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'state' => '3', 'status' => '0'), array('id' => $id));
}

public function starList($projectId = 0, $limit = 20, $offset = 0) {
Expand Down Expand Up @@ -159,4 +167,14 @@ public function starByBugId($array) {
$row = $query->result_array();
return $row;
}

public function getBugAct($id) {
$row = array();
$this->db->select('id');
$this->db->where('issue_id', $id);
$this->db->where('status', 1);
$query = $this->db->get($this->_table);
$row = $query->result_array();
return $row;
}
}
4 changes: 4 additions & 0 deletions application/models/model_bugcomment.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ public function rows($bugId, $limit = 100, $offset = 0) {
public function del($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'status' => '-1'), array('id' => $id));
}

public function delByBug($id) {
return $this->db->update($this->_table, array('last_time' => time(), 'last_user' => $this->input->cookie('uids'), 'status' => '-1'), array('bug_id' => $id));
}
}
2 changes: 1 addition & 1 deletion application/models/model_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function listByIssueId($id) {
$db = clone($this->db);
$rows['total'] = $this->db->count_all_results($this->_table);
$this->db = $db;
$this->db->order_by('repos_id', 'desc');
$this->db->order_by('repos_id,id', 'desc');
$query = $this->db->get($this->_table);
$rows['data'] = $query->result_array();
return $rows;
Expand Down
4 changes: 2 additions & 2 deletions application/views/bug_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

<h5 class="subtitle">快捷方式</h5>
<ul class="nav nav-pills nav-stacked nav-email mb20">
<li><a href="/bug/index/to_me"><i class="glyphicon glyphicon-folder-open"></i> 我负责的</a></li>
<li><a href="/bug/index/from_me"><i class="glyphicon glyphicon-folder-open"></i> 我创建的</a></li>
<li><a href="/bug/index/to_me"><i class="glyphicon glyphicon-folder-close"></i> 我负责的</a></li>
<li><a href="/bug/index/from_me"><i class="glyphicon glyphicon-folder-close"></i> 我创建的</a></li>
</ul>
</div><!-- col-sm-3 -->
<div class="col-sm-9 col-lg-10">
Expand Down
17 changes: 11 additions & 6 deletions application/views/bug_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@
<div class="face"><img alt="" src="/static/avatar/<?php echo $users[$value['accept_user']]['username']?>.jpg" align="absmiddle" title="处理人:<?php echo $users[$value['accept_user']]['realname'];?>"></div>
</a>
</td>
<td width="50px">
<?php
if ($value['status'] == 1) {
echo '<span class="label label-info">开启</span>';
} elseif ($value['status'] == 0) {
echo '<span class="label label-default">关闭</span>';
}elseif ($value['status'] == '-1') {
echo '<span class="label label-default">删除</span>';
}
?>
</td>
<td width="70px">
<?php if ($value['status'] == 1) {?>
<?php if ($value['state'] === '-1') {?>
<span class="label label-default">无效反馈</span>
<?php } ?>
Expand All @@ -119,11 +129,6 @@
<?php if ($value['state'] === '3') {?>
<span class="label label-success">已处理</span>
<?php } ?>
<?php } elseif ($value['status'] == 0) {?>
<span class="label label-default">已关闭</span>
<?php } elseif ($value['status'] == -1) {?>
<span class="label label-default">已删除</span>
<?php } ?>
</td>
<td>
<?php if ($value['level']) {?><?php echo "<strong style='color:#ff0000;' title='".$level[$value['level']]['alt']."'>".$level[$value['level']]['name']."</strong> ";?><?php } ?> <a href="/bug/view/<?php echo $value['id'];?>"><?php echo $value['subject'];?></a> <span class="badge"><?php echo $users[$value['add_user']]['realname'];?></span>
Expand Down
Loading

0 comments on commit d45c37f

Please sign in to comment.