diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 184095c..d4955db 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -72,98 +72,6 @@ class Schedule extends Backend return $this->view->fetch(); } - public function custom_index() - { - //当前是否为关联查询 - $this->relationSearch = true; - //设置过滤方法 - $this->request->filter(['strip_tags', 'trim']); - if ($this->request->isAjax()) { - - - $filter = $this->request->param('filter'); - $filter = json_decode($filter, true); - - $startDate = date('Y-m-01'); - $endDate = date('Y-m-t'); - - if (isset($filter['timetype']) && $filter['timetype'] == 2) { - $startDate = date('Y-m-d', strtotime('monday this week')); - $endDate = date('Y-m-d', strtotime('sunday this week')); - } - - $res = []; - - if (!$this->auth->isSuperAdmin()) { - $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); - } else{ - $admins = Db::name('admin')->field('id,nickname')->select(); - } - - $admins = array_column($admins, NULL, 'id'); - $adminIds = array_keys($admins); - - $adminNames = array_column($admins, 'nickname', 'id'); - - $tmpDate = $startDate; - $dates = []; - while(true) { - - if ($tmpDate > $endDate) { - break; - } - - foreach ($adminIds as $adminId) { - $res[$adminId][$tmpDate] = '无'; - $res[$adminId]['admin_id'] = $adminId; - $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_edit') ? 1 : 0; - } - - $dates[] = $tmpDate; - $tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400); - } - - $builder = $this->model - ->with([ - 'admin' - ]) - ->where('date', '>=', $startDate) - ->where('date', '<=', $endDate); - - if (!$this->auth->isSuperAdmin()) { - $builder = $builder->where('exec_admin_id', $this->auth->id); - } - - $queryData = $builder->select(); - foreach ($queryData as $queryDatum) { - $queryDatum = $queryDatum->toArray(); - - $adminId = $queryDatum['admin']['id']; - $date = $queryDatum['date']; - $type = $queryDatum['type']; - - if (isset($res[$adminId][$date])) { - $res[$adminId][$date] = $this->model->getTypeList()[$type]; - } - } - - - $res = array_values($res); - - $result = array("total" => count($res), "rows" => $res); - - return json($result); - } - - $timeType = [ - 1 => '本月排班', - 2 => '本周排班', - ]; - $this->view->assign("timetype", $timeType); - return $this->view->fetch(); - } - /** * 添加 * @@ -262,59 +170,4 @@ class Schedule extends Backend } $this->success(); } - - - public function editable() - { - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $date = $params['field']; - $adminId = $params['admin_id']; - - $value = $params[$date] ?? '无'; - $valueMap = [ - '无' => 0, - '早班' => 1, - '中班' => 2, - '晚班' => 3, - '行政班' => 4, - ]; - - if ($value == '无') { - $this->model->where('exec_admin_id', $adminId)->delete(); - $this->success(); - } - - $dbValue = $valueMap[$value]; - - $data = $this->model - ->where('date', '=', $date) - ->where('exec_admin_id', '=', $adminId) - ->find(); - - $nowTime = date('Y-m-d H:i:s'); - if (!empty($data)) { - $data->save([ - "date" => $date, - "exec_admin_id" => $adminId, - "type" => $dbValue, - "update_time" => $nowTime, - ]); - } - - $this->model->insert([ - "date" => $date, - "exec_admin_id" => $adminId, - "type" => $dbValue, - "create_time" => $nowTime, - "update_time" => $nowTime, - ]); - - $this->success(); - } } diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index 0f909de..745ce72 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -36,130 +36,6 @@ class Detail extends Backend * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ - public function custom_index() - { - //当前是否为关联查询 - $this->relationSearch = true; - //设置过滤方法 - $this->request->filter(['strip_tags', 'trim']); - - $items = Db::name('salary_item')->field('id,attr,type,name')->select(); - - $salaryItem = []; - foreach ($items as $item) { - $idAttr[$item['id']] = $item['attr']; - if ($item['attr'] == 'JXKHJL') { - $salaryItem[] = [ - 'id' => 'jx_total', - 'name' => '绩效提成', - ]; - } - $salaryItem[] = [ - 'id' => 'item_' . $item['id'], - 'name' => $item['name'], - ]; - } - $salaryItem[] = [ - 'id' => 'total', - 'name' => '总计', - ]; - - $month = date('Y-m-01'); - - if ($this->request->isAjax()) { - - - $filter = $this->request->param('filter'); - $filter = json_decode($filter, true); - - if (!empty($filter['month'])) { - $month = $filter['month'] . '-01'; - } - - $res = []; - - if (!$this->auth->isSuperAdmin()) { - $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); - } else{ - $admins = Db::name('admin')->field('id,nickname')->select(); - } - - $admins = array_column($admins, NULL, 'id'); - $adminIds = array_keys($admins); - - $adminNames = array_column($admins, 'nickname', 'id'); - - $builder = $this->model - ->where('salary_month', '=', $month); - if (!$this->auth->isSuperAdmin()) { - $builder = $builder->where('target_admin_id', $this->auth->id); - } - - $queryData = $builder->select(); - $queryRes = []; - foreach ($queryData as $queryDatum) { - $targetAdminId = $queryDatum['target_admin_id']; - $itemId = $queryDatum['item_id']; - $queryRes[$targetAdminId][$itemId] = $queryDatum['item_value']; - } - - $querySettleData = Db::name('salary_settle') - ->whereIn('target_admin_id', $adminIds) - ->where('salary_month', '=', $month) - ->field('id,target_admin_id,settle_status') - ->select(); - $querySettleRes = []; - foreach ($querySettleData as $querySettleDatum) { - $targetAdminId = $querySettleDatum['target_admin_id']; - $querySettleRes[$targetAdminId] = $querySettleDatum['settle_status']; - } - - - foreach ($adminIds as $adminId) { - $attrValue = []; - $total = 0; - foreach ($items as $item) { - - $res[$adminId]['target_admin_id'] = $adminId; - $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['month'] = $month; - - $itemKey = 'item_' . $item['id']; - - $value = 0; - - if (!empty($queryRes[$adminId][$item['id']])) { - $value = $this->clean_number($queryRes[$adminId][$item['id']]); - $total = $this->calc_total($total, $item['type'], $queryRes[$adminId][$item['id']]); - } - - $attrValue[$item['attr']] = $value; - if ($item['attr'] == 'TD') { - $value = $value . '%'; - } - $res[$adminId][$itemKey] = $value; - } - - $jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100; - $res[$adminId]['jx_total'] = $this->clean_number($jxTotal); - $res[$adminId]['total'] = $this->clean_number($total + $jxTotal); - $res[$adminId]['settle_status'] = $querySettleRes[$adminId] ?? 0; - } - - $res = array_values($res); - - $result = array("total" => count($res), "rows" => $res); - - - return json($result); - } - - $this->assignconfig("manage", $this->auth->check('salary/detail/custom_edit')); - $this->view->assign("month", $month); - $this->view->assign("salaryitem", json_encode($salaryItem)); - return $this->view->fetch(); - } - public function calc_total($total, $type, $value){ if ($type == 1) { return $total + $value; @@ -175,140 +51,6 @@ class Detail extends Backend return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.'); } - public function custom_add() - { - - if (false === $this->request->isPost()) { - - $items = Db::name('salary_item')->field('id,type,name')->select(); - - $typeMap = [ - 1 => '应发工资', - 2 => '应扣款项', - 3 => '其他' - ]; - $groupedItems = []; - foreach ($items as $item) { - $type = $item['type']; - $label = $typeMap[$type]; - $groupedItems[$label][] = $item; - } - - $this->view->assign('groupedItems', $groupedItems); - $this->view->assign('items', $items); - return $this->view->fetch(); - } - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $month = $params['salary_month'] . '-01'; - $targetAdminId = $params['target_admin_id']; - $salaryDetails = []; - - foreach ($params as $k => $v) { - if (!str_contains($k, 'item')) { - continue; - } - $salaryDetails[] = [ - 'target_admin_id' => $targetAdminId, - 'salary_month' => $month, - 'item_id' => explode('_', $k)[1], - 'item_value' => $v, - ]; - } - - Db::name('salary_detail') - ->where('salary_month', $month) - ->where('target_admin_id', $targetAdminId) - ->delete(); - - Db::name('salary_detail') - ->insertAll($salaryDetails); - - $this->success(); - } - - - public function custom_edit() - { - - if (false === $this->request->isPost()) { - - - $targetAdminId = $this->request->get('target_admin_id'); - $month = $this->request->get('month'); - - $row['salary_month'] = $month; - $row['target_admin_id'] = $targetAdminId; - - - $queryData = $this->model - ->where('salary_month', '=', $month) - ->where('target_admin_id', $targetAdminId) - ->select(); - $items = Db::name('salary_item')->field('id,name,type')->select(); - $queryData = array_column($queryData, NULL, 'item_id'); - - foreach ($items as $item) { - $itemKey = 'item_' . $item['id']; - $row[$itemKey] = !empty($queryData[$item['id']]) ? $queryData[$item['id']]['item_value'] : 0; - } - - $typeMap = [ - 1 => '应发工资', - 2 => '应扣款项', - 3 => '其他' - ]; - $groupedItems = []; - foreach ($items as $item) { - $type = $item['type']; - $label = $typeMap[$type]; - $groupedItems[$label][] = $item; - } - - $this->view->assign('groupedItems', $groupedItems); - $this->view->assign('items', $items); - $this->view->assign('row', $row); - return $this->view->fetch(); - } - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $month = $params['salary_month'] . '-01'; - $targetAdminId = $params['target_admin_id']; - $salaryDetails = []; - - foreach ($params as $k => $v) { - if (!str_contains($k, 'item')) { - continue; - } - $salaryDetails[] = [ - 'target_admin_id' => $targetAdminId, - 'salary_month' => $month, - 'item_id' => explode('_', $k)[1], - 'item_value' => $v, - ]; - } - - Db::name('salary_detail') - ->where('salary_month', $month) - ->where('target_admin_id', $targetAdminId) - ->delete(); - - Db::name('salary_detail') - ->insertAll($salaryDetails); - - $this->success(); - } - public function settle() { diff --git a/application/admin/view/oa/schedule/custom_index.html b/application/admin/view/oa/schedule/custom_index.html deleted file mode 100644 index 9b6bbbb..0000000 --- a/application/admin/view/oa/schedule/custom_index.html +++ /dev/null @@ -1,52 +0,0 @@ -