Skip to content
Snippets Groups Projects
Commit 5cca4c72 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files

Merge branch 'feature/correctif/seb/08022023' into develop

# Conflicts:
#	composer.lock
parents aa4dfd96 1905e90d
No related branches found
Tags 2.4.6
No related merge requests found
Pipeline #41778 passed
......@@ -20,10 +20,18 @@
use App\Models\MeasureLevel;
use App\Models\User;
use App\Repository\EvaluationRepository;
use App\Repository\GraphDataRepository;
use Illuminate\Support\Facades\Auth;
class EvaluationsController extends Controller
{
private GraphDataRepository $repository;
public function __construct(GraphDataRepository $repository)
{
$this->repository = $repository;
}
public function all()
{
$user = Auth::user();
......@@ -126,7 +134,6 @@ public function save(EvaluationRepository $repository, EvaluationRequest $reques
$previous_measures_array = MeasureLevel::where('evaluation_id', $evaluation['id'])->pluck('id')->toArray();
foreach ($data['measure_levels'] as $put_measure_level) {
$measure = Measure::find($put_measure_level['measure_id']);
$fundamentalMeasure = $measure->fundamental;
if (isset($put_measure_level['id'])) {
$measure_level = MeasureLevel::find($put_measure_level['id']);
......@@ -137,11 +144,7 @@ public function save(EvaluationRepository $repository, EvaluationRequest $reques
$measure_level->measure_id = $put_measure_level['measure_id'];
$measure_level->evaluation_id = $evaluation['id'];
$measure_level->actual_level = $put_measure_level['actual_level'] ?? null;
if ($fundamentalMeasure && 2 === (int) $evaluation->current_step) {
$measure_level->expected_level = $put_measure_level['actual_level'] < 3 ? $put_measure_level['actual_level'] + 1 : null;
} else {
$measure_level->expected_level = $put_measure_level['expected_level'] ?? null;
}
$measure_level->expected_level = $put_measure_level['expected_level'] ?? null;
$measure_level->manager = $put_measure_level['manager'] ?? null;
$measure_level->end_date = $put_measure_level['end_date'] ?? null;
$measure_level->save();
......@@ -193,6 +196,19 @@ public function save(EvaluationRepository $repository, EvaluationRequest $reques
$evaluation->save();
if (Evaluation::STEP_ACTIONS === intval($evaluation->current_step)) {
// Ajout du niveau supérieur pour les mesures preconisées
$preconizedMeasure = array_slice($this->repository->getBestMeasuresForEvaluation($evaluation), 0, 4);
foreach ($evaluation->measureLevels as $measureLevel) {
$measureLevelpreconized = MeasureLevel::whereId($measureLevel->id)
->first();
if ($measureLevelpreconized && in_array($measureLevelpreconized['measure_id'], $preconizedMeasure, true)) {
$measureLevelpreconized->expected_level = $measureLevelpreconized['actual_level'] < 3 ? $measureLevelpreconized['actual_level'] + 1 : null;
}
$measureLevelpreconized->save();
}
}
// si mofification d'un step, reinitialisation des steps suivants
if (isset($data['draft']) && $data['draft']) {
if (1 === $evaluation->current_step) {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment