diff --git a/app/Http/Controllers/SavedReportsController.php b/app/Http/Controllers/SavedReportsController.php index 3efbe600f5..487ded803a 100644 --- a/app/Http/Controllers/SavedReportsController.php +++ b/app/Http/Controllers/SavedReportsController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\CustomField; use App\Models\SavedReport; use Illuminate\Http\Request; @@ -21,6 +22,16 @@ class SavedReportsController extends Controller return redirect()->route('reports/custom', ['report' => $report->id]); } + public function edit(Request $request, $reportId) + { + $report = SavedReport::findOrFail($reportId); + + return view('reports/custom', [ + 'customfields' => CustomField::get(), + 'savedReport' => $report, + ]); + } + public function update(Request $request) { $this->authorize('update',SavedReport::class); diff --git a/resources/views/reports/custom.blade.php b/resources/views/reports/custom.blade.php index ca7c30e535..29a9511bd9 100644 --- a/resources/views/reports/custom.blade.php +++ b/resources/views/reports/custom.blade.php @@ -28,12 +28,52 @@

- @if ($savedReport->name) + @if ($savedReport->exists && request()->routeIs('saved-templates.edit')) + Updating: {{ $savedReport->name }} + @elseif($savedReport->exists) Saved Template: {{ $savedReport->name }} @else {{ trans('general.customize_report') }} @endif

+ @if ($savedReport->exists && request()->routeIs('saved-templates.edit')) +
+ {{-- todo --}} +
+ @csrf + @method('PUT') + + + +
+
+ @elseif ($savedReport->exists) +
+ + + Update + + {{-- these were pulled from hardware.index and the one below doesn't work...--}} + + Delete + +
+ @endif
@@ -371,66 +411,68 @@
-
-
- @csrf - - {{--this means that the name of a loaded report is in the input box. could lead to confusion with update--}} - -
-
- -
-{{-- --}} -{{-- {{ trans('admin/reports/general.select_template') }}--}} -{{-- --}} -{{-- --}} -{{-- {!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}--}} - - - @if($saved_reports->first()!="") - -
+ @if (! request()->routeIs('saved-templates.edit')) +
+ @csrf - - - + + {{--this means that the name of a loaded report is in the input box. could lead to confusion with update--}} + - - @endif +
- @push('js') - - @endpush -
+
+ {{-- --}} + {{-- {{ trans('admin/reports/general.select_template') }}--}} + {{-- --}} + {{-- --}} + {{-- {!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}--}} + + +{{-- @if($saved_reports->first()!="")--}} +{{-- --}} +{{--
--}} +{{-- @csrf--}} +{{-- --}} +{{-- --}} +{{-- --}} +{{--
--}} +{{-- --}} +{{-- @endif--}} + + @push('js') + + @endpush +
+ @endif
diff --git a/routes/web.php b/routes/web.php index f86d9b286d..b4aafaf011 100644 --- a/routes/web.php +++ b/routes/web.php @@ -359,7 +359,9 @@ Route::group(['middleware' => ['auth']], function () { Route::post('reports/custom', [ReportsController::class, 'postCustom']); // @todo: change to saved-template? Route::post('reports/savedtemplate', [SavedReportsController::class, 'store'])->name('savedreports/store'); - Route::post('report/savedtemplate', [SavedReportsController::class, 'update'])->name('savedreports/update'); + // @todo: starting the process of adding "-" to saved-template... + Route::get('reports/saved-templates/{reportId}/edit', [SavedReportsController::class, 'edit'])->name('saved-templates.edit'); + Route::put('report/savedtemplate', [SavedReportsController::class, 'update'])->name('savedreports/update'); Route::get( 'reports/activity',