Commit b0ba3362 by lizhilin

更新

parent 50469b0a
......@@ -12,6 +12,16 @@
class CovenantClosed extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
......@@ -47,13 +57,12 @@ public function handle(Request $request)
*/
public function render()
{
$cid = $this->getKey() ?? 0;
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已结案')
->button("已结案")
->body(CovenantClosedForm::make()->payload(['id' => $this->getKey()]));
->body(CovenantClosedForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
......
......@@ -13,6 +13,17 @@
class CovenantInvoice extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
*/
......@@ -52,7 +63,7 @@ public function render()
->lg()
->title('添加开票')
->button("添加开票")
->body(CovenantInvoiceForm::make()->payload(['id' => $this->getKey()]));
->body(CovenantInvoiceForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
......
......@@ -12,6 +12,16 @@
class CovenantReceive extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
......@@ -50,9 +60,9 @@ public function render()
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('添加收款')
->title('添加收款' . $this->cid)
->button("添加收款")
->body(CovenantReceiveForm::make()->payload(['id' => $this->getKey()]));
->body(CovenantReceiveForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
......
......@@ -13,6 +13,17 @@
class CovenantReturn extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
*/
......@@ -47,13 +58,12 @@ public function handle(Request $request)
*/
public function render()
{
$cid = $this->getKey() ?? 0;
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已退还')
->button("已退还")
->body(CovenantReturnForm::make()->payload(['id' => $this->getKey()]));
->body(CovenantReturnForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
......
......@@ -73,12 +73,12 @@ protected function grid()
$actions->disableDelete();
}
//已结案
if (Admin::user()->can('hetong-closed')) {
$actions->append(new CovenantClosed($actions->row->id));
if (Admin::user()->can('hetong-closed') && $actions->row->is_closed == 0) {
$actions->append(new CovenantClosed('已结案', $actions->row->id));
}
// 已退还
if (Admin::user()->can('hetong-return')) {
$actions->append(new CovenantReturn($actions->row->id));
if (Admin::user()->can('hetong-return') && $actions->row->is_return == 0) {
$actions->append(new CovenantReturn('已退还', $actions->row->id));
}
});
});
......
......@@ -35,7 +35,7 @@ protected function grid()
// $grid->disableViewButton();
// $grid->disableCreateButton();
$grid->filter(function (Grid\Filter $filter) {
$grid->filter(function (Grid\Filter $filter) use ($number) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"));
......
......@@ -73,11 +73,11 @@ protected function grid()
$grid->actions(function (Grid\Displayers\Actions $actions) use ($lawyerID) {
//添加收款
if (Admin::user()->can('receive-payment')) {
$actions->append(new CovenantReceive($actions->row->id));
$actions->append(new CovenantReceive('添加收款', $actions->row->cid));
}
//添加开票
if (Admin::user()->can('invoiced-payment')) {
$actions->append(new CovenantInvoice($actions->row->id));
$actions->append(new CovenantInvoice('添加开票', $actions->row->cid));
}
//查看收款
$cid = $actions->row->cid;
......
......@@ -24,14 +24,12 @@ class CovenantClosedForm extends Form implements LazyRenderable
*/
public function handle(array $input)
{
$cid = $this->payload['id'];
$cid = $this->payload['cid'];
DB::beginTransaction();
try {
$return_fee = floatval($input['return_fee']);
$uObj = ModelsCovenant::find($cid);
if ($uObj && $uObj->is_return == 0 && $return_fee) {
$uObj->is_return = 1;
$uObj->return_fee = $return_fee;
if ($uObj && $uObj->is_closed == 0) {
$uObj->is_closed = 1;
$uObj->save();
}
DB::commit();
......
......@@ -25,7 +25,7 @@ class CovenantInvoiceForm extends Form implements LazyRenderable
*/
public function handle(array $input)
{
$cid = $this->payload['id']; //合同ID
$cid = $this->payload['cid']; //合同ID
DB::beginTransaction();
try {
$invoiced_at = trim($input['invoiced_at']);
......
......@@ -25,7 +25,7 @@ class CovenantReceiveForm extends Form implements LazyRenderable
*/
public function handle(array $input)
{
$cid = $this->payload['id']; //合同ID
$cid = $this->payload['cid']; //合同ID
DB::beginTransaction();
try {
$received_type = (int)$input['received_type'];
......
......@@ -24,12 +24,14 @@ class CovenantReturnForm extends Form implements LazyRenderable
*/
public function handle(array $input)
{
$cid = $this->payload['id'];
$cid = $this->payload['cid'];
DB::beginTransaction();
try {
$return_fee = floatval($input['return_fee']);
$uObj = ModelsCovenant::find($cid);
if ($uObj && $uObj->is_closed == 0) {
$uObj->is_closed = 1;
if ($uObj && $uObj->is_return == 0 && $return_fee) {
$uObj->is_return = 1;
$uObj->return_fee = $return_fee;
$uObj->save();
}
DB::commit();
......@@ -46,7 +48,7 @@ public function handle(array $input)
*/
public function form()
{
$this->text('return_fee', '退还结案费');
$this->text('return_fee', '退还结案费')->required();
}
/**
......
......@@ -54,7 +54,8 @@ public function get(Grid\Model $model)
$sort = $model->getSort();
// 获取筛选条件
$number = $model->filter()->input('number');
$lawyerID = $model->filter()->input('no') ?? 0;
$number = $model->filter()->input('number') ?? ''; //合同编号
$cname = $model->filter()->input('cname');
$principal = $model->filter()->input('principal');
$received_at = $invoiced_at = [];
......@@ -66,7 +67,7 @@ public function get(Grid\Model $model)
$param = [
'sort' => $sort,
'start' => $start,
'search' => ['number' => $number, 'cname' => $cname, 'principal' => $principal, 'invoiced_at' => $invoiced_at, 'received_at' => $received_at,]
'search' => ['lawyer_id' => $lawyerID, 'number' => $number, 'cname' => $cname, 'principal' => $principal, 'invoiced_at' => $invoiced_at, 'received_at' => $received_at,]
];
$data = $this->getList($param);
......@@ -82,12 +83,16 @@ public function getList(array $param)
{
$prePage = $param['per_page'] ?? 20;
$start = $param['start'] ?? 0;
$lawyer_id = $param['search']['lawyer_id'] ?? 0;
$number = $param['search']['number'] ?? '';
$cname = $param['search']['cname'] ?? '';
$invoiced_at = $param['search']['invoiced_at'] ?? [];
$principal = $param['search']['principal'] ?? '';
$received_at = $param['search']['received_at'] ?? [];
$list = [];
$list = $condition = [];
if ($lawyer_id) {
$condition['rp.lawyer_id'] = $lawyer_id;
}
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
......@@ -100,6 +105,7 @@ public function getList(array $param)
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->where($condition)
->groupBy('rp.cid');
} else {
if ($in_end) {
......@@ -108,6 +114,7 @@ public function getList(array $param)
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->where($condition)
->groupBy('rp.cid');
} elseif ($re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp')
......@@ -115,6 +122,7 @@ public function getList(array $param)
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end])
->where($condition)
->groupBy('rp.cid');
} else {
$note_monitor = DB::table('covenant_receive_payment AS rp')
......@@ -122,6 +130,7 @@ public function getList(array $param)
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start)
->where($condition)
->groupBy('rp.cid');
}
}
......@@ -141,12 +150,14 @@ public function getList(array $param)
->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');
} 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');
}
// 计算列表总数
......@@ -166,12 +177,14 @@ public function getList(array $param)
->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');
} 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');
}
// 计算列表总数
......@@ -182,6 +195,9 @@ public function getList(array $param)
}
} 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);
}
......
......@@ -28,6 +28,7 @@ public function get(Grid\Model $model)
{
// 获取筛选条件
$year = $model->filter()->input('year') ?? date("Y");
$lnum = $model->filter()->input('no') ?? '';
$data = [];
$nowyear = date('Y');
......@@ -42,61 +43,64 @@ public function get(Grid\Model $model)
//总计
$tmp['total'] = 0;
for ($i = 1; $i <= $monthNum; $i++) {
$tmp[$i] = '0.00';
$condition = ['year' => $year, 'month' => $i, 'number' => $lnum];
//基本工资
if ($val['field'] == 'basic_salary') {
$basic_salary = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('basic_salary');
$basic_salary = ModelLawyerCost::where($condition)->sum('basic_salary');
$tmp[$i] = $basic_salary;
$fieldTotal += $basic_salary;
}
//专项附加
if ($val['field'] == 'special_additional') {
$special_additional = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('special_additional');
$special_additional = ModelLawyerCost::where($condition)->sum('special_additional');
$tmp[$i] = $special_additional;
$fieldTotal += $special_additional;
}
//社保
if ($val['field'] == 'social') {
$social_person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_person_fee');
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_company_fee');
$social_person_fee = ModelLawyerCost::where($condition)->sum('social_person_fee');
$social_company_fee = ModelLawyerCost::where($condition)->sum('social_company_fee');
$tmp[$i] = sprintf("%.2f", ($social_person_fee + $social_company_fee));
}
//社保个人部分
if ($val['field'] == 'social_person_fee') {
$social_person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_person_fee');
$social_person_fee = ModelLawyerCost::where($condition)->sum('social_person_fee');
$tmp[$i] = $social_person_fee;
}
//社保企业部分
if ($val['field'] == 'social_company_fee') {
$social_company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('social_company_fee');
$social_company_fee = ModelLawyerCost::where($condition)->sum('social_company_fee');
$tmp[$i] = $social_company_fee;
}
//公积金
if ($val['field'] == 'accumulation_fund') {
$person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_person_fee');
$company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_company_fee');
$person_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_person_fee');
$company_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_company_fee');
$tmp[$i] = sprintf("%.2f", ($person_fee + $company_fee));
}
//公积金个人部分
if ($val['field'] == 'accumulation_fund_person_fee') {
$person_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_person_fee');
$person_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_person_fee');
$tmp[$i] = sprintf("%.2f", $person_fee);
}
//公积金企业部分
if ($val['field'] == 'accumulation_fund_company_fee') {
$company_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('accumulation_fund_company_fee');
$company_fee = ModelLawyerCost::where($condition)->sum('accumulation_fund_company_fee');
$tmp[$i] = sprintf("%.2f", $company_fee);
}
//律所年检费
if ($val['field'] == 'annual_inspection_fee') {
$annual_inspection_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annual_inspection_fee');
$annual_inspection_fee = ModelLawyerCost::where($condition)->sum('annual_inspection_fee');
$tmp[$i] = $annual_inspection_fee;
}
//律所年金
if ($val['field'] == 'annuity') {
$annuity = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('annuity');
$annuity = ModelLawyerCost::where($condition)->sum('annuity');
$tmp[$i] = $annuity;
}
......@@ -104,25 +108,25 @@ public function get(Grid\Model $model)
//助理律师成本
if ($val['field'] == 'assistant_fee') {
$assistant_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('assistant_fee');
$assistant_fee = ModelLawyerCost::where($condition)->sum('assistant_fee');
$tmp[$i] = $assistant_fee;
}
//办公室租赁成本
if ($val['field'] == 'office_rental_fee') {
$office_rental_fee = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('office_rental_fee');
$office_rental_fee = ModelLawyerCost::where($condition)->sum('office_rental_fee');
$tmp[$i] = $office_rental_fee;
}
//无票成本
if ($val['field'] == 'noticket_cost') {
$noticket_cost = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('noticket_cost');
$noticket_cost = ModelLawyerCost::where($condition)->sum('noticket_cost');
$tmp[$i] = $noticket_cost;
}
//个人所得税
if ($val['field'] == 'personal_income_tax') {
$personal_income_tax = ModelLawyerCost::where(['year' => $year, 'month' => $i])->sum('personal_income_tax');
$personal_income_tax = ModelLawyerCost::where($condition)->sum('personal_income_tax');
$tmp[$i] = $personal_income_tax;
}
......@@ -132,14 +136,7 @@ public function get(Grid\Model $model)
$data[$key] = $tmp;
}
// echo "<pre>";
// print_r($data);
// die;
return $data;
// $data = [
// ['id' => 1, 'year' => '2016', 'jzsqNum' => '100', 'jzhpNum' => '100', 'sbTotal' => '100'],
// ['id' => 2, 'year' => '2017', 'jzsqNum' => '100', 'jzhpNum' => '100', 'sbTotal' => '100']
// ];
// return $data;
}
}
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