| xqd
@@ -16,6 +16,7 @@ use Encore\Admin\Facades\Admin;
|
|
|
use Encore\Admin\Form;
|
|
|
use Encore\Admin\Grid;
|
|
|
use Encore\Admin\Show;
|
|
|
+use Illuminate\Support\Facades\Date;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class OrderVaccinesController extends AdminController
|
| xqd
@@ -35,36 +36,57 @@ class OrderVaccinesController extends AdminController
|
|
|
protected function grid()
|
|
|
{
|
|
|
$grid = new Grid(new Order());
|
|
|
-
|
|
|
$res = request()->all();
|
|
|
|
|
|
- $grid->model()->orderByDesc('id');
|
|
|
+ $grid->disableExport(false);
|
|
|
+ $grid->export(function ($export) {
|
|
|
+ $export->filename('疫苗订单'.Date('Y-m-d',time()));
|
|
|
+ $export->column('order_status', function ($value, $original) {
|
|
|
+ $order_status_arr = Order::getStatus();
|
|
|
+ return $order_status_arr[intval($original)];
|
|
|
+ } );
|
|
|
+ });
|
|
|
+// $grid->model()->orderByDesc('orders.id');
|
|
|
+
|
|
|
+// if(!empty($res['orderPatient']['appoint_start_time']['start']) || !empty($res['orderPatient']['appoint_start_time']['start']) ){
|
|
|
+//
|
|
|
+// $grid->model()->leftJoin('order_patients','order_patients.order_id','=','orders.id')->orderByDesc('order_patients.appoint_start_time');
|
|
|
+//
|
|
|
+// $grid->model()->whereHas('orderPatient',function($query){
|
|
|
+// $query->orderBy( OrderPatient::select('appoint_start_time')
|
|
|
+// ->whereColumn('order_id', 'orders.id')
|
|
|
+// ->orderBy('appoint_start_time', 'asc'));
|
|
|
+// });
|
|
|
+// } else {
|
|
|
+// $grid->model()->whereHas('orderPatient',function($query){
|
|
|
+// return $query->orderBy('appoint_start_time','desc')->groupBy('appoint_start_time');
|
|
|
+// });
|
|
|
+// }
|
|
|
+ DB::enableQueryLog();
|
|
|
+
|
|
|
+// select bm_orders.*,bm_order_patients.appoint_end_time,bm_order_patients.appoint_start_time,bm_order_patients.name from `bm_orders`
|
|
|
+//left join `bm_order_patients` on `bm_order_patients`.`order_id` = `bm_orders`.`id` ORDER BY bm_order_patients.appoint_start_time asc;
|
|
|
+
|
|
|
+//
|
|
|
+// $grid->model()->leftJoin('order_patients','order_patients.order_id','=','orders.id')
|
|
|
+// ->orderByDesc('order_patients.appoint_start_time');
|
|
|
+// $grid->model()->orderByDesc('orders.idaa');
|
|
|
|
|
|
- if(!empty($res['orderPatient']['appoint_start_time']['start']) || !empty($res['orderPatient']['appoint_start_time']['start']) ){
|
|
|
|
|
|
- $grid->model()->whereHas('orderPatient',function($query){
|
|
|
- $query->orderBy( OrderPatient::select('appoint_start_time')
|
|
|
- ->whereColumn('order_id', 'orders.id')
|
|
|
- ->orderBy('appoint_start_time', 'asc'));
|
|
|
- });
|
|
|
- } else {
|
|
|
- $grid->model()->whereHas('orderPatient',function($query){
|
|
|
- return $query->orderBy('appoint_start_time','desc')->groupBy('appoint_start_time');
|
|
|
- });
|
|
|
- }
|
|
|
$user = Admin::user();
|
|
|
$is_admin = Admin::user()->inRoles(['administrator','devloper']);
|
|
|
|
|
|
|
|
|
$is_docter = $user->docter_id;
|
|
|
+ $where = ['product_type'=>4];
|
|
|
if(!$is_admin){
|
|
|
$org_id = $user->org_id;
|
|
|
$where = ['product_type'=>4,'organization_id'=>$org_id];
|
|
|
// if($is_docter) {
|
|
|
// $where['docter_id'] = Docter::where(['id'=>$user->docter_id])->value('id');
|
|
|
// }
|
|
|
- $grid->model()->where($where);
|
|
|
}
|
|
|
+ $grid->model()->where($where);
|
|
|
|
|
|
$grid->column('id', __('Id'));
|
|
|
$grid->column('user.nickname', __('预约用户'));
|