Skip to content

Commit

Permalink
impove report with scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Aug 24, 2023
1 parent 7757e71 commit 8703d52
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 34 deletions.
52 changes: 34 additions & 18 deletions app/Http/Controllers/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ public function domains(Request $request)
// get all scopes
$scopes = DB::table('controls')
->select('scope')
->whereNotNull('scope')
->where('scope', '<>', '')
->whereNull('realisation_date')
->distinct()
->orderBy('scope')
Expand Down Expand Up @@ -444,6 +442,22 @@ public function measures(Request $request)
// Get all domains
$domains = Domain::All();

// get all scopes
$scopes = DB::table('controls')
->select('scope')
->whereNull('realisation_date')
->distinct()
->orderBy('scope')
->get()
->pluck('scope')
->toArray();

$cur_scope = $request->get("scope");
if ($cur_scope !== null)
$request->session()->put('scope', $cur_scope);
else
$request->session()->forget('scope');

$cur_date = $request->get('cur_date');
if ($cur_date === null) {
$cur_date = today()->format('Y-m-d');
Expand All @@ -457,28 +471,32 @@ public function measures(Request $request)
->select(
DB::raw(
'
max(c1.id) AS control_id,
max(c1.name) AS name,
c1.clause AS clause,
c1.measure_id AS measure_id,
max(c1.domain_id) AS domain_id,
max(c1.plan_date) AS plan_date,
max(c1.realisation_date) AS realisation_date,
max(c1.score) AS score,
max(c2.plan_date) AS next_date,
max(c2.id) AS next_id'
c1.id AS control_id,
c1.name,
c1.clause,
c1.scope,
c1.measure_id,
c1.domain_id,
c1.plan_date,
c1.realisation_date,
c1.score AS score,
c2.plan_date AS next_date,
c2.id AS next_id'
)
)
->leftjoin('controls as c2', 'c1.next_id', '=', 'c2.id')
->where('c2.realisation_date', '=', null)
->where('c1.next_id', '<>', null)
->where('c2.realisation_date', '=', null);
if ($cur_scope !=null)
$controls = $controls->where('c1.scope','=',$cur_scope);
$controls = $controls
->where('c1.realisation_date', '<=', $cur_date)
->groupBy('c1.measure_id', 'c1.clause')
->orderBy('c1.clause')
->orderBy('clause')
->orderBy('scope')
->get();

// return
return view('radar.controls')
->with('scopes', $scopes)
->with('controls', $controls)
->with('cur_date', $cur_date)
->with('domains', $domains);
Expand Down Expand Up @@ -551,8 +569,6 @@ public function plan(int $id)

$scopes = DB::table('controls')
->select('scope')
->whereNotNull('scope')
->where('scope', '<>', '')
->whereNull('realisation_date')
->distinct()
->orderBy('scope')
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
'success' => 'Success',
'unknown' => 'Unknown',

'date' => 'Date',

'never' => 'Never',
'day' => 'Daily',
'week' => 'Weekly',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/fr/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
'success' => 'Réussi',
'unknown' => 'Inconnu',

'date' => 'Date',

'never' => 'Jamais',
'day' => 'Journalièrement',
'week' => 'Hebdomadairement',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/controls/plan.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>
<div class="cell-4">
<input type="text" name="scope" data-role="input" autocomplete="off" size="32"
value="{{ $control->scope }}" data-autocomplete=" {{ implode(",",$scopes) }} "/>
value="{{ $control->scope }}" data-autocomplete="{{ implode(",",$scopes) }}"/>
</div>
</div>

Expand Down
47 changes: 36 additions & 11 deletions resources/views/radar/controls.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,42 @@
<div class="row">
<div class="cell-12">

@foreach($domains as $domain)
<div class="row">
<div class="cell-10">
<b>{{ $domain->title }} - {{ $domain->description }}</b>
</div>

@if ($loop->first)
<div class="cell-2" valign="right">
<form action="/control/radar/measures">
<form action="/control/radar/measures">
<div class="row">
<div class="cell-8">
</div>
<div class="cell-2">
{{ trans("cruds.control.fields.scope") }}
<select name="scope" data-role="select" id="scope">
@foreach ($scopes as $scope)
<option
@if (Session::get("scope")==$scope)
selected
@endif >
{{ $scope }}
</option>
@endforeach
</select>
</div>
<div class="cell-2" valign="right">
{{ trans("common.date") }}
<input type="text"
data-role="calendarpicker"
name="cur_date"
data-dialog-mode="true"
value="{{$cur_date}}"
data-input-format="%Y-%m-%d"
onchange="this.form.submit()">
</form>
</div>
</div>
@endif
</form>

@foreach($domains as $domain)

<div class="row">
<div class="cell-10">
<b>{{ $domain->title }} - {{ $domain->description }}</b>
</div>
</div>
<div class="row">
<div class="cell-4">
Expand All @@ -41,6 +57,7 @@
<th>{{ trans("cruds.control.fields.note") }}</th>
<th><center>#</center></th>
<th>{{ trans("cruds.control.fields.name") }}</th>
<th>{{ trans("cruds.control.fields.scope") }}</th>
<th>{{ trans("cruds.control.fields.realisation_date") }}</th>
<th>{{ trans("cruds.control.fields.next") }}</th>
</tr>
Expand All @@ -63,6 +80,7 @@

<td><a href="/measures/{{ $control->measure_id }}">{{ $control->clause }}</a></td>
<td>{{ $control->name }}</td>
<td>{{ $control->scope }}</td>
<td><a href="/controls/{{ $control->control_id }}">{{ $control->realisation_date }}</a></td>
<td><a href="/controls/{{ $control->next_id }}">{{ $control->next_date }}</a></td>
</tr>
Expand Down Expand Up @@ -185,6 +203,13 @@
});
@endforeach
window.addEventListener('load', function(){
var select = document.getElementById('scope');
select.addEventListener('change', function(){
window.location = '/control/radar/measures?scope=' + this.value;
}, false);
});
</script>
@endsection

1 change: 0 additions & 1 deletion resources/views/radar/domains.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<form action="/control/radar/domains">
<strong>{{ trans("cruds.control.fields.scope") }}</strong>
<select name="scope" data-role="select" id="scope">
<option></option>
@foreach ($scopes as $scope)
<option
@if (Session::get("scope")==$scope)
Expand Down
3 changes: 0 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,5 @@
Route::get('/export/attributes', 'AttributeController@export');
Route::get('/export/measures', 'MeasureController@export');
Route::get('/export/controls', 'ControlController@export');
Route::get('/export/controls', 'ControlController@export');

/* test chart */
// Route::get('/testChart', 'ReportController@testChart');
});

0 comments on commit 8703d52

Please sign in to comment.