diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql index 58eac152b8d96be2083c38bb2ca94d576bc4245e..c71e998918fd298062c7ac74e71202ca0d8efa3a 100644 --- a/migration/19.12/1912.sql +++ b/migration/19.12/1912.sql @@ -86,6 +86,8 @@ where group_id in ( UPDATE actions SET component = 'confirmAction', action_page = 'confirm_status' WHERE action_page in ('validate_mail', 'process', 'visa_mail'); DELETE FROM actions WHERE action_page = 'view' OR component = 'viewDoc'; +UPDATE actions SET component = 'rejectVisaBackToPrevious' WHERE action_page = 'rejection_visa_previous'; + /* FOLDERS */ DO $$ BEGIN diff --git a/sql/data_fr.sql b/sql/data_fr.sql index 6edf576b4841faf137d193bcca9a1de79e0688b6..f25df523f4a8e8a0cfc14d883133b6402295b55e 100755 --- a/sql/data_fr.sql +++ b/sql/data_fr.sql @@ -996,7 +996,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 (400, '', 'Envoyer un AR', '_NOSTATUS_', 'N', 'send_attachments_to_contact', 'Y', 'v1Action'); 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', 'v1Action'); +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', 'rejectVisaBackToPrevious'); 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 (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'); diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index 2eec67ad3ef5b79536f87cf1eeb60b77b33f3335..e153a703b68b6d7ff01cf03381819a1a985f69e6 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -50,6 +50,7 @@ class ActionMethodController 'updateAcknowledgementSendDateAction' => 'updateAcknowledgementSendDateAction', 'sendShippingAction' => 'createMailevaShippings', 'sendSignatureBookAction' => 'sendSignatureBook', + 'rejectVisaBackToPrevious' => 'rejectVisaBackToPrevious', 'noConfirmAction' => null ]; @@ -341,4 +342,32 @@ class ActionMethodController return ['history' => $historyInfo]; } + + public static function rejectVisaBackToPrevious(array $args) + { + ValidatorModel::notEmpty($args, ['resId']); + ValidatorModel::intVal($args, ['resId']); + + $listInstances = ListInstanceModel::get([ + 'select' => ['listinstance_id'], + 'where' => ['res_id = ?', 'difflist_type = ?', 'process_date is not null'], + 'data' => [$args['resId'], 'VISA_CIRCUIT'], + 'order_by' => ['listinstance_id desc'], + 'limit' => 1 + ]); + + if (empty($listInstances)) { + return false; + } + + $listInstances = $listInstances[0]; + + ListInstanceModel::update([ + 'set' => ['process_date' => null], + 'where' => ['listinstance_id = ?'], + 'data' => [$listInstances['listinstance_id']] + ]); + + return true; + } }