|
|
@ -13,7 +13,6 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
public $POST; |
|
|
|
public $POST; |
|
|
|
public $ExcelSetModel; |
|
|
|
public $ExcelSetModel; |
|
|
|
public function init() { |
|
|
|
public function init() { |
|
|
|
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');} |
|
|
|
|
|
|
|
$this->Squirrelmodel = new SquirrelModel(); |
|
|
|
$this->Squirrelmodel = new SquirrelModel(); |
|
|
|
$this->CageModel = new CageModel(); |
|
|
|
$this->CageModel = new CageModel(); |
|
|
|
$this->CageSetModel=new CageSetModel(); |
|
|
|
$this->CageSetModel=new CageSetModel(); |
|
|
@ -84,7 +83,7 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
//查询笼位号 |
|
|
|
//查询笼位号 |
|
|
|
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow(); |
|
|
|
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow(); |
|
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; |
|
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; |
|
|
|
|
|
|
|
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
$data['type'] = $this->POST['type']; |
|
|
|
$data['type'] = $this->POST['type']; |
|
|
|
$data['number'] = "SN00000".$CageNum; |
|
|
|
$data['number'] = "SN00000".$CageNum; |
|
|
|
if($CageNum>9) $data['number'] = "SN0000".$CageNum; |
|
|
|
if($CageNum>9) $data['number'] = "SN0000".$CageNum; |
|
|
@ -101,11 +100,10 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?Tool_Fnc::apiMsg('请填写备注', '500'):Tool_Fnc::safe_string($this->POST['remark']); |
|
|
|
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?Tool_Fnc::apiMsg('请填写备注', '500'):Tool_Fnc::safe_string($this->POST['remark']); |
|
|
|
$data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']); |
|
|
|
$data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']); |
|
|
|
$data['created'] = date('Y-m-d H:i:s',time()); |
|
|
|
$data['created'] = date('Y-m-d H:i:s',time()); |
|
|
|
$data['c_user_id'] = $_SESSION['uid']; |
|
|
|
|
|
|
|
//判断鼠笼鼠的数量是否可以容纳 |
|
|
|
//判断鼠笼鼠的数量是否可以容纳 |
|
|
|
if(!$this->Squirrelmodel->isFull($data['cage'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500'); |
|
|
|
if(!$this->Squirrelmodel->isFull($data['cage'],$this->POST['uid'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500'); |
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
$params['user_id'] = $_SESSION['uid']; |
|
|
|
$params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params); |
|
|
|
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params); |
|
|
|
//根据生日获取各个提醒时间 |
|
|
|
//根据生日获取各个提醒时间 |
|
|
|
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday']))); |
|
|
|
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday']))); |
|
|
@ -146,6 +144,7 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
* } |
|
|
|
* } |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function editAction(){ |
|
|
|
public function editAction(){ |
|
|
|
|
|
|
|
$data['uid'] = empty($this->POST['uid'])||!isset($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):Tool_Fnc::safe_string($this->POST['id']); |
|
|
|
$data['id'] = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($this->POST['id']); |
|
|
|
$data['id'] = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($this->POST['id']); |
|
|
|
$data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']); |
|
|
|
$data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']); |
|
|
|
$data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请填写生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']); |
|
|
|
$data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请填写生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']); |
|
|
@ -155,13 +154,9 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
$data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($this->POST['gene']); |
|
|
|
$data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($this->POST['gene']); |
|
|
|
$data['hair_color'] =empty($this->POST['hair_color'])||!isset($this->POST['hair_color'])?Tool_Fnc::apiMsg('请选择毛色', '500'):Tool_Fnc::safe_string($this->POST['hair_color']); |
|
|
|
$data['hair_color'] =empty($this->POST['hair_color'])||!isset($this->POST['hair_color'])?Tool_Fnc::apiMsg('请选择毛色', '500'):Tool_Fnc::safe_string($this->POST['hair_color']); |
|
|
|
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']); |
|
|
|
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']); |
|
|
|
// $data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']); |
|
|
|
|
|
|
|
$data['created'] = date('Y-m-d H:i:s',time()); |
|
|
|
$data['created'] = date('Y-m-d H:i:s',time()); |
|
|
|
// $data['c_user_id'] = $_SESSION['uid']; |
|
|
|
|
|
|
|
// //判断鼠笼鼠的数量是否可以容纳 |
|
|
|
|
|
|
|
// if(!$this->Squirrelmodel->isFull($data['cage'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500'); |
|
|
|
|
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
$params['user_id'] = $_SESSION['uid']; |
|
|
|
$params['user_id'] = $data['uid']; |
|
|
|
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params); |
|
|
|
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params); |
|
|
|
//根据生日获取各个提醒时间 |
|
|
|
//根据生日获取各个提醒时间 |
|
|
|
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday']))); |
|
|
|
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday']))); |
|
|
|