更新人事离职
This commit is contained in:
parent
3cdab12c95
commit
b0a044009b
|
@ -116,47 +116,37 @@ class UserPersonal extends ApiController
|
|||
public function leave_add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$count = Db::name('Department')->where(['leader_id' => $param['uid']])->count();
|
||||
if($count>0){
|
||||
return to_assign(1,'请先撤销该员工的部门负责人头衔再添加离职档案');
|
||||
}
|
||||
$param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0;
|
||||
if ($param['id'] > 0) {
|
||||
$param['update_time'] = time();
|
||||
$res = Db::name('PersonalQuit')->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} else {
|
||||
$param['create_time'] = time();
|
||||
$param['admin_id'] = $this->uid;
|
||||
$res = Db::name('PersonalQuit')->strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $res, $param);
|
||||
}
|
||||
if ($res!==false) {
|
||||
Db::name('Admin')->where('id', $param['uid'])->update(['status' => 2]);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$where = array();
|
||||
if ($id>0) {
|
||||
$where['p.id'] = array('eq', $id);
|
||||
$detail = Db::name('PersonalQuit')
|
||||
->field('p.*,u.name as name,l.name as lead_admin_name,d.title as department')
|
||||
->alias('p')
|
||||
->join('admin u', 'p.uid = u.id', 'LEFT')
|
||||
->join('admin l', 'p.lead_admin_id = l.id', 'LEFT')
|
||||
->join('department d', 'u.did = d.id', 'LEFT')
|
||||
->where($where)
|
||||
->find();
|
||||
$this_uids_name = Db::name('Admin')->where([['id','in', $detail['connect_uids']]])->column('name');
|
||||
$detail['connect_names'] = implode(',', $this_uids_name);
|
||||
$detail['quit_time'] = date('Y-m-d', $detail['quit_time']);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
if (empty($param['uid'])) {
|
||||
$this->apiError("请选择离职人员");
|
||||
}
|
||||
if (empty($param['lead_admin_id'])) {
|
||||
$this->apiError("请选择部门负责人");
|
||||
}
|
||||
if (empty($param['connect_uids'])) {
|
||||
$this->apiError("请选择交接人员");
|
||||
}
|
||||
if (empty($param['quit_time'])) {
|
||||
$this->apiError("请选择离职时间");
|
||||
}
|
||||
$count = Db::name('Department')->where(['leader_id' => $param['uid']])->count();
|
||||
if($count>0){
|
||||
$this->apiError("请先撤销该员工的部门负责人头衔再添加离职档案");
|
||||
}
|
||||
$param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0;
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
$param['update_time'] = time();
|
||||
$res = Db::name('PersonalQuit')->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} else {
|
||||
$param['create_time'] = time();
|
||||
$param['admin_id'] = JWT_UID;
|
||||
$res = Db::name('PersonalQuit')->strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $res, $param);
|
||||
}
|
||||
if ($res!==false) {
|
||||
Db::name('Admin')->where('id', $param['uid'])->update(['status' => 2]);
|
||||
}
|
||||
$this->apiError("操作成功");
|
||||
}
|
||||
|
||||
//删除离职档案
|
||||
|
|
Loading…
Reference in New Issue