Commit 3b4f4080 by liuyingkang

分支初始化

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

File added
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
*.log
\ No newline at end of file
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantClosedForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantClosed extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
//$this->title = $title;
}
/**
* @return string
*/
protected $title = '<i class="feather icon-lock"> 已结案 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-lock"></i> ' . $this->title;
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已结案')
->button($this->title)
->body(CovenantClosedForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
//return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantInvoiceForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantInvoice extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 添加开票 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('添加开票')
->button("添加开票")
->body(CovenantInvoiceForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
// return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantReceiveForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantReceive extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
$this->title = $title;
}
/**
* @return string
*/
protected $title = '<i class="feather icon-stop-circle"> 添加收款 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('添加收款')
->button("添加收款")
->body(CovenantReceiveForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
// return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use App\Command\Log;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* 导出 律师提成汇总表
*
* @package App\Admin\Actions
*/
class CovenantReceivePaymentControllerExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
/**
* 接收参数
*/
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
//protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载模板</button>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
/**
* Handle the action request.
*
* @return Response
*/
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
//调用导出接口
return $this->response()->download('/lawyer-commission-Export?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
class CovenantReceivePaymentExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
return $this->response()->download('/covenant-receive-payment?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
\ No newline at end of file
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Response;
use App\Admin\Forms\CovenantReturnForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class CovenantReturn extends RowAction
{
protected $cid = 0;
/**
* 接收参数
*/
public function __construct($title = '', $cid = 0)
{
$this->cid = $cid;
parent::__construct($title);
//$this->title = $title;
}
/**
* @return string
*/
protected $title = '<i class="feather icon-circle"> 已退案 </i>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<i class="feather icon-stop-circle"></i> ' . $this->title . '';
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$id = $this->getKey() ?? 0;
return $this->response()->success('成功')->refresh();
}
/**
* 渲染模态框.
* @return Modal
*/
public function render()
{
// 这里直接创建一个modal框 model的内容由工具表单提供,这里也需要创建一个工具表单才行
return Modal::make()
->lg()
->title('已退案')
->button($this->title)
->body(CovenantReturnForm::make()->payload(['cid' => $this->cid]));
//->button("<button class='btn btn-sm btn-primary'>$this->title</button>"); // 这个button就是对应上面的按钮
}
/**
* @return string|array|void
*/
public function confirm()
{
//return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{
return [];
}
}
<?php
namespace App\Admin\Actions;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Support\Facades\Storage;
/**
* 下载导入模板
* Class DownloadTemplate
*
* @package App\Admin\Actions
*/
class DownloadTemplateExcel extends Action
{
/**
* @return string
*/
protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载导入模板</button>';
/**
* Handle the action request.
*
* @return Response
*/
public function handle()
{
$file_name = '';
switch ($this->getKey()) {
case 'ModelsCovenant':
$file_name = '合同信息导入模版';
break;
}
return $this->response()->download('/excelTemplate/' . $file_name . '.xlsx');
}
public function parameters()
{
return [
'mode' => '',
];
}
}
<?php
namespace App\Admin\Actions;
use App\Command\Log;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* 导出 律师提成汇总表
*
* @package App\Admin\Actions
*/
class LawyerCollectControllerExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
/**
* 接收参数
*/
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
//protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载模板</button>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
/**
* Handle the action request.
*
* @return Response
*/
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
//调用导出接口
return $this->response()->download('/lawyer-collect-Export?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
<?php
namespace App\Admin\Actions;
use App\Command\Log;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* 导出 律师提成汇总表
*
* @package App\Admin\Actions
*/
class LawyerCommissionCollectExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
/**
* 接收参数
*/
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
//protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载模板</button>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
/**
* Handle the action request.
*
* @return Response
*/
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
//调用导出接口
return $this->response()->download('/lawyer-commission-Export?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
<?php
namespace App\Admin\Actions;
use App\Command\Log;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* 导出 律师成本汇总表
*
* @package App\Admin\Actions
*/
class LawyerCostCollectExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
/**
* 接收参数
*/
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
//protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载模板</button>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
/**
* Handle the action request.
*
* @return Response
*/
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
//调用导出接口
return $this->response()->download('/lawyer-cost-Export?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
<?php
namespace App\Admin\Actions;
use App\Command\Log;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Actions\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* 导出 汇总表
* Class DownloadTemplate
*
* @package App\Admin\Actions
*/
class ReceivedInvoicedExcel extends Action
{
protected $request_param = [];
protected $request_filename = '';
protected $title = '';
/**
* 接收参数
*/
public function __construct($param = [], $filename = '', $title = '')
{
$this->request_param = $param;
$this->request_filename = $filename;
parent::__construct($title);
$this->title = $title;
}
//protected $title = '<button class="btn btn-primary"><i class="feather icon-download"></i> 下载模板</button>';
/**
* 按钮文本
*
* @return string|void
*/
public function title()
{
return '<button class="btn btn-primary"><i class="feather icon-download"></i> ' . $this->title . '</button>';
}
/**
* Handle the action request.
*
* @return Response
*/
public function handle(Request $request)
{
$param = $request->get('param');
$filename = $request->get('filename');
//调用导出接口
return $this->response()->download('/received-invoiced-Export?filename=' . $filename . '&param=' . json_encode($param) . '&_export_=1');
}
public function parameters()
{
return [
'mode' => '',
'param' => $this->request_param,
'filename' => $this->request_filename,
'title' => $this->title,
];
}
}
<?php
namespace App\Admin\Controllers;
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
class AuthController extends BaseAuthController
{
protected $view = 'admin.login';
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Covenant;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Lawyer as ModelLawyer;
use App\Models\Principal as ModelPrincipal;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantClosed;
use App\Admin\Actions\CovenantReturn;
use Dcat\Admin\Admin;
use Illuminate\Support\Facades\DB;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Widgets\Card;
use App\Admin\Forms\ImportExcel;
use App\Admin\Actions\DownloadTemplateExcel;
class CovenantController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(ModelsCovenant::with(['lawyer']), function (Grid $grid) {
//工具栏
$grid->tools(function (Grid\Tools $tools) {
$tools->append(Modal::make()
// 大号弹窗
->lg()
// 弹窗标题
->title('上传文件')
// 按钮
->button('<button class="btn btn-primary"><i class="feather icon-upload"></i> 导入数据</button>')
// 弹窗内容
->body(ImportExcel::make()->payload(['className' => ModelsCovenant::class])));
// 下载导入模板
$tools->append(DownloadTemplateExcel::make()->setKey('ModelsCovenant'));
});
$grid->model()->orderBy('id', 'DESC');
//$grid->column('id')->sortable();
$grid->column('number');
$grid->column('cname')->width(200);
$grid->column('ctype')->display(function ($val) {
return Covenant::CTYPE[$val];
});
$grid->column('sign_at');
$grid->column('principal', '委托人');
$grid->column('lawyer.name', '办案律师');
$grid->column('amount')->display(function ($val) {
return number_format($val, 2);
});
$grid->column('payment_method')->display(function ($val) {
return $val == 1 ? '开票付款' : '付款开票';
});
$grid->column('reserve_fee', '预留结案费')->display(function () {
$lawyerObj = ModelLawyer::find($this->lawyer_id);
$commission_rate = $lawyerObj->commission_rate;
$result = $this->amount * $commission_rate / 100 * 0.05;
return number_format($result, 2);
});
$grid->column('is_closed', '结案状态')->display(function ($val) {
return $val ? '已结案' : '未结案';
});
$grid->column('is_return', '退案状态')->display(function ($val) {
return $val ? '已退案' : '未退案';
});
$grid->column('return_fee', '退案结案费');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableRowSelector();
//禁用增加按钮
if (!Admin::user()->can('hetong-add')) {
$grid->disableCreateButton();
}
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number')->width(3);
$filter->like('cname')->width(3);
$filter->like('principal', '委托人')->width(3);
$filter->like('lawyer.name', '办案律师')->width(3);
$filter->equal('ctype')->select(Covenant::CTYPE)->width(3);
$filter->equal('payment_method')->select(Covenant::PAYMENT_METHOD)->width(3);
$filter->between('sign_at', '签约日期')->date()->width(4);
});
$grid->export()->rows(function ($rows) {
foreach ($rows as $index => &$row) {
$row['ctype'] = Covenant::CTYPE[$row['ctype']];
$row['payment_method'] = ($row['payment_method'] == 1) ? '开票付款' : '付款开票';
$row['is_closed'] = ($row['is_closed'] == 1) ? '已结案' : '未结案';
$row['is_return'] = ($row['is_return'] == 1) ? '已退案' : '未退案';
}
return $rows;
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('hetong-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('hetong-delete')) {
$actions->disableDelete();
}
//已结案
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->row->is_return == 0) {
$actions->append(new CovenantReturn('', $actions->row->id));
}
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Covenant(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('cname');
$show->field('ctype');
$show->field('sign_at');
$show->field('principal_id');
$show->field('lawyer_id');
$show->field('amount');
$show->field('payment_method');
$show->field('case_reason');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$list = ModelLawyer::select(['id', 'number', 'name'])->limit(1000)->get()->toArray();
$lawyers = [];
if ($list) {
foreach ($list as $item) {
$lawyers[$item['id']] = $item['number'] . ' ' . $item['name'];
}
}
$form = Form::make(new Covenant(), function (Form $form) use ($lawyers) {
$form->display('id');
$form->text('number')->required();
$form->select('ctype')->options(Covenant::CTYPE)->default(1)->required();
$form->text('cname')->required();
$form->date('sign_at')->format('YYYY-MM-DD')->default(date("Y-m-d"))->required();
$form->select('principal_type')->options([1 => '单位', 2 => '个人'])->default(1)->load('principal_id', '/principal-list');;
$form->select('principal_id')->required();
$form->text('case_reason')->required();
$form->select('lawyer_id')->options($lawyers)->required();
$form->text('amount')->required();
$form->select('payment_method')->options(Covenant::PAYMENT_METHOD)->default(1)->required();
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->display('created_at');
$form->display('updated_at');
});
$form->saved(
function (Form $form, $result) {
$cid = $form->getKey();
if (isset($_POST['principal_id']) && $_POST['principal_id']) {
$pObj = ModelPrincipal::find($_POST['principal_id']);
$pname = $pObj->name ? $pObj->name : $pObj->company;
DB::table('covenant')->where("id", $cid)->update(['principal' => $pname]);
}
}
);
return $form;
}
public function destroy($id)
{
$res = $this->form()->destroy($id);
if ($res) {
//收款开票信息
ModelCovenantReceivePayment::where('cid', $id)->delete();
}
return $res;
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use App\Models\Covenant as ModelsCovenant;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Repositories\CovenantReceivePaymentCollect;
use Carbon\Carbon;
use Dcat\Admin\Support\Helper;
use App\Admin\Extensions\CovenantReceivePaymentExportExten;
use App\Admin\Actions\CovenantReceivePaymentExcel;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
class CovenantReceivePaymentController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new CovenantReceivePaymentCollect(), function (Grid $grid) {
// 获取筛选条件
$params = [];
$params['lnum'] = $_GET['lnum'] ?? '';
$params['lname'] = $_GET['lname'] ?? '';
$params['cnum'] = $_GET['cnum'] ?? '';
$params['ctype'] = $_GET['ctype'] ?? '';
$params['principal'] = $_GET['principal'] ?? '';
$received_at = $invoiced_at = [];
$received_at['start'] = $_GET['received_at']['start'] ?? '';
$received_at['end'] = $_GET['received_at']['end'] ?? '';
$invoiced_at['start'] = $_GET['invoiced_at']['start'] ?? '';
$invoiced_at['end'] = $_GET['invoiced_at']['end'] ?? '';
//已收款
$receivedMoney = ModelsCovenantReceivePayment::getTotalReceivedAmount($params, $received_at, $invoiced_at);
//开票金额
$invoicedMoney = ModelsCovenantReceivePayment::getTotalInvoicedMoney($params, $received_at, $invoiced_at);
//已收款未开票
$receiptNoinvoice = ($receivedMoney - $invoicedMoney) > 0 ? number_format($receivedMoney - $invoicedMoney, 2) : 0;
//已开票未收款
$invoiceNoreceipt = ($invoicedMoney - $receivedMoney) > 0 ? number_format($invoicedMoney - $receivedMoney, 2) : 0;
// 添加一行表头数据
// $grid->header(function () use ($invoicedMoney, $receivedMoney, $receiptNoinvoice, $invoiceNoreceipt) {
// return '<div class="row" style="text-align:center;">' .
// '<div class="col-md-7" >合计</div>' .
// '<div class="col-md-1">' . $invoicedMoney . '</div>' .
// '<div class="col-md-1">' . $receivedMoney . '</div>' .
// '<div class="col-md-1">' . $receiptNoinvoice . '</div>' .
// '<div class="col-md-2">' . $invoiceNoreceipt . '</div>' .
// '</div>';
// });
$grid->header(function () use ($invoicedMoney, $receivedMoney, $receiptNoinvoice, $invoiceNoreceipt) {
return '<div class="table-responsive table-wrapper complex-container table-middle mt-1 table-collapse ">
<table class="table custom-data-table data-table" id="grid-table" border=0>
<thead>
<tr>
<th width="90"></th>
<th width="90"></th>
<th width="90">合计</th>
<th width="90"></th>
<th width="90"></th>
<th width="90">' . number_format($invoicedMoney, 2) . '</th>
<th width="90">' . number_format($receivedMoney, 2) . '</th>
<th width="90">' . $receiptNoinvoice . '</th>
<th width="90"> ' . $invoiceNoreceipt . '</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>';
});
//$grid->column('id')->sortable();
//$grid->column('lnum', '律师编号')->width(90);
$grid->column('lname', '律师姓名')->width(90);
$grid->column('covenant_num', '合同编号')->width(90);
$grid->column('covenant_name', '合同名称')->width(90);
$grid->column('covenant_type', '合同类型')->width(90);
$grid->column('principal', '委托人')->width(90);
$grid->column('invoice_amount', '开票金额')->width(90);
$grid->column('receipt_money', '已收款')->width(90);
$grid->column('receipt_noinvoice', '已收款未开票')->width(90);
$grid->column('invoice_noreceipt', '已开票未收款')->width(90);
//$grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
//$filter->like('lnum', '律师编号')->width(3);
$filter->like('lname', '律师名称')->width(3);
// $filter->like('cnum', '合同编号')->width(3);
// $filter->equal('ctype', '合同类型')->select(ModelsCovenant::CTYPE)->width(3);
// $filter->like('principal', '委托人')->width(3);
// $filter->between('received_at', '收款日期')->date()->width(4);
// $filter->between('invoiced_at', '开票日期')->date()->width(4);
});
// 添加导出按钮
$grid->tools(function (Grid\Tools $tools) use ($grid) {
// 获取筛选参数
$params = [];
$params['lnum'] = request()->input('lnum', '');
$params['lname'] = request()->input('lname', '');
$params['cnum'] = request()->input('cnum', '');
$params['ctype'] = request()->input('ctype', '');
$params['principal'] = request()->input('principal', '');
$received_at = [];
$received_at['start'] = request()->input('received_at.start') ? request()->input('received_at.start') . "-01" : '';
$received_at['end'] = request()->input('received_at.end') ? request()->input('received_at.end') . "-31" : '';
$invoiced_at = [];
$invoiced_at['start'] = request()->input('invoiced_at.start') ? request()->input('invoiced_at.start') . "-01" : '';
$invoiced_at['end'] = request()->input('invoiced_at.end') ? request()->input('invoiced_at.end') . "-31" : '';
// 导出按钮参数
$param = [
'search' => $params,
'received_at' => $received_at,
'invoiced_at' => $invoiced_at,
];
$filename = '开票付款汇总'.date('YmdHis',time());;
$tools->append(new CovenantReceivePaymentExcel($param, $filename, '导出'));
});
});
}
/**
* 导出
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
$filename = $request->get('filename');
$param = json_decode($request->get('param'), true);
//获取筛选参数
$received_at = $invoiced_at = [];
$received_at['start'] = isset($_GET['received_at']['start']) && $_GET['received_at']['start'] ? $_GET['received_at']['start'] . "-01" : '';
$received_at['end'] = isset($_GET['received_at']['end']) && $_GET['received_at']['end'] ? $_GET['received_at']['end'] . "-31" : '';
$invoiced_at['start'] = isset($_GET['invoiced_at']['start']) && $_GET['invoiced_at']['start'] ? $_GET['invoiced_at']['start'] . "-01" : '';
$invoiced_at['end'] = isset($_GET['invoiced_at']['end']) && $_GET['invoiced_at']['end'] ? $_GET['invoiced_at']['end'] . "-31" : '';
$param['received_at'] = $received_at;
$param['invoiced_at'] = $invoiced_at;
// 检查是否有输出缓冲区
while (ob_get_level()) {
ob_end_clean();
}
return Excel::download(new CovenantReceivePaymentExportExten($param), $filename . '.xlsx');
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Admin;
use Illuminate\Support\Facades\Auth;
class HomeController extends Controller
{
public function index(Content $content)
{
$user = Admin::user();
// $user = Administrator::findOrFail($userId); // 获取用户模型
$roles = $user->roles; // 获取用户的角色
$permissions = [];
foreach ($roles as $role) {
$permissions = array_merge($permissions, $role->permissions->pluck('slug')->toArray());
}
// echo "<pre>";
// print_r($permissions);
// die;
return $content
->header('Dashboard')
->description('Description...')
->body(function (Row $row) {
// $row->column(6, function (Column $column) {
// $column->row(Dashboard::title());
// $column->row(new Examples\Tickets());
// });
// $row->column(6, function (Column $column) {
// $column->row(function (Row $row) {
// $row->column(6, new Examples\NewUsers());
// $row->column(6, new Examples\NewDevices());
// });
// $column->row(new Examples\Sessions());
// $column->row(new Examples\ProductOrders());
// });
$row->column(12, '欢迎登录');
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Admin\Repositories\LawyerCommission;
use App\Models\Lawyer as ModelsLawyer;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\LawyerCommissionCollectExcel;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Admin\Extensions\lawyerCommissionExportExten;
class LawyerCommissionCollectController extends AdminController
{
/**
* 律师提成汇总
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new LawyerCommission(), function (Grid $grid) {
$number = $grid->model()->filter()->input('no') ?? ''; //律师编号
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
$grid->column('title', '项目名称')->width('10%');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->column('total', '合计')->display(function ($val) {
return $val ? $val : '';
});
// $grid->disableViewButton();
// $grid->disableCreateButton();
$grid->filter(function (Grid\Filter $filter) use ($number) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"));
});
$grid->disableRowSelector();
$grid->disableActions();
$grid->disableCreateButton();
$grid->disablePagination();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $number, $year) {
$fullname = '';
if ($number) {
$obj = ModelsLawyer::where('number', $number)->first();
$fullname = $obj->name;
}
// 导出按钮 获取筛选条件
$param = [
'search' => ['number' => $number, 'year' => $year]
];
// 导出
$filename = $year . '年' . $fullname . '律师提成汇总表';
$tools->append(new LawyerCommissionCollectExcel($param, $filename, '导出'));
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
});
}
/**
* 导出
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function lawyerCommissionExport(Request $request)
{
$filename = $request->get('filename');
$param = json_decode($request->get('param'));
ob_end_clean();
return Excel::download(new lawyerCommissionExportExten($param), $filename . '.xlsx');
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Lawyer;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Admin;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
class LawyerCommissionController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Lawyer(), function (Grid $grid) {
$year = $grid->model()->filter()->input('year') ?? date('Y');
//$grid->column('id')->sortable();
//$grid->column('number', '律师编号');
$grid->column('name', '律师姓名');
$grid->column('received_money', '创收已收款')->display(function ($val) use ($year) {
$money = self::getReceivedMoney($year, $this->id);
return number_format($money, 2);
});
$grid->column('commission_rate', '提成比例 %');
$grid->column('paid_amount', '已支付款项')->display(function ($val) use ($year) {
$paid_amount = self::getPaidAmount($year, $this->id);
return number_format($paid_amount, 2);
});
$grid->column('posting_tickets_money', '贴票金额')->display(function () use ($year) {
$tickets_money = ModelLawyerCost::getAllPostingTicketsMoney($this->id, $year);
return number_format($tickets_money, 2);
});
$grid->column('commission_retention', '预留结案费')->display(function () use ($year) {
$received_money = ModelCovenantReceivePayment::getReceivedMoney($this->id, $year); //创收已收款
$commission_rate = $this->commission_rate; //提成比例
$result = $received_money * ($commission_rate / 100) * 0.05;
return number_format($result, 2);
});
$grid->column('payable_amount', '可支付提成结算金额')->display(function () use ($year) {
$received_money = ModelCovenantReceivePayment::getReceivedMoney($this->id, $year); //创收已收款
$paid_amount = ModelLawyerCost::getPaidAmount($this->id, $year); //已支付款项
$commission_rate = $this->commission_rate; //提成比例
$result = $received_money * ($commission_rate / 100) - $paid_amount;
return number_format($result, 2);
});
$grid->column('personal_income_tax', '个人所得税')->display(function ($val) use ($year) {
$amount = self::getPersonalIncomeTax($year, $this->id);
return number_format($amount, 2);
});
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
//$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//查看
if (Admin::user()->can('lawyer-commission-collect-view')) {
$actions->append('<a href="/lawyer-commission-collect?no=' . $this->number . '" alt="查看"><i class="feather icon-eye"> 查看 </i></a>');
}
});
});
}
//创收已收款
public static function getReceivedMoney($year, $lawyer_id)
{
$money = ModelCovenantReceivePayment::where(['lawyer_id' => $lawyer_id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
return $money;
}
//已支付款项
public static function getPaidAmount($year, $lawyer_id)
{
$paid_amount = 0;
$list = ModelLawyerCost::where(['lawyer_id' => $lawyer_id, 'year' => $year])->get();
if ($list->toArray()) {
$basic_salary = $special_additional = $social_company_fee = $accumulation_fund_company_fee = 0;
$annual_inspection_fee = $annuity = $office_rental_fee = $assistant_fee = 0;
foreach ($list as $item) {
$basic_salary += $item->basic_salary;
$special_additional += $item->special_additional;
$social_company_fee += $item->social_company_fee;
$accumulation_fund_company_fee += $item->accumulation_fund_company_fee;
$annual_inspection_fee += $item->annual_inspection_fee;
$annuity += $item->annuity;
$office_rental_fee += $item->office_rental_fee;
$assistant_fee += $item->assistant_fee;
}
$paid_amount = $basic_salary + $special_additional + $social_company_fee + $accumulation_fund_company_fee + $annual_inspection_fee + $annuity + $office_rental_fee + $assistant_fee;
}
return $paid_amount;
}
//个人所得税
public static function getPersonalIncomeTax($year, $lawyer_id)
{
$amount = 0;
$list = ModelLawyerCost::where(['lawyer_id' => $lawyer_id, 'year' => $year])->get();
if ($list->toArray()) {
$personal_income_tax = 0;
foreach ($list as $item) {
$amount += $item->personal_income_tax;
}
}
return $amount;
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Lawyer(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('name');
$show->field('sex');
$show->field('identity_card');
$show->field('phone');
$show->field('bank_account');
$show->field('sign_at');
$show->field('commission_rate');
$show->field('settlement_period');
$show->field('created_at');
$show->field('updated_at');
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Lawyer;
use App\Models\Lawyer as ModelLawyer;
use App\Models\Covenant as ModelCovenant;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Admin;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\LawyersExport;
class LawyerController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Lawyer(), function (Grid $grid) {
//$grid->column('id')->sortable();
$grid->column('number');
$grid->column('name');
$grid->column('sex')->display(function ($val) {
return $val == 1 ? '男' : '女';
});
$grid->column('identity_card');
$grid->column('phone');
$grid->column('bank_account');
$grid->column('sign_at');
$grid->column('commission_rate');
$grid->column('settlement_period')->display(function ($val) {
return $val == 1 ? '月' : '年';
});
$grid->column('ticket_ratio', '贴票比例(%)');
$grid->column('settlement_method', '结算方式')->display(function ($val) {
return $val == 1 ? '贴票' : '个税';
});
$grid->column('commission_retention', '提成留底');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableRowSelector();
//禁用增加按钮
if (!Admin::user()->can('lawyer-add')) {
$grid->disableCreateButton();
}
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('name')->width(3);
$filter->like('identity_card')->width(3);
$filter->like('phone')->width(3);
$filter->equal('settlement_period')->select(Lawyer::SETTLEMENT_PERIOD)->width(3);
$filter->equal('settlement_method')->select(Lawyer::SETTLEMENT_METHOD)->width(3);
});
//添加导出按钮
$grid->export()->rows(function ($rows) {
foreach ($rows as $index => &$row) {
$row['sex'] = ($row['sex'] == 1) ? '男' : '女';
$row['settlement_period'] = ($row['settlement_period'] == 1) ? '月' : '年';
$row['settlement_method'] = ($row['settlement_method'] == 1) ? '贴票' : '个税';
}
return $rows;
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('lawyer-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('lawyer-delete')) {
$actions->disableDelete();
}
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Lawyer(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('name');
$show->field('sex');
$show->field('identity_card');
$show->field('phone');
$show->field('bank_account');
$show->field('sign_at');
$show->field('commission_rate');
$show->field('settlement_period');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new Lawyer(), function (Form $form) {
$form->display('id');
//$form->text('number');
$form->text('name')->required();
$form->select('sex')->options([1 => '男', 2 => '女'])->default(1)->required();
$form->text('identity_card')->required();
$form->text('phone')->required();
$form->text('bank_account')->required();
$form->date('sign_at')->format('YYYY-MM-DD')->required();
$form->text('commission_rate');//提成比例,提了在更新代码
$form->select('settlement_period')->options([1 => '月', 2 => '年'])->default(1)->required();
$form->text('ticket_ratio', '贴票比例')->required();
$form->select('settlement_method', '结算方式')->options([1 => '贴票', 2 => '个税'])->default(1)->required();
$form->text('commission_retention', '提成留底');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$number = $form->number;
$form->hidden('number');
if (!$number) {
$form->saving(function (Form $form) {
$form->number = self::getRandNumber();
});
}
// $form->display('created_at');
// $form->display('updated_at');
});
return $form;
}
//生成编号
public static function getRandNumber()
{
$rndnumber = '';
$flag = 0;
do {
$rndnumber = mt_rand(10000, 99999);
$rowObj = ModelLawyer::where('number', $rndnumber)->count();
$flag = $rowObj ? 0 : 1;
} while ($flag < 1);
return $rndnumber;
}
public function destroy($id)
{
$res = $this->form()->destroy($id);
if ($res) {
//合同信息
ModelCovenant::where('lawyer_id', $id)->delete();
//收款开票信息
ModelCovenantReceivePayment::where('lawyer_id', $id)->delete();
}
return $res;
}
public function getList(Request $request)
{
$name = $request->get('q');
$where = [];
if ($name) {
$where['name'] = ['like', '%' . $name . '%'];
}
$data = [];
$list = ModelLawyer::whereNull('deleted_at')->where($where)
->select(['id', 'number', 'name'])->limit(100)
->get()
->toArray();
foreach ($list as $item) {
$tmp = [];
$tmp['id'] = $item['number'];
$tmp['text'] = $item['number'] . ' ' . $item['name'];
array_push($data, $tmp);
}
return $data;
}
/**
* 导出律师数据
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export()
{
return Excel::download(new LawyersExport(), 'lawyers.xlsx');
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Admin\Repositories\LawyerCost;
use App\Models\Lawyer as ModelsLawyer;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\LawyerCostCollectExcel;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Admin\Extensions\lawyerCostExportExten;
class LawyerCostCollectController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new LawyerCost(), function (Grid $grid) {
$number = $grid->model()->filter()->input('no') ?? ''; //律师编号
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
$grid->column('title', '项目名称')->width('10%');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->column('total', '合计');
// $grid->disableViewButton();
// $grid->disableCreateButton();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"));
});
$grid->disableRowSelector();
$grid->disableActions();
$grid->disableCreateButton();
$grid->disablePagination();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $number, $year) {
$fullname = '';
if ($number) {
$obj = ModelsLawyer::where('number', $number)->first();
$fullname = $obj->name;
}
// 导出按钮 获取筛选条件
$param = [
'search' => ['number' => $number, 'year' => $year]
];
// 导出
$filename = $year . '年' . $fullname . '律师成本汇总表';
$tools->append(new LawyerCostCollectExcel($param, $filename, '导出'));
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new ModelLawyerCost(), function (Show $show) {
$show->field('id');
$show->field('year');
$show->field('month');
$show->field('number');
$show->field('lname');
$show->field('basic_salary');
$show->field('social_person_fee');
$show->field('social_company_fee');
$show->field('accumulation_fund_person_fee');
$show->field('accumulation_fund_company_fee');
$show->field('annual_inspection_fee');
$show->field('annuity');
$show->field('office_rental_fee');
$show->field('noticket_cost');
$show->field('posting_tickets_fee');
$show->field('assistant_fee');
$show->field('special_additional');
$show->field('advance_fee');
$show->field('personal_income_tax');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year');
$form->select('month')->options(ModelLawyerCost::MONTH);
$form->display('number');
$form->text('lname');
$form->text('basic_salary');
$form->text('social_person_fee');
$form->text('social_company_fee');
//$form->display('social', '社保')->default(100);
$form->text('accumulation_fund_person_fee');
$form->text('accumulation_fund_company_fee');
$form->text('annual_inspection_fee');
$form->text('annuity');
$form->text('office_rental_fee');
//$form->text('noticket_cost');
//$form->text('posting_tickets_fee');
$form->text('assistant_fee');
$form->text('special_additional');
$form->text('advance_fee');
$form->text('personal_income_tax');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->display('created_at');
$form->display('updated_at');
});
}
/**
* 导出
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function lawyerCostExport(Request $request)
{
$filename = $request->get('filename');
$param = json_decode($request->get('param'));
ob_end_clean();
return Excel::download(new lawyerCostExportExten($param), $filename . '.xlsx');
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Covenant;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Lawyer as ModelLawyer;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Actions\CovenantReceive;
use App\Admin\Actions\CovenantInvoice;
use Dcat\Admin\Admin;
class LawyerCovenantIncomeController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Covenant(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
if ($lawyerID) {
$grid->model()->where('lawyer_id', $lawyerID);
}
//$grid->column('cid')->sortable();
$grid->column('number', '合同编号');
$grid->column('cname', '合同名称');
$grid->column('ctype', '合同类型')->display(function ($val) {
return ModelsCovenant::CTYPE[$val];
});
$grid->column('principal', '委托人');
$grid->column('invoice_amount', '开票金额');
$grid->column('receipt_money', '已收款');
$grid->column('receipt_noinvoice', '已收款未开票');
$grid->column('invoice_noreceipt', '已开票未收款');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableRowSelector();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('number', '合同编号')->width(3);
$filter->like('cname', '合同名称')->width(3);
$filter->like('principal', '委托人')->width(3);
$filter->between('received_at', '收款日期')->date()->width(4);
$filter->between('invoiced_at', '开票日期')->date()->width(4);
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID) {
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
$grid->actions(function (Grid\Displayers\Actions $actions) use ($lawyerID) {
//添加收款
if (Admin::user()->can('receive-payment')) {
$actions->append(new CovenantReceive('添加收款', $actions->row->cid));
}
//添加开票
if (Admin::user()->can('invoiced-payment')) {
$actions->append(new CovenantInvoice('添加开票', $actions->row->cid));
}
//查看收款
$cid = $actions->row->cid;
if (Admin::user()->can('view-received')) {
$actions->append('<a href="/view-covenant-received?cid=' . $cid . '" alt="查看收款" >查看收款</a>');
}
//查看开票
if (Admin::user()->can('view-invoiced')) {
$actions->append('<a href="/view-covenant-invoiced?cid=' . $cid . '" alt="查看开票" >查看开票</a>');
}
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Covenant(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('cname');
$show->field('ctype');
$show->field('sign_at');
$show->field('principal_id');
$show->field('lawyer_id');
$show->field('amount');
$show->field('payment_method');
$show->field('case_reason');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$list = ModelLawyer::select(['id', 'number', 'name'])->limit(1000)->get()->toArray();
$lawyers = [];
if ($list) {
foreach ($list as $item) {
$lawyers[$item['id']] = $item['number'] . ' ' . $item['name'];
}
}
return Form::make(new Covenant(), function (Form $form) use ($lawyers) {
$form->display('id');
$form->text('number')->required();
$form->select('ctype')->options(Covenant::CTYPE)->default(1);
$form->text('cname')->required();
$form->date('sign_at')->format('YYYY-MM-DD')->default(date("Y-m-d"));
$form->select('principal_type')->options([1 => '单位', 2 => '个人'])->default(1)->load('principal_id', '/principal-list');;
$form->select('principal_id');
$form->text('case_reason');
$form->select('lawyer_id')->options($lawyers);
$form->text('amount');
$form->select('payment_method')->options(Covenant::PAYMENT_METHOD)->default(1);
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->display('created_at');
$form->display('updated_at');
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Admin;
class LawyerIncomeController extends AdminController
{
/**
* 律师创收信息
* Make a grid builder.
* @return Grid
*/
protected function grid()
{
return Grid::make(new ModelLawyer(), function (Grid $grid) {
//$grid->column('id')->sortable();
$year = $grid->model()->filter()->input('year') ?? date('Y');
//$grid->column('number', '律师编号');
$grid->column('name', '律师姓名');
$grid->column('sex', '性别')->display(function ($val) {
return $val == 1 ? '男' : '女';
});
$grid->column('identity_card', '身份证号');
$grid->column('phone', '手机号');
$grid->column('field1', '开票金额')->display(function () use ($year) {
//开票金额
$invoiced_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 2])
->where('invoiced_at', 'like', $year . '%')
->sum('invoiced_money');
return number_format($invoiced_money, 2);
});
$grid->column('field2', '已收款')->display(function () use ($year) {
//已收款
$receipt_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
return number_format($receipt_money, 2);
});
$grid->column('field3', '已收款未开票')->display(function () use ($year) {
//开票金额
$invoiced_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 2])
->where('invoiced_at', 'like', $year . '%')
->sum('invoiced_money');
//已收款
$receipt_money = ModelCovenantReceivePayment::where(['lawyer_id' => $this->id, 'rtype' => 1])
->where('received_at', 'like', $year . '%')
->sum('received_amount');
//已收款未开票
$receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? number_format($receipt_money - $invoiced_money, 2) : '-';
return $receipt_noinvoice;
});
$grid->column('field4', '已开票未收款')->display(function ($val) {
$id = $this->id;
$year = date('Y');
$linkstr = '';
//创收收款表
if (Admin::user()->can('lawyer-covenant-income')) {
$linkstr .= '<a href="/lawyer-covenant-income?no=' . $id . '" >创收收款表</a>&nbsp;&nbsp;';
}
//已收款/已开票汇总
if (Admin::user()->can('received-invoiced')) {
$linkstr .= '<a href="/receive_payment?no=' . $id . '&year=' . $year . '" >已收款/已开票汇总</a><br/>';
}
return $linkstr;
});
$grid->disableCreateButton();
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableRowSelector();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
//$filter->like('number', '律师编号')->width(3);
$filter->like('name', '律师姓名')->width(3);
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
//$filter->date('sign_at')->format('YYYY-MM-DD');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new ModelLawyerCost(), function (Show $show) {
$show->field('id');
$show->field('year');
$show->field('month');
$show->field('number');
$show->field('lname');
$show->field('basic_salary');
$show->field('social_person_fee');
$show->field('social_company_fee');
$show->field('accumulation_fund_person_fee');
$show->field('accumulation_fund_company_fee');
$show->field('annual_inspection_fee');
$show->field('annuity');
$show->field('office_rental_fee');
$show->field('noticket_cost');
$show->field('posting_tickets_fee');
$show->field('assistant_fee');
$show->field('special_additional');
$show->field('advance_fee');
$show->field('personal_income_tax');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new ModelLawyerCost(), function (Form $form) {
$form->display('id');
$form->text('year');
$form->select('month')->options(ModelLawyerCost::MONTH);
$form->text('number');
$form->text('lname');
$form->text('basic_salary');
$form->text('social_person_fee');
$form->text('social_company_fee');
//$form->display('social', '社保')->default(100);
$form->text('accumulation_fund_person_fee');
$form->text('accumulation_fund_company_fee');
$form->text('annual_inspection_fee');
$form->text('annuity');
$form->text('office_rental_fee');
//$form->text('noticket_cost');
//$form->text('posting_tickets_fee');
$form->text('assistant_fee');
$form->text('special_additional');
$form->text('advance_fee');
$form->text('personal_income_tax');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->display('created_at');
$form->display('updated_at');
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\Principal;
use App\Models\Principal as ModelsPrincipal;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Card;
class PrincipalController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Principal(), function (Grid $grid) {
$ptype = $grid->model()->filter()->input('wtype') ?? 0;
$where = $ptype ? ['wtype' => $ptype] : [];
$grid->model()->where($where)->orderBy("id", "desc");
//$grid->column('id')->sortable();
$grid->column('number');
$grid->column('wtype', '类型')->display(function ($val) {
return $val == 1 ? '单位' : '个人';
})->width(50);
//if ($ptype == 1) {
$grid->column('company');
$grid->column('tax_number');
$grid->column('address');
$grid->column('tel');
$grid->column('bank_name', '开户银行');
$grid->column('bank_account')->width(90)->if(function ($column) {
return $column->getValue();
})->display('查看')->modal(function ($modal) {
$modal->title('开户账号');
$content = $this->bank_account;
$card = new Card(null, $content);
return "<div style='padding:10px 10px 0;width:100%;'>$card</div>";
})->else(function ($column) {
return '';
});
$grid->column('contacts')->width(90);
//} else {
$grid->column('name');
//$grid->column('identity_card');
$grid->column('identity_card')->width(90)->if(function ($column) {
return $column->getValue();
})->display('查看')->modal(function ($modal) {
$modal->title('身份信息');
$content = $this->identity_card;
$card = new Card(null, $content);
return "<div style='padding:10px 10px 0;width:100%;'>$card</div>";
})->else(function ($column) {
return '';
});
$grid->column('address', '联系地址');
//}
$grid->column('phone');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->disableViewButton();
$grid->disableRowSelector();
//禁用增加按钮
if (!Admin::user()->can('principal-add')) {
$grid->disableCreateButton();
}
$grid->filter(function (Grid\Filter $filter) use ($ptype) {
// 更改为 panel 布局
$filter->panel();
$filter->like('company')->width(3);
$filter->like('tax_number')->width(3);
$filter->like('name')->width(3);
$filter->like('identity_card')->width(3);
$filter->equal('wtype', '类型')->select([1 => '单位', 2 => '个人'])->width(3);
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('principal-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('principal-delete')) {
$actions->disableDelete();
}
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Principal(), function (Show $show) {
$show->field('id');
$show->field('number');
$show->field('company');
$show->field('username');
$show->field('identity_card');
$show->field('tax_number');
$show->field('address');
$show->field('tel');
$show->field('bank_name');
$show->field('bank_account');
$show->field('contacts');
$show->field('phone');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new Principal(), function (Form $form) {
$form->display('id');
$form->radio('wtype', '类型')
->when(1, function (Form $form) {
$form->text('company')->setLabelClass(['asterisk']);
$form->text('tax_number')->setLabelClass(['asterisk']);
$form->text('tel');
$form->text('bank_name', '开户银行');
$form->text('bank_account');
$form->text('contacts');
})
->when(2, function (Form $form) {
$form->text('name')->setLabelClass(['asterisk']);
$form->text('identity_card');
})
->options([
1 => '单位',
2 => '个人',
])
->default(1);
$form->text('address');
$form->text('phone');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$number = $form->number;
$form->hidden('number');
if (!$number) {
$form->saving(function (Form $form) {
$form->number = self::getRandNumber();
});
}
$form->display('created_at');
$form->display('updated_at');
});
$form->submitted(function (Form $form) {
$wtype = isset($_POST['wtype']) ? $_POST['wtype'] : 0;
$company = isset($_POST['company']) ? $_POST['company'] : '';
$tax_number = isset($_POST['tax_number']) ? $_POST['tax_number'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : ''; //姓名
$identity_card = isset($_POST['identity_card']) ? $_POST['identity_card'] : '';
if ($wtype == 1) {
if (!$company) {
$form->responseValidationMessages('company', "单位全称不为空");
}
if (!$tax_number) {
$form->responseValidationMessages('tax_number', "税号不为空");
}
} elseif ($wtype == 2) {
if (!$name) {
$form->responseValidationMessages('name', "姓名不为空");
}
// if (!$identity_card) {
// $form->responseValidationMessages('identity_card', "身份证号码不为空");
// }
}
});
// Admin::script(
// <<<JS
// $(function () {
// //社保
// $("input[name='wtype']").on('click', function() {
// var wtype = $(this).val();
// console.log('-----'+wtype);
// if(wtype==1) {
// $("input[name='company']").attr('required',1);
// $("input[name='tax_number']").attr('required',1);
// $("input[name='name']").removeAttr('required');
// $("input[name='identity_card']").removeAttr('required');
// } else {
// $("input[name='name']").attr('required',1);
// $("input[name='identity_card']").attr('required',1);
// $("input[name='company']").removeAttr('required');
// $("input[name='tax_number']").removeAttr('required');
// }
// });
// });
// JS
// );
return $form;
}
//生成编号
public static function getRandNumber()
{
$rndnumber = '';
$flag = 0;
do {
$rndnumber = mt_rand(10000, 99999);
$rowObj = ModelsPrincipal::where('number', $rndnumber)->count();
$flag = $rowObj ? 0 : 1;
} while ($flag < 1);
return $rndnumber;
}
public function getList(Request $request)
{
$wtype = $request->get('q'); //委托人类型
if ($wtype == 1) {
$list = ModelsPrincipal::where('wtype', $wtype)->limit(1000)->get(['id', 'company as text']);
} else {
$list = ModelsPrincipal::where('wtype', $wtype)->limit(1000)->get(['id', 'name as text']);
}
return $list->toArray() ? $list : new \stdClass;;
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use App\Models\Covenant;
use App\Models\Lawyer;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Tab;
use Dcat\Admin\Grid;
use App\Models\Lawyer as ModelsLawyer;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use App\Admin\Repositories\LawyerReceivePaymentCollect;
use App\Admin\Repositories\LawyerInvoicedPaymentCollect;
use App\Admin\Actions\ReceivedInvoicedExcel;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Admin\Extensions\ReceivedInvoicedExport;
class ReceivePaymentController extends Controller
{
public function index(Content $content)
{
// 创建第一个数据列表 已收款汇总表
$grid1 = Grid::make(new LawyerReceivePaymentCollect(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->disableActions();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disablePagination();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID, $year) {
//导出按钮
// 获取筛选条件
$param = [
'search' => ['lawyer_id' => $lawyerID, 'year' => $year, 'rtype' => 1]
];
// 导出
$filename = '已收款汇总表';
$tools->append(new ReceivedInvoicedExcel($param, $filename, '导出'));
//文字展示
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelsLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
// $grid->export()->disableExportAll();
// $grid->export()->disableExportSelectedRow();
// $grid->export()->rows(function ($rows) {
// return $rows;
// });
});
// 创建第二个数据列表
$grid2 = Grid::make(new LawyerInvoicedPaymentCollect(), function (Grid $grid) {
$lawyerID = $grid->model()->filter()->input('no') ?? ''; //律师ID
$nowyear = date("Y");
$year = $grid->model()->filter()->input('year') ?? date('Y');
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->disableActions();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disablePagination();
$grid->filter(function (Grid\Filter $filter) {
// 更改为 panel 布局
$filter->panel();
$filter->like('year', '年份')->width(3)->default(date("Y"))->ignore();
});
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $lawyerID, $year) {
//导出按钮
// 获取筛选条件
$param = [
'search' => ['lawyer_id' => $lawyerID, 'year' => $year, 'rtype' => 2]
];
// 导出
$filename = '已开票汇总表';
$tools->append(new ReceivedInvoicedExcel($param, $filename, '导出'));
//文字展示
$fullname = $number = '';
if ($lawyerID) {
$obj = ModelsLawyer::find($lawyerID);
$fullname = $obj->name;
$number = $obj->number;
}
$card_info = "&nbsp;&nbsp;律师编号:{$number}&nbsp;&nbsp;&nbsp;律师姓名:{$fullname}";
$tools->append($card_info);
});
// $grid->export()->disableExportAll();
// $grid->export()->disableExportSelectedRow();
// $grid->export()->rows(function ($rows) {
// return $rows;
// });
});
// 使用Tab面板展示两个数据列表
$tab = Tab::make()->add('已收款汇总表', $grid1)->add('已开票汇总表', $grid2);
return $content->body($tab);
}
/**
* 导出
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function receivedInvoicedExport(Request $request)
{
$filename = $request->get('filename');
$param = json_decode($request->get('param'));
ob_end_clean();
return Excel::download(new ReceivedInvoicedExport($param), $filename . '.xlsx');
}
}
<?php
namespace App\Admin\Controllers;
use App\Handlers\AilOss;
use Dcat\Admin\Traits\HasUploadedFile;
use Intervention\Image\Facades\Image;
class UploadController{
use HasUploadedFile;
/**
* 删除OSS私有桶资源文件
*/
public function deleteOssFile(){
$ossPath = request()->post('key') ?? '';
$aliOss = new AilOss();
$res = $aliOss->delete($ossPath);
return $res ? $this->responseDeleted() : $this->responseDeleteFailed('文件删除失败');
}
/**
* 删除OSS公有桶资源文件
*/
public function deletePublicOssFile(){
$ossPath = request()->post('key') ?? '';
$aliOss = new AilOss();
$res = $aliOss->delete($ossPath,'OSS_PUBLIC_BUCKET');
return $res ? $this->responseDeleted() : $this->responseDeleteFailed('文件删除失败');
}
/**
* 上传用户头像
*/
public function uploadUserAvatar()
{
$aliOss = new AilOss();
// 获取上传的文件
$file = $this->file();;
//获取文件扩展名
$file = $this->file();;
Image::make($file->getRealPath())
->resize(640, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('jpg', 90);
$fileName = md5(uniqid()) . '.jpg';
$date = date('Y_m_d');
$ossFilePath = 'userAvatar/'.$date.'/'.$fileName;
//获取文件的绝对路径
$path = $file->getRealPath();
$res = $aliOss->upload($ossFilePath, $path,'OSS_PUBLIC_BUCKET');
return $res
? $this->responseUploaded(env('OSS_PUBLIC_IMAGE_URL').$ossFilePath,'')
: $this->responseErrorMessage('文件上传失败');
}
/**
* 上传轮播图
*/
public function uploadCarousel()
{
$aliOss = new AilOss();
// 获取上传的文件
$file = $this->file();;
Image::make($file->getRealPath())
->resize(640, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('jpg', 90);
$fileName = md5(uniqid()) . '.jpg';
$date = date('Y_m_d');
$ossFilePath = 'Carousel/'.$date.'/'.$fileName;
//获取文件的绝对路径
$path = $file->getRealPath();
$res = $aliOss->upload($ossFilePath, $path,'OSS_PUBLIC_BUCKET');
return $res
? $this->responseUploaded(env('OSS_PUBLIC_IMAGE_URL').$ossFilePath,'')
: $this->responseErrorMessage('文件上传失败');
}
/**
* 上传资源库图片
*/
public function uploadResourceImg()
{
$aliOss = new AilOss();
// 获取上传的文件
$file = $this->file();;
Image::make($file->getRealPath())
->resize(640, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode('jpg', 90);
$fileName = md5(uniqid()) . '.jpg';
$date = date('Y_m_d');
$ossFilePath = 'ResourceImg/'.$date.'/'.$fileName;
//获取文件的绝对路径
$path = $file->getRealPath();
$res = $aliOss->upload($ossFilePath, $path,'OSS_PUBLIC_BUCKET');
return $res
? $this->responseUploaded(env('OSS_PUBLIC_IMAGE_URL').$ossFilePath,'')
: $this->responseErrorMessage('文件上传失败');
}
//上传资源文件
public function uploadResourceFile()
{
$aliOss = new AilOss();
// 获取上传的文件
$file = $this->file();;
//获取文件扩展名
$ext = $file->getClientOriginalExtension();
$fileName = uniqid().'.'.$ext;
$date = date('Y_m_d');
$ossFilePath = 'ResourceFile/'.$date.'/'.$fileName;
//获取文件的绝对路径
$path = $file->getRealPath();
$res = $aliOss->upload($ossFilePath, $path,'OSS_PUBLIC_BUCKET');
return $res
? $this->responseUploaded(env('OSS_PUBLIC_IMAGE_URL').$ossFilePath,'')
: $this->responseErrorMessage('文件上传失败');
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\Principal as ModelsPrincipal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Dcat\Admin\Widgets\Modal;
use App\Admin\Forms\CovenantInvoiceForm;
use Dcat\Admin\Admin;
use App\Models\Lawyer as ModelsLawyer;
class ViewCovenantInvoicedController extends AdminController
{
/**
* 查看收款信息
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ModelsCovenantReceivePayment(), function (Grid $grid) {
$cid = $grid->model()->filter()->input('cid') ?? 0;
$lawyer_id = 0;
if ($cid) {
$cobj = ModelsCovenant::find($cid);
$lawyer_id = $cobj->lawyer_id;
}
if (Admin::user()->can('view-invoiced-add')) {
$grid->tools(function (Grid\Tools $tools) use ($cid) {
$tools->append(Modal::make()
// 大号弹窗
->lg()
// 弹窗标题
->title('新增')
// 按钮
->button('<button class="btn btn-primary"><i class="feather icon-plus"></i> 新增</button>')
// 弹窗内容
->body(CovenantInvoiceForm::make()->payload(['cid' => $cid])));
});
}
$grid->model()->where(['rtype' => 2, 'lawyer_id' => $lawyer_id, 'cid' => $cid])->orderBy("id", "desc");
//$grid->column('id')->sortable();
$grid->column('invoiced_at', '开票时间');
$grid->column('invoiced_money', '开票金额')->display(function ($val) {
return number_format($val, 2);
});
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $cid) {
$principal = $cnumber = $lnumber = $lname = '';
$invoiced_money = $received_money = $received_noinvoiced = $invoiced_noreceived = 0;
if ($cid) {
$cobj = ModelsCovenant::find($cid);
$principal = $cobj->principal;
$cnumber = $cobj->number;
$lobj = ModelsLawyer::find($cobj->lawyer_id);
$lnumber = $lobj->number;
$lname = $lobj->name;
//开票金额
$invoiced_money = self::getInvoicedByCid($cid);
//已收款
$received_money = self::getReceivedByCid($cid);
//已收款未开票
$received_noinvoiced = ($received_money - $invoiced_money) > 0 ? number_format($received_money - $invoiced_money, 2) : 0;
//已开票未收款
$invoiced_noreceived = ($invoiced_money - $received_money) > 0 ? number_format($invoiced_money - $received_money, 2) : 0;
}
$card_info = "&nbsp;&nbsp;合同编号:{$cnumber}&nbsp;&nbsp;&nbsp;委托人:{$principal}";
$card_info .= "&nbsp;&nbsp;律师编号:{$lnumber}&nbsp;&nbsp;&nbsp;律师姓名:{$lname}";
$card_info .= "&nbsp;&nbsp;开票金额:" . number_format($invoiced_money, 2) . "&nbsp;&nbsp;&nbsp;已收款:" . number_format($received_money, 2);
$card_info .= "&nbsp;&nbsp;已收款未开票:{$received_noinvoiced}&nbsp;&nbsp;&nbsp;已开票未收款:{$invoiced_noreceived}";
$tools->append($card_info);
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('view-invoiced-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('view-invoiced-delete')) {
$actions->disableDelete();
}
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new ModelsCovenantReceivePayment(), function (Form $form) {
//$form->display('id');
$form->date('invoiced_at', '收款时间')->format('YYYY-MM-DD');
$form->text('invoiced_money', '收款金额');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->disableListButton();
});
return $form;
}
//开票金额
public static function getInvoicedByCid($cid)
{
return ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 2])->sum('invoiced_money');
}
//已收款
public static function getReceivedByCid($cid)
{
return ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 1])->sum('received_amount');
}
}
<?php
namespace App\Admin\Controllers;
use App\Models\Principal as ModelsPrincipal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Modal;
use App\Admin\Forms\CovenantReceiveForm;
use App\Models\Lawyer as ModelsLawyer;
use Dcat\Admin\Admin;
class ViewCovenantReceivedController extends AdminController
{
/**
* 查看收款信息
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ModelsCovenantReceivePayment(), function (Grid $grid) {
$cid = $grid->model()->filter()->input('cid') ?? 0;
$lawyer_id = 0;
if ($cid) {
$cobj = ModelsCovenant::find($cid);
$lawyer_id = $cobj->lawyer_id;
}
$grid->tools(function (Grid\Tools $tools) use ($cid) {
if (Admin::user()->can('view-received-add')) {
$tools->append(Modal::make()
// 大号弹窗
->lg()
// 弹窗标题
->title('新增')
// 按钮
->button('<button class="btn btn-primary"><i class="feather icon-plus"></i> 新增</button>')
// 弹窗内容
->body(CovenantReceiveForm::make()->payload(['cid' => $cid])));
}
});
$grid->model()->where(['rtype' => 1, 'lawyer_id' => $lawyer_id, 'cid' => $cid])->orderBy("id", "desc");
//$grid->column('id')->sortable();
$grid->column('received_type', '收款账户')->display(function ($val) {
return $val == 1 ? '基本户' : '其它';
});
$grid->column('pay_method', '支付方式')->display(function ($val) {
return ModelsCovenantReceivePayment::PAYMENT_METHOD[$val];
});
$grid->column('received_at', '收款时间');
$grid->column('received_amount', '收款金额')->display(function ($val) {
return number_format($val, 2);
});
$grid->column('paymenter', '付款人');
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableRowSelector();
//文字信息
$grid->tools(function (Grid\Tools $tools) use ($grid, $cid) {
$principal = $cnumber = $lnumber = $lname = '';
$invoiced_money = $received_money = $received_noinvoiced = $invoiced_noreceived = 0;
if ($cid) {
$cobj = ModelsCovenant::find($cid);
$principal = $cobj->principal;
$cnumber = $cobj->number;
$lobj = ModelsLawyer::find($cobj->lawyer_id);
$lnumber = $lobj->number;
$lname = $lobj->name;
//开票金额
$invoiced_money = self::getInvoicedByCid($cid);
//已收款
$received_money = self::getReceivedByCid($cid);
//已收款未开票
$received_noinvoiced = ($received_money - $invoiced_money) > 0 ? number_format($received_money - $invoiced_money, 2) : 0;
//已开票未收款
$invoiced_noreceived = ($invoiced_money - $received_money) > 0 ? number_format($invoiced_money - $received_money, 2) : 0;
}
$card_info = "&nbsp;&nbsp;合同编号:{$cnumber}&nbsp;&nbsp;&nbsp;委托人:{$principal}";
$card_info .= "&nbsp;&nbsp;律师编号:{$lnumber}&nbsp;&nbsp;&nbsp;律师姓名:{$lname}";
$card_info .= "&nbsp;&nbsp;开票金额:" . number_format($invoiced_money, 2) . "&nbsp;&nbsp;&nbsp;已收款:" . number_format($received_money, 2);
$card_info .= "&nbsp;&nbsp;已收款未开票:{$received_noinvoiced}&nbsp;&nbsp;&nbsp;已开票未收款:{$invoiced_noreceived}";
$tools->append($card_info);
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
//编辑
if (!Admin::user()->can('view-received-edit')) {
$actions->disableEdit();
}
//删除
if (!Admin::user()->can('view-received-delete')) {
$actions->disableDelete();
}
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = Form::make(new ModelsCovenantReceivePayment(), function (Form $form) {
//$form->display('id');
$form->select('received_type', '账户类型')->options(ModelsCovenantReceivePayment::RECEIVEDTYPE)->required();
$form->select('pay_method', '支付方式')->options(ModelsCovenantReceivePayment::PAYMENT_METHOD)->required();
$form->date('received_at', '收款时间')->format('YYYY-MM-DD')->required();
$form->text('received_amount', '收款金额')->required();
$form->text('paymenter', '付款人');
$form->disableCreatingCheck();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableDeleteButton();
$form->disableViewButton();
$form->disableListButton();
});
return $form;
}
//开票金额
public static function getInvoicedByCid($cid)
{
return ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 2])->sum('invoiced_money');
}
//已收款
public static function getReceivedByCid($cid)
{
return ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 1])->sum('received_amount');
}
}
<?php
namespace App\Admin\Extensions;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use App\Models\Covenant as ModelsCovenant;
class CovenantReceivePaymentExportExten implements FromCollection, WithHeadings
{
private $row;
private $data;
private $headings;
/**
* Constructor
* @param array $param 筛选条件
* @param array $data 数据
* @param array $headings 表头
*/
public function __construct($param = [], $data = [], $headings = [])
{
$param = json_decode(json_encode($param), true);
//表头设定
$header = [
'lname' => '律师姓名',
'covenant_num' => '合同编号',
'covenant_name' => '合同名称',
'covenant_type' => '合同类型',
'principal' => '委托人',
'invoice_amount' => '开票金额',
'receipt_money' => '已收款',
'receipt_noinvoice' => '已收款未开票',
'invoice_noreceipt' => '已开票未收款'
];
$headings = [$header];
$data = $this->getList($param);
$this->headings = $headings;
$this->data = $data;
}
public function headings(): array
{
return $this->headings;
}
public function collection()
{
return collect($this->data);
}
// 获取列表数据
public function getList($param)
{
$data = [];
$search = $param['search'] ?? [];
$received_at = $param['received_at'] ?? [];
$invoiced_at = $param['invoiced_at'] ?? [];
DB::enableQueryLog();
$query = DB::table("covenant_receive_payment as rp")
->select(DB::raw('rp.cid, c.cname as covenant_name, c.ctype as covenant_type, c.number as covenant_num, c.principal, l.name as lname,
sum(CASE WHEN rp.rtype = 2 THEN rp.invoiced_money ELSE 0 END) as invoice_amount,
sum(CASE WHEN rp.rtype = 1 THEN rp.received_amount ELSE 0 END) as receipt_money'))
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
// 筛选条件
if (!empty($search['lname'])) {
$query->where('l.name', 'like', '%'.$search['lname'].'%');
}
if (!empty($search['cnum'])) {
$query->where('c.number', 'like', '%'.$search['cnum'].'%');
}
if (!empty($search['ctype'])) {
$query->where('c.ctype', $search['ctype']);
}
if (!empty($search['principal'])) {
$query->where('c.principal', 'like', '%'.$search['principal'].'%');
}
// 日期筛选
if (!empty($received_at)) {
if (!empty($received_at['start'])) {
$query->where('rp.received_at', '>=', $received_at['start']);
}
if (!empty($received_at['end'])) {
$query->where('rp.received_at', '<=', $received_at['end']);
}
}
if (!empty($invoiced_at)) {
if (!empty($invoiced_at['start'])) {
$query->where('rp.invoiced_at', '>=', $invoiced_at['start']);
}
if (!empty($invoiced_at['end'])) {
$query->where('rp.invoiced_at', '<=', $invoiced_at['end']);
}
}
$records = $query->groupBy('rp.cid')->get();
// 计算合计
$total_invoice_amount = 0;
$total_receipt_money = 0;
$total_receipt_noinvoice = 0;
$total_invoice_noreceipt = 0;
foreach ($records as $record) {
$total_invoice_amount += $record->invoice_amount ?? 0;
$total_receipt_money += $record->receipt_money ?? 0;
}
$total_receipt_noinvoice = ($total_receipt_money - $total_invoice_amount) > 0 ? $total_receipt_money - $total_invoice_amount : 0;
$total_invoice_noreceipt = ($total_invoice_amount - $total_receipt_money) > 0 ? $total_invoice_amount - $total_receipt_money : 0;
// 添加合计行
$data[] = [
'lname' => '合计',
'covenant_num' => '',
'covenant_name' => '',
'covenant_type' => '',
'principal' => '',
'invoice_amount' => number_format($total_invoice_amount, 2),
'receipt_money' => number_format($total_receipt_money, 2),
'receipt_noinvoice' => number_format($total_receipt_noinvoice, 2),
'invoice_noreceipt' => number_format($total_invoice_noreceipt, 2)
];
foreach ($records as $record) {
$tmp = [];
$tmp['lname'] = $record->lname ?? '';
$tmp['covenant_num'] = $record->covenant_num ?? '';
$tmp['covenant_name'] = $record->covenant_name ?? '';
$tmp['covenant_type'] = ModelsCovenant::CTYPE[$record->covenant_type] ?? '-';
$tmp['principal'] = $record->principal ?? '';
$tmp['invoice_amount'] = number_format($record->invoice_amount ?? 0, 2);
$tmp['receipt_money'] = number_format($record->receipt_money ?? 0, 2);
$tmp['receipt_noinvoice'] = number_format(($record->receipt_money - $record->invoice_amount) > 0 ? $record->receipt_money - $record->invoice_amount : 0, 2);
$tmp['invoice_noreceipt'] = number_format(($record->invoice_amount - $record->receipt_money) > 0 ? $record->invoice_amount - $record->receipt_money : 0, 2);
$data[] = $tmp;
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Admin\Extensions;
use App\Command\Log;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Models\Lawyer as ModelLawyer;
class LawyerCollectExportExten implements FromCollection, WithHeadings
{
private $row;
private $data;
private $headings;
/**
* TaskDataExcelExpoter constructor.
* @param array $param 筛选条件
* @param array $data 数据
* @param array $headings 表头
*/
public function __construct($param = [], $data = [], $headings = [])
{
$param = json_decode(json_encode($param), true);
//表头设定
$header = [
'lname' => '律师名称',
'commission_ratio' => '提成比例(%)',
'receipt_money' => '创收已收款',
'commission_amount' => '提成金额',
'receipt_noinvoice' => '已收款未开票',
'invoice_noreceipt' => '已开票未收款',
'cost' => '成本合计',
'basic_salary' => '基本工资',
'special_additional' => '专项附加',
'social' => '社保',
'accumulation_fund' => '公积金',
'posting_tickets_fee' => '贴票金额',
'advance_fee' => '预支款',
'payable_commission' => '可结算提成'
];
$headings = [$header];
$data = $this->getList($param);
$this->headings = $headings;
$this->data = $data;
}
public function headings(): array
{
return $this->headings;
}
public function collection()
{
return collect($this->data);
}
// 获取列表数据
public function getList($param)
{
$param = json_decode(json_encode($param), true);
$name = $param['search']['name'] ?? ''; //律师姓名
$year = $param['search']['year'] ?? date('Y');
$received_at = $param['received_at'] ?? [];
$invoiced_at = $param['invoiced_at'] ?? [];
$data = [];
// 获取律师信息
$query = ModelLawyer::query();
if ($name) {
$query->where('name', 'like', '%' . $name . '%');
}
$lawyers = $query->get();
foreach ($lawyers as $lawyer) {
$params = [
'number' => $lawyer->number,
'name' => $lawyer->name,
'year' => $year
];
$totalInfo = ModelLawyer::getTotalInfo($params, $received_at, $invoiced_at);
$tmp = [];
$tmp['lname'] = $lawyer->name;
$tmp['commission_ratio'] = $lawyer->commission_rate;
$tmp['receipt_money'] = number_format($totalInfo['receipt_money'], 2);
$tmp['commission_amount'] = number_format($totalInfo['commission_amount'], 2);
$tmp['receipt_noinvoice'] = number_format(($totalInfo['receipt_money'] - $totalInfo['invoiced_money']) > 0 ? $totalInfo['receipt_money'] - $totalInfo['invoiced_money'] : 0, 2);
$tmp['invoice_noreceipt'] = number_format(($totalInfo['invoiced_money'] - $totalInfo['receipt_money']) > 0 ? $totalInfo['invoiced_money'] - $totalInfo['receipt_money'] : 0, 2);
$tmp['cost'] = number_format($totalInfo['cost'], 2);
$tmp['basic_salary'] = number_format($totalInfo['salary'], 2);
$tmp['special_additional'] = number_format($totalInfo['special_additional'], 2);
$tmp['social'] = number_format($totalInfo['social'], 2);
$tmp['accumulation_fund'] = number_format($totalInfo['accumulation_fund'], 2);
$tmp['posting_tickets_fee'] = number_format($totalInfo['tickets_money'], 2);
$tmp['advance_fee'] = number_format($totalInfo['advance_fee'], 2);
$tmp['payable_commission'] = number_format($totalInfo['payable_commission'], 2);
$data[] = $tmp;
}
return $data;
}
}
<?php
namespace App\Admin\Extensions;
use App\Command\Log;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
class ReceivedInvoicedExport implements FromCollection, WithHeadings
{
private $row;
private $data;
private $headings;
/**
* TaskDataExcelExpoter constructor.
* @param array $param 筛选条件
* @param array $data 数据
* @param array $headings 表头
*/
public function __construct($param = [], $data = [], $headings = [])
{
$param = json_decode(json_encode($param), true);
$year = $param['search']['year'] ?? date("Y");
$nowyear = date("Y");
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
//表头设定
for ($i = 1; $i <= $monthNum; $i++) {
$tmp[$i] = $i . '月';
}
$header = $tmp;
$headings = [$header];
$data = $this->getList($param);
$this->headings = $headings;
$this->data = $data;
}
public function headings(): array
{
return $this->headings;
}
public function collection()
{
return collect($this->data);
}
// 获取列表数据
public function getList($param)
{
$param = json_decode(json_encode($param), true);
$lawyer_id = $param['search']['lawyer_id'] ?? 0;
$rtype = $param['search']['rtype'] ?? 1;
$year = $param['search']['year'] ?? date("Y");
$data = [];
$nowyear = date("Y");
$monthNum = ($year && $year < $nowyear) ? 12 : date('m');
for ($i = 1; $i <= $monthNum; $i++) {
if ($rtype == 1) { //已收款
$amount = ModelsCovenantReceivePayment::where(['rtype' => $rtype, 'lawyer_id' => $lawyer_id, 'year' => $year, 'month' => $i])->sum('received_amount');
} else { //已开票
$amount = ModelsCovenantReceivePayment::where(['rtype' => $rtype, 'lawyer_id' => $lawyer_id, 'year' => $year, 'month' => $i])->sum('invoiced_money');
}
$data[$i] = number_format($amount, 2);
}
return [$data];
return $data;
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
class CovenantClosedForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['cid'];
DB::beginTransaction();
try {
$uObj = ModelsCovenant::find($cid);
if ($uObj && $uObj->is_closed == 0) {
$uObj->is_closed = 1;
$uObj->save();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功' . $cid)->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->html('<div class="row" style="text-align:center;">
是否确认已结案
</div>');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
class CovenantInvoiceForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['cid']; //合同ID
DB::beginTransaction();
try {
$invoiced_at = trim($input['invoiced_at']);
$invoiced_money = trim($input['invoiced_money']);
$datearr = explode('-', $invoiced_at);
$year = $datearr[0];
$month = $datearr[1];
$cObj = ModelsCovenant::find($cid);
if (!$cObj) {
throw new Exception('该合同不存在!');
}
$receivePaymentObj = new ModelsCovenantReceivePayment();
$receivePaymentObj->invoiced_money = $invoiced_money;
$receivePaymentObj->year = $year;
$receivePaymentObj->month = $month;
$receivePaymentObj->rtype = 2;
$receivePaymentObj->cid = $cid;
$receivePaymentObj->lawyer_id = $cObj->lawyer_id;
$receivePaymentObj->principal = $cObj->principal;
$receivePaymentObj->invoiced_at = $invoiced_at;
$receivePaymentObj->save();
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->date('invoiced_at', '开票时间')->format('YYYY-MM-DD')->default(date("Y-m-d"))->required();
$this->text('invoiced_money', '开票金额')->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
class CovenantReceiveForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$cid = $this->payload['cid']; //合同ID
DB::beginTransaction();
try {
$received_type = (int)$input['received_type'];
$pay_method = trim($input['pay_method']);
$received_at = trim($input['received_at']);
$received_amount = trim($input['received_amount']);
$paymenter = trim($input['paymenter']);
$datearr = explode('-', $received_at);
$year = $datearr[0];
$month = $datearr[1];
$cObj = ModelsCovenant::find($cid);
if (!$cObj) {
throw new Exception('该合同不存在!');
}
$receivePaymentObj = new ModelsCovenantReceivePayment();
$receivePaymentObj->received_type = $received_type;
$receivePaymentObj->pay_method = $pay_method;
$receivePaymentObj->received_at = $received_at;
$receivePaymentObj->received_amount = $received_amount;
$receivePaymentObj->paymenter = $paymenter;
$receivePaymentObj->cid = $cid;
$receivePaymentObj->lawyer_id = $cObj->lawyer_id;
$receivePaymentObj->principal = $cObj->principal;
$receivePaymentObj->year = $year;
$receivePaymentObj->month = $month;
$receivePaymentObj->rtype = 1;
$receivePaymentObj->save();
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->select('received_type', '收款账户')->options([1 => '基本户', 2 => '其它'])->required();
$this->select('pay_method', '支付方式')->options(ModelsCovenantReceivePayment::PAYMENT_METHOD)->required();
$this->date('received_at', '收款时间')->format('YYYY-MM-DD')->default(date("Y-m-d"))->required();
$this->text('received_amount', '收款金额')->required();
$this->text('paymenter', '付款人');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Command\Log;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use App\Models\Covenant as ModelsCovenant;
class CovenantReturnForm extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$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;
$uObj->save();
}
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
return $this->response()->error($exception->getMessage())->refresh();
}
return $this->response()->success('提交成功' . $cid)->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->text('return_fee', '退案结案费')->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Imports\ImportExcel as uImportExcel;
use App\Jobs\ansyImportExcel;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class ImportExcel extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$file_path = storage_path('app/public' . $input['e_file']);
dispatch(new ansyImportExcel($this->payload['className'], $file_path));
return $this
->response()
->success('导入成功,请稍后刷新页面查看数据.')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->file('e_file', '数据文件')
->disk('public')
->accept('xls,xlsx')
->uniqueName()
->move('/import')
->autoUpload()
->help('仅支持xls,xlsx格式文件上传')
->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return [
'name' => 'John Doe',
'email' => 'John.Doe@gmail.com',
];
}
}
<?php
namespace App\Admin\Forms;
use App\Models\User;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Illuminate\Support\Facades\DB;
class TruncateTable extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$status = (int)$input['status'];
$tablename = trim($this->payload['tablename']);
if ($status == 1 && $tablename) {
DB::table($tablename)->truncate(); // 清空数据表
}
return $this->response()->success('确认成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->radio('status', '清空状态')->options([1 => '是', 0 => '否'])->default(0)->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
// 获取外部传递参数
return [];
}
}
<?php
namespace App\Admin\Forms;
use App\Models\PersonalAccessToken;
use App\Models\User;
use App\Models\UserPermission;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class updatePassword extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$user = User::find($this->payload['id']);
$user->password = bcrypt($input['password']);
if(!$user->save()){
return $this
->response()
->error('修改用户密码失败')
->refresh();
}
PersonalAccessToken::where(['tokenable_id'=>$user->id])->delete();
return $this
->response()
->success('修改用户密码成功.')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->display('name','姓名');
$this->display('phone','手机');
$this->text('password','密码')->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
$user = User::find($this->payload['id']);
return [
'name' => $user->name,
'phone' => $user->phone,
];
}
}
<?php
namespace App\Admin\Metrics\Examples;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Metrics\Donut;
class NewDevices extends Donut
{
protected $labels = ['Desktop', 'Mobile'];
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$color = Admin::color();
$colors = [$color->primary(), $color->alpha('blue2', 0.5)];
$this->title('New Devices');
$this->subTitle('Last 30 days');
$this->chartLabels($this->labels);
// 设置图表颜色
$this->chartColors($colors);
}
/**
* 渲染模板
*
* @return string
*/
public function render()
{
$this->fill();
return parent::render();
}
/**
* 写入数据.
*
* @return void
*/
public function fill()
{
$this->withContent(44.9, 28.6);
// 图表数据
$this->withChart([44.9, 28.6]);
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data
]);
}
/**
* 设置卡片头部内容.
*
* @param mixed $desktop
* @param mixed $mobile
*
* @return $this
*/
protected function withContent($desktop, $mobile)
{
$blue = Admin::color()->alpha('blue2', 0.5);
$style = 'margin-bottom: 8px';
$labelWidth = 120;
return $this->content(
<<<HTML
<div class="d-flex pl-1 pr-1 pt-1" style="{$style}">
<div style="width: {$labelWidth}px">
<i class="fa fa-circle text-primary"></i> {$this->labels[0]}
</div>
<div>{$desktop}</div>
</div>
<div class="d-flex pl-1 pr-1" style="{$style}">
<div style="width: {$labelWidth}px">
<i class="fa fa-circle" style="color: $blue"></i> {$this->labels[1]}
</div>
<div>{$mobile}</div>
</div>
HTML
);
}
}
<?php
namespace App\Admin\Metrics\Examples;
use Dcat\Admin\Widgets\Metrics\Line;
use Illuminate\Http\Request;
class NewUsers extends Line
{
/**
* 初始化卡片内容
*
* @return void
*/
protected function init()
{
parent::init();
$this->title('New Users');
$this->dropdown([
'7' => 'Last 7 Days',
'28' => 'Last 28 Days',
'30' => 'Last Month',
'365' => 'Last Year',
]);
}
/**
* 处理请求
*
* @param Request $request
*
* @return mixed|void
*/
public function handle(Request $request)
{
$generator = function ($len, $min = 10, $max = 300) {
for ($i = 0; $i <= $len; $i++) {
yield mt_rand($min, $max);
}
};
switch ($request->get('option')) {
case '365':
// 卡片内容
$this->withContent(mt_rand(1000, 5000).'k');
// 图表数据
$this->withChart(collect($generator(30))->toArray());
break;
case '30':
// 卡片内容
$this->withContent(mt_rand(400, 1000).'k');
// 图表数据
$this->withChart(collect($generator(30))->toArray());
break;
case '28':
// 卡片内容
$this->withContent(mt_rand(400, 1000).'k');
// 图表数据
$this->withChart(collect($generator(28))->toArray());
break;
case '7':
default:
// 卡片内容
$this->withContent('89.2k');
// 图表数据
$this->withChart([28, 40, 36, 52, 38, 60, 55,]);
}
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => [
[
'name' => $this->title,
'data' => $data,
],
],
]);
}
/**
* 设置卡片内容.
*
* @param string $content
*
* @return $this
*/
public function withContent($content)
{
return $this->content(
<<<HTML
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
<h2 class="ml-1 font-lg-1">{$content}</h2>
<span class="mb-0 mr-1 text-80">{$this->title}</span>
</div>
HTML
);
}
}
<?php
namespace App\Admin\Metrics\Examples;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Http\Request;
class ProductOrders extends Round
{
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$this->title('Product Orders');
$this->chartLabels(['Finished', 'Pending', 'Rejected']);
$this->dropdown([
'7' => 'Last 7 Days',
'28' => 'Last 28 Days',
'30' => 'Last Month',
'365' => 'Last Year',
]);
}
/**
* 处理请求
*
* @param Request $request
*
* @return mixed|void
*/
public function handle(Request $request)
{
switch ($request->get('option')) {
case '365':
case '30':
case '28':
case '7':
default:
// 卡片内容
$this->withContent(23043, 14658, 4758);
// 图表数据
$this->withChart([70, 52, 26]);
// 总数
$this->chartTotal('Total', 344);
}
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data,
]);
}
/**
* 卡片内容.
*
* @param int $finished
* @param int $pending
* @param int $rejected
*
* @return $this
*/
public function withContent($finished, $pending, $rejected)
{
return $this->content(
<<<HTML
<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
<div class="chart-info d-flex justify-content-between mb-1 mt-2" >
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-primary"></i>
<span class="text-bold-600 ml-50">Finished</span>
</div>
<div class="product-result">
<span>{$finished}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-warning"></i>
<span class="text-bold-600 ml-50">Pending</span>
</div>
<div class="product-result">
<span>{$pending}</span>
</div>
</div>
<div class="chart-info d-flex justify-content-between mb-1">
<div class="series-info d-flex align-items-center">
<i class="fa fa-circle-o text-bold-700 text-danger"></i>
<span class="text-bold-600 ml-50">Rejected</span>
</div>
<div class="product-result">
<span>{$rejected}</span>
</div>
</div>
</div>
HTML
);
}
}
<?php
namespace App\Admin\Metrics\Examples;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Metrics\Bar;
use Illuminate\Http\Request;
class Sessions extends Bar
{
/**
* 初始化卡片内容
*/
protected function init()
{
parent::init();
$color = Admin::color();
$dark35 = $color->dark35();
// 卡片内容宽度
$this->contentWidth(5, 7);
// 标题
$this->title('Avg Sessions');
// 设置下拉选项
$this->dropdown([
'7' => 'Last 7 Days',
'28' => 'Last 28 Days',
'30' => 'Last Month',
'365' => 'Last Year',
]);
// 设置图表颜色
$this->chartColors([
$dark35,
$dark35,
$color->primary(),
$dark35,
$dark35,
$dark35
]);
}
/**
* 处理请求
*
* @param Request $request
*
* @return mixed|void
*/
public function handle(Request $request)
{
switch ($request->get('option')) {
case '7':
default:
// 卡片内容
$this->withContent('2.7k', '+5.2%');
// 图表数据
$this->withChart([
[
'name' => 'Sessions',
'data' => [75, 125, 225, 175, 125, 75, 25],
],
]);
}
}
/**
* 设置图表数据.
*
* @param array $data
*
* @return $this
*/
public function withChart(array $data)
{
return $this->chart([
'series' => $data,
]);
}
/**
* 设置卡片内容.
*
* @param string $title
* @param string $value
* @param string $style
*
* @return $this
*/
public function withContent($title, $value, $style = 'success')
{
// 根据选项显示
$label = strtolower(
$this->dropdown[request()->option] ?? 'last 7 days'
);
$minHeight = '183px';
return $this->content(
<<<HTML
<div class="d-flex p-1 flex-column justify-content-between" style="padding-top: 0;width: 100%;height: 100%;min-height: {$minHeight}">
<div class="text-left">
<h1 class="font-lg-2 mt-2 mb-0">{$title}</h1>
<h5 class="font-medium-2" style="margin-top: 10px;">
<span class="text-{$style}">{$value} </span>
<span>vs {$label}</span>
</h5>
</div>
<a href="#" class="btn btn-primary shadow waves-effect waves-light">View Details <i class="feather icon-chevrons-right"></i></a>
</div>
HTML
);
}
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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