Commit 1e501cdb authored by liyuanhong's avatar liyuanhong

add some rights control

parent 5dbe497e
......@@ -11,7 +11,9 @@ class Filters extends BaseConfig
'toolbar' => \CodeIgniter\Filters\DebugToolbar::class,
'honeypot' => \CodeIgniter\Filters\Honeypot::class,
'login_filter' => \App\Filters\LoginFilter::class,
'login_page_filter' => \App\Filters\LoginPageFilter::class
'login_page_filter' => \App\Filters\LoginPageFilter::class,
'rights_common_user_filter' => \App\Filters\RightsCommonUserFilter::class, //限制普通用户的操作权限
'login_filter' => \App\Filters\LoginFilter::class //登录用户权限的接口控制
];
// Always applied before every request
......@@ -38,6 +40,38 @@ class Filters extends BaseConfig
// 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']],
public $filters = [
'login_page_filter' => ['before' => ['devManage','devManage/*','orgManage','orgManage/*','userManage','userManage/*']],
'login_filter' => ['before' => ['devManageCtr','devManageCtr/*']]
'login_filter' => ['before' => [
'UserManageCtr',
'UserManageCtr/modifyUserInfo'
]
],
'rights_common_user_filter' => ['before' => [
'devManageCtr',
'devManageCtr/addFirstCategory',
'devManageCtr/editFirstCategory',
'devManageCtr/delAnFirstCategoryItem',
'devManageCtr/delAnSecondCategoryItem',
'devManageCtr/addSecondCategory',
'devManageCtr/editSecondCategory',
'devManageCtr/addDev',
'devManageCtr/delDev',
'devManageCtr/updateDev',
'devManageCtr/modifyDevInfo',
'devManageCtr/deleleDevImg',
'devManageCtr/addDevBorrowInfo',
'devManageCtr/refuseBorrow',
'devManageCtr/acceptBorrow',
'devManageCtr/confirmGiveBack',
'devManageCtr/borrowDevicesToUser',
'OrgManageCtr',
'OrgManageCtr/addOrgSection',
'OrgManageCtr/delOrgSection',
'OrgManageCtr/updateOrgSection',
'UserManageCtr',
'UserManageCtr/addUser',
'UserManageCtr/editUser',
'UserManageCtr/delUser'
]
]
];
}
......@@ -75,6 +75,13 @@ class DevManage extends BaseController
$devManageModel = new \App\Models\DevManageModel();
$devInfo = $devManageModel->getDeviceInfoById($devId);
$devImg = $devManageModel->getDevImgsById($devId);
if(count($devInfo) != 0){
$firstCategory = $devManageModel->getAllFirstCategory();
$firstCategoryId = $devInfo[0]["first_category_id"];
$secondCategory = $devManageModel->getSecondCategoryByFirstCategoryId($firstCategoryId);
}
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if(count($devInfo) == 0){
$devInfo[0] = array();
}
......@@ -82,6 +89,12 @@ class DevManage extends BaseController
$data["userInfo"] = $userInfo[0];
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["orgSections"] = $orgSections;
if(count($devInfo[0]) != 0){
$data["category"] = array();
$data["category"]["firstCategory"] = $firstCategory;
$data["category"]["secondCategory"] = $secondCategory;
}
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
......@@ -104,7 +117,7 @@ class DevManage extends BaseController
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
......@@ -127,13 +140,34 @@ class DevManage extends BaseController
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$page = (int)$this->request->getGet("page");
if($page == 0){
$page = 1;
}
$perPage = (int)$this->request->getGet("perPage");
if($perPage == 0){
$perPage = 20;
}
$item = array();
$item["page"] = $page;
$item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
$devManageModel = new \App\Models\DevManageModel();
$borrowInfo = $devManageModel->getBorrowInfoByPage($item);
$totalNums = $devManageModel->getTatalBorrowNum()[0]["total"];
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["borrowInfo"] = $borrowInfo;
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
......@@ -141,10 +175,6 @@ class DevManage extends BaseController
}
}
$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);
}
......
......@@ -34,6 +34,35 @@ class DevManageCtr extends BaseController
echo $result;
}
/****************************************************
* 编辑一级分类
/****************************************************/
public function editFirstCategory(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["category_id"] = $param->first_category_id;
$item["category_name"] = $param->first_category_name;
$item["detail"] = $param->first_category_detail;
$item["edit_time"] = $curTime;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->editFirstCategoryData($item);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 删除一条一级分类
/****************************************************/
......@@ -109,6 +138,35 @@ class DevManageCtr extends BaseController
echo $result;
}
/****************************************************
* 编辑二级分类
/****************************************************/
public function editSecondCategory(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["category_id"] = $param->second_category_id;
$item["category_name"] = $param->second_category_name;
$item["detail"] = $param->second_category_detail;
$item["edit_time"] = $curTime;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->editSecondCategoryData($item);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 获取所有一级分类
/****************************************************/
......@@ -280,7 +338,6 @@ class DevManageCtr extends BaseController
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["id"] = $param->dev_id;
$item["dev_name"] = $param->dev_name;
$item["dev_code"] = $param->dev_code;
......@@ -298,6 +355,48 @@ class DevManageCtr extends BaseController
$item["dev_detail"] = $param->dev_detail;
$item["dev_feature"] = $param->dev_feature;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->updateDevice($item);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 设备详情页面修改设备信息
/****************************************************/
public function modifyDevInfo(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["id"] = $param->dev_id;
$item["dev_name"] = $param->dev_name;
$item["dev_code"] = $param->dev_code;
$item["dev_brand"] = $param->dev_brand;
$item["dev_model"] = $param->dev_model;
$item["dev_system"] = $param->dev_system;
$item["dev_version"] = $param->dev_version;
$item["dev_color"] = $param->dev_color;
$item["update_time"] = $curTime;
$item["dev_status"] = 0;
$item["dev_delete"] = 0;
$item["first_category_id"] = $param->dev_first_category;
$item["second_category_id"] = $param->dev_second_category;
$item["org_section_id"] = $param->dev_org_section;
$item["dev_detail"] = $param->dev_detail;
$item["dev_feature"] = $param->dev_feature;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->updateDevice($item);
......@@ -425,34 +524,206 @@ class DevManageCtr extends BaseController
$item["user_id"] = $param->userId;
$item["borrower"] = $param->borrower;
$item["comment"] = $param->comment;
$item["borrower_time"] = $curTime;
$item["borrow_time"] = $curTime;
$item["borrow_status"] = 1; //1:表示申请签借中,还未通过审核
if($param->borrower == ""){
$result["status"] = COMMON_FAIL;
$result["message"] = "名字不能为空!";
}else{
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;
}
/****************************************************
* 拒绝签借
/****************************************************/
function refuseBorrow(){
$result = array();
$param = $this->request->getJSON();
$borrowId = $param->borrowId;
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){
$devManageModel->deleteBorrowMsgById($borrowId);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 通过签借
/****************************************************/
function acceptBorrow(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["id"] = $param->borrowId;
$item["borrow_status"] = 2;
$item["borrow_time"] = $curTime;
$item1 = array(); #用于更新设备的签借ID
$item1["id"] = $param->devId;
$item1["borrow_id"] = $param->borrowId;
$item2 = array(); #用于审核后删除非借出的相同设备id的设备签借信息
$item2["dev_id"] = $param->devId;
$item2["borrow_id"] = $param->borrowId;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->updateTheDeviceInfo($item1);
$devManageModel->modifyBorrowStatus($item);
$devManageModel->deleteBorrowMsgBydevidButId($item2);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 申请归还设备(只有注册的用户有该操作)
/****************************************************/
function applyForGiveBack(){
}
/****************************************************
* 确认归还设备
/****************************************************/
function confirmGiveBack(){
$result = array();
$param = $this->request->getJSON();
$devId = $param->devId;
$item = array();
$item["devId"] = $devId;
$item1 = array(); #用于更新设备的签借ID
$item1["id"] = $param->devId;
$item1["borrow_id"] = 0;
try{
$devManageModel = new \App\Models\DevManageModel();
$devManageModel->updateTheDeviceInfo($item1);
$devManageModel->deleteBorrowMsgBydevid($devId);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 将设备手动借出去
/****************************************************/
function borrowDevicesToUser(){
$result = array();
$param = $this->request->getJSON();
$userType = $param->userType;
$devId = $param->devId;
$userId = $param->userId;
$username = $param->username;
$comment = $param->comment;
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["dev_id"] = $devId;
$item["user_id"] = $userId;
$item["borrower"] = $username;
$item["comment"] = $comment;
$item["borrow_time"] = $curTime;
$item["borrow_status"] = 2;
try{
$devManageModel = new \App\Models\DevManageModel();
$borrowitems = $devManageModel->searchBorrowerInfoByDevidAndStatus($devId,2);
if(count($borrowitems) > 0){
$result["status"] = COMMON_FAIL;
$result["message"] = "该设备已经借出";
$result["message"] = "该设备已经借出";
}else{
if(count($borrowInfo2) == 0){
if($userType == 0){
$devManageModel->deleteBorrowMsgBydevid($devId);
$devManageModel->insertBorrowInfo($item);
$borrow_id = $devManageModel->searchBorrowerInfoByDevidAndStatus($devId,2)[0]["id"];
$item1 = array();
$item1["id"] = $devId;
$item1["borrow_id"] = $borrow_id;
$devManageModel->updateTheDeviceInfo($item1);
$result["status"] = SUCESS;
$result["message"] = "设备申请成功!";
$result["message"] = "借出成功!";
}else{
$result["status"] = COMMON_FAIL;
$result["message"] = "你已经申请该设备!";
}
$devManageModel->deleteBorrowMsgBydevid($devId);
$devManageModel->insertBorrowInfo($item);
$borrow_id = $devManageModel->searchBorrowerInfoByDevidAndStatus($devId,2)[0]["id"];
$item1 = array();
$item1["id"] = $devId;
$item1["borrow_id"] = $borrow_id;
$devManageModel->updateTheDeviceInfo($item1);
$result["status"] = SUCESS;
$result["message"] = "借出成功!";
}
}
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
......@@ -463,6 +734,6 @@ class DevManageCtr extends BaseController
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
}
}
......@@ -18,6 +18,10 @@ class Home extends BaseController
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if(count($userInfo) == 0){
$userInfo = array();
$userInfo[0]["token"] = null;
}
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
......@@ -53,8 +57,22 @@ class Home extends BaseController
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($username == "" || $token == "" || $userInfo[0]["token"] == $token){
if(count($userInfo) == 0){
$userInfo = array();
$userInfo[0]["token"] = null;
}
if($username == "" || $token == "" || $userInfo[0]["token"] != $token){
$data["userInfo"] = [];
$devManageModel = new \App\Models\DevManageModel();
$devices = $devManageModel->getDevicesAllInfoByPage($item);
$totalNums = $devManageModel->getTatalDeviceNum()[0]["total"];
$data["devices"] = $devices;
$data["pageInfo"] = array();
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
$data["notification"] = [];
}else{
$devManageModel = new \App\Models\DevManageModel();
$devices = $devManageModel->getDevicesAllInfoByPage($item);
......@@ -66,10 +84,10 @@ class Home extends BaseController
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
$data["notification"] = [];
$data["uri"] = getUriInfo($this->request);
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}
$data["uri"] = getUriInfo($this->request);
return view('home/show_devs',$data);
}
......@@ -85,18 +103,58 @@ class Home extends BaseController
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($username == "" || $token == "" || $userInfo[0]["token"] == $token){
if(count($userInfo) == 0){
$userInfo = array();
$userInfo[0]["token"] = null;
}
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){
$firstCategory = $devManageModel->getAllFirstCategory();
$firstCategoryId = $devInfo[0]["first_category_id"];
$secondCategory = $devManageModel->getSecondCategoryByFirstCategoryId($firstCategoryId);
}
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if(count($devInfo) == 0){
$devInfo[0] = array();
$devInfo[0] = array();
}
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["orgSections"] = $orgSections;
if(count($devInfo[0]) != 0){
$data["category"] = array();
$data["category"]["firstCategory"] = $firstCategory;
$data["category"]["secondCategory"] = $secondCategory;
}
$data["notification"] = [];
}else{
$devManageModel = new \App\Models\DevManageModel();
$devInfo = $devManageModel->getDeviceInfoById($devId);
$devImg = $devManageModel->getDevImgsById($devId);
$data["userInfo"] = $userInfo[0];
if(count($devInfo) != 0){
$firstCategory = $devManageModel->getAllFirstCategory();
$firstCategoryId = $devInfo[0]["first_category_id"];
$secondCategory = $devManageModel->getSecondCategoryByFirstCategoryId($firstCategoryId);
}
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if(count($devInfo) == 0){
$devInfo[0] = array();
}
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["orgSections"] = $orgSections;
if(count($devInfo[0]) != 0){
$data["category"] = array();
$data["category"]["firstCategory"] = $firstCategory;
$data["category"]["secondCategory"] = $secondCategory;
}
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
......@@ -104,6 +162,39 @@ class Home extends BaseController
$data["uri"] = getUriInfo($this->request);
return view('home/show_dev_detail',$data);
}
/*********************************************
* 进入个人主页
*********************************************/
public function profilePage()
{
$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(count($userInfo) == 0){
$userInfo = array();
$userInfo[0]["token"] = null;
}
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["orgSections"] = $orgSections;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/profile',$data);
}
}
......
......@@ -92,4 +92,68 @@ class UserManageCtr extends BaseController
echo $result;
}
/****************************************************
* 修改个人信息
/****************************************************/
public function modifyUserInfo(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["id"] = $param->userId;
$item["username"] = $param->username;
$item["nick"] = $param->nick;
$item["password"] = $param->password;
if($param->password == ""){
$result["status"] = COMMON_FAIL;
$message = "密码不能为空!";
$result["message"] = $message;
echo $result;
return;
}
$item["status"] = 0;
$item["role"] = $param->role;
$item["org_section_id"] = $param->org_section_id;
$item["update_time"] = $curTime;
try{
$userManageModel = new \App\Models\UserManageModel();
$userManageModel->updateUserInfo($item);
$result["status"] = SUCESS;
$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;
}
/****************************************************
* 通过用户名,模糊查找用户
/****************************************************/
function searchUsersByUsername(){
$result = array();
$param = $this->request->getJSON();
$username = $param->username;
$item = array();
$item["username"] = $username;
try{
$userManageModel = new \App\Models\UserManageModel();
$users = $userManageModel->selectUsersByUserName($item);
$result["status"] = SUCESS;
$result["users"] = $users;
}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;
}
}
\ No newline at end of file
<?php namespace App\Filters;
helper('statusCode');
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
use Config\Services;
/*********************************************
* 针对接口访问的过滤器
......@@ -11,7 +13,23 @@ class LoginFilter implements FilterInterface
{
public function before(RequestInterface $request)
{
$result = array();
$param = $request->getJSON();
$loginName = $param->loginName;
$token = $param->token;
if($loginName == "" || $token == ""){
$result["status"] = COMMON_FAIL;
$result["message"] = "未登录,不可进行该操作!";
return Services::response()->setBody(json_encode($result));
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($loginName);
if($userInfo[0]["token"] != $token){
$result["status"] = COMMON_FAIL;
$result["message"] = "未登录,不可进行该操作!";
return Services::response()->setBody(json_encode($result));
}
}
}
//--------------------------------------------------------------------
......
......@@ -20,6 +20,9 @@ class LoginPageFilter implements FilterInterface
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if(count($userInfo) == 0){
return redirect("sign");
}
if($userInfo[0]["token"] != $token){
return redirect("sign");
}
......
<?php namespace App\Filters;
helper('statusCode');
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
use Config\Services;
/*********************************************
* 针对权限接口访问的过滤器
* 针对普通用户的权限限制过滤器
*********************************************/
class RightsFilter implements FilterInterface
class RightsCommonUserFilter implements FilterInterface
{
public function before(RequestInterface $request)
{
$result = array();
$param = $request->getJSON();
$loginName = $param->loginName;
$token = $param->token;
if($loginName == "" || $token == ""){
$result["status"] = COMMON_FAIL;
$result["message"] = "未登录,不可进行该操作!";
return Services::response()->setBody(json_encode($result));
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($loginName);
if($userInfo[0]["token"] != $token){
$result["status"] = COMMON_FAIL;
$result["message"] = "未登录,不可进行该操作!";
return Services::response()->setBody(json_encode($result));
}
if($userInfo[0]["role"] == 2){
$result["status"] = COMMON_FAIL;
$result["message"] = "普通用户无权限进行该操作!";
return Services::response()->setBody(json_encode($result));
}
}
}
//--------------------------------------------------------------------
......
......@@ -30,6 +30,40 @@ class DevManageModel extends Model
$insertObj = $this->db->query($sql);
}
/****************************************************
* 编辑一级分类
/****************************************************/
public function editFirstCategoryData($data){
$sql = 'update first_category set ';
$isAdd = 0;
if(array_key_exists("category_name",$data)){
if($isAdd == 0){
$sql = $sql.'category_name="'.$data["category_name"].'"';
$isAdd = 1;
}else{
$sql = $sql.',category_name="'.$data["category_name"].'"';
}
}
if(array_key_exists("detail",$data)){
if($isAdd == 0){
$sql = $sql.'detail="'.$data["detail"].'"';
$isAdd = 1;
}else{
$sql = $sql.',detail="'.$data["detail"].'"';
}
}
if(array_key_exists("edit_time",$data)){
if($isAdd == 0){
$sql = $sql.'edit_time="'.$data["edit_time"].'"';
$isAdd = 1;
}else{
$sql = $sql.',edit_time="'.$data["edit_time"].'"';
}
}
$sql = $sql.' where id='.$data["category_id"].'';
$obj = $this->db->query($sql);
}
/****************************************************
* 删除一条第一分类数据
/****************************************************/
......@@ -60,6 +94,40 @@ class DevManageModel extends Model
$insertObj = $this->db->query($sql);
}
/****************************************************
* 编辑二级分类
/****************************************************/
public function editSecondCategoryData($data){
$sql = 'update second_category set ';
$isAdd = 0;
if(array_key_exists("category_name",$data)){
if($isAdd == 0){
$sql = $sql.'category_name="'.$data["category_name"].'"';
$isAdd = 1;
}else{
$sql = $sql.',category_name="'.$data["category_name"].'"';
}
}
if(array_key_exists("detail",$data)){
if($isAdd == 0){
$sql = $sql.'detail="'.$data["detail"].'"';
$isAdd = 1;
}else{
$sql = $sql.',detail="'.$data["detail"].'"';
}
}
if(array_key_exists("edit_time",$data)){
if($isAdd == 0){
$sql = $sql.'edit_time="'.$data["edit_time"].'"';
$isAdd = 1;
}else{
$sql = $sql.',edit_time="'.$data["edit_time"].'"';
}
}
$sql = $sql.' where id='.$data["category_id"].'';
$obj = $this->db->query($sql);
}
/****************************************************
* 获取第一级分类表的所有数据
/****************************************************/
......@@ -108,7 +176,7 @@ class DevManageModel extends Model
}
/****************************************************
* 更新设备信息
* 更新设备信息(信息全部写入)
/****************************************************/
public function updateDevice($data){
$sql = 'update devices set dev_name="'
......@@ -131,6 +199,183 @@ class DevManageModel extends Model
$obj = $this->db->query($sql);
}
/****************************************************
* 更新设备指定信息(只针对改动的信息其中的一条信息)
/****************************************************/
public function updateTheDeviceInfo($data){
$sql = 'update devices set ';
if(array_key_exists("dev_name",$data)){
$sql = $sql.'dev_name="'.$data["dev_name"].'",';
}else if(array_key_exists("dev_code",$data)){
$sql = $sql.'dev_code="'.$data["dev_code"].'",';
}else if(array_key_exists("dev_brand",$data)){
$sql = $sql.'dev_brand="'.$data["dev_brand"].'",';
}else if(array_key_exists("dev_model",$data)){
$sql = $sql.'dev_model="'.$data["dev_model"].'",';
}else if(array_key_exists("dev_system",$data)){
$sql = $sql.'dev_system="'.$data["dev_system"].'",';
}else if(array_key_exists("dev_version",$data)){
$sql = $sql.'dev_version="'.$data["dev_version"].'",';
}else if(array_key_exists("dev_color",$data)){
$sql = $sql.'dev_color="'.$data["dev_color"].'",';
}else if(array_key_exists("update_time",$data)){
$sql = $sql.'update_time="'.$data["update_time"].'",';
}else if(array_key_exists("dev_status",$data)){
$sql = $sql.'dev_status='.$data["dev_status"].',';
}else if(array_key_exists("dev_delete",$data)){
$sql = $sql.'dev_delete='.$data["dev_delete"].',';
}else if(array_key_exists("first_category_id",$data)){
$sql = $sql.'first_category_id='.$data["first_category_id"].',';
}else if(array_key_exists("second_category_id",$data)){
$sql = $sql.'second_category_id='.$data["second_category_id"].',';
}else if(array_key_exists("org_section_id",$data)){
$sql = $sql.'org_section_id='.$data["org_section_id"].',';
}else if(array_key_exists("dev_detail",$data)){
$sql = $sql.'dev_detail="'.$data["dev_detail"].'",';
}else if(array_key_exists("dev_feature",$data)){
$sql = $sql.'dev_feature="'.$data["dev_feature"].'",';
}else if(array_key_exists("borrow_id",$data)){
$sql = $sql.'borrow_id='.$data["borrow_id"];
}
$sql = $sql.' where id="'.$data["id"].'"';
$obj = $this->db->query($sql);
}
/****************************************************
* 更新设备指定信息(只针对改动的信息)
/****************************************************/
public function updateTheDeviceInfo2($data){
$sql = 'update devices set ';
$isAdd = 0;
if(array_key_exists("dev_name",$data)){
if($isAdd == 0){
$sql = $sql.'dev_name="'.$data["dev_name"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_name="'.$data["dev_name"].'"';
}
}
if(array_key_exists("dev_code",$data)){
if($isAdd == 0){
$sql = $sql.'dev_code="'.$data["dev_code"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_code="'.$data["dev_code"].'"';
}
}
if(array_key_exists("dev_brand",$data)){
if($isAdd == 0){
$sql = $sql.'dev_brand="'.$data["dev_brand"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_brand="'.$data["dev_brand"].'"';
}
}
if(array_key_exists("dev_model",$data)){
if($isAdd == 0){
$sql = $sql.'dev_model="'.$data["dev_model"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_model="'.$data["dev_model"].'"';
}
}
if(array_key_exists("dev_system",$data)){
if($isAdd == 0){
$sql = $sql.'dev_system="'.$data["dev_system"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_system="'.$data["dev_system"].'"';
}
}
if(array_key_exists("dev_version",$data)){
if($isAdd == 0){
$sql = $sql.'dev_version="'.$data["dev_version"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_version="'.$data["dev_version"].'"';
}
}
if(array_key_exists("dev_color",$data)){
if($isAdd == 0){
$sql = $sql.'dev_color="'.$data["dev_color"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_color="'.$data["dev_color"].'"';
}
}else if(array_key_exists("update_time",$data)){
if($isAdd == 0){
$sql = $sql.'update_time="'.$data["update_time"].'"';
$isAdd = 1;
}else{
$sql = $sql.',update_time="'.$data["update_time"].'"';
}
}
if(array_key_exists("dev_status",$data)){
if($isAdd == 0){
$sql = $sql.'dev_status='.$data["dev_status"].'';
$isAdd = 1;
}else{
$sql = $sql.',dev_status='.$data["dev_status"].'';
}
}if(array_key_exists("dev_delete",$data)){
if($isAdd == 0){
$sql = $sql.'dev_delete='.$data["dev_delete"].'';
$isAdd = 1;
}else{
$sql = $sql.',dev_delete='.$data["dev_delete"].'';
}
}if(array_key_exists("first_category_id",$data)){
if($isAdd == 0){
$sql = $sql.'first_category_id='.$data["first_category_id"].'';
$isAdd = 1;
}else{
$sql = $sql.',first_category_id='.$data["first_category_id"].'';
}
}
if(array_key_exists("second_category_id",$data)){
if($isAdd == 0){
$sql = $sql.'second_category_id='.$data["second_category_id"].'';
$isAdd = 1;
}else{
$sql = $sql.',second_category_id='.$data["second_category_id"].'';
}
}
if(array_key_exists("org_section_id",$data)){
if($isAdd == 0){
$sql = $sql.'org_section_id='.$data["org_section_id"].'';
$isAdd = 1;
}else{
$sql = $sql.',org_section_id='.$data["org_section_id"].'';
}
}
if(array_key_exists("dev_detail",$data)){
if($isAdd == 0){
$sql = $sql.'dev_detail="'.$data["dev_detail"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_detail="'.$data["dev_detail"].'"';
}
}
if(array_key_exists("dev_feature",$data)){
if($isAdd == 0){
$sql = $sql.'dev_feature="'.$data["dev_feature"].'"';
$isAdd = 1;
}else{
$sql = $sql.',dev_feature="'.$data["dev_feature"].'"';
}
}
if(array_key_exists("borrow_id",$data)){
if($isAdd == 0){
$sql = $sql.'borrow_id='.$data["borrow_id"];
$isAdd = 1;
}else{
$sql = $sql.',borrow_id='.$data["borrow_id"];
}
}
$sql = $sql.' where id="'.$data["id"].'"';
$obj = $this->db->query($sql);
}
/****************************************************
* 分页获取设备信息
/****************************************************/
......@@ -155,7 +400,7 @@ class DevManageModel extends Model
$sql = 'select t1.*,
t2.category_name,
t3.org_section_name,
t4.id as borrow_id,t4.borrower,t4.user_id,t4.borrow_status
t4.id as borrow_id,t4.borrower,t4.user_id,t4.borrow_status,t4.borrow_time
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
......@@ -239,12 +484,12 @@ class DevManageModel extends Model
* 添加设备签借信息
/****************************************************/
public function insertBorrowInfo($data){
$sql = 'insert into dev_borrow (dev_id,user_id,borrower,comment,borrower_time,borrow_status) values ('
$sql = 'insert into dev_borrow (dev_id,user_id,borrower,comment,borrow_time,borrow_status) values ('
.$data["dev_id"].','
.$data["user_id"].',"'
.$data["borrower"].'","'
.$data["comment"].'","'
.$data["borrower_time"].'",'
.$data["borrow_time"].'",'
.$data["borrow_status"].')';
$this->db->query($sql);
}
......@@ -263,9 +508,77 @@ class DevManageModel extends Model
* 根据设备id查询签借信息
/****************************************************/
public function searchBorrowerInfoByDevid($data){
$sql = 'select * from dev_borrow where borrower="'.$data["borrower"].'" and dev_id='.$data["dev_id"];
$sql = 'select * from dev_borrow where dev_id='.$data["dev_id"];
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 根据设备id和设备状态查询签借信息
/****************************************************/
public function searchBorrowerInfoByDevidAndStatus($dev_id,$borrow_status){
$sql = 'select * from dev_borrow where dev_id='.$dev_id.' and borrow_status='.$borrow_status;
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 查询设备签借信息
/****************************************************/
public function getBorrowInfoByPage($data){
$sql = 'select t1.*,
t2.dev_name,t2.dev_code
from dev_borrow t1
left join devices t2 on t1.dev_id = t2.id
where t1.borrow_status=1 limit '.(($data["page"] - 1) * $data["perPage"]).','.$data["perPage"];
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 获取所有的签借消息(未借出的设备)
/****************************************************/
public function getTatalBorrowNum(){
$sql = 'select count(*) as total from dev_borrow where borrow_status=1';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 删除签借消息通过消息id
/****************************************************/
public function deleteBorrowMsgById($id){
$sql = "delete from dev_borrow where id=".$id;
$this->db->query($sql);
}
/****************************************************
* 删除指定设备id的所有签借消息
/****************************************************/
public function deleteBorrowMsgBydevid($id){
$sql = "delete from dev_borrow where dev_id=".$id;
$this->db->query($sql);
}
/****************************************************
* 删除指定设备id的所有签借消息,除了指定的签借id
/****************************************************/
public function deleteBorrowMsgBydevidButId($data){
$sql = "delete from dev_borrow where dev_id=".$data["dev_id"].' and id<>'.$data["borrow_id"];
$this->db->query($sql);
}
/****************************************************
* 修改签借状态
/****************************************************/
public function modifyBorrowStatus($data){
$sql = 'update dev_borrow set borrow_status='.$data["borrow_status"]
.',borrow_time="'.$data["borrow_time"].'"'
.' where id='.$data["id"];
$this->db->query($sql);
}
}
\ No newline at end of file
......@@ -93,6 +93,15 @@ class UserManageModel extends Model
$sql = "delete from users where id=".$id;
$this->db->query($sql);
}
/****************************************************
* 通过用户名搜索用户
/****************************************************/
public function selectUsersByUserName($data){
$sql = 'select * from users where nick like "%'.$data["username"].'%"';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/////////////////////////////////////////////////// 权限管理区域(目前没有权限表) ////////////////////////////////////////////////////////////////
/****************************************************
......
<?php $data = $this->data; ?>
<?php $pager = \Config\Services::pager(); ?>
<?= view("header.php",$data); ?>
<?= view("devManage/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
......@@ -13,32 +16,46 @@
<thead>
<tr>
<th>#</th>
<th>昵称</th>
<th>用户名</th>
<th>角色</th>
<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>
<?php for($i = 0;$i < count($data["borrowInfo"]);$i++){ ?>
<tr borrow_id='<?= $data["borrowInfo"][$i]["id"] ?>' dev_id='<?= $data["borrowInfo"][$i]["dev_id"] ?>'>
<td><?= $i + 1 ?></td>
<td><?= $data["borrowInfo"][$i]["dev_name"] ?></td>
<td><?= $data["borrowInfo"][$i]["dev_code"] ?></td>
<td><?= $data["borrowInfo"][$i]["borrower"] ?></td>
<td><?= $data["borrowInfo"][$i]["comment"] ?></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>
<button class="btn btn-success btn-mini" href="#editUserWindow" data-toggle="modal" onclick="acceptBorrow(this)">同意</button>
<button class="btn btn-danger btn-mini" onclick="refuseBorrow(this)">拒绝</button>
</td>
</tr>
<?php //} ?>
<?php } ?>
</tbody>
</table>
</div>
</div>
<!-- 分页区域 -->
<div class="pagination" style="text-align:right;padding-right:30px;height:50px;">
<div>
<div style="display:inline;">
<select id="per_page" size="1" style="width:100px;margin:0px;float:right;height:30px;margin-left:5px;" onchange="perPageChange()">
<option value="10" <?php if($data["pageInfo"]["perPage"] == 15){ echo 'selected="selected"';}?>>10 条/页</option>
<option value="20" <?php if($data["pageInfo"]["perPage"] == 20){ echo 'selected="selected"';}?>>20 条/页</option>
<option value="50" <?php if($data["pageInfo"]["perPage"] == 50){ echo 'selected="selected"';}?>>50 条/页</option>
<option value="100" <?php if($data["pageInfo"]["perPage"] == 100){ echo 'selected="selected"';}?>>100 条/页</option>
</select>
</div>
<?= $pager->makeLinks($data["pageInfo"]["page"], $data["pageInfo"]["perPage"],$data["pageInfo"]["total"]) ?>
</div>
</div>
</div>
<!-- /block -->
</div>
......@@ -46,4 +63,123 @@
</div>
</div>
<?= view("footer.php",$data); ?>
<style>
.pagination {
margin: 0px 0px;
}
</style>
<script>
/*****************************************************
* 改变页码后,刷新页面
*****************************************************/
function perPageChange(){
var perPage = $("#per_page").val();
var host = window.location.host;
var oriParam = window.location.search;
var paramStr = oriParam.substring(1);
paramArr = paramStr.split("&");
param = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
for(var i = 0;i < paramArr.length;i++){
keyVal = paramArr[i].split("=");
param[keyVal[0]] = keyVal[1];
}
var url = window.location.href.split("?")[0];
delete param["perPage"];
for(var key in param){
if(url.indexOf("?") !== -1){
url = url + "&" + key + "=" + param[key];
}else{
url = url + "?" + key + "=" + param[key];
}
}
if(url.indexOf("&") !== -1){
url = url + "&perPage=" + perPage;
}else{
url = url + "?perPage=" + perPage;
}
window.location.href = url;
}
/*****************************************************
* 拒绝签借
*****************************************************/
function refuseBorrow(e){
var borrowId = $(e).parent().parent().attr("borrow_id");
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/refuseBorrow"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["borrowId"] = borrowId;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
}else{
}
}
});
}
/*****************************************************
* 通过签借
*****************************************************/
function acceptBorrow(e){
var borrowId = $(e).parent().parent().attr("borrow_id");
var devId = $(e).parent().parent().attr("dev_id");
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/acceptBorrow"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["borrowId"] = borrowId;
postData["devId"] = devId;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
}else{
}
}
});
}
</script>
......@@ -31,7 +31,7 @@
<td style="width:37%;">
<button class="btn btn-primary btn-mini" onclick="showSecondCategoryInFirstCategory(this)">显示子分类</button>
<button class="btn btn-primary btn-mini" href="#addSecondCatetoryWindow" data-toggle="modal" onclick="showSecondAddWindow(this)">添加子分类</button>
<button class="btn btn-primary btn-mini">编辑</button>
<button class="btn btn-primary btn-mini" href="#editFirstCatetoryWindow" data-toggle="modal" onclick="showEditFirstCatetoryWindow(this)">编辑</button>
<button class="btn btn-danger btn-mini" onclick="delFirstCategory(this)">删除</button>
</td>
</tr>
......@@ -54,6 +54,7 @@
<tr>
<th>#</th>
<th>子分类名</th>
<th>分类描述</th>
<th>编辑</th>
</tr>
</thead>
......@@ -62,8 +63,9 @@
<tr id="<?= $data["category"]["secondCategory"][$i]["id"]; ?>">
<td><?= $i + 1; ?></td>
<td><?= $data["category"]["secondCategory"][$i]["category_name"]; ?></td>
<td><?= $data["category"]["secondCategory"][$i]["detail"]; ?></td>
<td>
<button class="btn btn-primary btn-mini">编辑</button>
<button class="btn btn-primary btn-mini" href="#editSecondCatetoryWindow" data-toggle="modal" onclick="showEditSecondCategory(this)">编辑</button>
<button class="btn btn-danger btn-mini" onclick="delSecondCategory(this)">删除</button>
</td>
</tr>
......@@ -78,6 +80,7 @@
</div>
</div>
</div>
<!-- 添加第一分类弹窗 -->
<div id="addFirstCatetoryWindow" 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>
......@@ -98,10 +101,9 @@
<td><button data-dismiss="modal" class="btn btn-primary" style="width:100%;" onclick="addFirstCategory()">确定</button></td>
</tr>
</table>
</div>
</div>
<!-- 添加第二分类弹窗 -->
<div id="addSecondCatetoryWindow" 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>
......@@ -128,6 +130,60 @@
</table>
</div>
</div>
<!-- 编辑第一分类弹窗 -->
<div id="editFirstCatetoryWindow" 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">
<table>
<tr>
<td><label>一级分id:</label></td>
<td><input disabled class="input-xlarge focused" id="edit_first_category_id" type="text" value="" style="display:inline;margin: 0px;width:300px;"></td>
</tr>
<tr>
<td><label>一级分类名:</label></td>
<td><input class="input-xlarge focused" id="edit_first_category_name" type="text" value="" style="display:inline;margin: 0px;width:300px;"></td>
</tr>
<tr>
<td><label>一级分类描述:</label></td>
<td><textarea style="width:300px;" id="edit_first_category_detail"></textarea></td>
</tr>
<tr>
<td></td>
<td><button data-dismiss="edit_modal" class="btn btn-primary" style="width:100%;" onclick="sendEditFirstCategoryInfo()">确定</button></td>
</tr>
</table>
</div>
</div>
<!-- 编辑第二分类弹窗 -->
<div id="editSecondCatetoryWindow" 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">
<table>
<tr>
<td><label>二级分类id:</label></td>
<td><input disable class="input-xlarge focused" disabled id="edit_second_category_id" type="text" value="" style="display:inline;margin: 0px;width:300px;"></td>
</tr>
<tr>
<td><label>二级分类名:</label></td>
<td><input class="input-xlarge focused" id="edit_second_category_name" type="text" value="" style="display:inline;margin: 0px;width:300px;"></td>
</tr>
<tr>
<td><label>二级分类描述:</label></td>
<td><textarea style="width:300px;" id="edit_second_category_detail"></textarea></td>
</tr>
<tr>
<td></td>
<td><button data-dismiss="modal" class="btn btn-primary" style="width:100%;" onclick="sendEditSecondCategoryInfo()">确定</button></td>
</tr>
</table>
</div>
</div>
<?= view("footer.php",$data); ?>
<style>
......@@ -149,6 +205,16 @@ function addFirstCategory(){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/addFirstCategory"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["category_name"] = category_name;
postData["detail"] = detail;
$.ajax({
......@@ -161,7 +227,57 @@ function addFirstCategory(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
}
/*****************************************************
* 展示编辑一级分类弹窗
*****************************************************/
function showEditFirstCatetoryWindow(e){
var first_category_id = $(e).parent().parent().attr("id");
var first_category_name = $($(e).parent().prevAll()[1]).text();
var first_category_detail = $($(e).parent().prevAll()[0]).text();
$("#edit_first_category_id").val(first_category_id);
$("#edit_first_category_name").val(first_category_name);
$("#edit_first_category_detail").val(first_category_detail);
}
/*****************************************************
* 发送编辑一级分类信息
*****************************************************/
function sendEditFirstCategoryInfo(){
var first_category_id = $("#edit_first_category_id").val();
var first_category_name = $("#edit_first_category_name").val();
var first_category_detail = $("#edit_first_category_detail").val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/editFirstCategory"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["first_category_id"] = first_category_id;
postData["first_category_name"] = first_category_name;
postData["first_category_detail"] = first_category_detail;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "POST",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -183,6 +299,16 @@ function addSecondCategory(){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/addSecondCategory"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["category_name"] = category_name;
postData["detail"] = detail;
postData["first_category_id"] = first_category_id;
......@@ -196,12 +322,63 @@ function addSecondCategory(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
}
/*****************************************************
* 发送编辑二级分类信息
*****************************************************/
function sendEditSecondCategoryInfo(){
var second_category_id = $("#edit_second_category_id").val();
var second_category_name = $("#edit_second_category_name").val();
var second_category_detail = $("#edit_second_category_detail").val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/editSecondCategory"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["second_category_id"] = second_category_id;
postData["second_category_name"] = second_category_name;
postData["second_category_detail"] = second_category_detail;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "POST",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
}
/*****************************************************
* 展示编辑二级分类弹窗
*****************************************************/
function showEditSecondCategory(e){
var second_category_id = $(e).parent().parent().attr("id");
var second_category_name = $($(e).parent().prevAll()[1]).text();
var second_category_detail = $($(e).parent().prevAll()[0]).text();
$("#edit_second_category_id").val(second_category_id);
$("#edit_second_category_name").val(second_category_name);
$("#edit_second_category_detail").val(second_category_detail);
}
/*****************************************************
* 删除一级分类
*****************************************************/
......@@ -210,6 +387,16 @@ function delFirstCategory(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/delAnFirstCategoryItem"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["id"] = devId;
var isSure = confirm("确定删除该部门?");
if(isSure == true){
......@@ -223,7 +410,7 @@ function delFirstCategory(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -238,6 +425,16 @@ function delSecondCategory(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/delAnSecondCategoryItem"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["id"] = devId;
var isSure = confirm("确定删除该部门?");
if(isSure == true){
......@@ -251,7 +448,7 @@ function delSecondCategory(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -265,6 +462,16 @@ function showSecondCategoryInFirstCategory(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/getSecondCategoryByFirstCategoryId"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["first_category_id"] = categoryId;
$.ajax({
url: url,
......@@ -281,7 +488,8 @@ function showSecondCategoryInFirstCategory(e){
var content = "<tr id='" + items[i].id + "'>";
content = content + "<td>" + (i + 1) + "</td>";
content = content + "<td>" + items[i].category_name + "</td>";
content = content + '<td><button class="btn btn-primary btn-mini">编辑</button>';
content = content + "<td>" + items[i].detail + "</td>";
content = content + '<td><button class="btn btn-primary btn-mini" href="#editSecondCatetoryWindow" data-toggle="modal" onclick="showEditSecondCategory(this)">编辑</button>';
content = content + '<button class="btn btn-danger btn-mini" onclick="delSecondCategory(this)">删除</button></td>';
content = content + '</tr>';
container_secondCategory.append(content);
......@@ -291,7 +499,7 @@ function showSecondCategoryInFirstCategory(e){
$("button").trigger("create");
}
}else{
alert(data.message);
}
}
});
......
......@@ -9,8 +9,13 @@
<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>
<button class="btn btn-primary" onclick="commitChangedDevInfo()">提 交</button>
<?php if($data["devInfo"]["borrow_status"] == 2){ ?>
<button class="btn btn-success" onclick="giveBackDevs(this)">归 还</button>
<?php }else{ ?>
<button class="btn btn-primary" href="#borrowToWindow" data-toggle="modal" onclick="showBorrowToWindow()">借 给</button>
<?php } ?>
<button class="btn btn-danger" onclick="deleteDev()">删 除</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>
......@@ -87,31 +92,43 @@
</td>
<td>
<label>第一分类:</label>
<input disabled class="input-xlarge focused" id="dev_first_category_show" type="text" value="<?= $data["devInfo"]["first_category_id"] ?>">
<select disabled id="dev_first_category_show" style="display:inline;margin: 0px;width:73%;height:32px;" onchange="getSecondCategory_edit(this)">
<?php for($i = 0;$i < count($data["category"]["firstCategory"]);$i++){ ?>
<option value='<?= $data["category"]["firstCategory"][$i]["id"] ?>' <?php if($data["category"]["firstCategory"][$i]["id"] == $data["devInfo"]["first_category_id"]){echo 'selected="selected"';}?>><?= $data["category"]["firstCategory"][$i]["category_name"] ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>
<label>第二分类:</label>
<input disabled class="input-xlarge focused" id="dev_second_category_show" type="text" value="<?= $data["devInfo"]["second_category_id"] ?>">
<select disabled id="dev_second_category_show" style="display:inline;margin: 0px;width:73%;height:32px;">
<?php for($i = 0;$i < count($data["category"]["secondCategory"]);$i++){ ?>
<option value='<?= $data["category"]["secondCategory"][$i]["id"] ?>' <?php if($data["category"]["secondCategory"][$i]["id"] == $data["devInfo"]["second_category_id"]){echo 'selected="selected"';}?>><?= $data["category"]["secondCategory"][$i]["category_name"] ?></option>
<?php } ?>
</select>
</td>
<td>
<label>所属部门:</label>
<input disabled class="input-xlarge focused" id="dev_org_section_show" type="text" value="<?= $data["devInfo"]["org_section_id"] ?>">
<label>所属部门:</label>
<select disabled id="dev_org_section_show" style="display:inline;margin: 0px;width:73%;height:32px;">
<?php for($i = 0;$i < count($data["orgSections"]);$i++){ ?>
<option value='<?= $data["orgSections"][$i]["id"] ?>' <?php if($data["orgSections"][$i]["id"] == $data["devInfo"]["org_section_id"]){echo 'selected="selected"';}?>><?= $data["orgSections"][$i]["org_section_name"] ?></option>
<?php } ?>
</select>
</td>
<td>
<label>设备状态:</label>
<input disabled class="input-xlarge focused" id="dev_status_show" type="text" value="<?= $data["devInfo"]["dev_status"] ?>">
<input disabled class="input-xlarge focused" id="dev_status_show" type="text" value="<?php if($data["devInfo"]["borrow_status"] == 0 || $data["devInfo"]["borrow_status"] == "" || $data["devInfo"]["borrow_status"] == 1){ echo "未借出";}else if($data["devInfo"]["borrow_status"] == 2){echo "已借出";}?>">
</td>
<td>
<label style="color:red;">签借人:</label>
<input disabled class="input-xlarge focused" id="dev_borrower_show" type="text" value="">
<input disabled class="input-xlarge focused" id="dev_borrower_show" type="text" borrower_id="<?= $data["devInfo"]["user_id"] ?>" value="<?= $data["devInfo"]["borrower"] ?>">
</td>
</tr>
<tr>
<td>
<label>借出时间:</label>
<input disabled class="input-xlarge focused" id="dev_borrow_time_show" type="text" value="">
<input disabled class="input-xlarge focused" id="dev_borrow_time_show" type="text" value="<?php if($data["devInfo"]["borrow_status"] == 2){echo $data["devInfo"]["borrow_time"];} ?>">
</td>
<td>
<label>归还时间:</label>
......@@ -165,6 +182,52 @@
</div>
</div>
<!-- 展示借给弹窗 -->
<div id="borrowToWindow" class="modal hide" style="width:500px;transform: translateX(-50%);margin:0px;left:50%;" dev_id="0">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button">&times;</button>
<h3 style="_padding-left:10px;">借出设备</h3>
</div>
<div class="modal-body" style="padding:10px;max-height:420px;">
<ul style="list-style: none;" id="noname_1">
<li style="display: inline-block;padding-left: 10px;width: 70px;text-align: right;">
<label style="display: inline-block;padding-left: 10px;">
<input type="radio" value="0" name="borrowerType" checked="checked" onclick="switchBorrowUserType(this)" value="0" style="margin:0px;margin-right:5px;"/>
游客</label>
</li>
<li style="display: inline-block;padding-left: 10px;">
<label style="width:100px;display: inline-block;padding-left: 10px;text-align: right;">
<input type="radio" value="1" name="borrowerType" onclick="switchBorrowUserType(this)" value="1" style="margin:0px;margin-right:5px;"/>
系统用户</label>
</li>
</ul>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">游客名:</label>
<input class="input-xlarge focused" id="borrower_name" type="text" value="" style="display:inline;margin: 0px;_width:380px;">
</div>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<div>
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">搜索用户:</label>
<input class="input-xlarge focused" id="search_key" disabled type="text" value="" style="display:inline;margin: 0px;_width:380px;">
<button class="btn btn-primary" onclick="searchUserToBorrow()">搜索</button>
</div>
<div style="margin-top:5px;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">选择用户:</label>
<select disabled id="borrow_user" style="display:inline;margin: 0px;width:282px;height:32px;">
<option></option>
</select>
</div>
</div>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">说明:</label>
<textArea class="input-xlarge focused" id="borrower_comment" type="text" value="" style="display:inline;margin: 0px;_width:380px;"></textarea>
</div>
<div style="margin-top:10px;text-align:center;">
<button class="btn btn-primary" style="width:40%;" onclick="borrowTo()">借 给 他</button>
</div>
</div>
</div>
<?= view("footer.php",$data); ?>
......@@ -194,6 +257,8 @@ tbody tr td input {
/*****************************************************
* 上传设备图片
*****************************************************/
var isEdit = 0; //设备信息是否处于编辑状态:0:没有 1:处于编辑状态
function uploadFile(){
var formData = new FormData();
var devId = $("#dev_id_show").val();
......@@ -203,19 +268,23 @@ function uploadFile(){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/devImageUpload"
$.ajax({
url: url,
type:'post',
async: false, //使用同步请求,图片未上传完不可进行其他操做
data: formData,
contentType: false,
processData: false,
success:function(res){
alert(res.message);
location.reload();
// $("#fileInput").val("");
}
});
if($("#fileInput")[0].files[0] == undefined){
alert("请选择图片!");
}else{
$.ajax({
url: url,
type:'post',
async: false, //使用同步请求,图片未上传完不可进行其他操做
data: formData,
contentType: false,
processData: false,
success:function(res){
alert(res.message);
location.reload();
// $("#fileInput").val("");
}
});
}
}
/*****************************************************
* 删除设备图片
......@@ -226,6 +295,16 @@ function deleteDevImg(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/deleleDevImg"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["devId"] = devId;
postData["imgId"] = imgId;
var isSure = confirm("确定删除该设备?");
......@@ -240,7 +319,7 @@ function deleteDevImg(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -297,11 +376,12 @@ function editDevInfo(e){
$("#dev_first_category_show").removeAttr("disabled");
$("#dev_second_category_show").removeAttr("disabled");
$("#dev_org_section_show").removeAttr("disabled");
$("#dev_status_show").removeAttr("disabled");
$("#dev_borrower_show").removeAttr("disabled");
// $("#dev_status_show").removeAttr("disabled");
// $("#dev_borrower_show").removeAttr("disabled");
// $("#dev_borrow_time_show").removeAttr("disabled");
// $("#dev_return_time_show").removeAttr("disabled");
$("#dev_detail_show").removeAttr("disabled");
isEdit = 1;
}else{
$(e).attr("status","0");
$(e).text("编 辑");
......@@ -319,14 +399,339 @@ function editDevInfo(e){
$("#dev_feature_show").attr("disabled","disabled");
$("#dev_first_category_show").attr("disabled","disabled");
$("#dev_second_category_show").attr("disabled","disabled");
$("#dev_org_section_show").attr("disabled");
$("#dev_status_show").attr("disabled","disabled");
$("#dev_borrower_show").attr("disabled","disabled");
$("#dev_org_section_show").attr("disabled","disabled");
// $("#dev_status_show").attr("disabled","disabled");
// $("#dev_borrower_show").attr("disabled","disabled");
// $("#dev_borrow_time_show").attr("disabled","disabled");
// $("#dev_return_time_show").attr("disabled","disabled");
$("#dev_detail_show").attr("disabled","disabled");
isEdit = 0;
}
}
/*****************************************************
* 编辑设备获取二级分类
*****************************************************/
function getSecondCategory_edit(e){
var first_category_id = $(e).val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/getSecondCategoryByFirstCategoryId"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["first_category_id"] = first_category_id;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
$("#dev_second_category_show").empty();
var items = data.data;
for(var i = 0 ;i < items.length ;i++){
var content = '<option value="' + items[i]["id"] + '">' + items[i]["category_name"] + '</option>';
$("#dev_second_category_show").append(content);
}
}else{
alert(data.message);
}
}
});
}
/*****************************************************
* 提交修改后的设备信息
*****************************************************/
function commitChangedDevInfo(){
if(isEdit == 0){
alert("请先编辑设备!");
}else{
var dev_id = $("#dev_id_show").val();
var dev_name = $("#dev_name_show").val();
var dev_code = $("#dev_code_show").val();
var dev_brand = $("#dev_brand_show").val();
var dev_model = $("#dev_model_show").val();
var dev_system = $("#dev_system_show").val();
var dev_version = $("#dev_version_show").val();
var dev_color = $("#dev_color_show").val();
var dev_feature = $("#dev_feature_show").val();
var dev_first_category = $("#dev_first_category_show").val();
var dev_second_category = $("#dev_second_category_show").val();
var dev_org_section = $("#dev_org_section_show").val();
var dev_detail = $("#dev_detail_show").val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/modifyDevInfo"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["dev_id"] = dev_id;
postData["dev_name"] = dev_name;
postData["dev_code"] = dev_code;
postData["dev_brand"] = dev_brand;
postData["dev_model"] = dev_model;
postData["dev_system"] = dev_system;
postData["dev_version"] = dev_version;
postData["dev_color"] = dev_color;
postData["dev_feature"] = dev_feature;
postData["dev_first_category"] = dev_first_category;
postData["dev_second_category"] = dev_second_category;
postData["dev_org_section"] = dev_org_section;
postData["dev_detail"] = dev_detail;
$.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);
}
}
});
}
}
/*****************************************************
* 归还设备
*****************************************************/
function giveBackDevs(e){
var devId = $("#dev_id_show").val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/confirmGiveBack"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["devId"] = devId;
var isSure = confirm("确定已归还该设备?");
if(isSure == true){
$.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);
}
}
});
}
}
/*****************************************************
* 展示借给弹窗
*****************************************************/
function showBorrowToWindow(e){
var devId = $("#dev_id_show").val();
$("#borrowToWindow").attr("dev_id",devId);
}
/*****************************************************
* 点击搜索要借给的系统用户
*****************************************************/
function searchUserToBorrow(){
if(borrowToType == 0){
alert("请选择系统用户");
}else if(borrowToType == 1){
var searchKey = $("#search_key").val();
if(searchKey == ""){
alert("请输入搜索词!");
}else{
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/searchUsersByUsername"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["username_borrow"] = searchKey;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
$("#borrow_user").empty();
var items = data.users;
for(var i = 0 ;i < items.length ;i++){
var content = '<option value="' + items[i]["id"] + '">' + items[i]["nick"] + '</option>';
$("#borrow_user").append(content);
}
}else{
alert(data.message);
}
}
});
}
}
}
/*****************************************************
* 借给指定用户
*****************************************************/
function borrowTo(){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/borrowDevicesToUser"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
if(borrowToType == "0"){ //借给游客
var borrower_name = $("#borrower_name").val();
var comment = $("#borrower_comment").val();
if(borrower_name == ""){
alert("用户名不能为空");
}else{
var username = $("#borrower_name").val();
var devId = $("#borrowToWindow").attr("dev_id");
postData["userType"] = 0;
postData["userId"] = 0;
postData["username"] = username;
postData["devId"] = devId;
postData["comment"] = comment;
$.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);
}
}
});
}
}else if(borrowToType == "1"){ //借给系统用户
var userToBorrow = $("#borrow_user").val();
var comment = $("#borrower_comment").val();
if(userToBorrow == "" || userToBorrow == undefined){
alert("请选择一个用户!");
}else{
var userId = $("#borrow_user").val();
var username = $("#borrow_user").find("option:selected").text();
var devId = $("#borrowToWindow").attr("dev_id");
postData["userType"] = 1;
postData["userId"] = userId;
postData["username"] = username;
postData["devId"] = devId;
postData["comment"] = comment;
$.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);
}
}
});
}
}
}
/*****************************************************
* 改变借给用户类型
*****************************************************/
function switchBorrowUserType(e){
if($(e).val() == "0"){
$("#search_key").attr("disabled","disabled");
$("#borrow_user").attr("disabled","disabled");
$("#borrower_name").removeAttr("disabled");
borrowToType = 0;
}else if($(e).val() == "1"){
$("#search_key").removeAttr("disabled");
$("#borrow_user").removeAttr("disabled");
$("#borrower_name").attr("disabled","disabled");
borrowToType = 1
}
}
/*****************************************************
* 删除设备
*****************************************************/
function deleteDev(){
var devId = $("#dev_id_show").val();
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/delDev"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["devId"] = devId;
var isSure = confirm("确定删除该设备?");
if(isSure == true){
$.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>
......@@ -8,6 +8,7 @@
<div>
<div style="margin:0px 10px;margin-top:10px;padding:0px 10px;">
<button class="btn btn-primary" href="#addDevWindow" data-toggle="modal">添加设备</button>
<button class="btn btn-primary">导出设备</button>
</div>
<div class="row-fluid" style="width:auto;margin:0px 10px;">
<!-- block -->
......@@ -19,6 +20,7 @@
<tr>
<th>#</th>
<th>设备名</th>
<th>设备id</th>
<th>设备编号</th>
<th>品牌</th>
<th>型号</th>
......@@ -34,17 +36,26 @@
<tr dev_id='<?= $data["devices"][$i]["id"] ?>'>
<td><?= $i +1 ?></td>
<td><?= $data["devices"][$i]["dev_name"] ?></td>
<td><?= $data["devices"][$i]["id"] ?></td>
<td><?= $data["devices"][$i]["dev_code"] ?></td>
<td><?= $data["devices"][$i]["dev_brand"] ?></td>
<td><?= $data["devices"][$i]["dev_model"] ?></td>
<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>
<?php if($data["devices"][$i]["borrow_status"] != 2){ ?>
<td></td>
<?php }else{ ?>
<td><span style="padding:4px;" class="label label-success" title="系统用户"><?= $data["devices"][$i]["borrower"] ?></span></td>
<?php } ?>
<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>
<?php if($data["devices"][$i]["borrow_status"] != 2){ ?>
<button class="btn btn-primary btn-mini" onclick="showBorrowToWindow(this)" href="#borrowToWindow" data-toggle="modal">借给</button>
<?php }else{ ?>
<button class="btn btn-success btn-mini" onclick="giveBackDevs(this)">归还</button>
<?php } ?>
<button class="btn btn-danger btn-mini" onclick="deleteDev(this)">删除</button>
</td>
</tr>
......@@ -53,7 +64,7 @@
</table>
</div>
</div>
<div class="pagination" style="text-align:right;padding-right:30px;">
<div class="pagination" style="text-align:right;padding-right:30px;height:50px;">
<div>
<div style="display:inline;">
<select id="per_page" size="1" style="width:100px;margin:0px;float:right;height:30px;margin-left:5px;" onchange="perPageChange()">
......@@ -166,7 +177,7 @@
<button data-dismiss="modal" class="close" type="button">&times;</button>
<h3 style="padding-left:30px;">编辑设备</h3>
</div>
<div class="modal-body">
<div class="modal-body" style="padding:10px;max-height:420px;">
<table>
<tr>
<td>
......@@ -251,6 +262,52 @@
</table>
</div>
</div>
<!-- 展示借给弹窗 -->
<div id="borrowToWindow" class="modal hide" style="width:500px;transform: translateX(-50%);margin:0px;left:50%;" dev_id="0">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button">&times;</button>
<h3 style="_padding-left:10px;">借出设备</h3>
</div>
<div class="modal-body" style="padding:10px;max-height:420px;">
<ul style="list-style: none;" id="noname_1">
<li style="display: inline-block;padding-left: 10px;width: 70px;text-align: right;">
<label style="display: inline-block;padding-left: 10px;">
<input type="radio" value="0" name="borrowerType" checked="checked" onclick="switchBorrowUserType(this)" value="0" style="margin:0px;margin-right:5px;"/>
游客</label>
</li>
<li style="display: inline-block;padding-left: 10px;">
<label style="width:100px;display: inline-block;padding-left: 10px;text-align: right;">
<input type="radio" value="1" name="borrowerType" onclick="switchBorrowUserType(this)" value="1" style="margin:0px;margin-right:5px;"/>
系统用户</label>
</li>
</ul>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">游客名:</label>
<input class="input-xlarge focused" id="borrower_name" type="text" value="" style="display:inline;margin: 0px;_width:380px;">
</div>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<div>
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">搜索用户:</label>
<input class="input-xlarge focused" id="search_key" disabled type="text" value="" style="display:inline;margin: 0px;_width:380px;">
<button class="btn btn-primary" onclick="searchUserToBorrow()">搜索</button>
</div>
<div style="margin-top:5px;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">选择用户:</label>
<select disabled id="borrow_user" style="display:inline;margin: 0px;width:282px;height:32px;">
<option></option>
</select>
</div>
</div>
<div style="margin-top:10px;border-style: solid;border-width: 0px;border-top-width: 1px;padding-top: 10px;border-color: gray;">
<label style="width:70px;display: inline-block;padding-left: 10px;text-align: right;">说明:</label>
<textArea class="input-xlarge focused" id="borrower_comment" type="text" value="" style="display:inline;margin: 0px;_width:380px;"></textarea>
</div>
<div style="margin-top:10px;text-align:center;">
<button class="btn btn-primary" style="width:40%;" onclick="borrowTo()">借 给 他</button>
</div>
</div>
</div>
</div>
<?= view("footer.php",$data); ?>
......@@ -265,6 +322,7 @@
</style>
<script>
var borrowToType = 0 //0表示借给游客,1:借给系统用户
/*****************************************************
* 添加设备
*****************************************************/
......@@ -283,6 +341,16 @@ function addDev(){
var dev_detail = $("#dev_detail").val();
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["dev_name"] = dev_name;
postData["dev_code"] = dev_code;
postData["dev_brand"] = dev_brand;
......@@ -318,7 +386,7 @@ function addDev(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -333,6 +401,16 @@ function deleteDev(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/delDev"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["devId"] = devId;
var isSure = confirm("确定删除该设备?");
if(isSure == true){
......@@ -346,7 +424,7 @@ function deleteDev(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -361,6 +439,16 @@ function getSecondCategory_add(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/getSecondCategoryByFirstCategoryId"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["first_category_id"] = first_category_id;
$.ajax({
url: url,
......@@ -377,7 +465,7 @@ function getSecondCategory_add(e){
$("#second_category_id").append(content);
}
}else{
alert(data.message);
}
}
});
......@@ -504,6 +592,16 @@ function getSecondCategory_edit(e){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/getSecondCategoryByFirstCategoryId"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["first_category_id"] = first_category_id;
$.ajax({
url: url,
......@@ -520,7 +618,7 @@ function getSecondCategory_edit(e){
$("#second_category_id_edit").append(content);
}
}else{
alert(data.message);
}
}
});
......@@ -544,6 +642,16 @@ function updateDev(){
var dev_detail = $("#dev_detail_edit").val();
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["dev_id"] = devId;
postData["dev_name"] = dev_name;
postData["dev_code"] = dev_code;
......@@ -580,13 +688,183 @@ function updateDev(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
}
}
/*****************************************************
* 归还设备
*****************************************************/
function giveBackDevs(e){
var devId = $(e).parent().parent().attr("dev_id");
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/confirmGiveBack"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["devId"] = devId;
var isSure = confirm("确定已归还该设备?");
if(isSure == true){
$.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);
}
}
});
}
}
/*****************************************************
* 展示借给弹窗
*****************************************************/
function showBorrowToWindow(e){
var devId = $(e).parent().parent().attr("dev_id");
$("#borrowToWindow").attr("dev_id",devId);
}
/*****************************************************
* 点击搜索要借给的系统用户
*****************************************************/
function searchUserToBorrow(){
if(borrowToType == 0){
alert("请选择系统用户");
}else if(borrowToType == 1){
var searchKey = $("#search_key").val();
if(searchKey == ""){
alert("请输入搜索词!");
}else{
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/searchUsersByUsername"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["username"] = searchKey;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "DELETE",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
$("#borrow_user").empty();
var items = data.users;
for(var i = 0 ;i < items.length ;i++){
var content = '<option value="' + items[i]["id"] + '">' + items[i]["nick"] + '</option>';
$("#borrow_user").append(content);
}
}else{
alert(data.message);
}
}
});
}
}
}
/*****************************************************
* 借给指定用户
*****************************************************/
function borrowTo(){
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/borrowDevicesToUser"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
if(borrowToType == "0"){ //借给游客
var borrower_name = $("#borrower_name").val();
var comment = $("#borrower_comment").val();
if(borrower_name == ""){
alert("用户名不能为空");
}else{
var username = $("#borrower_name").val();
var devId = $("#borrowToWindow").attr("dev_id");
postData["userType"] = 0;
postData["userId"] = 0;
postData["username"] = username;
postData["devId"] = devId;
postData["comment"] = comment;
$.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);
}
}
});
}
}else if(borrowToType == "1"){ //借给系统用户
var userToBorrow = $("#borrow_user").val();
var comment = $("#borrower_comment").val();
if(userToBorrow == "" || userToBorrow == undefined){
alert("请选择一个用户!");
}else{
var userId = $("#borrow_user").val();
var username = $("#borrow_user").find("option:selected").text();
var devId = $("#borrowToWindow").attr("dev_id");
postData["userType"] = 1;
postData["userId"] = userId;
postData["username"] = username;
postData["devId"] = devId;
postData["comment"] = comment;
$.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);
}
}
});
}
}
}
/*****************************************************
* 改变页码后,刷新页面
*****************************************************/
......@@ -633,5 +911,22 @@ function gotoDevDetail(e){
}
window.location.href = "http://" + host + "/devManage/devDetail" + "?username=" + username + "&token=" + token + "&devId=" + devId;
}
/*****************************************************
* 改变借给用户类型
*****************************************************/
function switchBorrowUserType(e){
if($(e).val() == "0"){
$("#search_key").attr("disabled","disabled");
$("#borrow_user").attr("disabled","disabled");
$("#borrower_name").removeAttr("disabled");
borrowToType = 0;
}else if($(e).val() == "1"){
$("#search_key").removeAttr("disabled");
$("#borrow_user").removeAttr("disabled");
$("#borrower_name").attr("disabled","disabled");
borrowToType = 1
}
}
</script>
......@@ -35,7 +35,7 @@
</a>
<ul class="dropdown-menu">
<li>
<a tabindex="-1" href="#">个人主页</a>
<a tabindex="-1" href="#" onclick="gotoProfile()">个人主页</a>
</li>
<li class="divider"></li>
<li>
......@@ -55,7 +55,7 @@
<ul class="nav">
<li class="active" style="padding:6px 0px;margin-top:4px;background:lightgray;border-radius:8px;">
<i class="hide-sidebar" style="padding:10px 20px;display:none;"><a class="icon-chevron-left" href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
<i class="show-sidebar" style="display:none;padding:10px 20px;display:inline;"><a class="icon-chevron-right" href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
<i class="show-sidebar" style="padding:10px 20px;display:inline;"><a class="icon-chevron-right" href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
</li>
<li class="dropdown" style="margin-left:10px;">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">功能 <i class="caret"></i>
......@@ -65,19 +65,23 @@
<li onclick="funcSwich(this)" id="switch_home" <?php if($data["uri"]["seg"][0] == "/" || $data["uri"]["seg"][0] == "home"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">首页</a>
</li>
<li onclick="funcSwich(this)" id="switch_devman" <?php if($data["uri"]["seg"][0] == "devManage"){echo "class='active'";} ?> >
<a tabindex="-1" href="#">设备管理</a>
</li>
<li onclick="funcSwich(this)" id="switch_userman" <?php if($data["uri"]["seg"][0] == "userManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">用户管理</a>
</li>
<li onclick="funcSwich(this)" id="switch_orgman" <?php if($data["uri"]["seg"][0] == "orgManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">组织管理</a>
</li>
<li class="divider"></li>
<li onclick="funcSwich(this)" id="switch_sysman" <?php if($data["uri"]["seg"][0] == "sysManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">系统设置</a>
</li>
<?php if($data["userInfo"] != []){ ?>
<?php if($data["userInfo"]["role"] != 2){ ?>
<li onclick="funcSwich(this)" id="switch_devman" <?php if($data["uri"]["seg"][0] == "devManage"){echo "class='active'";} ?> >
<a tabindex="-1" href="#">设备管理</a>
</li>
<li onclick="funcSwich(this)" id="switch_userman" <?php if($data["uri"]["seg"][0] == "userManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">用户管理</a>
</li>
<li onclick="funcSwich(this)" id="switch_orgman" <?php if($data["uri"]["seg"][0] == "orgManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">组织管理</a>
</li>
<li class="divider"></li>
<li onclick="funcSwich(this)" id="switch_sysman" <?php if($data["uri"]["seg"][0] == "sysManage"){echo "class='active'";} ?>>
<a tabindex="-1" href="#">系统设置</a>
</li>
<?php } ?>
<?php } ?>
</ul>
</li>
</ul>
......@@ -157,6 +161,22 @@ function gotoHome(){
window.location.href = "http://" + host + "?username=" + username + "&token=" + token ;
}
/* *************************************
* 进入个人主页
************************************** */
function gotoProfile(){
var host = window.location.host;
var username = $.cookie('username');
var token = $.cookie('token');
if(username == undefined){
username = "";
}
if(token == undefined){
token = "";
}
window.location.href = "http://" + host + "/home/profilePage?username=" + username + "&token=" + token ;
}
function alertMes(){
alert("你有10新消息!");
......
......@@ -12,6 +12,9 @@
<li <?php if($data["uri"]["seg"][1] == "showDevDetail"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_show_dev_detail">
<a><i class="icon-chevron-right"></i> 设备详情</a>
</li>
<li <?php if($data["uri"]["seg"][1] == "profilePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_profile">
<a><i class="icon-chevron-right"></i> 个人主页</a>
</li>
</ul>
</div>
</div>
......@@ -39,6 +42,8 @@
window.location.href = "http://" + host + "/home/showDevs" + "?username=" + username + "&token=" + token;
}else if(id == "left_show_dev_detail"){
window.location.href = "http://" + host + "/home/showDevDetail" + "?username=" + username + "&token=" + token;
}else if(id == "left_profile"){
window.location.href = "http://" + host + "/home/profilePage" + "?username=" + username + "&token=" + token;
}
}
......
<?php $data = $this->data; ?>
<?= view("header.php",$data); ?>
<?= view("home/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
<div style="width:100%;min-height:700px;">
<?php if(count($data["userInfo"]) == 0){ ?>
<div style="width:500px;height:100px;padding-top:150px;margin:auto;">
<h1 style="width:100%;text-align:center;">我只是个过客</h1>
<a href="<?= base_url().'/'; ?>sign/loginPage" style="margin:auto;display:block;width:100%;text-align:center;font-size:20px;text-decoration:underline;"> 我要去登录... </a>
</div>
<?php }else{ ?>
<div style="width:800px;min-height:500px;_background:pink;margin:auto;text-align:center;padding-top:100px;">
<div style="border-style: solid;border-width: 1px;border-color: #cccccc;padding: 10px;box-shadow: 0px 0px 5px #cccccc inset;border-radius: 5px;">
<h1 style="width:100%;text-align:center;">我的信息</h1>
<table>
<tr>
<td>
<label>用户id:</label>
<input disabled class="input-xlarge focused" id="user_id" type="text" value="<?= $data["userInfo"]["id"] ?>" style="display:inline;margin: 0px;width:300px;">
</td>
<td>
<label>用户名:</label>
<input disabled class="input-xlarge focused" id="user_name" type="text" value="<?= $data["userInfo"]["username"] ?>" style="display:inline;margin: 0px;width:300px;">
</td>
</tr>
<tr>
<td>
<label>昵称:</label>
<input disabled class="input-xlarge focused" id="user_nick" type="text" value="<?= $data["userInfo"]["nick"] ?>" style="display:inline;margin: 0px;width:300px;">
</td>
<td>
<label>密码:</label>
<input disabled class="input-xlarge focused" id="user_password" type="text" value="" style="display:inline;margin: 0px;width:300px;">
</td>
</tr>
<tr>
<td>
<label>角色:</label>
<select disabled id="user_role" style="display:inline;margin: 0px;width:314px;height:32px;">
<option value='0' <?php if($data["userInfo"]["role"] == 0){echo 'selected=selected';} ?>>超级管理员</option>
<option value='1' <?php if($data["userInfo"]["role"] == 1){echo 'selected=selected';} ?>>管理员</option>
<option value='2' <?php if($data["userInfo"]["role"] == 2){echo 'selected=selected';} ?>>普通用户</option>
</select>
</td>
<td>
<label>部门:</label>
<select disabled id="user_org_section" style="display:inline;margin: 0px;width:314px;height:32px;">
<?php for($i = 0;$i < count($data["orgSections"]);$i++){ ?>
<option <?php if($data["orgSections"][$i]["id"] == $data["userInfo"]["org_section_id"]){echo 'selected=selected';} ?> value='<?= $data["orgSections"][$i]["id"]?>'><?= $data["orgSections"][$i]["org_section_name"]?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td><button data-dismiss="modal" class="btn btn-primary" style="width:50%;" onclick="modifyProfileInfo(this)">修改信息</button></td>
<td><button data-dismiss="modal" class="btn btn-primary" style="width:50%;" onclick="submitProfileInfo()">提交信息</button></td>
</tr>
</table>
</div>
</div>
<?php } ?>
</div>
</div>
<?= view("footer.php",$data); ?>
<style>
label {
display: inline-block !important;
width: 65px !important;
text-align: right;
}
td label,input,select,button {
margin: 10px 0px;
}
</style>
<script>
/*****************************************************
* 点击修改个人信息
*****************************************************/
var infoModify = 0; //是否处于修改信息状态
function modifyProfileInfo(e){
if(infoModify == 0){
$("#user_name").removeAttr("disabled");
$("#user_nick").removeAttr("disabled");
$("#user_password").removeAttr("disabled");
$("#user_role").removeAttr("disabled");
$("#user_org_section").removeAttr("disabled");
$(e).text("取消修改");
infoModify = 1;
}else if(infoModify == 1){
$("#user_name").attr("disabled","disabled");
$("#user_nick").attr("disabled","disabled");
$("#user_password").attr("disabled","disabled");
$("#user_role").attr("disabled","disabled");
$("#user_org_section").attr("disabled","disabled");
$(e).text("修改信息");
infoModify = 0;
}
}
/*****************************************************
* 提交个人信息
*****************************************************/
function submitProfileInfo(){
if(infoModify == 0){
alert("请点击修改信息!");
}else{
var userId = $("#user_id").val();
var username = $("#user_name").val();
var nick = $("#user_nick").val();
var password = $("#user_password").val()
if(password == ""){
alert("密码不能为空!");
return;
}
password = md5(password);
var role = $("#user_role").val()
var org_section_id = $("#user_org_section").val();
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/modifyUserInfo"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["userId"] = userId;
postData["username"] = username;
postData["nick"] = nick;
postData["password"] = password;
postData["role"] = role;
postData["org_section_id"] = org_section_id;
var isSure = confirm("确认修改信息?");
if(isSure == true){
$.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>
......@@ -8,7 +8,7 @@
<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>
<button class="btn btn-primary" href="#showBorrowWindow" data-toggle="modal" userId='<?php if($data["userInfo"] != []){ echo $data["userInfo"]["id"];}else{ echo "0";}?>' onclick="showBorrowWindow(this)">签 借</button>
<?php } ?>
</div>
......@@ -76,31 +76,43 @@
</td>
<td>
<label>第一分类:</label>
<input disabled class="input-xlarge focused" id="dev_first_category_show" type="text" value="<?= $data["devInfo"]["first_category_id"] ?>">
<select disabled id="dev_first_category_show" style="display:inline;margin: 0px;width:73%;height:32px;" onchange="getSecondCategory_edit(this)">
<?php for($i = 0;$i < count($data["category"]["firstCategory"]);$i++){ ?>
<option value='<?= $data["category"]["firstCategory"][$i]["id"] ?>' <?php if($data["category"]["firstCategory"][$i]["id"] == $data["devInfo"]["first_category_id"]){echo 'selected="selected"';}?>><?= $data["category"]["firstCategory"][$i]["category_name"] ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>
<label>第二分类:</label>
<input disabled class="input-xlarge focused" id="dev_second_category_show" type="text" value="<?= $data["devInfo"]["second_category_id"] ?>">
<select disabled id="dev_second_category_show" style="display:inline;margin: 0px;width:73%;height:32px;">
<?php for($i = 0;$i < count($data["category"]["secondCategory"]);$i++){ ?>
<option value='<?= $data["category"]["secondCategory"][$i]["id"] ?>' <?php if($data["category"]["secondCategory"][$i]["id"] == $data["devInfo"]["second_category_id"]){echo 'selected="selected"';}?>><?= $data["category"]["secondCategory"][$i]["category_name"] ?></option>
<?php } ?>
</select>
</td>
<td>
<label>所属部门:</label>
<input disabled class="input-xlarge focused" id="dev_org_section_show" type="text" value="<?= $data["devInfo"]["org_section_id"] ?>">
<select disabled id="dev_org_section_show" style="display:inline;margin: 0px;width:73%;height:32px;">
<?php for($i = 0;$i < count($data["orgSections"]);$i++){ ?>
<option value='<?= $data["orgSections"][$i]["id"] ?>' <?php if($data["orgSections"][$i]["id"] == $data["devInfo"]["org_section_id"]){echo 'selected="selected"';}?>><?= $data["orgSections"][$i]["org_section_name"] ?></option>
<?php } ?>
</select>
</td>
<td>
<label>设备状态:</label>
<input disabled class="input-xlarge focused" id="dev_status_show" type="text" value="<?= $data["devInfo"]["dev_status"] ?>">
<input disabled class="input-xlarge focused" id="dev_status_show" type="text" value="<?php if($data["devInfo"]["borrow_status"] == 0 || $data["devInfo"]["borrow_status"] == "" || $data["devInfo"]["borrow_status"] == 1){ echo "未借出";}else if($data["devInfo"]["borrow_status"] == 2){echo "已借出";}?>">
</td>
<td>
<label style="color:red;">签借人:</label>
<input disabled class="input-xlarge focused" id="dev_borrower_show" type="text" value="">
<input disabled class="input-xlarge focused" id="dev_borrower_show" type="text" borrower_id="<?= $data["devInfo"]["user_id"] ?>" value="<?= $data["devInfo"]["borrower"] ?>">
</td>
</tr>
<tr>
<td>
<label>借出时间:</label>
<input disabled class="input-xlarge focused" id="dev_borrow_time_show" type="text" value="">
<input disabled class="input-xlarge focused" id="dev_borrow_time_show" type="text" value="<?php if($data["devInfo"]["borrow_status"] == 2){echo $data["devInfo"]["borrow_time"];} ?>">
</td>
<td>
<label>归还时间:</label>
......@@ -153,8 +165,48 @@
</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 style="width:100%;">签借原因:</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 style="width:100%;">输入名字:</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 style="width:100%;">签借原因:</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>
<?= view("footer.php",$data); ?>
<style>
td {
......@@ -205,4 +257,64 @@ function showDevById(){
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 = $("#dev_id_show").val()
$("#send_borrow_button").attr("devId",devId);
}else{
var devId = $("#dev_id_show").val()
$("#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 = $("#user_name").val();
}else{
var borrower = $(e).attr("user_name");
}
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/addDevBorrowInfo"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
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"){
alert(data.message);
// location.reload();
}else{
alert(data.message);
}
}
});
}
</script>
\ No newline at end of file
<?php $data = $this->data; ?>
<?php $pager = \Config\Services::pager(); ?>
<?= view("header.php",$data); ?>
<?= view("home/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
......@@ -21,6 +19,7 @@
<tr>
<th>#</th>
<th>设备名</th>
<th>设备id</th>
<th>设备编号</th>
<th>品牌</th>
<th>型号</th>
......@@ -36,13 +35,18 @@
<tr dev_id='<?= $data["devices"][$i]["id"] ?>'>
<td><?= $i +1 ?></td>
<td><?= $data["devices"][$i]["dev_name"] ?></td>
<td><?= $data["devices"][$i]["id"] ?></td>
<td><?= $data["devices"][$i]["dev_code"] ?></td>
<td><?= $data["devices"][$i]["dev_brand"] ?></td>
<td><?= $data["devices"][$i]["dev_model"] ?></td>
<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>
<?php if($data["devices"][$i]["borrow_status"] != 2){ ?>
<td></td>
<?php }else{ ?>
<td><span style="padding:4px;" class="label label-success" title="系统用户"><?= $data["devices"][$i]["borrower"] ?></span></td>
<?php } ?>
<td>
<button class="btn btn-primary btn-mini" onclick="gotoShowDevDetail(this)">详情</button>
<?php if($data["devices"][$i]["borrow_status"] != 2){ ?>
......@@ -55,7 +59,7 @@
</table>
</div>
</div>
<div class="pagination" style="text-align:right;padding-right:30px;">
<div class="pagination" style="text-align:right;padding-right:30px;height:50px;">
<div>
<div style="display:inline;">
<select id="per_page" size="1" style="width:100px;margin:0px;float:right;height:30px;margin-left:5px;" onchange="perPageChange()">
......@@ -115,6 +119,7 @@
<?php } ?>
</div>
</div>
<?= view("footer.php",$data); ?>
<style>
.modal-body table tr td label,input,select {
......@@ -197,13 +202,23 @@ function sendBorrow(e){
var devId = $(e).attr("devId");
var comment = $("#borrow_comment").val();
if(userId == 0){
var borrower = $(e).attr("user_name");
var borrower = $("#user_name").val();
}else{
var borrower = $(e).attr("user_name");
}
var host = window.location.host;
var url = "http://" + host + "/devManageCtr/addDevBorrowInfo"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["userId"] = userId;
postData["devId"] = devId;
postData["comment"] = comment;
......@@ -216,7 +231,8 @@ function sendBorrow(e){
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
location.reload();
alert(data.message);
// location.reload();
}else{
alert(data.message);
}
......
......@@ -102,6 +102,16 @@ function addOrgSection(){
var host = window.location.host;
var url = "http://" + host + "/orgManageCtr/addOrgSection"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["org_section_name"] = org_section_name;
postData["org_section_detail"] = org_section_detail;
if(org_section_name == ""){
......@@ -117,7 +127,7 @@ function addOrgSection(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -132,6 +142,16 @@ function delOrgSection(e){
var host = window.location.host;
var url = "http://" + host + "/orgManageCtr/delOrgSection"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["org_section_id"] = orgSectionId;
var isSure = confirm("确定删除该部门?");
if(isSure == true){
......@@ -145,7 +165,7 @@ function delOrgSection(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -175,6 +195,16 @@ function updateOrgSection(){
var host = window.location.host;
var url = "http://" + host + "/orgManageCtr/updateOrgSection"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["org_section_id"] = org_section_id;
postData["org_section_name"] = org_section_name;
postData["org_section_detail"] = org_section_detail;
......@@ -188,7 +218,7 @@ function updateOrgSection(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......
......@@ -17,7 +17,7 @@
<form class="form-signin">
<h2 class="form-signin-heading">请登录...</h2>
<input type="text" class="input-block-level" placeholder="用户名" id="username">
<input type="password" class="input-block-level" placeholder="密码" id="password">
<input type="password" class="input-block-level" placeholder="密码" id="password" onkeydown="loginKeyEnter(this,event)">
<button class="btn btn-large btn-primary" type="button" onclick="login()">登 录</button>
<a href="<?= base_url().'/'; ?>sign/registerPage" style="margin:12px;float:right;">没有账号,去注册?</a>
<a href="<?= base_url().'/'; ?>" style="margin:12px;float:right;">首页</a>
......@@ -60,6 +60,41 @@ function login(){
});
}
}
/* *************************************
* 登录
************************************** */
function loginKeyEnter(a,e){
var username = $("#username").val();
var password = $("#password").val();
password = md5(password);
if(e.keyCode == 13){
if(password == "" || username == ""){
alert("用户名或密码不能为空!");
}else{
var host = window.location.host;
var url = "http://" + host + "/signCtr/login"
var postData = {};
postData["username"] = username;
postData["password"] = password;
$.ajax({
url: url,
data: JSON.stringify(postData),
type: "POST",
dataType: "json",
contentType:"application/json",
success: function(data) {
if(data.status == "200"){
$.cookie('token', data.user.token, { expires: 7, path: '/' });
$.cookie('username', data.user.username, { expires: 7, path: '/' });
window.location.href = "http://" + host + "?username=" + data.user.username + "&token=" + data.user.token ;
}else{
alert(data.message);
}
}
});
}
}
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -47,7 +47,7 @@
</table>
</div>
</div>
<div class="pagination" style="text-align:right;padding-right:30px;">
<div class="pagination" style="text-align:right;padding-right:30px;height:50px;">
<div style="display:inline;">
<select id="per_page" size="1" style="width:100px;margin:0px;float:right;height:30px;margin-left:5px;" onchange="perPageChange()">
<option value="10" <?php if($data["pageInfo"]["perPage"] == 15){ echo 'selected="selected"';}?>>10 条/页</option>
......@@ -184,6 +184,16 @@ function delUser(e){
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/delUser"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["userId"] = userId;
var isSure = confirm("确定删除该用户吗?");
if(isSure == true){
......@@ -197,7 +207,7 @@ function delUser(e){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -218,6 +228,16 @@ function addUser(){
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/addUser"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["username"] = username;
postData["nick"] = nick;
postData["password"] = password;
......@@ -234,7 +254,7 @@ function addUser(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......@@ -266,6 +286,16 @@ function showEditUserWindow(e){
var host = window.location.host;
var url = "http://" + host + "/orgManageCtr/getAllOrgSections"
postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
$.ajax({
url: url,
data: JSON.stringify(postData),
......@@ -309,6 +339,16 @@ function updateUserInfo(){
var host = window.location.host;
var url = "http://" + host + "/userManageCtr/editUser"
var postData = {};
var loginName = $.cookie('username');
var token = $.cookie('token');
if(loginName == undefined){
loginName = "";
}
if(token == undefined){
token = "";
}
postData["loginName"] = loginName;
postData["token"] = token;
postData["userId"] = userId;
postData["username"] = username;
postData["nick"] = nick;
......@@ -326,7 +366,7 @@ function updateUserInfo(){
if(data.status == "200"){
location.reload();
}else{
alert(data.message);
}
}
});
......
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