Skip to content

Commit 3167e12

Browse files
authored
Merge pull request #588 from dbarzin/dev
Dev
2 parents 855c976 + 2bc8982 commit 3167e12

File tree

17 files changed

+113
-71
lines changed

17 files changed

+113
-71
lines changed

app/Http/Controllers/ActionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function edit(int $id)
278278
);
279279

280280
// Get the action
281-
$action = Action::find($id);
281+
$action = Action::query()->find($id);
282282

283283
// Control not found
284284
abort_if($action === null, Response::HTTP_NOT_FOUND, '404 Not Found');

app/Http/Controllers/ControlController.php

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public function store(Request $request)
379379
'scope' => 'max:32',
380380
'objective' => 'required',
381381
'plan_date' => 'required',
382-
'periodicity' => 'required|integer',
382+
'periodicity' => 'required|integer|in:-1,0,1,3,6,12',
383383
]
384384
);
385385

@@ -791,17 +791,31 @@ public function history()
791791
foreach ($controls as $control) {
792792
$expandedControls->push($control);
793793

794-
if (($control->realisation_date === null) &&
795-
($control->periodicity > 0) && ($control->periodicity <= 12)) {
796-
for ($i = 1; $i <= 12 / $control->periodicity; $i++) {
797-
$repeatedControl = clone $control;
798-
$repeatedControl->id = null;
799-
$repeatedControl->score = null;
800-
$repeatedControl->observations = null;
801-
$repeatedControl->realisation_date = null;
802-
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addMonthsNoOverflow($i * $control->periodicity);
803-
$expandedControls->push($repeatedControl);
794+
if ($control->realisation_date === null) {
795+
if ($control->periodicity === -1) {
796+
// weekly
797+
for ($i = 1; $i <= 52; $i++) {
798+
$repeatedControl = clone $control;
799+
$repeatedControl->id = null;
800+
$repeatedControl->score = null;
801+
$repeatedControl->observations = null;
802+
$repeatedControl->realisation_date = null;
803+
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addDays($i * 7);
804+
$expandedControls->push($repeatedControl);
805+
}
804806
}
807+
else if (($control->periodicity > 0) && ($control->periodicity <= 12)) {
808+
// Monthly
809+
for ($i = 1; $i <= 12 / $control->periodicity; $i++) {
810+
$repeatedControl = clone $control;
811+
$repeatedControl->id = null;
812+
$repeatedControl->score = null;
813+
$repeatedControl->observations = null;
814+
$repeatedControl->realisation_date = null;
815+
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addMonthsNoOverflow($i * $control->periodicity);
816+
$expandedControls->push($repeatedControl);
817+
}
818+
}
805819
}
806820
}
807821
// Return view with controls
@@ -1285,7 +1299,7 @@ public function doPlan(Request $request)
12851299
// Validate fields
12861300
$this->validate($request, [
12871301
'plan_date' => 'required',
1288-
'periodicity' => 'required',
1302+
'periodicity' => 'required|integer|in:-1,0,1,3,6,12',
12891303
]);
12901304

12911305
// Find the control
@@ -1357,10 +1371,19 @@ public function make(Request $request)
13571371
$next_date = null;
13581372
} else {
13591373
// Computer next Date
1360-
$next_date =
1361-
Carbon::createFromFormat('Y-m-d', $control->plan_date)
1362-
->addMonthsNoOverflow($control->periodicity)
1363-
->format('Y-m-d');
1374+
if ($control->periodicity === -1) {
1375+
// One week
1376+
$next_date =
1377+
Carbon::createFromFormat('Y-m-d', $control->plan_date)
1378+
->addDays(7)
1379+
->format('Y-m-d');
1380+
}
1381+
else
1382+
// Add months
1383+
$next_date =
1384+
Carbon::createFromFormat('Y-m-d', $control->plan_date)
1385+
->addMonthsNoOverflow($control->periodicity)
1386+
->format('Y-m-d');
13641387
}
13651388

13661389
// return view
@@ -1461,16 +1484,19 @@ public function doMake(Request $request)
14611484
$new_control->score = null;
14621485
$new_control->status = 0;
14631486
// only admin and user can update the plan_date, realisation_date and action_plan
1464-
if (Auth::User()->role === 1 || Auth::User()->role === 2) {
1487+
if (Auth::User()->isAdmin() || Auth::User()->isUser()) {
14651488
$new_control->plan_date = request('next_date');
14661489
} else {
1467-
$new_control->plan_date = date(
1468-
'Y-m-d',
1469-
strtotime(
1470-
$control->periodicity . ' months',
1471-
strtotime($control->plan_date)
1472-
)
1473-
);
1490+
if ($control->periodicity === -1)
1491+
// One week
1492+
$new_control->plan_date = Carbon::parse($control->plan_date)
1493+
->addDays(7)
1494+
->toDateString();
1495+
else
1496+
// Months
1497+
$new_control->plan_date = Carbon::parse($control->plan_date)
1498+
->addMonths($control->periodicity)
1499+
->toDateString();
14741500
}
14751501
$new_control->save();
14761502

@@ -1505,13 +1531,13 @@ public function save(Request $request)
15051531
{
15061532
// Only for CISO
15071533
abort_if(
1508-
Auth::User()->role !== 1,
1534+
! Auth::User()->isAdmin(),
15091535
Response::HTTP_FORBIDDEN,
15101536
'403 Forbidden'
15111537
);
15121538

15131539
// Get the control
1514-
$control = Control::find($request->id);
1540+
$control = Control::query()->find($request->id);
15151541

15161542
// Control not found
15171543
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');
@@ -1523,7 +1549,7 @@ public function save(Request $request)
15231549
'scope' => 'max:32',
15241550
'objective' => 'required',
15251551
'plan_date' => 'required',
1526-
'periodicity' => 'required|integer',
1552+
'periodicity' => 'required|integer|in:-1,0,1,3,6,12',
15271553
]
15281554
);
15291555

@@ -1583,7 +1609,7 @@ public function draft(Request $request)
15831609
{
15841610
// Not for API
15851611
abort_if(
1586-
Auth::User()->role === 4,
1612+
Auth::User()->isAPI(),
15871613
Response::HTTP_FORBIDDEN,
15881614
'403 Forbidden'
15891615
);
@@ -1611,7 +1637,7 @@ public function draft(Request $request)
16111637
$control->score = request('score') === 0 ? null : request('score');
16121638

16131639
// only admin and user can update the plan_date and action_plan
1614-
if (Auth::User()->role === 1 || Auth::User()->role === 2) {
1640+
if (Auth::User()->isAdmin() || Auth::User()->isUser()) {
16151641
$control->plan_date = request('plan_date');
16161642
$control->action_plan = request('action_plan');
16171643
// do not save the realisation date as it is in draft
@@ -1632,7 +1658,7 @@ public function reject(Request $request)
16321658
{
16331659
// Only for Admin and user
16341660
abort_if(
1635-
! (Auth::User()->role === 1 || Auth::User()->role === 2),
1661+
! (Auth::User()->isAdmin() || Auth::User()->isUser()),
16361662
Response::HTTP_FORBIDDEN,
16371663
'403 Forbidden'
16381664
);
@@ -1766,15 +1792,15 @@ public function tempo(Request $request)
17661792
{
17671793
// For administrators and users only
17681794
abort_if(
1769-
Auth::User()->role !== 1 && Auth::User()->role !== 2,
1795+
! Auth::User()->isAdmin() && !Auth::User()->isUser(),
17701796
Response::HTTP_FORBIDDEN,
17711797
'403 Forbidden'
17721798
);
17731799

17741800
// get measures
17751801
if ($request->id !== null) {
17761802
// Find associate control
1777-
$measures = Measure::where('clause', '=', $request->id)->get();
1803+
$measures = Measure::query()->where('clause', '=', $request->id)->get();
17781804
} else {
17791805
$measures = Collect();
17801806
}
@@ -1795,7 +1821,7 @@ public function template(Request $request)
17951821
{
17961822
// Not for API
17971823
abort_if(
1798-
Auth::User()->role === 4,
1824+
Auth::User()->isAPI(),
17991825
Response::HTTP_FORBIDDEN,
18001826
'403 Forbidden'
18011827
);

app/Http/Controllers/HomeController.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,18 +419,30 @@ private function getExpandedControls()
419419
return $controls->flatMap(function ($control) {
420420
$expanded = collect([$control]);
421421

422-
if ($control->realisation_date === null && $control->periodicity > 0 && $control->periodicity <= 12) {
423-
for ($i = 1; $i <= 12 / $control->periodicity; $i++) {
424-
$repeatedControl = clone $control;
425-
$repeatedControl->id = null;
426-
$repeatedControl->score = null;
427-
$repeatedControl->observations = null;
428-
$repeatedControl->realisation_date = null;
429-
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addMonthsNoOverflow($i * $control->periodicity);
430-
$expanded->push($repeatedControl);
422+
if ($control->realisation_date === null) {
423+
if ($control->periodicity === -1) {
424+
for ($i = 1; $i <= 32; $i++) {
425+
$repeatedControl = clone $control;
426+
$repeatedControl->id = null;
427+
$repeatedControl->score = null;
428+
$repeatedControl->observations = null;
429+
$repeatedControl->realisation_date = null;
430+
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addDays($i * 7);
431+
$expanded->push($repeatedControl);
432+
}
433+
}
434+
else if ($control->periodicity > 0 && $control->periodicity <= 12) {
435+
for ($i = 1; $i <= 12 / $control->periodicity; $i++) {
436+
$repeatedControl = clone $control;
437+
$repeatedControl->id = null;
438+
$repeatedControl->score = null;
439+
$repeatedControl->observations = null;
440+
$repeatedControl->realisation_date = null;
441+
$repeatedControl->plan_date = Carbon::parse($control->plan_date)->addMonthsNoOverflow($i * $control->periodicity);
442+
$expanded->push($repeatedControl);
443+
}
431444
}
432445
}
433-
434446
return $expanded;
435447
});
436448
}

app/Http/Controllers/MeasureController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public function activate(Request $request) : RedirectResponse
558558
$request,
559559
[
560560
'plan_date' => 'required',
561-
'periodicity' => 'required',
561+
'periodicity' => 'required|integer|in:-1,0,1,3,6,12',
562562
'measures' => 'array|min:1',
563563
]
564564
);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2026.03.04",
2+
"version": "2026.03.16",
33
"license": "GPL-3.0",
44
"author": "Didier Barzin",
55
"repository": "https://www.github.com/dbarzin/deming",

resources/lang/de/common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'validate' => 'Validieren',
2222

2323
'once' => 'einmalig',
24+
'weekly' => 'wöchentlich',
2425
'monthly' => 'monatlich',
2526
'quarterly' => 'quartal',
2627
'biannually' => 'halbjährlich',

resources/lang/en/common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'validate' => 'Validate',
2525

2626
'once' => 'Once',
27+
'weekly' => 'Weekly',
2728
'monthly' => 'Monthly',
2829
'quarterly' => 'Quarterly',
2930
'biannually' => 'Biannually',

resources/lang/fr/common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'validate' => 'Valider',
2525

2626
'once' => 'Une fois',
27+
'weekly' => 'Hebdomadaire',
2728
'monthly' => 'Mensuel',
2829
'quarterly' => 'Trimestriel',
2930
'biannually' => 'Bisanuel',

resources/views/actions/index.blade.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,22 @@
9898
@foreach($actions as $action)
9999
<tr>
100100
<td>
101-
<b id="{{ $action->reference }}"><a href="/action/show/{{ $action->id }}">{{ $action->reference==null ? ("ACT-".$action->id) : $action->reference }}<a>
101+
<b id="{{ $action->reference }}">
102+
<a href="/action/show/{{ $action->id }}">{{ $action->reference==null ? ("ACT-".$action->id) : $action->reference }}</a>
103+
</b>
102104
</td>
103105
<td>
104-
<p id="{{ $action->type }}">
105-
@if ($action->type==1)
106-
<p class="fg-red text-bold">
107-
{{ trans('cruds.action.types.major') }}
108-
</p>
109-
@elseif ($action->type==2)
110-
<p class="fg-orange text-bold">
111-
{{ trans('cruds.action.types.minor') }}
112-
</p>
113-
@elseif ($action->type==3)
114-
<p class="fg-yellow text-bold">
115-
{{ trans('cruds.action.types.observation') }}
116-
</p>
117-
@elseif ($action->type==4)
118-
<p class="fg-green text-bold">
119-
{{ trans('cruds.action.types.opportunity') }}
120-
</p>
121-
@endif
122-
</p>
106+
<center>
107+
@if ($action->type==1)
108+
<span class="mif-warning fg-red" style="font-size: 1.5rem;" title="{{ trans('cruds.action.types.major') }}"></span>
109+
@elseif ($action->type==2)
110+
<span class="mif-warning fg-orange" style="font-size: 1.5rem;" title="{{ trans('cruds.action.types.minor') }}"></span>
111+
@elseif ($action->type==3)
112+
<span class="mif-eye fg-dark-gray" style="font-size: 1.5rem;" title="{{ trans('cruds.action.types.observation') }}"></span>
113+
@elseif ($action->type==4)
114+
<span class="mif-thumbs-up fg-green" style="font-size: 1.5rem;" title="{{ trans('cruds.action.types.opportunity') }}"></span>
115+
@endif
116+
</center>
123117
</td>
124118
<td id="{{ $action->status }}">
125119
@if ($action->status==0)

0 commit comments

Comments
 (0)