Commit 5dbe497e authored by liyuanhong's avatar liyuanhong

second commit

parent 2fdfca3c
......@@ -22,7 +22,7 @@ class App extends BaseConfig
|
*/
// public $baseURL = 'http://localhost:8080/';
public $baseURL = 'http://10.16.4.205:8080/';
public $baseURL = 'http://10.16.9.166:8080/';
// public $baseURL = 'http://localhost/ci4/public/';
......
......@@ -120,4 +120,32 @@ class DevManage extends BaseController
return view('devManage/category_manage',$data);
}
/****************************************************
* 签借审核页面
/****************************************************/
public function borrowCheckPage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
$data["category"] = array();
$devManageModel = new \App\Models\DevManageModel();
$data["category"]["firstCategory"] = $devManageModel->getAllFirstCategory();
$data["category"]["secondCategory"] = $devManageModel->getSecondCategoryByFirstCategoryId();
return view('devManage/borrow_check',$data);
}
}
......@@ -409,5 +409,60 @@ class DevManageCtr extends BaseController
}
/////////////////////////////////////////////////// 设备签借区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 添加设备签借信息
/****************************************************/
function addDevBorrowInfo(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["dev_id"] = $param->devId;
$item["user_id"] = $param->userId;
$item["borrower"] = $param->borrower;
$item["comment"] = $param->comment;
$item["borrower_time"] = $curTime;
$item["borrow_status"] = 1; //1:表示申请签借中,还未通过审核
try{
$devManageModel = new \App\Models\DevManageModel();
$borrowInfo1 = $devManageModel->searchBorrowerInfoByDevid($item);
$borrowInfo2 = $devManageModel->searchBorrowInfoByBorrowerAndDevid($item);
if(count($borrowInfo1) == 0 || count($borrowInfo1) > 1){
if(count($borrowInfo2) == 0){
$devManageModel->insertBorrowInfo($item);
$result["status"] = SUCESS;
$result["message"] = "设备申请成功!";
}else{
$result["status"] = COMMON_FAIL;
$result["message"] = "你已经申请该设备!";
}
}else if($borrowInfo1[0]["borrow_status"] == 2){
$result["status"] = COMMON_FAIL;
$result["message"] = "该设备已经借出!";
}else{
if(count($borrowInfo2) == 0){
$devManageModel->insertBorrowInfo($item);
$result["status"] = SUCESS;
$result["message"] = "设备申请成功!";
}else{
$result["status"] = COMMON_FAIL;
$result["message"] = "你已经申请该设备!";
}
}
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
}
......@@ -51,15 +51,15 @@ class Home extends BaseController
$item["page"] = $page;
$item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($username == "" || $token == "" || $userInfo[0]["token"] == $token){
$data["userInfo"] = [];
}else{
$devManageModel = new \App\Models\DevManageModel();
$devices = $devManageModel->getDevicesAllInfoByPage($item);
$totalNums = $devManageModel->getTatalDeviceNum()[0]["total"];
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["devices"] = $devices;
$data["pageInfo"] = array();
......@@ -67,12 +67,9 @@ class Home extends BaseController
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
$data["notification"] = [];
$data["uri"] = getUriInfo($this->request);
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/show_devs',$data);
}
......@@ -86,26 +83,23 @@ class Home extends BaseController
$token = $this->request->getGet("token");
$devId = (int)$this->request->getGet("devId");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($username == "" || $token == "" || $userInfo[0]["token"] == $token){
$data["userInfo"] = [];
}else{
$devManageModel = new \App\Models\DevManageModel();
$devInfo = $devManageModel->getDeviceInfoById($devId);
$devImg = $devManageModel->getDevImgsById($devId);
if(count($devInfo) == 0){
$devInfo[0] = array();
}
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/show_dev_detail',$data);
......
......@@ -56,7 +56,7 @@ class UserManage extends BaseController
/****************************************************
* 展示权限页面
/****************************************************/
public function showRightsPage(){
public function showRolePage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
......@@ -77,6 +77,6 @@ class UserManage extends BaseController
}
}
$data["uri"] = getUriInfo($this->request);
return view('userManage/show_rights',$data);
return view('userManage/show_role',$data);
}
}
\ No newline at end of file
......@@ -137,10 +137,12 @@ class DevManageModel extends Model
public function getDevicesAllInfoByPage($data){
$sql = 'select t1.*,
t2.category_name,
t3.org_section_name
t3.org_section_name,
t4.id as borrow_id,t4.borrower,t4.user_id,t4.borrow_status
from devices t1
left join first_category t2 on t1.first_category_id = t2.id
left join org_section t3 on t1.org_section_id = t3.id limit '.(($data["page"] - 1) * $data["perPage"]).','.$data["perPage"];
left join org_section t3 on t1.org_section_id = t3.id
left join dev_borrow t4 on t1.borrow_id = t4.id limit '.(($data["page"] - 1) * $data["perPage"]).','.$data["perPage"];
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
......@@ -152,10 +154,12 @@ class DevManageModel extends Model
public function getDeviceInfoById($id){
$sql = 'select t1.*,
t2.category_name,
t3.org_section_name
t3.org_section_name,
t4.id as borrow_id,t4.borrower,t4.user_id,t4.borrow_status
from devices t1
left join first_category t2 on t1.first_category_id = t2.id
left join org_section t3 on t1.org_section_id = t3.id where t1.id='.$id;
left join org_section t3 on t1.org_section_id = t3.id
left join dev_borrow t4 on t1.borrow_id = t4.id where t1.id='.$id;
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
......@@ -229,4 +233,39 @@ class DevManageModel extends Model
$sql = "delete from dev_img where dev_id=".$data["dev_id"]." and id=".$data["img_id"];
$this->db->query($sql);
}
/////////////////////////////////////////////////// 设备签借区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 添加设备签借信息
/****************************************************/
public function insertBorrowInfo($data){
$sql = 'insert into dev_borrow (dev_id,user_id,borrower,comment,borrower_time,borrow_status) values ('
.$data["dev_id"].','
.$data["user_id"].',"'
.$data["borrower"].'","'
.$data["comment"].'","'
.$data["borrower_time"].'",'
.$data["borrow_status"].')';
$this->db->query($sql);
}
/****************************************************
* 根据用户名和设备id查询签借信息
/****************************************************/
public function searchBorrowInfoByBorrowerAndDevid($data){
$sql = 'select * from dev_borrow where borrower="'.$data["borrower"].'" and dev_id='.$data["dev_id"];
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 根据设备id查询签借信息
/****************************************************/
public function searchBorrowerInfoByDevid($data){
$sql = 'select * from dev_borrow where borrower="'.$data["borrower"].'" and dev_id='.$data["dev_id"];
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
}
\ No newline at end of file
......@@ -12,6 +12,9 @@
<li <?php if($data["uri"]["seg"][1] == "categoryManagePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_category_man">
<a><i class="icon-chevron-right"></i> 分类管理</a>
</li>
<li <?php if($data["uri"]["seg"][1] == "borrowCheckPage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_borrow_check">
<a><i class="icon-chevron-right"></i> 签借审核</a>
</li>
</ul>
</div>
</div>
......@@ -38,6 +41,8 @@
window.location.href = "http://" + host + "/devManage/devDetail" + "?username=" + username + "&token=" + token ;;
}else if(id == "left_category_man"){
window.location.href = "http://" + host + "/devManage/categoryManagePage" + "?username=" + username + "&token=" + token ;;
}else if(id == "left_borrow_check"){
window.location.href = "http://" + host + "/devManage/borrowCheckPage" + "?username=" + username + "&token=" + token ;;
}
}
......
<?php $data = $this->data; ?>
<?= view("header.php",$data); ?>
<?= view("devManage/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
<div style="width:100%;min-height:700px;">
<div class="row-fluid" style="width:auto;margin:0px 10px;">
<!-- block -->
<div class="block">
<div class="block-content collapse in">
<div class="span12">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>昵称</th>
<th>用户名</th>
<th>角色</th>
<th>部门</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php //for($i = 0;$i < count($data["users"]);$i++){ ?>
<tr>
<td>1</td>
<td>啊啊啊</td>
<td>不不不</td>
<td>擦擦擦</td>
<td>对对对</td>
<td>
<button class="btn btn-primary btn-mini" href="#editUserWindow" data-toggle="modal" onclick="showEditUserWindow(this)">编辑</button>
<button class="btn btn-danger btn-mini" onclick="delUser(this)">删除</button>
</td>
</tr>
<?php //} ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- /block -->
</div>
</div>
</div>
<?= view("footer.php",$data); ?>
......@@ -7,10 +7,10 @@
<div style="margin:0px 10px;margin-top:10px;padding:0px 10px;_background:pink;_min-height:50px;">
<input class="input-xlarge focused" id="dev_id" type="text" value="<?php if(count($data["devInfo"]) != 0){echo $data["devInfo"]["id"];} ?>" placeholder="输入设备id" style="display:inline;margin: 0px;width:200px;">
<button class="btn btn-primary" onclick="showDevById()">查 看</button>
<?php if(count($data["devInfo"]) != 0){ ?>
<button class="btn btn-primary" onclick="editDevInfo(this)" status="0">编 辑</button>
<button class="btn btn-primary">提 交</button>
<form class="form-horizontal" style="display:inline;">
<div style="margin-bottom:0px;display:inline-block;border-style: solid;border-width: 1px;border-color: #ddd;border-radius: 5px;">
<label class="control-label" for="fileInput" style="width:110px;">上传设备图片:</label>
......@@ -20,6 +20,7 @@
</div>
</form>
<button class="btn btn-primary" onclick="uploadFile()">上 传</button>
<?php } ?>
</div>
<div class="row-fluid" _style="margin:0px 10px;padding:0px 10px;">
......
......@@ -40,10 +40,11 @@
<td><?= $data["devices"][$i]["dev_system"] ?></td>
<td first_category_id="<?= $data["devices"][$i]["first_category_id"] ?>"><?= $data["devices"][$i]["category_name"] ?></td>
<td><?= $data["devices"][$i]["org_section_name"] ?></td>
<td><span style="padding:4px;" class="label label-inverse">签借人</span></td>
<td><span style="padding:4px;" class="label label-success" title="系统用户">签借人</span></td>
<td>
<button class="btn btn-primary btn-mini" href="#editDevWindow" data-toggle="modal" onclick="showEdtiDevWindow(this)">编辑</button>
<button class="btn btn-primary btn-mini" onclick="gotoDevDetail(this)">详情</button>
<button class="btn btn-primary btn-mini" onclick="">借出</button>
<button class="btn btn-danger btn-mini" onclick="deleteDev(this)">删除</button>
</td>
</tr>
......
......@@ -30,7 +30,7 @@
<ul class="nav pull-right">
<a href="#"><span class="badge badge-important pull-right" style="position: absolute;left: 25px;top: 1px;padding: 1px 5px;z-index:100;" onclick="alertMes()">10</span></a>
<li class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-user"></i> 远洪,你好! <i class="caret"></i>
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-user"></i> <?= $data["userInfo"]["nick"] ?>,你好! <i class="caret"></i>
</a>
<ul class="dropdown-menu">
......
......@@ -7,7 +7,9 @@
<div style="margin:0px 10px;margin-top:10px;padding:0px 10px;_background:pink;_min-height:50px;">
<input class="input-xlarge focused" id="dev_id" type="text" value="<?php if(count($data["devInfo"]) != 0){echo $data["devInfo"]["id"];} ?>" placeholder="输入设备id" style="display:inline;margin: 0px;width:200px;">
<button class="btn btn-primary" onclick="showDevById()">查 看</button>
<?php if(count($data["devInfo"]) != 0){ ?>
<button class="btn btn-primary">签 借</button>
<?php } ?>
</div>
<div class="row-fluid" _style="margin:0px 10px;padding:0px 10px;">
......
......@@ -27,6 +27,7 @@
<th>系统</th>
<th>分类</th>
<th>部门</th>
<th>签借人</th>
<th>操作</th>
</tr>
</thead>
......@@ -41,9 +42,12 @@
<td><?= $data["devices"][$i]["dev_system"] ?></td>
<td first_category_id="<?= $data["devices"][$i]["first_category_id"] ?>"><?= $data["devices"][$i]["category_name"] ?></td>
<td><?= $data["devices"][$i]["org_section_name"] ?></td>
<td><span style="padding:4px;" class="label label-success" title="系统用户">签借人</span></td>
<td>
<button class="btn btn-primary btn-mini" onclick="gotoShowDevDetail(this)">详情</button>
<button class="btn btn-primary btn-mini">签借</button>
<?php if($data["devices"][$i]["borrow_status"] != 2){ ?>
<button userId='<?php if($data["userInfo"] != []){ echo $data["userInfo"]["id"];}else{ echo "0";} ?>' class="btn btn-primary btn-mini" href="#showBorrowWindow" data-toggle="modal" onclick="showBorrowWindow(this)">签借</button>
<?php } ?>
</td>
</tr>
<?php } ?>
......@@ -70,7 +74,47 @@
</div>
</div>
</div>
<?= view("footer.php",$data); ?>
<!-- 展示签借弹窗 -->
<div id="showBorrowWindow" class="modal hide" style="width:500px;transform: translateX(-50%);margin:0px;left:50%;">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button">&times;</button>
<h3>签借设备</h3>
</div>
<div class="modal-body">
<?php if($data["userInfo"] != []){ ?>
<table>
<tr>
<td><label>签借原因:</label></td>
<td><textarea style="width:380px;height:40px;margin-bottom:0px;" id="borrow_comment"></textarea></td>
</tr>
<tr>
<td></td>
<td>
<button id="send_borrow_button" devId="" userId="<?= $data["userInfo"]["id"] ?>" user_name="<?= $data["userInfo"]["nick"] ?>" data-dismiss="modal" class="btn btn-primary" style="width:100%;" onclick="sendBorrow(this)">确 定</button>
</td>
</tr>
</table>
<?php }else{ ?>
<table>
<tr>
<td><label>输入名字:</label></td>
<td><input class="input-xlarge focused" id="user_name" type="text" value="" style="display:inline;margin: 0px;width:380px;"></td>
</tr>
<tr>
<td><label>签借原因:</label></td>
<td><textarea style="width:100%;height:40px;margin-bottom:0px;" id="borrow_comment"></textarea></td>
</tr>
<tr>
<td></td>
<td>
<button id="send_borrow_button" userId="0" devId="" data-dismiss="modal" class="btn btn-primary" style="width:380px;" onclick="sendBorrow(this)">确 定</button>
</td>
</tr>
</table>
<?php } ?>
</div>
</div>
<style>
.modal-body table tr td label,input,select {
......@@ -130,6 +174,55 @@ function gotoShowDevDetail(e){
}
window.location.href = "http://" + host + "/home/showDevDetail" + "?username=" + username + "&token=" + token + "&devId=" + devId;
}
/*****************************************************
* 展示签借弹窗
*****************************************************/
function showBorrowWindow(e){
var userId = $(e).attr("userId");
if(userId == 0){
var devId = $(e).parent().parent().attr("dev_id");
$("#send_borrow_button").attr("devId",devId);
}else{
var devId = $(e).parent().parent().attr("dev_id");
$("#send_borrow_button").attr("devId",devId);
}
}
/*****************************************************
* 发送签借信息
*****************************************************/
function sendBorrow(e){
var userId = $(e).attr("userId");
var devId = $(e).attr("devId");
var comment = $("#borrow_comment").val();
if(userId == 0){
var borrower = $(e).attr("user_name");
}else{
var borrower = $(e).attr("user_name");
}
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/addDevBorrowInfo"
var postData = {};
postData["userId"] = userId;
postData["devId"] = devId;
postData["comment"] = comment;
postData["borrower"] = borrower;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
}
</script>
......
......@@ -6,8 +6,8 @@
<li <?php if($data["uri"]["seg"][1] == "/" || $data["uri"]["seg"][1] == "userManagePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_org_manage">
<a><i class="icon-chevron-right"></i> 用户管理</a>
</li>
<li <?php if($data["uri"]["seg"][1] == "showRightsPage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_show_rights">
<a><i class="icon-chevron-right"></i> 查看权限</a>
<li <?php if($data["uri"]["seg"][1] == "showRolePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_show_role">
<a><i class="icon-chevron-right"></i> 查看角色</a>
</li>
</ul>
</div>
......@@ -32,8 +32,8 @@
if(id == "left_org_manage"){
window.location.href = "http://" + host + "/userManage?username=" + username + "&token=" + token;
}else if(id == "left_show_rights"){
window.location.href = "http://" + host + "/userManage/showRightsPage?username=" + username + "&token=" + token;
}else if(id == "left_show_role"){
window.location.href = "http://" + host + "/userManage/showRolePage?username=" + username + "&token=" + token;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment