From 963b0de0b72058b11bf337ffb231af2b8a8f71e0 Mon Sep 17 00:00:00 2001 From: hdm Date: Wed, 17 Nov 2021 16:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=95=B0=E6=8D=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/home/controller/Check.php | 83 +++++ app/home/controller/Invoice.php | 344 +++++++++++++++++++ app/home/controller/Keywords.php | 26 +- app/home/controller/Schedule.php | 349 +++++++++++-------- app/home/controller/expense.php | 391 +++++++++++----------- app/home/model/Invoice.php | 7 + app/home/model/InvoiceSubject.php | 15 + app/home/validate/InvoiceCheck.php | 23 ++ app/home/validate/InvoiceSubjectCheck.php | 29 ++ app/home/view/check/add.html | 131 ++++++++ app/home/view/check/index.html | 88 +++++ app/home/view/department/add.html | 6 +- app/home/view/expense/cate.html | 6 +- app/home/view/invoice/add.html | 279 +++++++++++++++ app/home/view/invoice/check.html | 175 ++++++++++ app/home/view/invoice/index.html | 156 +++++++++ app/home/view/invoice/list.html | 161 +++++++++ app/home/view/invoice/subject.html | 146 ++++++++ app/home/view/invoice/view.html | 100 ++++++ app/home/view/keywords/add.html | 25 +- app/home/view/schedule/cate.html | 85 +++++ app/home/view/schedule/cate_add.html | 107 ++++++ app/home/view/search/index.html | 100 ------ app/install/data/gouguoa.sql | 28 +- 24 files changed, 2378 insertions(+), 482 deletions(-) create mode 100644 app/home/controller/Check.php create mode 100644 app/home/controller/Invoice.php create mode 100644 app/home/model/Invoice.php create mode 100644 app/home/model/InvoiceSubject.php create mode 100644 app/home/validate/InvoiceCheck.php create mode 100644 app/home/validate/InvoiceSubjectCheck.php create mode 100644 app/home/view/check/add.html create mode 100644 app/home/view/check/index.html create mode 100644 app/home/view/invoice/add.html create mode 100644 app/home/view/invoice/check.html create mode 100644 app/home/view/invoice/index.html create mode 100644 app/home/view/invoice/list.html create mode 100644 app/home/view/invoice/subject.html create mode 100644 app/home/view/invoice/view.html create mode 100644 app/home/view/schedule/cate.html create mode 100644 app/home/view/schedule/cate_add.html delete mode 100644 app/home/view/search/index.html diff --git a/app/home/controller/Check.php b/app/home/controller/Check.php new file mode 100644 index 0000000..99951a1 --- /dev/null +++ b/app/home/controller/Check.php @@ -0,0 +1,83 @@ +isAjax()) { + $param = get_params(); + $where = array(); + $where[] = ['a.status', '>=', 0]; + $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $content = Db::name('Check') + ->field('a.*,u.username as username,u.name as name') + ->alias('a') + ->join('Admin u', 'a.uid = u.id', 'LEFT') + ->where($where) + ->paginate($rows, false, ['query' => $param]); + return table_assign(0, '', $content); + } else { + return view(); + } + } + + //添加/编辑 + public function add() + { + $param = get_params(); + if (request()->isAjax()) { + if (!empty($param['id']) && $param['id'] > 0) { + $param['update_time'] = time(); + $res = Db::name('Check')->strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); + } else { + $param['create_time'] = time(); + $insertId = Db::name('Check')->strict(false)->field(true)->insertGetId($param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); + } + } else { + $id = isset($param['id']) ? $param['id'] : 0; + if ($id > 0) { + $detail = Db::name('Check')->where(['id' => $id])->find(); + $detail['name'] = Db::name('Admin')->where(['id' => $detail['uid']])->value('name'); + View::assign('detail', $detail); + } + View::assign('id', $id); + return view(); + } + } + + //删除 + public function delete() + { + $id = get_params("id"); + $data['status'] = '-1'; + $data['id'] = $id; + $data['update_time'] = time(); + if (Db::name('Config')->update($data) !== false) { + add_log('delete', $id, $data); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } +} diff --git a/app/home/controller/Invoice.php b/app/home/controller/Invoice.php new file mode 100644 index 0000000..ee892c8 --- /dev/null +++ b/app/home/controller/Invoice.php @@ -0,0 +1,344 @@ +isAjax()) { + $subject = Db::name('InvoiceSubject')->order('create_time asc')->select(); + return to_assign(0, '', $subject); + } else { + return view(); + } + } + //提交保存分类 + public function subject_add() + { + if (request()->isAjax()) { + $param = get_params(); + if (!empty($param['id']) && $param['id'] > 0) { + try { + validate(InvoiceSubjectCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $data['update_time'] = time(); + $res = InvoiceSubject::strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); + } else { + try { + validate(InvoiceSubjectCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + $insertId = InvoiceSubject::strict(false)->field(true)->insertGetId($param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); + } + } + } + + public function get_list($param = [], $where = []) + { + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $expense = ExpenseList::where($where) + ->order('create_time asc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month); + $item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time); + $item->user_name = Db::name('Admin')->where(['id' => $item->uid])->value('name'); + $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name'); + $item->department = Db::name('Department')->where(['id' => $item->did])->value('title'); + $item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name'); + $item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time); + $item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name'); + $item->pay_time = empty($item->pay_time) ? '-' : date('Y-m-d H:i', $item->pay_time); + $item->amount = Db::name('ExpenseInterfix')->where(['exid' => $item->id])->sum('amount'); + }); + return $expense; + } + + public function detail($id = 0) + { + $expense = Db::name('Expense')->where(['id' => $id])->find(); + if ($expense) { + $expense['income_month'] = empty($expense['income_month']) ? '-' : date('Y-m', $expense['income_month']); + $expense['expense_time'] = empty($expense['expense_time']) ? '-' : date('Y-m-d', $expense['expense_time']); + $expense['user_name'] = Db::name('Admin')->where(['id' => $expense['uid']])->value('name'); + $expense['department'] = Db::name('Department')->where(['id' => $expense['did']])->value('title'); + $expense['amount'] = Db::name('ExpenseInterfix')->where(['exid' => $expense['id']])->sum('amount'); + + if ($expense['check_admin_id'] > 0) { + $expense['check_admin'] = Db::name('Admin')->where(['id' => $expense['check_admin_id']])->value('name'); + $expense['check_time'] = date('Y-m-d H:i:s', $expense['check_time']); + } + if ($expense['pay_admin_id'] > 0) { + $expense['pay_admin'] = Db::name('Admin')->where(['id' => $expense['pay_admin_id']])->value('name'); + $expense['pay_time'] = date('Y-m-d H:i:s', $expense['pay_time']); + } + $expense['list'] = Db::name('ExpenseInterfix') + ->field('a.*,c.title as cate_title') + ->alias('a') + ->join('ExpenseCate c', 'a.cate_id = c.id') + ->where(['a.exid' => $expense['id']]) + ->select(); + } + return $expense; + } + + public function index() + { + if (request()->isAjax()) { + $param = get_params(); + $where = []; + $where[] = ['status', '=', 1]; + //按时间检索 + $start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0; + $end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0; + if ($start_time > 0 && $end_time > 0) { + $where[] = ['expense_time', 'between', [$start_time, $end_time]]; + } + $expense = $this->get_list($param, $where); + return table_assign(0, '', $expense); + } else { + return view(); + } + } + + function list() { + if (request()->isAjax()) { + $param = get_params(); + $where = []; + $where[] = ['admin_id', '=', $this->uid]; + $where[] = ['status', '=', 1]; + //按时间检索 + $start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0; + $end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0; + if ($start_time > 0 && $end_time > 0) { + $where[] = ['expense_time', 'between', [$start_time, $end_time]]; + } + $expense = $this->get_list($param, $where); + return table_assign(0, '', $expense); + } else { + return view(); + } + } + + //添加 + public function add() + { + $id = empty(get_params('id')) ? 0 : get_params('id'); + if ($id > 0) { + $expense = $this->detail($id); + View::assign('expense', $expense); + } + $expense_cate = Db::name('ExpenseCate')->where(['status' => 1])->select()->toArray(); + View::assign('user', get_admin($this->uid)); + View::assign('expense_cate', $expense_cate); + View::assign('id', $id); + return view(); + } + + //提交添加 + public function post_submit() + { + $admin_id = $this->uid; + $dbRes = false; + $param = get_params(); + $param['admin_id'] = $admin_id; + $param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0; + $param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0; + $param['check_status'] = 1; + if (!empty($param['id']) && $param['id'] > 0) { + try { + validate(ExpenseCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['update_time'] = time(); + Db::startTrans(); + try { + $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); + if ($res !== false) { + $exid = $param['id']; + //相关内容多个数组; + $amountData = isset($param['amount']) ? $param['amount'] : ''; + $remarksData = isset($param['remarks']) ? $param['remarks'] : ''; + $cateData = isset($param['cate_id']) ? $param['cate_id'] : ''; + $idData = isset($param['expense_id']) ? $param['expense_id'] : 0; + if ($amountData) { + foreach ($amountData as $key => $value) { + if (!$value) { + continue; + } + + $data = []; + $data['id'] = $idData[$key]; + $data['exid'] = $exid; + $data['admin_id'] = $admin_id; + $data['amount'] = $amountData[$key]; + $data['cate_id'] = $cateData[$key]; + $data['remarks'] = $remarksData[$key]; + if ($data['amount'] == 0) { + Db::rollback(); + return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零'); + } + if ($data['id'] > 0) { + $data['update_time'] = time(); + $resa = Db::name('ExpenseInterfix')->strict(false)->field(true)->update($data); + } else { + $data['create_time'] = time(); + $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); + } + } + } + add_log('edit', $exid, $param); + Db::commit(); + $dbRes = true; + } else { + Db::rollback(); + } + } catch (\Exception $e) { ##这里参数不能删除($e:错误信息) + Db::rollback(); + return to_assign(1, $e->getMessage()); + } + } else { + try { + validate(ExpenseCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + Db::startTrans(); + try { + $exid = ExpenseList::strict(false)->field(true)->insertGetId($param); + if ($exid) { + //相关内容多个数组; + $amountData = isset($param['amount']) ? $param['amount'] : ''; + $remarksData = isset($param['remarks']) ? $param['remarks'] : ''; + $cateData = isset($param['cate_id']) ? $param['cate_id'] : ''; + if ($amountData) { + foreach ($amountData as $key => $value) { + if (!$value) { + continue; + } + + $data = []; + $data['exid'] = $exid; + $data['admin_id'] = $admin_id; + $data['amount'] = $amountData[$key]; + $data['cate_id'] = $cateData[$key]; + $data['remarks'] = $remarksData[$key]; + $data['create_time'] = time(); + if ($data['amount'] == 0) { + Db::rollback(); + return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零'); + } + $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); + } + } + add_log('add', $exid, $param); + Db::commit(); + $dbRes = true; + } else { + Db::rollback(); + } + } catch (\Exception $e) { ##这里参数不能删除($e:错误信息) + Db::rollback(); + return to_assign(1, $e->getMessage()); + } + } + if ($dbRes == true) { + return to_assign(); + } else { + return to_assign(1, '保存失败'); + } + } + + //查看 + public function view() + { + $id = empty(get_params('id')) ? 0 : get_params('id'); + $expense = $this->detail($id); + View::assign('uid', $this->uid); + View::assign('expense', $expense); + return view(); + } + + //删除 + public function delete() + { + $id = get_params("id"); + $expense = $this->detail($id); + if ($expense['check_status'] == 2) { + return to_assign(1, "已审核的报销记录不能删除"); + } + if ($expense['check_status'] == 3) { + return to_assign(1, "已打款的报销记录不能删除"); + } + $data['status'] = '-1'; + $data['id'] = $id; + $data['update_time'] = time(); + if (Db::name('expense')->update($data) !== false) { + add_log('delete', $id); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } + //设置 + public function check() + { + $param = get_params(); + if (request()->isAjax()) { + if ($param['check_status'] == 2 || $param['check_status'] == 0) { + $param['check_admin_id'] = $this->uid; + $param['check_time'] = time(); + } + if ($param['check_status'] == 3) { + $param['pay_admin_id'] = $this->uid; + $param['pay_time'] = time(); + } + $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); + if ($res !== false) { + return to_assign(); + } else { + return to_assign(1, "操作失败"); + } + } else { + $expense = $this->detail($param['id']); + View::assign('expense', $expense); + View::assign('uid', $this->uid); + return view(); + } + } +} diff --git a/app/home/controller/Keywords.php b/app/home/controller/Keywords.php index c317610..a8dbac3 100644 --- a/app/home/controller/Keywords.php +++ b/app/home/controller/Keywords.php @@ -40,20 +40,8 @@ class Keywords extends BaseController //添加 public function add() { - $id = empty(get_params('id')) ? 0 : get_params('id'); - if ($id > 0) { - $keywords = Db::name('Keywords')->where(['id' => $id])->find(); - View::assign('keywords', $keywords); - } - View::assign('id', $id); - return view(); - } - - //提交添加 - public function post_submit() - { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { try { validate(KeywordsCheck::class)->scene('edit')->check($param); @@ -66,7 +54,6 @@ class Keywords extends BaseController if ($res) { add_log('edit', $param['id'], $param); } - return to_assign(); } else { try { @@ -80,11 +67,20 @@ class Keywords extends BaseController if ($insertId) { add_log('add', $insertId, $param); } - return to_assign(); } + } else { + $id = isset($param['id']) ? $param['id'] : 0; + if ($id > 0) { + $keywords = Db::name('Keywords')->where(['id' => $id])->find(); + View::assign('keywords', $keywords); + } + View::assign('id', $id); + return view(); } + } + //删除 public function delete() { diff --git a/app/home/controller/Schedule.php b/app/home/controller/Schedule.php index 39c4e4e..587ccfc 100644 --- a/app/home/controller/Schedule.php +++ b/app/home/controller/Schedule.php @@ -11,58 +11,123 @@ namespace app\home\controller; use app\home\BaseController; use app\home\model\Schedule as ScheduleList; -use app\home\validate\ScheduleCheck; -use think\exception\ValidateException; use schedule\Schedule as ScheduleIndex; use think\facade\Db; use think\facade\View; class Schedule extends BaseController { + public function cate() + { + if (request()->isAjax()) { + $param = get_params(); + $where = array(); + $where[] = ['s.status', '>=', 0]; + $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $content = Db::name('ScheduleCate') + ->field('s.*,d.title as department') + ->alias('s') + ->join('Department d', 's.did = d.id', 'LEFT') + ->where($where) + ->paginate($rows, false, ['query' => $param]); + return table_assign(0, '', $content); + } else { + return view(); + } + } + + //添加/编辑工作类别 + public function cate_add() + { + $param = get_params(); + if (request()->isAjax()) { + if (!empty($param['id']) && $param['id'] > 0) { + $param['update_time'] = time(); + $res = Db::name('ScheduleCate')->strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); + } else { + $param['create_time'] = time(); + $insertId = Db::name('ScheduleCate')->strict(false)->field(true)->insertGetId($param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); + } + } else { + $id = isset($param['id']) ? $param['id'] : 0; + $department = set_recursion(get_department()); + if ($id > 0) { + $detail = Db::name('ScheduleCate')->where(['id' => $id])->find(); + View::assign('detail', $detail); + } + View::assign('department', $department); + View::assign('id', $id); + return view(); + } + } + + //删除 + public function cate_delete() + { + $id = get_params("id"); + $data['status'] = '-1'; + $data['id'] = $id; + $data['update_time'] = time(); + if (Db::name('ScheduleCate')->update($data) !== false) { + add_log('delete', $id, $data); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } + + //工作记录 public function index() { if (request()->isAjax()) { - $param=get_params(); - $uid=$this->uid; + $param = get_params(); + $uid = $this->uid; if (!empty($param['uid'])) { $uid = $param['uid']; } - $where=[]; - $where[]=['start_time','>=',strtotime($param['start'])]; - $where[]=['end_time','<=',strtotime($param['end'])]; - $where[] =['admin_id','=',$uid]; - $where[] = ['status','=', 1]; + $where = []; + $where[] = ['start_time', '>=', strtotime($param['start'])]; + $where[] = ['end_time', '<=', strtotime($param['end'])]; + $where[] = ['admin_id', '=', $uid]; + $where[] = ['status', '=', 1]; $schedule = Db::name('Schedule')->where($where)->field('id,name,labor_time,start_time,end_time')->select()->toArray(); $events = []; - $countEvents=[]; + $countEvents = []; foreach ($schedule as $k => $v) { - $v['backgroundColor']='#009688'; - $v['borderColor']='#009688'; - $v['title']='['.$v['labor_time'].'工时] '.$v['name']; - $v['start']=date('Y-m-d H:i', $v['start_time']); - $v['end']=date('Y-m-d H:i', $v['end_time']); - $temData=date('Y-m-d', $v['start_time']); - if(array_key_exists($temData, $countEvents)){ - $countEvents[$temData]['times']+=$v['labor_time']; - } - else{ - $countEvents[$temData]['times']=$v['labor_time']; - $countEvents[$temData]['start']=date('Y-m-d', $v['start_time']); + $v['backgroundColor'] = '#009688'; + $v['borderColor'] = '#009688'; + $v['title'] = '[' . $v['labor_time'] . '工时] ' . $v['name']; + $v['start'] = date('Y-m-d H:i', $v['start_time']); + $v['end'] = date('Y-m-d H:i', $v['end_time']); + $temData = date('Y-m-d', $v['start_time']); + if (array_key_exists($temData, $countEvents)) { + $countEvents[$temData]['times'] += $v['labor_time']; + } else { + $countEvents[$temData]['times'] = $v['labor_time']; + $countEvents[$temData]['start'] = date('Y-m-d', $v['start_time']); } unset($v['name']); unset($v['start_time']); unset($v['end_time']); $events[] = $v; - } + } foreach ($countEvents as $kk => $vv) { - $vv['backgroundColor']='#FF5722'; - $vv['borderColor']='#FF5722'; - $vv['title']='【当天总工时:'.$vv['times'].'】'; - $vv['end']=$vv['start']; - $vv['id']=0; + $vv['backgroundColor'] = '#FF5722'; + $vv['borderColor'] = '#FF5722'; + $vv['title'] = '【当天总工时:' . $vv['times'] . '】'; + $vv['end'] = $vv['start']; + $vv['id'] = 0; unset($vv['times']); $events[] = $vv; - } + } $input_arrays = $events; $range_start = parseDateTime($param['start']); $range_end = parseDateTime($param['end']); @@ -70,7 +135,7 @@ class Schedule extends BaseController if (isset($_GET['timeZone'])) { $timeZone = new DateTimeZone($_GET['timeZone']); } - + // Accumulate an output array of event data arrays. $output_arrays = array(); foreach ($input_arrays as $array) { @@ -86,28 +151,26 @@ class Schedule extends BaseController return view(); } } - - public function list() - { + + function list() { if (request()->isAjax()) { $param = get_params(); //按时间检索 $start_time = isset($param['start_time']) ? strtotime($param['start_time']) : 0; $end_time = isset($param['end_time']) ? strtotime($param['end_time']) : 0; - $where=[]; + $where = []; if ($start_time > 0 && $end_time > 0) { - $where[]=['a.start_time','between', [$start_time,$end_time]]; - } + $where[] = ['a.start_time', 'between', [$start_time, $end_time]]; + } if (!empty($param['keywords'])) { - $where[] = ['a.name','like', '%' . trim($param['keywords']) . '%']; + $where[] = ['a.name', 'like', '%' . trim($param['keywords']) . '%']; } if (!empty($param['uid'])) { - $where[] =['a.admin_id','=',$param['uid']]; + $where[] = ['a.admin_id', '=', $param['uid']]; + } else { + $where[] = ['a.admin_id', '=', $this->uid]; } - else{ - $where[] =['a.admin_id','=',$this->uid]; - } - $where[] = ['a.status','=', 1]; + $where[] = ['a.status', '=', 1]; $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $schedule = ScheduleList::where($where) ->field('a.*,u.name as create_admin') @@ -116,45 +179,111 @@ class Schedule extends BaseController ->order('a.id desc') ->paginate($rows, false) ->each(function ($item, $key) { - $item->start_time = empty($item->start_time) ? '': date('Y-m-d H:i', $item->start_time); + $item->start_time = empty($item->start_time) ? '' : date('Y-m-d H:i', $item->start_time); //$item->end_time = empty($item->end_time) ? '': date('Y-m-d H:i', $item->end_time); - $item->end_time = empty($item->end_time) ? '': date('H:i', $item->end_time); + $item->end_time = empty($item->end_time) ? '' : date('H:i', $item->end_time); }); return table_assign(0, '', $schedule); } else { return view(); } } - + //保存日志数据 public function save() { $param = get_params(); - $admin_id=$this->uid; - if($param['id']==0){ - if(isset($param['start_time'])){ - $param['start_time'] = strtotime($param['start_time'].''.$param['start_time_1']); + $admin_id = $this->uid; + if ($param['id'] == 0) { + if (isset($param['start_time'])) { + $param['start_time'] = strtotime($param['start_time'] . '' . $param['start_time_1']); } - if(isset($param['end_time'])){ - $param['end_time'] = strtotime($param['end_time'].''.$param['end_time_1']); + if (isset($param['end_time'])) { + $param['end_time'] = strtotime($param['end_time'] . '' . $param['end_time_1']); } - if( $param['end_time'] <= $param['start_time']){ + if ($param['end_time'] <= $param['start_time']) { return to_assign(1, "结束时间需要大于开始时间"); } - $where1[]=['status','=',1]; - $where1[]=['admin_id','=',$admin_id]; - $where1[]=['start_time','between', [$param['start_time'],$param['end_time']-1]]; + $where1[] = ['status', '=', 1]; + $where1[] = ['admin_id', '=', $admin_id]; + $where1[] = ['start_time', 'between', [$param['start_time'], $param['end_time'] - 1]]; - $where2[]=['status','=',1]; - $where2[]=['admin_id','=',$admin_id]; - $where2[]=['start_time','<=',$param['start_time']]; - $where2[]=['start_time','>=',$param['end_time']]; + $where2[] = ['status', '=', 1]; + $where2[] = ['admin_id', '=', $admin_id]; + $where2[] = ['start_time', '<=', $param['start_time']]; + $where2[] = ['start_time', '>=', $param['end_time']]; - $where3[]=['status','=',1]; - $where3[]=['admin_id','=',$admin_id]; - $where3[]=['end_time','between', [$param['start_time']+1,$param['end_time']]]; + $where3[] = ['status', '=', 1]; + $where3[] = ['admin_id', '=', $admin_id]; + $where3[] = ['end_time', 'between', [$param['start_time'] + 1, $param['end_time']]]; $record = Db::name('Schedule') + ->where(function ($query) use ($where1) { + $query->where($where1); + }) + ->whereOr(function ($query) use ($where2) { + $query->where($where2); + }) + ->whereOr(function ($query) use ($where3) { + $query->where($where3); + }) + ->count(); + if ($record > 0) { + return to_assign(1, "您所选的时间区间已有工作记录,请重新选时间"); + } + $param['labor_time'] = ($param['end_time'] - $param['start_time']) / 3600; + $param['admin_id'] = $admin_id; + $param['did'] = get_admin($admin_id)['did']; + $param['create_time'] = time(); + $addid = Db::name('Schedule')->strict(false)->field(true)->insertGetId($param); + if ($addid > 0) { + add_log('add', $addid, $param); + return to_assign(0, '操作成功'); + } else { + return to_assign(0, '操作失败'); + } + } else { + $param['update_time'] = time(); + $res = Db::name('Schedule')->strict(false)->field(true)->update($param); + if ($res !== false) { + add_log('edit', $addid, $param); + return to_assign(0, '操作成功'); + } else { + return to_assign(0, '操作失败'); + } + } + } + + //更改工时 + public function update_labor_time() + { + $param = get_params(); + if (isset($param['start_time'])) { + $param['start_time'] = strtotime($param['start_time'] . '' . $param['start_time_1']); + } + if (isset($param['end_time'])) { + $param['end_time'] = strtotime($param['end_time'] . '' . $param['end_time_1']); + } + if ($param['end_time'] <= $param['start_time']) { + return to_assign(1, "结束时间需要大于开始时间"); + } + $where1[] = ['status', '=', 1]; + $where1[] = ['id', '<>', $param['id']]; + $where1[] = ['admin_id', '=', $param['admin_id']]; + $where1[] = ['start_time', 'between', [$param['start_time'], $param['end_time'] - 1]]; + + $where2[] = ['status', '=', 1]; + $where2[] = ['id', '<>', $param['id']]; + $where2[] = ['admin_id', '=', $param['admin_id']]; + $where2[] = ['start_time', '<=', $param['start_time']]; + $where2[] = ['start_time', '>=', $param['end_time']]; + + $where3[] = ['status', '=', 1]; + $where3[] = ['id', '<>', $param['id']]; + $where3[] = ['admin_id', '=', $param['admin_id']]; + $where3[] = ['end_time', 'between', [$param['start_time'] + 1, $param['end_time']]]; + + $record = Db::name('Schedule') ->where(function ($query) use ($where1) { $query->where($where1); }) @@ -165,78 +294,12 @@ class Schedule extends BaseController $query->where($where3); }) ->count(); - if($record>0){ - return to_assign(1, "您所选的时间区间已有工作记录,请重新选时间"); - } - $param['labor_time'] = ($param['end_time'] - $param['start_time']) / 3600; - $param['admin_id'] = $admin_id; - $param['did'] = get_admin($admin_id)['did']; - $param['create_time']=time(); - $addid = Db::name('Schedule')->strict(false)->field(true)->insertGetId($param); - if($addid>0){ - add_log('add', $addid, $param); - return to_assign(0,'操作成功'); - }else{ - return to_assign(0,'操作失败'); - } - }else{ - $param['update_time'] = time(); - $res = Db::name('Schedule')->strict(false)->field(true)->update($param); - if ($res!==false) { - add_log('edit', $addid, $param); - return to_assign(0,'操作成功'); - }else{ - return to_assign(0,'操作失败'); - } - } - } - - //更改工时 - public function update_labor_time() - { - $param = get_params(); - if(isset($param['start_time'])){ - $param['start_time'] = strtotime($param['start_time'].''.$param['start_time_1']); - } - if(isset($param['end_time'])){ - $param['end_time'] = strtotime($param['end_time'].''.$param['end_time_1']); - } - if( $param['end_time'] <= $param['start_time']){ - return to_assign(1, "结束时间需要大于开始时间"); - } - $where1[]=['status','=',1]; - $where1[]=['id','<>',$param['id']]; - $where1[]=['admin_id','=',$param['admin_id']]; - $where1[]=['start_time','between', [$param['start_time'],$param['end_time']-1]]; - - $where2[]=['status','=',1]; - $where2[]=['id','<>',$param['id']]; - $where2[]=['admin_id','=',$param['admin_id']]; - $where2[]=['start_time','<=',$param['start_time']]; - $where2[]=['start_time','>=',$param['end_time']]; - - $where3[]=['status','=',1]; - $where3[]=['id','<>',$param['id']]; - $where3[]=['admin_id','=',$param['admin_id']]; - $where3[]=['end_time','between', [$param['start_time']+1,$param['end_time']]]; - - $record = Db::name('Schedule') - ->where(function ($query) use ($where1) { - $query->where($where1); - }) - ->whereOr(function ($query) use ($where2) { - $query->where($where2); - }) - ->whereOr(function ($query) use ($where3) { - $query->where($where3); - }) - ->count(); - if($record>0){ + if ($record > 0) { return to_assign(1, "您所选的时间区间已有工作记录,请重新选时间"); - } + } $param['labor_time'] = ($param['end_time'] - $param['start_time']) / 3600; $res = Db::name('Schedule')->strict(false)->field(true)->update($param); - if ($res!==false) { + if ($res !== false) { return to_assign(0, "操作成功"); add_log('edit', $param['id'], $param); } else { @@ -261,34 +324,32 @@ class Schedule extends BaseController public function detail($id) { - $id=get_params('id'); - $schedule = Db::name('Schedule')->where(['id'=>$id])->find(); + $id = get_params('id'); + $schedule = Db::name('Schedule')->where(['id' => $id])->find(); if (!empty($schedule)) { $schedule['start_time_1'] = date('H:i', $schedule['start_time']); $schedule['end_time_1'] = date('H:i', $schedule['end_time']); $schedule['start_time'] = date('Y-m-d', $schedule['start_time']); $schedule['end_time'] = date('Y-m-d', $schedule['end_time']); $schedule['create_time'] = date('Y-m-d H:i:s', $schedule['create_time']); - $schedule['user'] = Db::name('Admin')->where(['id'=>$schedule['admin_id']])->value('name'); + $schedule['user'] = Db::name('Admin')->where(['id' => $schedule['admin_id']])->value('name'); } if (request()->isAjax()) { return to_assign(0, "", $schedule); - } - else{ + } else { return $schedule; - } + } } - + //读取日程弹层详情 public function view() { - $id=get_params('id'); - $schedule=$this->detail($id); - if($schedule){ + $id = get_params('id'); + $schedule = $this->detail($id); + if ($schedule) { View::assign('schedule', $schedule); return view(); - } - else{ + } else { echo '该工作记录不存在'; } } @@ -298,7 +359,7 @@ class Schedule extends BaseController { $this_year = date("Y"); $admin_did = \think\Session::get('vae_admin'); - return view('', ['this_year' => $this_year, 'this_uid' => $admin_did['id'],'username'=>$admin_did['nickname']]); + return view('', ['this_year' => $this_year, 'this_uid' => $admin_did['id'], 'username' => $admin_did['nickname']]); } } diff --git a/app/home/controller/expense.php b/app/home/controller/expense.php index 39cf8b9..2c3e585 100644 --- a/app/home/controller/expense.php +++ b/app/home/controller/expense.php @@ -30,12 +30,12 @@ class Expense extends BaseController } } //提交保存分类 - public function cate_post_submit() + public function cate_add() { if (request()->isAjax()) { $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { - try { + try { validate(ExpenseCateCheck::class)->scene('edit')->check($param); } catch (ValidateException $e) { // 验证失败 输出错误信息 @@ -48,7 +48,7 @@ class Expense extends BaseController } return to_assign(); } else { - try { + try { validate(ExpenseCateCheck::class)->scene('add')->check($param); } catch (ValidateException $e) { // 验证失败 输出错误信息 @@ -63,89 +63,88 @@ class Expense extends BaseController } } } - - public function get_list($param=[],$where=[]) + + public function get_list($param = [], $where = []) { - $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; - $expense = ExpenseList::where($where) - ->order('create_time asc') - ->paginate($rows, false, ['query' => $param]) - ->each(function ($item, $key) { - $item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month); - $item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time); - $item->user_name = Db::name('Admin')->where(['id' => $item->uid])->value('name'); - $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name'); - $item->department = Db::name('Department')->where(['id' => $item->did])->value('title'); - $item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name'); - $item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time); - $item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name'); - $item->pay_time = empty($item->pay_time) ? '-' : date('Y-m-d H:i', $item->pay_time); - $item->amount = Db::name('ExpenseInterfix')->where(['exid'=>$item->id])->sum('amount'); - }); - return $expense; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $expense = ExpenseList::where($where) + ->order('create_time asc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month); + $item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time); + $item->user_name = Db::name('Admin')->where(['id' => $item->uid])->value('name'); + $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name'); + $item->department = Db::name('Department')->where(['id' => $item->did])->value('title'); + $item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name'); + $item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time); + $item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name'); + $item->pay_time = empty($item->pay_time) ? '-' : date('Y-m-d H:i', $item->pay_time); + $item->amount = Db::name('ExpenseInterfix')->where(['exid' => $item->id])->sum('amount'); + }); + return $expense; } - - public function detail($id=0) + + public function detail($id = 0) { - $expense = Db::name('Expense')->where(['id' => $id])->find(); - if($expense){ - $expense['income_month'] = empty($expense['income_month']) ? '-' : date('Y-m', $expense['income_month']); + $expense = Db::name('Expense')->where(['id' => $id])->find(); + if ($expense) { + $expense['income_month'] = empty($expense['income_month']) ? '-' : date('Y-m', $expense['income_month']); $expense['expense_time'] = empty($expense['expense_time']) ? '-' : date('Y-m-d', $expense['expense_time']); - $expense['user_name'] = Db::name('Admin')->where(['id' => $expense['uid']])->value('name'); + $expense['user_name'] = Db::name('Admin')->where(['id' => $expense['uid']])->value('name'); $expense['department'] = Db::name('Department')->where(['id' => $expense['did']])->value('title'); - $expense['amount'] = Db::name('ExpenseInterfix')->where(['exid'=>$expense['id']])->sum('amount'); - - if($expense['check_admin_id']>0){ - $expense['check_admin'] = Db::name('Admin')->where(['id' => $expense['check_admin_id']])->value('name'); - $expense['check_time'] = date('Y-m-d H:i:s', $expense['check_time']); - } - if($expense['pay_admin_id']>0){ - $expense['pay_admin'] = Db::name('Admin')->where(['id' => $expense['pay_admin_id']])->value('name'); - $expense['pay_time'] = date('Y-m-d H:i:s', $expense['pay_time']); - } - $expense['list'] = Db::name('ExpenseInterfix') - ->field('a.*,c.title as cate_title') - ->alias('a') - ->join('ExpenseCate c', 'a.cate_id = c.id') - ->where(['a.exid'=>$expense['id']]) - ->select(); - } - return $expense; + $expense['amount'] = Db::name('ExpenseInterfix')->where(['exid' => $expense['id']])->sum('amount'); + + if ($expense['check_admin_id'] > 0) { + $expense['check_admin'] = Db::name('Admin')->where(['id' => $expense['check_admin_id']])->value('name'); + $expense['check_time'] = date('Y-m-d H:i:s', $expense['check_time']); + } + if ($expense['pay_admin_id'] > 0) { + $expense['pay_admin'] = Db::name('Admin')->where(['id' => $expense['pay_admin_id']])->value('name'); + $expense['pay_time'] = date('Y-m-d H:i:s', $expense['pay_time']); + } + $expense['list'] = Db::name('ExpenseInterfix') + ->field('a.*,c.title as cate_title') + ->alias('a') + ->join('ExpenseCate c', 'a.cate_id = c.id') + ->where(['a.exid' => $expense['id']]) + ->select(); + } + return $expense; } public function index() { if (request()->isAjax()) { $param = get_params(); - $where=[]; + $where = []; $where[] = ['status', '=', 1]; //按时间检索 $start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0; $end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0; if ($start_time > 0 && $end_time > 0) { - $where[] = ['expense_time', 'between', [$start_time,$end_time]]; + $where[] = ['expense_time', 'between', [$start_time, $end_time]]; } - $expense = $this->get_list($param,$where); + $expense = $this->get_list($param, $where); return table_assign(0, '', $expense); } else { return view(); } } - - public function list() - { + + function list() { if (request()->isAjax()) { $param = get_params(); - $where=[]; + $where = []; $where[] = ['admin_id', '=', $this->uid]; $where[] = ['status', '=', 1]; //按时间检索 $start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0; $end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0; if ($start_time > 0 && $end_time > 0) { - $where[] = ['expense_time', 'between', [$start_time,$end_time]]; + $where[] = ['expense_time', 'between', [$start_time, $end_time]]; } - $expense = $this->get_list($param,$where); + $expense = $this->get_list($param, $where); return table_assign(0, '', $expense); } else { return view(); @@ -157,10 +156,10 @@ class Expense extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); if ($id > 0) { - $expense = $this->detail($id ); + $expense = $this->detail($id); View::assign('expense', $expense); } - $expense_cate=Db::name('ExpenseCate')->where(['status' => 1])->select()->toArray(); + $expense_cate = Db::name('ExpenseCate')->where(['status' => 1])->select()->toArray(); View::assign('user', get_admin($this->uid)); View::assign('expense_cate', $expense_cate); View::assign('id', $id); @@ -170,124 +169,126 @@ class Expense extends BaseController //提交添加 public function post_submit() { - $admin_id=$this->uid; - $dbRes = false; - $param = get_params(); - $param['admin_id'] = $admin_id; - $param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0; - $param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0; - $param['check_status'] = 1; - if (!empty($param['id']) && $param['id'] > 0) { - try { - validate(ExpenseCheck::class)->scene('edit')->check($param); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - $param['update_time'] = time(); - Db::startTrans(); - try { - $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); - if ($res!==false) { - $exid = $param['id']; - //相关内容多个数组; - $amountData=isset($param['amount'])? $param['amount'] : ''; - $remarksData=isset($param['remarks'])? $param['remarks'] : ''; - $cateData=isset($param['cate_id'])? $param['cate_id'] : ''; - $idData=isset($param['expense_id'])? $param['expense_id'] : 0; - if($amountData){ - foreach ($amountData as $key => $value) { - if (!$value ) continue; - $data = []; - $data['id'] = $idData[$key]; - $data['exid'] = $exid; - $data['admin_id'] = $admin_id; - $data['amount'] = $amountData[$key]; - $data['cate_id'] = $cateData[$key]; - $data['remarks'] = $remarksData[$key]; - if($data['amount'] == 0){ - Db::rollback(); - return to_assign(1,'第'.($key+1).'条报销金额不能为零'); - } - if($data['id']>0){ - $data['update_time'] =time(); - $resa = Db::name('ExpenseInterfix')->strict(false)->field(true)->update($data); - } - else{ - $data['create_time'] =time(); - $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); - } - } - } - add_log('edit',$exid,$param); - Db::commit(); - $dbRes=true; - } else { - Db::rollback(); - } - } - catch (\Exception $e) { ##这里参数不能删除($e:错误信息) - Db::rollback(); - return to_assign(1,$e->getMessage()); - } - } else { - try { - validate(ExpenseCheck::class)->scene('add')->check($param); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - $param['create_time'] = time(); - Db::startTrans(); - try { - $exid = ExpenseList::strict(false)->field(true)->insertGetId($param); - if ($exid) { - //相关内容多个数组; - $amountData=isset($param['amount'])? $param['amount'] : ''; - $remarksData=isset($param['remarks'])? $param['remarks'] : ''; - $cateData=isset($param['cate_id'])? $param['cate_id'] : ''; - if($amountData){ - foreach ($amountData as $key => $value) { - if (!$value ) continue; - $data = []; - $data['exid'] = $exid; - $data['admin_id'] = $admin_id; - $data['amount'] = $amountData[$key]; - $data['cate_id'] = $cateData[$key]; - $data['remarks'] = $remarksData[$key]; - $data['create_time'] =time(); - if($data['amount'] == 0){ - Db::rollback(); - return to_assign(1,'第'.($key+1).'条报销金额不能为零'); - } - $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); - } - } - add_log('add',$exid,$param); - Db::commit(); - $dbRes=true; - } else { - Db::rollback(); - } - } - catch (\Exception $e) { ##这里参数不能删除($e:错误信息) - Db::rollback(); - return to_assign(1,$e->getMessage()); - } - } - if($dbRes==true){ - return to_assign(); - } - else{ - return to_assign(1,'保存失败'); - } + $admin_id = $this->uid; + $dbRes = false; + $param = get_params(); + $param['admin_id'] = $admin_id; + $param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0; + $param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0; + $param['check_status'] = 1; + if (!empty($param['id']) && $param['id'] > 0) { + try { + validate(ExpenseCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['update_time'] = time(); + Db::startTrans(); + try { + $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); + if ($res !== false) { + $exid = $param['id']; + //相关内容多个数组; + $amountData = isset($param['amount']) ? $param['amount'] : ''; + $remarksData = isset($param['remarks']) ? $param['remarks'] : ''; + $cateData = isset($param['cate_id']) ? $param['cate_id'] : ''; + $idData = isset($param['expense_id']) ? $param['expense_id'] : 0; + if ($amountData) { + foreach ($amountData as $key => $value) { + if (!$value) { + continue; + } + + $data = []; + $data['id'] = $idData[$key]; + $data['exid'] = $exid; + $data['admin_id'] = $admin_id; + $data['amount'] = $amountData[$key]; + $data['cate_id'] = $cateData[$key]; + $data['remarks'] = $remarksData[$key]; + if ($data['amount'] == 0) { + Db::rollback(); + return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零'); + } + if ($data['id'] > 0) { + $data['update_time'] = time(); + $resa = Db::name('ExpenseInterfix')->strict(false)->field(true)->update($data); + } else { + $data['create_time'] = time(); + $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); + } + } + } + add_log('edit', $exid, $param); + Db::commit(); + $dbRes = true; + } else { + Db::rollback(); + } + } catch (\Exception $e) { ##这里参数不能删除($e:错误信息) + Db::rollback(); + return to_assign(1, $e->getMessage()); + } + } else { + try { + validate(ExpenseCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + Db::startTrans(); + try { + $exid = ExpenseList::strict(false)->field(true)->insertGetId($param); + if ($exid) { + //相关内容多个数组; + $amountData = isset($param['amount']) ? $param['amount'] : ''; + $remarksData = isset($param['remarks']) ? $param['remarks'] : ''; + $cateData = isset($param['cate_id']) ? $param['cate_id'] : ''; + if ($amountData) { + foreach ($amountData as $key => $value) { + if (!$value) { + continue; + } + + $data = []; + $data['exid'] = $exid; + $data['admin_id'] = $admin_id; + $data['amount'] = $amountData[$key]; + $data['cate_id'] = $cateData[$key]; + $data['remarks'] = $remarksData[$key]; + $data['create_time'] = time(); + if ($data['amount'] == 0) { + Db::rollback(); + return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零'); + } + $eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data); + } + } + add_log('add', $exid, $param); + Db::commit(); + $dbRes = true; + } else { + Db::rollback(); + } + } catch (\Exception $e) { ##这里参数不能删除($e:错误信息) + Db::rollback(); + return to_assign(1, $e->getMessage()); + } + } + if ($dbRes == true) { + return to_assign(); + } else { + return to_assign(1, '保存失败'); + } } //查看 public function view() { $id = empty(get_params('id')) ? 0 : get_params('id'); - $expense = $this->detail($id ); + $expense = $this->detail($id); View::assign('uid', $this->uid); View::assign('expense', $expense); return view(); @@ -297,13 +298,13 @@ class Expense extends BaseController public function delete() { $id = get_params("id"); - $expense = $this->detail($id ); - if($expense['check_status'] == 2){ - return to_assign(1, "已审核的报销记录不能删除"); - } - if($expense['check_status'] == 3){ - return to_assign(1, "已打款的报销记录不能删除"); - } + $expense = $this->detail($id); + if ($expense['check_status'] == 2) { + return to_assign(1, "已审核的报销记录不能删除"); + } + if ($expense['check_status'] == 3) { + return to_assign(1, "已打款的报销记录不能删除"); + } $data['status'] = '-1'; $data['id'] = $id; $data['update_time'] = time(); @@ -314,29 +315,29 @@ class Expense extends BaseController return to_assign(1, "删除失败"); } } - //设置 + //设置 public function check() { $param = get_params(); - if (request()->isAjax()) { - if($param['check_status'] == 2 || $param['check_status'] == 0){ - $param['check_admin_id'] = $this->uid; - $param['check_time'] = time(); - } - if($param['check_status'] == 3){ - $param['pay_admin_id'] = $this->uid; - $param['pay_time'] = time(); - } - $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); - if($res !==false){ - return to_assign(); - } else { - return to_assign(1, "操作失败"); - } + if (request()->isAjax()) { + if ($param['check_status'] == 2 || $param['check_status'] == 0) { + $param['check_admin_id'] = $this->uid; + $param['check_time'] = time(); + } + if ($param['check_status'] == 3) { + $param['pay_admin_id'] = $this->uid; + $param['pay_time'] = time(); + } + $res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param); + if ($res !== false) { + return to_assign(); + } else { + return to_assign(1, "操作失败"); + } } else { - $expense = $this->detail($param['id']); - View::assign('expense', $expense); - View::assign('uid', $this->uid); + $expense = $this->detail($param['id']); + View::assign('expense', $expense); + View::assign('uid', $this->uid); return view(); } } diff --git a/app/home/model/Invoice.php b/app/home/model/Invoice.php new file mode 100644 index 0000000..247694f --- /dev/null +++ b/app/home/model/Invoice.php @@ -0,0 +1,7 @@ + 'require', + 'id' => 'require', + 'status' => 'require' + ]; + + protected $message = [ + 'code.require' => '报销凭证编号不能为空', + 'id.require' => '缺少更新条件', + 'status.require' => '状态为必选', + ]; + + protected $scene = [ + 'add' => ['code'], + 'edit' => ['id', 'code'] + ]; +} \ No newline at end of file diff --git a/app/home/validate/InvoiceSubjectCheck.php b/app/home/validate/InvoiceSubjectCheck.php new file mode 100644 index 0000000..bd047d7 --- /dev/null +++ b/app/home/validate/InvoiceSubjectCheck.php @@ -0,0 +1,29 @@ + 'require|unique:expense_cate', + 'id' => 'require', + ]; + + protected $message = [ + 'title.require' => '名称不能为空', + 'title.unique' => '同样的名称已经存在', + 'id.require' => '缺少更新条件', + ]; + + protected $scene = [ + 'add' => ['title'], + 'edit' => ['id', 'title'], + ]; +} diff --git a/app/home/view/check/add.html b/app/home/view/check/add.html new file mode 100644 index 0000000..ad31f93 --- /dev/null +++ b/app/home/view/check/add.html @@ -0,0 +1,131 @@ +{extend name="common/base"/} +{block name="style"} + + +{/block} + +{block name="body"} +
+ {if condition="$id eq 0"} + + + + + + + + + + + +
审核类型* + + 审核人* + + +
备注信息 + +
+ {else/} + + + + + + + + + + + +
审核类型* + + 审核人* + + +
备注信息 + +
+ {/if} +
+ + + + +
+
+{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="['employeepicker']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/check/index.html b/app/home/view/check/index.html new file mode 100644 index 0000000..3614161 --- /dev/null +++ b/app/home/view/check/index.html @@ -0,0 +1,88 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ +{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/department/add.html b/app/home/view/department/add.html index 9277d99..2120213 100644 --- a/app/home/view/department/add.html +++ b/app/home/view/department/add.html @@ -12,9 +12,9 @@ 上级部门* @@ -34,7 +34,7 @@ 上级部门* + + 入账月份* + + + + 原始单据日期* + + + + + + 报销人* + + + + + 报销部门 + + + + + + + 费用金额* + +
+ + + + + + + + + + + + + +
报销金额报销项目备注信息操作
+ + 删除
+
+ + + + {else/} + + + + + + + + + + + + + + + + + + + +
报销凭证编号* + + 入账月份* + + 原始单据日期* + +
报销人* + + + 报销部门 + + +
费用金额* +
+ + + + + + + + {volist name="$expense.list" id="val"} + + + + + + + {/volist} +
报销金额报销类别备注信息操作
+ + 删除
+
+
+ {/if} + +
+ + + +
+ + +{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['employeepicker']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/invoice/check.html b/app/home/view/invoice/check.html new file mode 100644 index 0000000..91518dd --- /dev/null +++ b/app/home/view/invoice/check.html @@ -0,0 +1,175 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

报销详情

+ + + + + + + + + + + + + + + + + + + + + + {if condition="$expense.check_admin_id > 0"} + + + + + + + {/if} + {if condition="$expense.pay_admin_id > 0"} + + + + + + + {/if} + + + + +
报销凭证编号{$expense.code}入账月份{$expense.income_month}原始单据日期{$expense.expense_time}
报销人{$expense.user_name}报销部门{$expense.department}报销总费用(元){$expense.amount}
报销状态 + {if condition="$expense.check_status == 0"} + 审核不通过 【原因:{$expense.check_remark}】 + {elseif condition="$expense.check_status == 1"} + 报销审核中 + {elseif condition="$expense.check_status == 2"} + 审核通过 + {elseif condition="$expense.check_status == 3"} + 已打款 + {/if} +
审核人{$expense.check_admin}审核时间{$expense.check_time}
打款确认人{$expense.pay_admin}打款确认时间{$expense.pay_time}
费用金额 +
+ + + + + + + {volist name="$expense.list" id="vo"} + + + + + + {/volist} +
报销金额(元)报销类别备注信息
{$vo.amount}{$vo.cate_title}{$vo.remarks}
+
+
+ +
+ + {if condition="($expense.check_status == 0) AND ($uid == $expense.admin_id)"} + 编辑 + {/if} + {eq name="$expense.check_status" value="1"} + + + {/eq} + {eq name="$expense.check_status" value="2"} + + {/eq} +
+
+{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/invoice/index.html b/app/home/view/invoice/index.html new file mode 100644 index 0000000..536f145 --- /dev/null +++ b/app/home/view/invoice/index.html @@ -0,0 +1,156 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ +{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['rightpage']" use="['table','form']" callback="init" /} +{/block} + diff --git a/app/home/view/invoice/list.html b/app/home/view/invoice/list.html new file mode 100644 index 0000000..c572226 --- /dev/null +++ b/app/home/view/invoice/list.html @@ -0,0 +1,161 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ + +{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['rightpage']" use="['table','form']" callback="init" /} +{/block} + diff --git a/app/home/view/invoice/subject.html b/app/home/view/invoice/subject.html new file mode 100644 index 0000000..cbad5c0 --- /dev/null +++ b/app/home/view/invoice/subject.html @@ -0,0 +1,146 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ +{/block} + + + +{block name="script"} + + {include file="common/layui" base='base' extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/invoice/view.html b/app/home/view/invoice/view.html new file mode 100644 index 0000000..abd5428 --- /dev/null +++ b/app/home/view/invoice/view.html @@ -0,0 +1,100 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

报销详情

+ + + + + + + + + + + + + + + + + + + + + + {if condition="$expense.check_admin_id > 0"} + + + + + + + {/if} + {if condition="$expense.pay_admin_id > 0"} + + + + + + + {/if} + + + + +
报销凭证编号{$expense.code}入账月份{$expense.income_month}原始单据日期{$expense.expense_time}
报销人{$expense.user_name}报销部门{$expense.department}报销总费用(元){$expense.amount}
报销状态 + {if condition="$expense.check_status == 0"} + 审核不通过 【原因:{$expense.check_remark}】 + {elseif condition="$expense.check_status == 1"} + 报销审核中 + {elseif condition="$expense.check_status == 2"} + 审核通过 + {elseif condition="$expense.check_status == 3"} + 已打款 + {/if} +
审核人{$expense.check_admin}审核时间{$expense.check_time}
打款确认人{$expense.pay_admin}打款确认时间{$expense.pay_time}
费用金额 +
+ + + + + + + {volist name="$expense.list" id="vo"} + + + + + + {/volist} +
报销金额(元)报销类别备注信息
{$vo.amount}{$vo.cate_title}{$vo.remarks}
+
+
+ {if condition="($expense.check_status == 0) AND ($uid == $expense.admin_id)"} +
+ 编辑 +
+ {/if} +
+{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/keywords/add.html b/app/home/view/keywords/add.html index f76f2ae..19471ce 100644 --- a/app/home/view/keywords/add.html +++ b/app/home/view/keywords/add.html @@ -4,23 +4,15 @@
- + + + + - - - - - -
关键字名称* + 关键字名称* + 排序 + 状态* - - - 排序 -
状态* - {if condition="$id eq 0"} @@ -34,6 +26,7 @@
+ @@ -52,7 +45,7 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/keywords/post_submit')}", + url: "{:url('home/keywords/add')}", type: 'post', data: data.field, success: function (e) { diff --git a/app/home/view/schedule/cate.html b/app/home/view/schedule/cate.html new file mode 100644 index 0000000..2043cef --- /dev/null +++ b/app/home/view/schedule/cate.html @@ -0,0 +1,85 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ + + +{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/schedule/cate_add.html b/app/home/view/schedule/cate_add.html new file mode 100644 index 0000000..0faa4f3 --- /dev/null +++ b/app/home/view/schedule/cate_add.html @@ -0,0 +1,107 @@ +{extend name="common/base"/} + +{block name="body"} + + {if condition="$id eq 0"} + + + + + + + + + + + + + +
工作类型名称* + + 关联部门* + + 状态* + + +
备注信息 + +
+ {else/} + + + + + + + + + + + + + +
工作类型名称* + + 关联部门* + + 状态* + + +
备注信息 + +
+ {/if} +
+ + + + +
+ +{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/search/index.html b/app/home/view/search/index.html deleted file mode 100644 index 6c1f179..0000000 --- a/app/home/view/search/index.html +++ /dev/null @@ -1,100 +0,0 @@ -{extend name="common/base"/} - -{block name="body"} -
-
-
- -
- -
-
-
- -{/block} - - - -{block name="script"} - -{include file="common/layui" base="base" extend="[]" callback="init" /} -{/block} - \ No newline at end of file diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index 2094421..550ddbc 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -134,7 +134,7 @@ INSERT INTO `oa_admin_menu` VALUES (17, 2, '审核人相关配置', 'home/check/ INSERT INTO `oa_admin_menu` VALUES (18, 2, '工作类型设置', 'home/schedule/cate', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (19, 2, '知识关键字设置', 'home/keywords/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (20, 2, '报销类型设置', 'home/expense/cate', '', 1, 0, 0); -INSERT INTO `oa_admin_menu` VALUES (21, 2, '发票主体设置', 'home/invoice/server', '', 1, 0, 0); +INSERT INTO `oa_admin_menu` VALUES (21, 2, '发票主体设置', 'home/invoice/subject', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (22, 3, '部门架构', 'home/department/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (23, 3, '岗位职称', 'home/position/index', '', 1, 0, 0); @@ -241,10 +241,10 @@ INSERT INTO `oa_admin_rule` VALUES (43, 42, 'home/expense/cate_add', '新增/编 INSERT INTO `oa_admin_rule` VALUES (44, 42, 'home/expense/cate_disable', '禁用报销类型','报销类型', 0, 0); INSERT INTO `oa_admin_rule` VALUES (45, 42, 'home/expense/cate_delete', '删除报销类型','报销类型', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (46, 2, 'home/invoice/server', '发票主体设置','发票主体', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (47, 46, 'home/invoice/server_add', '新增/编辑发票主体','发票主体', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (48, 46, 'home/invoice/server_disable', '禁用发票主体','发票主体', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (49, 46, 'home/invoice/server_delete', '删除发票主体','发票主体', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (46, 2, 'home/invoice/subject', '发票主体设置','发票主体', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (47, 46, 'home/invoice/subject_add', '新增/编辑发票主体','发票主体', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (48, 46, 'home/invoice/subject_disable', '禁用发票主体','发票主体', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (49, 46, 'home/invoice/subject_delete', '删除发票主体','发票主体', 0, 0); INSERT INTO `oa_admin_rule` VALUES (50, 3, 'home/department/index', '部门架构','部门', 0, 0); INSERT INTO `oa_admin_rule` VALUES (51, 50, 'home/department/add', '添加/编辑部门信息','部门', 0, 0); @@ -421,7 +421,7 @@ CREATE TABLE `oa_check` ( `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '审核人配置'; +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '审核人配置表'; -- ---------------------------- -- Records of oa_check @@ -766,6 +766,22 @@ CREATE TABLE `oa_schedule` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '工作记录'; +-- ---------------------------- +-- Table structure for oa_schedule_cate +-- ---------------------------- +DROP TABLE IF EXISTS `oa_schedule_cate`; +CREATE TABLE `oa_schedule_cate` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '工作类型名称', + `did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联部门id', + `service_cate_id` int(11) NOT NULL DEFAULT 0 COMMENT '预留字段:关联业务类型id', + `remark` varchar(1000) NULL DEFAULT '' COMMENT '备注', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '工作类型表'; + -- ---------------------------- -- Table structure for oa_schedule_interfix -- ----------------------------