Skip to content
This repository was archived by the owner on May 10, 2022. It is now read-only.

Commit 29bbb2b

Browse files
committed
View existing report from selected report format
1 parent 4558a47 commit 29bbb2b

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

Modules/ReportGenerator/Entities/DraggableComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ class DraggableComponent extends Model
4242
*/
4343
public function report_formats()
4444
{
45-
return $this->belongsToMany('Modules\ReportGenerator\Entities\ReportFormat');
45+
return $this->belongsToMany('Modules\ReportGenerator\Entities\ReportFormat')->withTimestamps();
4646
}
4747
}

Modules/ReportGenerator/Entities/ReportFormat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ReportFormat extends Model
4242
*/
4343
public function draggable_components()
4444
{
45-
return $this->belongsToMany('Modules\ReportGenerator\Entities\DraggableComponent');
45+
return $this->belongsToMany('Modules\ReportGenerator\Entities\DraggableComponent')->withTimestamps();
4646
}
4747

4848
/**

Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@ public function showReport($option_ids)
111111
]);
112112
}
113113

114+
/**
115+
* Get option_ids for report from selected report_format
116+
* @param: Request $report_format_id
117+
* @return: showReport($option_ids)
118+
*/
119+
public function view($report_format_id)
120+
{
121+
$draggable_components = ReportFormat::find($report_format_id)->draggable_components()->get();
122+
123+
$option_ids = [];
124+
foreach ($draggable_components as $draggable_component) {
125+
$option_ids[] = $draggable_component->option_id;
126+
}
127+
128+
$option_ids = serialize($option_ids);
129+
130+
return ReportGeneratorController::showReport($option_ids); // call showReport method above
131+
132+
}
133+
114134
/**
115135
* Show the form for creating a new resource.
116136
* @return Response

Modules/ReportGenerator/Http/routes.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
{
55
Route::get('/', 'ReportGeneratorController@index');
66

7-
Route::get('/generate', 'ReportGeneratorController@getComponents');
7+
Route::get('/generate', 'ReportGeneratorController@getComponents'); // get all option_ids for selected components and call the route below
88

9-
Route::get('/report/{option_ids}', 'ReportGeneratorController@showReport');
9+
Route::get('/report/{option_ids}', 'ReportGeneratorController@showReport')->name('showReport'); // show report from generated report page
10+
11+
Route::get('/report_format/view/{report_format_id}', 'ReportGeneratorController@view'); // show report from report_format page
1012

1113
/*** System Feature routes ***/
1214
Route::resource('system_feature', 'SystemFeatureController');

Modules/ReportGenerator/Resources/views/layouts/master.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252

5353
<a class="nav-link" href="{{ url('reportgenerator/report_format') }}" role="button" aria-haspopup="true" aria-expanded="false"><strong>Report formats</strong></a>
5454
</ul>
55-
<form class="form-inline my-2 my-lg-0">
55+
<!-- <form class="form-inline my-2 my-lg-0">
5656
<input class="form-control mr-sm-2" type="search" placeholder="Search system features" aria-label="Search">
5757
<button class="btn btn-success my-2 my-sm-0" type="submit">Search</button>
58-
</form>
58+
</form> -->
5959
</div>
6060
</nav><!-- /.navbar -->
6161
@if(session('error'))

Modules/ReportGenerator/Resources/views/report_formats.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<td>{{ $report_format->title }}</td>
2121
<td>{{ $report_format->description }}</td>
2222
<td>
23-
<a class="btn btn-success btn-sm" href="#" role="button" data-toggle="modal" data-target="#view-report-format" data-id="{{ $report_format->id }}" data-title="{{ $report_format->title }}" data-description="{{ $report_format->description }}"> View</a>
23+
<a class="btn btn-success btn-sm" href="{{ url('/reportgenerator/report_format/view/'.$report_format->id) }}" role="button"> View</a>
2424
<a class="btn btn-primary btn-sm" href="#" role="button" data-toggle="modal" data-target="#edit-report-format" data-id="{{ $report_format->id }}" data-title="{{ $report_format->title }}" data-description="{{ $report_format->description }}"> Edit</a>
2525
<a class="btn btn-danger btn-sm" href="#" role="button" data-toggle="modal" data-target="#delete-report-format" data-id="{{ $report_format->id }}" data-title="{{ $report_format->title }}"> Delete</a>
2626
</td>

0 commit comments

Comments
 (0)