Skip to content
Snippets Groups Projects
Commit 8c986506 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #10633 TIME 2:30 added validate recommendation action

parent afd41f3c
No related branches found
No related tags found
No related merge requests found
......@@ -309,7 +309,7 @@ An action page is described in a ACTIONPAGE tag :
<LABEL>_VALIDATE_RECOMMENDATION</LABEL>
<NAME>validate_recommendation</NAME>
<DESC>_VALIDATE_RECOMMENDATION_DESC</DESC>
<component>v1Action</component>
<component>validateRecommendationAction</component>
<ORIGIN>module</ORIGIN>
<MODULE>avis</MODULE>
<FLAG_CREATE>false</FLAG_CREATE>
......
......@@ -99,6 +99,7 @@ UPDATE actions SET component = 'sendToOpinionCircuitAction' WHERE action_page =
UPDATE actions SET component = 'continueOpinionCircuitAction' WHERE action_page = 'avis_workflow';
UPDATE actions SET component = 'giveOpinionParallelAction' WHERE action_page = 'avis_workflow_simple';
UPDATE actions SET component = 'sendToParallelOpinion' WHERE action_page = 'send_docs_to_recommendation';
UPDATE actions SET component = 'validateRecommendationAction' WHERE action_page = 'validate_recommendation';
DELETE FROM actions_groupbaskets WHERE id_action IN (SELECT id FROM actions WHERE action_page = 'put_in_copy');
DELETE FROM actions_categories WHERE action_id IN (SELECT id FROM actions WHERE action_page = 'put_in_copy');
......
......@@ -66,6 +66,7 @@ class ActionMethodController
'sendToOpinionCircuitAction' => 'sendToOpinionCircuit',
'continueOpinionCircuitAction' => 'continueOpinionCircuit',
'giveOpinionParallelAction' => 'giveOpinionParallel',
'validateRecommendationAction' => 'validateRecommendation',
'noConfirmAction' => null
];
......@@ -562,7 +563,7 @@ class ActionMethodController
$opinionLimitDate = new \DateTime($args['data']['opinionLimitDate']);
$today = new \DateTime('today');
if ($opinionLimitDate < $today) {
return ['errors' => "Opinion limit date is not a valid date"];
return ['errors' => ["Opinion limit date is not a valid date"]];
}
ResModel::update([
......@@ -591,7 +592,7 @@ class ActionMethodController
$opinionLimitDate = new \DateTime($args['data']['opinionLimitDate']);
$today = new \DateTime('today');
if ($opinionLimitDate < $today) {
return ['errors' => "Opinion limit date is not a valid date"];
return ['errors' => ["Opinion limit date is not a valid date"]];
}
if (empty($args['data']['opinionCircuit'])) {
......@@ -734,4 +735,53 @@ class ActionMethodController
return true;
}
public static function validateRecommendation(array $args)
{
ValidatorModel::notEmpty($args, ['resId']);
ValidatorModel::intVal($args, ['resId']);
if (empty($args['data']['opinionLimitDate'])) {
return ["errors" => ["Opinion limit date is missing"]];
}
$opinionLimitDate = new \DateTime($args['data']['opinionLimitDate']);
$today = new \DateTime('today');
if ($opinionLimitDate < $today) {
return ['errors' => ["Opinion limit date is not a valid date"]];
}
$latestNote = NoteModel::get([
'where' => ['identifier = ?', "note_text like '[" . _TO_AVIS . "]%'"],
'data' => [$args['resId']],
'oderBy' => ['creation_date desc'],
'limit' => 1
]);
if (empty($latestNote)) {
return ["errors" => ["No note for opinion available"]];
}
$latestNote = $latestNote[0];
$newNote = $args['data']['note'];
NoteModel::delete([
'where' => ['id = ?'],
'data' => [$latestNote['id']]
]);
NoteModel::create([
'resId' => $args['resId'],
'user_id' => $GLOBALS['id'],
'note_text' => $newNote
]);
ResModel::update([
'set' => ['opinion_limit_date' => $args['data']['opinionLimitDate']],
'where' => ['res_id = ?'],
'data' => [$args['resId']]
]);
return true;
}
}
......@@ -447,3 +447,4 @@ define("_HAS_INTERRUPTED_WORKFLOW", "Has interrupted the workflow ");
define("_AVIS_SENT", "Notice given");
define("_BY", "by");
define("_TO_AVIS", "For recommendation");
......@@ -446,3 +446,4 @@ define("_HAS_INTERRUPTED_WORKFLOW", "A terminé le circuit");
define("_AVIS_SENT", "Avis donné");
define("_BY", "par");
define("_TO_AVIS", "POUR AVIS");
......@@ -452,3 +452,4 @@ define("_HAS_INTERRUPTED_WORKFLOW", "Has interrupted the workflow "); //TO TRANS
define('_AVIS_SENT', 'Gegeven bericht');
define('_BY', 'door');
define('_TO_AVIS', 'VOOR BERICHT');
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