From 89d7e81e197b49dcaf91a5317e0716d1af30ba89 Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Tue, 14 Jan 2020 15:24:06 +0100 Subject: [PATCH] FEAT #10633 TIME 1:30 added action interrupt visa --- core/xml/actions_pages.xml | 2 +- migration/19.12/1912.sql | 1 + sql/data_fr.sql | 2 +- .../controllers/ActionMethodController.php | 43 ++++++++++++++++++- src/core/lang/lang-en.php | 3 ++ src/core/lang/lang-fr.php | 3 ++ src/core/lang/lang-nl.php | 3 ++ 7 files changed, 54 insertions(+), 3 deletions(-) diff --git a/core/xml/actions_pages.xml b/core/xml/actions_pages.xml index ecd6709776f..f4f76621f72 100755 --- a/core/xml/actions_pages.xml +++ b/core/xml/actions_pages.xml @@ -268,7 +268,7 @@ An action page is described in a ACTIONPAGE tag : <LABEL>_INTERRUPT_WORKFLOW</LABEL> <NAME>interrupt_visa</NAME> <DESC>_INTERRUPT_WORKFLOW_DESC</DESC> - <component>v1Action</component> + <component>interruptVisaAction</component> <ORIGIN>module</ORIGIN> <MODULE>visa</MODULE> <FLAG_CREATE>false</FLAG_CREATE> diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql index 634bc5e96ec..280c3ad5dfa 100644 --- a/migration/19.12/1912.sql +++ b/migration/19.12/1912.sql @@ -90,6 +90,7 @@ UPDATE actions SET component = 'rejectVisaBackToPrevious' WHERE action_page = 'r UPDATE actions SET component = 'redirectInitiatorEntityAction' WHERE action_page = 'redirect_visa_entity'; UPDATE actions SET component = 'rejectVisaBackToPreviousAction' WHERE action_page = 'rejection_visa_previous'; UPDATE actions SET component = 'rejectVisaBackToRedactorAction' WHERE action_page = 'rejection_visa_redactor'; +UPDATE actions SET component = 'interruptVisaAction' WHERE action_page = 'interrupt_visa'; /* FOLDERS */ diff --git a/sql/data_fr.sql b/sql/data_fr.sql index 9b5199372b3..abb2ff2be80 100755 --- a/sql/data_fr.sql +++ b/sql/data_fr.sql @@ -997,7 +997,7 @@ INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_pag INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (405, '', 'Viser le courrier', '_NOSTATUS_', 'N', 'confirm_status', 'Y', 'confirmAction'); INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (407, '', 'Renvoyer pour traitement', 'COU', 'N', 'confirm_status', 'Y', 'confirmAction'); INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (408, '', 'Refuser le visa et remonter le circuit', '_NOSTATUS_', 'N', 'rejection_visa_previous', 'N', 'rejectVisaBackToPreviousAction'); -INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (410, '', 'Transmettre la réponse signée', 'EENV', 'N', 'interrupt_visa', 'Y', 'v1Action'); +INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (410, '', 'Transmettre la réponse signée', 'EENV', 'N', 'interrupt_visa', 'Y', 'interruptVisaAction'); INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (414, '', 'Envoyer au parapheur', '_NOSTATUS_', 'N', 'send_to_visa', 'Y', 'v1Action'); INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (416, '', 'Valider et poursuivre le circuit', '_NOSTATUS_', 'N', 'visa_workflow', 'Y', 'v1Action'); --INSERT INTO actions (id, keyword, label_action, id_status, is_system, action_page, history, component) VALUES (417, '', 'Envoyer l''AR', 'SVX', 'N', 'send_to_contact_with_mandatory_attachment', 'Y', 'v1Action'); diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index e7ce9f2984b..657e4b39c6e 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -56,6 +56,7 @@ class ActionMethodController 'redirectInitiatorEntityAction' => 'redirectInitiatorEntityAction', 'rejectVisaBackToPreviousAction' => 'rejectVisaBackToPrevious', 'rejectVisaBackToRedactorAction' => 'rejectVisaBackToRedactor', + 'interruptVisaAction' => 'interruptVisa', 'noConfirmAction' => null ]; @@ -405,7 +406,7 @@ class ActionMethodController 'select' => ['listinstance_id'], 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is not null'], 'data' => [$args['resId'], 'VISA_CIRCUIT'], - 'order_by' => ['listinstance_id desc'], + 'orderBy' => ['listinstance_id desc'], 'limit' => 1 ]); @@ -437,4 +438,44 @@ class ActionMethodController return true; } + + public static function interruptVisa(array $args) + { + ValidatorModel::notEmpty($args, ['resId']); + ValidatorModel::intVal($args, ['resId']); + + + $listInstances = ListInstanceModel::get([ + 'select' => ['listinstance_id'], + 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is null'], + 'data' => [$args['resId'], 'VISA_CIRCUIT'], + 'orderBy' => ['listinstance_id'], + 'limit' => 1 + ]); + + if (!empty($listInstances)) { + $listInstances = $listInstances[0]; + + ListInstanceModel::update([ + 'set' => [ + 'process_date' => 'CURRENT_TIMESTAMP', + 'process_comment' => _HAS_INTERRUPTED_WORKFLOW + ], + 'where' => ['listinstance_id = ?'], + 'data' => [$listInstances['listinstance_id']] + ]); + } + + + ListInstanceModel::update([ + 'set' => [ + 'process_date' => 'CURRENT_TIMESTAMP', + 'process_comment' => _INTERRUPTED_WORKFLOW + ], + 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is null'], + 'data' => [$args['resId'], 'VISA_CIRCUIT'] + ]); + + return true; + } } diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index 84119f936e6..fa70aef13c3 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -447,3 +447,6 @@ define("_DATE_LOCALE", "en_US.utf8"); define("_USER_PREFERENCE_UPDATED", "User preferences updated"); define("_NO_SENDERS", "No sender linked to resource"); + +define("_INTERRUPTED_WORKFLOW", "Interrupted workflow"); +define("_HAS_INTERRUPTED_WORKFLOW", "Has interrupted the workflow "); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index 7fc5d7a9f6c..2d9105449b2 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -446,3 +446,6 @@ define("_DATE_LOCALE", "fr_FR.utf8"); define("_USER_PREFERENCE_UPDATED", "Préférences utilisateur modifiées"); define("_NO_SENDERS", "Aucun expéditeur lié au courrier"); + +define("_INTERRUPTED_WORKFLOW", "Circuit Interrompu"); +define("_HAS_INTERRUPTED_WORKFLOW", "A terminé le circuit"); diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php index cad00b643fa..20bb6bd103f 100755 --- a/src/core/lang/lang-nl.php +++ b/src/core/lang/lang-nl.php @@ -452,3 +452,6 @@ define("_DATE_LOCALE", "en_US.utf8"); define("_USER_PREFERENCE_UPDATED", "User preferences updated"); //TO TRANSLATE define("_NO_SENDERS", "No sender linked to resource"); //TO TRANSLATE + +define("_INTERRUPTED_WORKFLOW", "Interrupted workflow"); //TO TRANSLATE +define("_HAS_INTERRUPTED_WORKFLOW", "Has interrupted the workflow "); //TO TRANSLATE -- GitLab