鼠笼管理系统
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.
 
 
 
 

101 lines
4.3 KiB

<?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;
}
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'];
//笼位设置
$val['cageSet'] = empty($CageSetModel->getsetinfo($params))?[]:$CageSetModel->getsetinfo($params);
$val['cageisSet'] = empty($val['cageSet'])?0:1;
//鼠设置
$val['squirrelSet'] = empty($SquirrelSetModel->getsetinfo($params))?[]:$SquirrelSetModel->getsetinfo($params);
$val['squirrelisSet'] = empty($val['squirrelSet'])?0:1;
//excel导出设置
$val['excelSet'] = empty($ExcelSetModel->getsetinfo($params))?[]:$ExcelSetModel->getsetinfo($params);
$val['excelisSet'] = empty($val['excelSet'])?0:1;
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
public function remindAction(){
}
public function remindlistAction(){
}
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'];
$id = $_POST['id'];
if($table=='ExcelSetModel'){
$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');
print_r($_POST['now_squirrel']);
print_r($array);
print_r(array_merge(array_diff($array,$_POST['now_squirrel']),array_diff($_POST['now_squirrel'],$array)));die;
}
}
}