| | |
| | | // 启动事务 |
| | | Db::startTrans(); |
| | | try { |
| | | Db::name('AttendanceGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); |
| | | // Db::name('PositionGroup')->where(['pid' => $param['id']])->delete(); |
| | | // foreach ($param['group_id'] as $k => $v) { |
| | | // $data[$k] = [ |
| | | // 'pid' => $param['id'], |
| | | // 'group_id' => $v, |
| | | // 'create_time' => time(), |
| | | // ]; |
| | | // } |
| | | // Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data); |
| | | $setData = [ |
| | | 'name' => $param['name'], |
| | | 'type' => $param['type'], |
| | | 'is_del' => 0, |
| | | 'create_time' => time(), |
| | | 'mon_work_plan_id' => isset($param['work1']) && $param['work1'] == "on" && isset($param['mon_work_plan_id']) ? intval($param['mon_work_plan_id']) : 0, |
| | | 'tue_work_plan_id' => isset($param['work2']) && $param['work2'] == "on" && isset($param['tue_work_plan_id']) ? intval($param['tue_work_plan_id']) : 0, |
| | | 'wed_work_plan_id' => isset($param['work3']) && $param['work3'] == "on" && isset($param['wed_work_plan_id']) ? intval($param['wed_work_plan_id']) : 0, |
| | | 'thur_work_plan_id' => isset($param['work4']) && $param['work4'] == "on" && isset($param['thur_work_plan_id']) ? intval($param['thur_work_plan_id']) : 0, |
| | | 'fri_work_plan_id' => isset($param['work5']) && $param['work5'] == "on" && isset($param['fri_work_plan_id']) ? intval($param['fri_work_plan_id']) : 0, |
| | | 'sat_work_plan_id' => isset($param['work6']) && $param['work6'] == "on" && isset($param['sat_work_plan_id']) ? intval($param['sat_work_plan_id']) : 0, |
| | | 'sun_work_plan_id' => isset($param['work7']) && $param['work7'] == "on" && isset($param['sun_work_plan_id']) ? intval($param['sun_work_plan_id']) : 0, |
| | | ]; |
| | | Db::name('AttendanceGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($setData); |
| | | // 删除用户关联 |
| | | Db::name('AttendanceUserLink')->where(['group_id' => $param['id']])->delete(); |
| | | // 删除时间 |
| | | $specialDateIds = Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $param['id']])->column('special_date_id'); |
| | | Db::name('AttendanceSpecialDate')->where('id', 'in', $specialDateIds)->delete(); |
| | | Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $param['id']])->delete(); |
| | | // 插入用户关联表 |
| | | $this->model->insertUserLinks(intval($param['id']), $param['attendance_participants_id'], 1); |
| | | $this->model->insertUserLinks(intval($param['id']), $param['attendance_not_participants_id'], 2); |
| | | |
| | | // 插入时间表 |
| | | if (isset($param['necessaryTime'])) { |
| | | $this->model->insertSpecialDates(intval($param['id']), $param['necessaryTime'], 1); |
| | | } |
| | | if (isset($param['unNecessaryTime'])) { |
| | | $this->model->insertSpecialDates(intval($param['id']), $param['unNecessaryTime'], 2); |
| | | } |
| | | add_log('edit', $param['id'], $param); |
| | | //清除菜单\权限缓存 |
| | | // clear_cache('adminMenu'); |
| | | // clear_cache('adminRules'); |
| | | // 提交事务 |
| | | Db::commit(); |
| | | } catch (\Exception $e) { |
| | |
| | | $userName1[] = $value['userInfo']['name']; |
| | | $userId1[] = $value['userInfo']['id']; |
| | | } |
| | | $detail['attendance_participants'] = implode(",",$userName1); |
| | | $detail['attendance_participants_id'] = implode(",",$userId1); |
| | | $detail['attendance_participants'] = implode(",", $userName1); |
| | | $detail['attendance_participants_id'] = implode(",", $userId1); |
| | | $user2 = array_values(array_filter($mappingUsers, function ($item) { |
| | | return $item['type'] == 2; |
| | | })); |
| | |
| | | $userName2[] = $value['userInfo']['name']; |
| | | $userName2[] = $value['userInfo']['id']; |
| | | } |
| | | $detail['attendance_not_participants'] = implode(",",$userName2); |
| | | $detail['attendance_not_participants_id'] = implode(",",$userId2); |
| | | $detail['attendance_not_participants'] = implode(",", $userName2); |
| | | $detail['attendance_not_participants_id'] = implode(",", $userId2); |
| | | // 获取关联的班次 |
| | | $detail['mon_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['mon_work_plan_id']])->find(); |
| | | $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['mon_work_plan_id']])->column('work_time_id'); |
| | |
| | | return view(); |
| | | } |
| | | } |
| | | |
| | | // 删除 |
| | | public function delete() |
| | | { |
| | | $id = get_params("id"); |
| | | if (Db::name('AttendanceGroup')->where('id', $id)->update(['is_del' => 1]) !== false) { |
| | | add_log('delete', $id, [], '考勤组'); |
| | | return to_assign(0, "删除成功"); |
| | | } else { |
| | | return to_assign(1, "删除失败"); |
| | | } |
| | | } |
| | | } |