From d3b0b406b731a23381ef93e664ed6b1b6ab61440 Mon Sep 17 00:00:00 2001 From: Maxime Merrien Date: Thu, 31 Oct 2024 17:44:31 +0100 Subject: [PATCH] =?UTF-8?q?Reprise=20des=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/DossierController.php | 32 ++++++ .../services/DossierEffectifsDegagements.php | 41 +++++++ .../effectifs-degagements-dossier.phtml | 63 ++++++++++- .../formrecupeffectifsdegagements.phtml | 26 +++++ .../views/scripts/dossier/prescription.phtml | 102 +++++++++--------- 5 files changed, 212 insertions(+), 52 deletions(-) create mode 100644 application/views/scripts/dossier/formrecupeffectifsdegagements.phtml diff --git a/application/controllers/DossierController.php b/application/controllers/DossierController.php index 239e6c202..c6a65136c 100755 --- a/application/controllers/DossierController.php +++ b/application/controllers/DossierController.php @@ -3073,6 +3073,38 @@ public function recupprescriptionAction(): void $service_dossier->copyPrescriptionDossier($prescriptionAmelioration, $idDossier, $idDossierInitial); } + public function formrecupeffectifsdegagementsAction(): void + { + // récupération de l'établissement attaché au dossier + $dbEtabDossier = new Model_DbTable_EtablissementDossier(); + $listeEtab = $dbEtabDossier->getEtablissementListe($this->_getParam('idDossier')); + + $this->view->assign('nbEtab', count($listeEtab)); + $this->view->assign('idDossier', $this->_getParam('idDossier')); + + if (1 == $this->view->nbEtab) { + // si il n'y a qu'un établissement, on affiche la liste des dossiers qu'il contient + $service_etablissement = new Service_Etablissement(); + $dossiers = $service_etablissement->getDossiers($listeEtab['0']['ID_ETABLISSEMENT']); + $this->view->assign('etudes', $dossiers['etudes']); + $this->view->assign('visites', $dossiers['visites']); + $this->view->assign('autres', $dossiers['autres']); + } + } + + public function recupeffectifsdegagementsAction(): void + { + $this->_helper->viewRenderer->setNoRender(); + + $idDossierInitial = (int) $this->_getParam('dossierSelect'); + $idDossier = (int) $this->_getParam('idDossier'); + + $serviceDossierEffectifsDegagements = new Service_DossierEffectifsDegagements(); + + $rubriques = $serviceDossierEffectifsDegagements->getRubriques($idDossierInitial, 'Dossier'); + $serviceDossierEffectifsDegagements->copyValeurs($idDossier, $rubriques); + } + public function lienmultipleAction(): void { $this->_helper->viewRenderer->setNoRender(); diff --git a/application/services/DossierEffectifsDegagements.php b/application/services/DossierEffectifsDegagements.php index df8a3835e..ccb53cbc6 100644 --- a/application/services/DossierEffectifsDegagements.php +++ b/application/services/DossierEffectifsDegagements.php @@ -10,4 +10,45 @@ public function __construct() new Service_RubriqueDossier() ); } + + public function copyValeurs(int $idDossier, array $rubriques): void + { + $serviceChamp = new Service_Champ(); + + foreach ($rubriques as $rubrique) { + $champs = $rubrique['CHAMPS']; + + foreach ($champs as $champ) { + if ('Parent' !== $champ['TYPE']) { + $this->saveValeurChamp('champ-'.$champ['ID_CHAMP'], $idDossier, 'Dossier', $champ['VALEUR']); + + continue; + } + + if (!$serviceChamp->isTableau($champ)) { + foreach ($champ['FILS'] as $enfant) { + $this->saveValeurChamp( + implode('-', ['champ', $enfant['ID_CHAMP']]), + $idDossier, + 'Dossier', + $enfant['VALEUR'] + ); + } + + continue; + } + + foreach ($champ['FILS']['VALEURS'] as $index => $champs) { + foreach ($champs as $idChamp => $data) { + $this->saveValeurChamp( + implode('-', ['champ', $idChamp, $index]), + $idDossier, + 'Dossier', + $data['VALEUR'] + ); + } + } + } + } + } } diff --git a/application/views/scripts/dossier/effectifs-degagements-dossier.phtml b/application/views/scripts/dossier/effectifs-degagements-dossier.phtml index d22773461..59005d254 100644 --- a/application/views/scripts/dossier/effectifs-degagements-dossier.phtml +++ b/application/views/scripts/dossier/effectifs-degagements-dossier.phtml @@ -1,6 +1,6 @@
hasData): ?> - @@ -23,3 +23,64 @@ ]); ?>
+ + diff --git a/application/views/scripts/dossier/formrecupeffectifsdegagements.phtml b/application/views/scripts/dossier/formrecupeffectifsdegagements.phtml new file mode 100644 index 000000000..8ba0779b4 --- /dev/null +++ b/application/views/scripts/dossier/formrecupeffectifsdegagements.phtml @@ -0,0 +1,26 @@ +nbEtab != 1): ?> + Pour pouvoir utiliser cette fonctionnalité, le dossier ne doit concerner qu'un seul établissement + +
+ + Sélectionnez le dossier pour lequel vous souhaitez reprendre les effectifs et dégagements + + etudes) === 0) : ?> + + +
+ etudes) > 0): ?> +

Études

+
    + partialLoop('dossier/results/dossier.phtml', $this->etudes) ?> +
+ +
+ +
+ diff --git a/application/views/scripts/dossier/prescription.phtml b/application/views/scripts/dossier/prescription.phtml index b5e673bf2..5d1c78427 100755 --- a/application/views/scripts/dossier/prescription.phtml +++ b/application/views/scripts/dossier/prescription.phtml @@ -409,63 +409,63 @@ $(document).ready(function(){ return false; }); - //Récupération des prescriptions d'un autre dossier - var dialogRecupPresc = $('
').appendTo('body'); - - dialogRecupPresc.dialog({ - title: "Reprise des prescriptions d'un dossier précédent", - modal: true, - autoOpen: false, - width: 1200, - height: 'auto', - buttons: [ - { - text: 'Reprendre les prescriptions', - class: 'btn btn-success', - click: function() { - if ($('input[type=radio][name=dossierSelect]:checked').length == 1) { - $.ajax({ - type: "POST", - url: "/dossier/recupprescription", - data: $("#selectionDossier").serialize(), - before: function(){ - dialogRecupPresc.html("Veuillez patienter pendant la reprise des prescriptions "); - }, - success: function(msg){ - window.location='/dossier/prescription/id/'+$("#idDossier").val(); - } - }); - } else { - return false; - } + //Récupération des prescriptions d'un autre dossier + var dialogRecupPresc = $('
').appendTo('body'); + dialogRecupPresc.dialog({ + title: "Reprise des prescriptions d'un dossier précédent", + modal: true, + autoOpen: false, + width: 1200, + height: 'auto', + buttons: [ + { + text: 'Reprendre les prescriptions', + class: 'btn btn-success', + click: function() { + if ($('input[type=radio][name=dossierSelect]:checked').length == 1) { + $.ajax({ + type: "POST", + url: "/dossier/recupprescription", + data: $("#selectionDossier").serialize(), + before: function(){ + dialogRecupPresc.html("Veuillez patienter pendant la reprise des prescriptions "); + }, + success: function(msg){ + window.location='/dossier/prescription/id/'+$("#idDossier").val(); + } + }); + } else { return false; } - }, - { - text: 'Annuler', - class: 'btn', - click: function() { - $(this).html(""); - $(this).dialog("close"); - } - } - ], - }); - $(".recupPrescDossier").live('click',function(){ - //On ouvre la boite de dialogue - $.ajax({ - type: "POST", - url: "/dossier/formrecupprescription", - data: "&idDossier="+$("#idDossier").val(), - success: function(msg){ - dialogRecupPresc.html(msg); - dialogRecupPresc.dialog("open"); + return false; } - }); - return false; + }, + { + text: 'Annuler', + class: 'btn', + click: function() { + $(this).html(""); + $(this).dialog("close"); + } + } + ], + }); + + $(".recupPrescDossier").live('click',function(){ + //On ouvre la boite de dialogue + $.ajax({ + type: "POST", + url: "/dossier/formrecupprescription", + data: "&idDossier="+$("#idDossier").val(), + success: function(msg){ + dialogRecupPresc.html(msg); + dialogRecupPresc.dialog("open"); + } }); + return false; + }); //Edition des prescriptions d'un dossier var dialogPrescEdit = $('
').appendTo('body');