鼠笼管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
5.6 KiB

7 months ago
<?php
class Admin_UserController extends Ctrl_Admin{
public function indexAction(){
}
public function getlistAction(){
$UserModel = new UserModel();
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$sql = "select * from {$UserModel->table}";
$count = $UserModel->query($sql);
$sql = "select * from {$UserModel->table} order by id desc limit {$offset},{$limit} ";
$data = $UserModel->query($sql);
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
7 months ago
public function usersetAction()
{
}
public function usersetlistAction(){
$UserModel = new UserModel();
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$sql = "select * from {$UserModel->table}";
$count = $UserModel->query($sql);
$sql = "select * from {$UserModel->table} order by id desc limit {$offset},{$limit} ";
$data = $UserModel->query($sql);
$CageSetModel = new CageSetModel();
$SquirrelSetModel = new SquirrelSetModel();
$ExcelSetModel = new ExcelSetModel();
foreach($data as $key => &$val){
$params['user_id'] = $val['id'];
//笼位设置
7 months ago
$val['cageSet'] = empty($CageSetModel->getsetinfo($params))?[]:$CageSetModel->getsetinfo($params);
$val['cageisSet'] = empty($val['cageSet'])?0:1;
7 months ago
//鼠设置
7 months ago
$val['squirrelSet'] = empty($SquirrelSetModel->getsetinfo($params))?[]:$SquirrelSetModel->getsetinfo($params);
$val['squirrelisSet'] = empty($val['squirrelSet'])?0:1;
7 months ago
//excel导出设置
7 months ago
$val['excelSet'] = empty($ExcelSetModel->getsetinfo($params))?[]:$ExcelSetModel->getsetinfo($params);
$val['excelisSet'] = empty($val['excelSet'])?0:1;
7 months ago
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
public function remindAction(){
}
public function remindlistAction(){
}
7 months ago
public function editAction(){
$CageSetModel = new CageSetModel();
$SquirrelSetModel = new SquirrelSetModel();
$ExcelSetModel = new ExcelSetModel();
$UserModel = new UserModel();
$data['id'] = empty($_POST['id'])||!isset($_POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['id']);
$field = empty($_POST['field'])||!isset($_POST['field'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['field']);
$status = empty($_POST['status'])||!isset($_POST['status'])?0:Tool_Fnc::safe_string($_POST['status']);
$data[$field] = $status;
if($field=='status' && $status==1){
//查询默认设置
$cage = $CageSetModel->field("*")->where("c_user_id=0")->fRow();
unset($cage['id']);
$cage['c_user_id'] = $data['id'];
$CageSetModel->insert($cage);
$squirrel = $SquirrelSetModel->field("*")->where("user_id=0")->fRow();
unset($squirrel['id']);
$squirrel['user_id'] = $data['id'];
$SquirrelSetModel->insert($squirrel);
$excel = $ExcelSetModel->field("*")->where("user_id=0")->fRow();
unset($excel['id']);
$excel['user_id'] = $data['id'];
$ExcelSetModel->insert($excel);
}
if(!$UserModel->update($data)) Tool_Fnc::ajaxMsg('变更失败', '500');
Tool_Fnc::ajaxMsg('变更成功', '1');
}
public function userseteditAction(){
$table = $_POST['table'];
6 months ago
$data = $_POST;
unset($data['table']);
$model = new $table();
7 months ago
if($table=='ExcelSetModel'){
6 months ago
$data['now_squirrel'] = $this->excelarray($data['now_squirrel']);
$data['handle_squirrel'] = $this->excelarray($data['handle_squirrel']);
7 months ago
}
6 months ago
if(!$model->update($data)) Tool_Fnc::ajaxMsg('变更失败', '500');
Tool_Fnc::ajaxMsg('变更成功', '1');
}
public function excelarray($excelarray){
$array = array('number'=>'on','sex'=>'on','birthday'=>'on','strains_id'=>'on','gene'=>'on','cage_num'=>'on','content'=>'on','hair_color'=>'on','fenlong'=>'on','fanzhi'=>'on','breeding_tag'=>'on','see_bole_tag'=>'on','give_medicine'=>'on','father'=>'on','mother'=>'on','remark'=>'on');
$diff = array_diff_key($array,$excelarray);
foreach($diff as $key => &$val){
$val = false;
}
foreach($excelarray as $ke => &$va){
$va = true;
}
return json_encode(array_merge($diff,$excelarray));
7 months ago
}
6 months ago
public function passwordAction(){
6 months ago
}
public function updatePsdAction(){
6 months ago
$password = empty($_POST['password'])||!isset($_POST['password'])?Tool_Fnc::apiMsg('请输入新密码', '500'):Tool_Fnc::safe_string($_POST['password']);
$repassword = empty($_POST['repassword'])||!isset($_POST['repassword'])?Tool_Fnc::apiMsg('请确认新密码', '500'):Tool_Fnc::safe_string($_POST['repassword']);
$id = $_SESSION['admin']['id'];
$adminModel = new AdminModel();
if($password!=$repassword) Tool_Fnc::ajaxMsg('两次输入密码不一致', '500');
$up['id'] = $id;
$up['password'] = md5($password);
if(!$adminModel->update($up)) Tool_Fnc::ajaxMsg('密码未改变', '500');
Tool_Fnc::ajaxMsg('密码已变更', '1');
6 months ago
}
7 months ago
}