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']; $data = $_POST; unset($data['table']); $model = new $table(); if($table=='ExcelSetModel'){ $data['now_squirrel'] = $this->excelarray($data['now_squirrel']); $data['handle_squirrel'] = $this->excelarray($data['handle_squirrel']); } 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)); } public function updatePassAction(){ } public function updatePsdAction(){ // $_P[] } }