Commit 46930de9 by lizhilin

更新

parent 98b6239e
......@@ -62,7 +62,7 @@ protected function grid()
return self::getPersonalIncomeTax($this->number, $year);
});
if (!Admin::user()->can('lawyer_cost_add')) {
if (!Admin::user()->can('lawyer_cost_add') || !Admin::user()->can('lawyer_cost_list_edit')) {
$grid->disableCreateButton();
}
$grid->disableViewButton();
......@@ -206,26 +206,47 @@ protected function form()
{
$form = Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year')->default(date('Y'));
$form->select('month')->options(ModelLawyerCost::MONTH)->required();
$form->text('number')->required();
$form->text('lname')->required();
$form->text('basic_salary')->required();
$form->text('special_additional')->required();
$form->text('social_person_fee')->required();
$form->text('social_company_fee')->required();
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->required();
$form->text('accumulation_fund_company_fee')->required();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->required();
$form->text('annuity')->required();
$form->text('assistant_fee')->required();
$form->text('office_rental_fee')->required();
$form->text('noticket_cost')->readOnly();
//$form->text('posting_tickets_fee');
$form->text('advance_fee');
$form->text('personal_income_tax')->required();
if (Admin::user()->can('lawyer_cost_list_edit')) {
$form->text('year')->default(date('Y'));
$form->select('month')->options(ModelLawyerCost::MONTH)->required();
$form->text('number')->required();
$form->text('lname')->required();
$form->text('basic_salary')->required();
$form->text('special_additional')->required();
$form->text('social_person_fee')->required();
$form->text('social_company_fee')->required();
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->required();
$form->text('accumulation_fund_company_fee')->required();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->readOnly();
$form->text('annuity')->readOnly();
$form->text('assistant_fee')->readOnly();
$form->text('office_rental_fee')->readOnly();
$form->text('noticket_cost')->readOnly();
$form->text('advance_fee')->readOnly();
$form->text('personal_income_tax')->readOnly();
} else {
$form->text('year')->default(date('Y'))->readOnly();
$form->select('month')->options(ModelLawyerCost::MONTH)->readOnly();
$form->text('number')->readOnly();
$form->text('lname')->readOnly();
$form->text('basic_salary')->readOnly();
$form->text('special_additional')->readOnly();
$form->text('social_person_fee')->readOnly();
$form->text('social_company_fee')->readOnly();
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->readOnly();
$form->text('accumulation_fund_company_fee')->readOnly();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->required();
$form->text('annuity')->required();
$form->text('assistant_fee')->required();
$form->text('office_rental_fee')->required();
$form->text('noticket_cost')->readOnly();
$form->text('advance_fee');
$form->text('personal_income_tax')->required();
}
$form->disableCreatingCheck();
$form->disableEditingCheck();
......@@ -278,6 +299,20 @@ protected function form()
JS
);
$form->submitted(function (Form $form) {
$number = isset($_POST['number']) ? $_POST['number'] : '';
$month = isset($_POST['month']) ? $_POST['month'] : 0;
$year = isset($_POST['year']) ? $_POST['year'] : 0;
$lawyer_id = DB::table('lawyer')->where('number', $number)->value('id');
if (!$number || !$lawyer_id) {
$form->responseValidationMessages('number', "该律师信息不存在");
}
$exist = DB::table('lawyer_cost')->where(['year' => $year, 'month' => $month, 'lawyer_id' => $lawyer_id])->value('id');
if ($exist) {
$form->responseValidationMessages('month', "当前月份成本信息已存在");
}
});
//副表保存规格
$form->saved(
function (Form $form, $result) {
......
......@@ -53,6 +53,9 @@ protected function grid()
$grid->column('annuity', '律所年金');
$grid->column('posting_tickets_fee', '贴票成本')->display(function () use ($year) {
$lawyerObj = ModelsLawyer::find($this->lawyer_id);
if (!$lawyerObj) {
return 0;
}
return ModelLawyerCost::getPostingTicketsMoney($this->lawyer_id, $year, $lawyerObj->commission_rate, $lawyerObj->ticket_ratio);
});
$grid->column('assistant_fee', '助理律师成本');
......@@ -64,7 +67,7 @@ protected function grid()
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
if (!Admin::user()->can('lawyer_cost_list_edit')) {
if (!Admin::user()->can('lawyer_cost_list_edit') && !Admin::user()->can('lawyer_cost_list_cwedit')) {
$grid->disableEditButton();
}
if (!Admin::user()->can('lawyer_cost_list_delete')) {
......@@ -134,28 +137,57 @@ protected function form()
{
$form = Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year')->required();
$form->select('month')->options(ModelLawyerCost::MONTH);
$form->display('number');
$form->text('lname')->required();
$form->text('basic_salary')->required();
$form->text('special_additional')->required();
$form->text('social_person_fee')->required();
$form->text('social_company_fee')->required();
//$social = $form->model()->social;
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->required();
$form->text('accumulation_fund_company_fee')->required();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->required();
$form->text('annuity')->required();
$form->text('assistant_fee')->required();
$form->text('office_rental_fee')->required();
$form->text('noticket_cost')->readOnly();
//$form->text('posting_tickets_fee');
$form->text('advance_fee');
$form->text('personal_income_tax')->required();
if (Admin::user()->can('lawyer_cost_list_edit')) {
$form->text('year')->default(date('Y'));
$form->select('month')->options(ModelLawyerCost::MONTH)->required();
$form->text('number')->required();
$form->text('lname')->required();
$form->text('basic_salary')->required();
$form->text('special_additional')->required();
$form->text('social_person_fee')->required();
$form->text('social_company_fee')->required();
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->required();
$form->text('accumulation_fund_company_fee')->required();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->readOnly();
$form->text('annuity')->readOnly();
$form->text('assistant_fee')->readOnly();
$form->text('office_rental_fee')->readOnly();
$form->text('noticket_cost')->readOnly();
$form->text('advance_fee')->readOnly();
$form->text('personal_income_tax')->readOnly();
} else {
$form->text('year')->default(date('Y'))->readOnly();
//$form->select('month')->options(ModelLawyerCost::MONTH)->disable();
// $form->select('month')
// ->options(ModelLawyerCost::MONTH)
// ->default(function () use ($form) {
// // 获取模型实例
// $model = $form->model();
// // 返回默认值,这里保留数据库中的值
// return $model->month;
// })
// ->readOnly();
$form->text('month')->readOnly();
$form->text('number')->readOnly();
$form->text('lname')->readOnly();
$form->text('basic_salary')->readOnly();
$form->text('special_additional')->readOnly();
$form->text('social_person_fee')->readOnly();
$form->text('social_company_fee')->readOnly();
$form->text('social', '社保')->readOnly();
$form->text('accumulation_fund_person_fee')->readOnly();
$form->text('accumulation_fund_company_fee')->readOnly();
$form->text('accumulation_fund', '公积金')->readOnly();
$form->text('annual_inspection_fee')->required();
$form->text('annuity')->required();
$form->text('assistant_fee')->required();
$form->text('office_rental_fee')->required();
$form->text('noticket_cost')->readOnly();
$form->text('advance_fee');
$form->text('personal_income_tax')->required();
}
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
......
......@@ -94,6 +94,10 @@ public function getList(array $param)
if ($lawyer_id) {
$condition['rp.lawyer_id'] = $lawyer_id;
}
DB::enableQueryLog();
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype', 'c.number'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id');
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
......@@ -101,71 +105,37 @@ public function getList(array $param)
$re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) {
if ($in_end && $re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$re_start, $re_end])
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->where($condition)
->groupBy('rp.cid');
->where($condition);
} else {
if ($in_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $re_start)
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->where($condition)
->groupBy('rp.cid');
->where($condition);
} elseif ($re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end])
->where($condition)
->groupBy('rp.cid');
->where($condition);
} else {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start)
->where($condition)
->groupBy('rp.cid');
->where($condition);
}
}
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$start, $end])
->where($condition)
->groupBy('rp.cid');
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end])
->where($condition);
} else {
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $start)
->where($condition)
->groupBy('rp.cid');
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start)
->where($condition);
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
}
//
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
......@@ -174,52 +144,42 @@ public function getList(array $param)
if ($start) {
if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$start, $end])
->where($condition)
->groupBy('rp.cid');
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end])
->where($condition);
} else {
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(['rp.*', 'c.cname', 'c.ctype'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $start)
->where($condition)
->groupBy('rp.cid');
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start)
->where($condition);
}
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
}
} else { //关键词搜索
$note_monitor = DB::table('covenant')->select(['id as cid', 'number', 'cname', 'principal', 'ctype']);
if ($lawyer_id) {
$note_monitor = $note_monitor->where("lawyer_id", $lawyer_id);
}
if ($number) {
$note_monitor = $note_monitor->where("number", $number);
}
if ($cname) {
$note_monitor = $note_monitor->where("cname", $cname);
}
if ($principal) {
$note_monitor = $note_monitor->where("principal", $principal);
}
// 计算列表总数
$count = $note_monitor->count();
}
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->get()->toArray();
if ($number) {
$note_monitor = $note_monitor->having("number", $number);
}
if ($principal) {
$note_monitor = $note_monitor->having("principal", $principal);
}
if ($cname) {
$note_monitor = $note_monitor->having("cname", $cname);
}
// 计算列表总数
$count = 0; //$note_monitor->count();
$cObj = $note_monitor->groupBy('rp.cid')->get();
if ($cObj->toArray()) {
$count = count($cObj->toArray());
}
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
$queries = DB::getQueryLog();
// echo "<pre>";
// print_r($queries);
// die;
foreach ($list as $key => $item) {
$tmp = [];
$tmp['cid'] = $item->cid;
//$tmp['number'] = $item->number;
$tmp['number'] = $item->number;
$tmp['cname'] = $item->cname;
$tmp['ctype'] = $item->ctype;
$tmp['principal'] = $item->principal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment