diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 27916242163e..bfa7d98b243e 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -23,6 +23,7 @@ use League\Csv\Reader; use Symfony\Component\HttpFoundation\StreamedResponse; use League\Csv\EscapeFormula; +use App\Http\Requests\CustomAssetReportRequest; /** @@ -403,11 +404,12 @@ public function getCustomReport() * @since [v1.0] * @return \Illuminate\Http\Response */ - public function postCustom(Request $request) + public function postCustom(CustomAssetReportRequest $request) { ini_set('max_execution_time', env('REPORT_TIME_LIMIT', 12000)); //12000 seconds = 200 minutes $this->authorize('reports.view'); + \Debugbar::disable(); $customfields = CustomField::get(); $response = new StreamedResponse(function () use ($customfields, $request) { @@ -645,7 +647,7 @@ public function postCustom(Request $request) if (($request->filled('created_start')) && ($request->filled('created_end'))) { $created_start = \Carbon::parse($request->input('created_start'))->startOfDay(); $created_end = \Carbon::parse($request->input('created_end'))->endOfDay(); - + $assets->whereBetween('assets.created_at', [$created_start, $created_end]); } if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) { @@ -656,22 +658,22 @@ public function postCustom(Request $request) } if (($request->filled('checkin_date_start'))) { - $assets->whereBetween('last_checkin', [ - Carbon::parse($request->input('checkin_date_start'))->startOfDay(), - // use today's date is `checkin_date_end` is not provided - Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(), - ]); + $assets->whereBetween('last_checkin', [ + Carbon::parse($request->input('checkin_date_start'))->startOfDay(), + // use today's date is `checkin_date_end` is not provided + Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(), + ]); } if (($request->filled('expected_checkin_start')) && ($request->filled('expected_checkin_end'))) { - $assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]); + $assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]); } if (($request->filled('last_audit_start')) && ($request->filled('last_audit_end'))) { - $last_audit_start = \Carbon::parse($request->input('last_audit_start'))->startOfDay(); - $last_audit_end = \Carbon::parse($request->input('last_audit_end'))->endOfDay(); + $last_audit_start = \Carbon::parse($request->input('last_audit_start'))->startOfDay(); + $last_audit_end = \Carbon::parse($request->input('last_audit_end'))->endOfDay(); - $assets->whereBetween('assets.last_audit_date', [$last_audit_start, $last_audit_end]); + $assets->whereBetween('assets.last_audit_date', [$last_audit_start, $last_audit_end]); } if (($request->filled('next_audit_start')) && ($request->filled('next_audit_end'))) { diff --git a/app/Http/Requests/CustomAssetReportRequest.php b/app/Http/Requests/CustomAssetReportRequest.php new file mode 100644 index 000000000000..a34d1b8ae8bd --- /dev/null +++ b/app/Http/Requests/CustomAssetReportRequest.php @@ -0,0 +1,49 @@ + 'date|date_format:Y-m-d|nullable', + 'checkout_date' => 'date|date_format:Y-m-d|nullable', + 'checkin_date' => 'date|date_format:Y-m-d|nullable', + 'purchase_start' => 'date|date_format:Y-m-d|nullable', + 'purchase_end' => 'date|date_format:Y-m-d|nullable', + 'created_start' => 'date|date_format:Y-m-d|nullable', + 'created_end' => 'date|date_format:Y-m-d|nullable', + 'checkout_date_start' => 'date|date_format:Y-m-d|nullable', + 'checkout_date_end' => 'date|date_format:Y-m-d|nullable', + 'expected_checkin_start' => 'date|date_format:Y-m-d|nullable', + 'expected_checkin_end' => 'date|date_format:Y-m-d|nullable', + 'checkin_date_start' => 'date|date_format:Y-m-d|nullable', + 'checkin_date_end' => 'date|date_format:Y-m-d|nullable', + 'last_audit_start' => 'date|date_format:Y-m-d|nullable', + 'last_audit_end' => 'date|date_format:Y-m-d|nullable', + 'next_audit_start' => 'date|date_format:Y-m-d|nullable', + 'next_audit_end' => 'date|date_format:Y-m-d|nullable', + ]; + } + + public function response(array $errors) + { + return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag); + } +} diff --git a/resources/views/reports/custom.blade.php b/resources/views/reports/custom.blade.php index 5b0bd384ee6c..959be57c9c6d 100644 --- a/resources/views/reports/custom.blade.php +++ b/resources/views/reports/custom.blade.php @@ -259,79 +259,131 @@
-
+
-
+
-
- +
+ to - +
+ + @if ($errors->has('purchase_start') || $errors->has('purchase_end')) +
+ {!! $errors->first('purchase_start', '') !!} + {!! $errors->first('purchase_end', '') !!} +
+ @endif +
-
+
-
- +
+ to - +
+ + @if ($errors->has('created_start') || $errors->has('created_end')) +
+ {!! $errors->first('created_start', '') !!} + {!! $errors->first('created_end', '') !!} +
+ @endif
-
+
-
- +
+ to - +
+ + @if ($errors->has('checkout_date_start') || $errors->has('checkout_date_end')) +
+ {!! $errors->first('checkout_date_start', '') !!} + {!! $errors->first('checkout_date_end', '') !!} +
+ @endif +
-
+
-
- +
+ {{ strtolower(trans('general.to')) }} - +
+ + @if ($errors->has('checkin_date_start') || $errors->has('checkin_date_end')) +
+ {!! $errors->first('checkin_date_start', '') !!} + {!! $errors->first('checkin_date_end', '') !!} +
+ @endif
-
+
-
- +
+ to - +
+ + @if ($errors->has('expected_checkin_start') || $errors->has('expected_checkin_end')) +
+ {!! $errors->first('expected_checkin_start', '') !!} + {!! $errors->first('expected_checkin_end', '') !!} +
+ @endif +
-
+
-
- +
+ to - +
+ + @if ($errors->has('last_audit_start') || $errors->has('last_audit_end')) +
+ {!! $errors->first('last_audit_start', '') !!} + {!! $errors->first('last_audit_end', '') !!} +
+ @endif
-
+
-
- +
+ to - +
+ + @if ($errors->has('next_audit_start') || $errors->has('next_audit_end')) +
+ {!! $errors->first('next_audit_start', '') !!} + {!! $errors->first('next_audit_end', '') !!} +
+ @endif