Skip to content

Commit

Permalink
Reprise des données
Browse files Browse the repository at this point in the history
  • Loading branch information
A709197 committed Oct 31, 2024
1 parent 92be96e commit d3b0b40
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 52 deletions.
32 changes: 32 additions & 0 deletions application/controllers/DossierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
41 changes: 41 additions & 0 deletions application/services/DossierEffectifsDegagements.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class='action-buttons pull-right'>
<?php if (!$this->hasData): ?>
<button type="button" class="btn btn-info">
<button type="button" class="btn btn-info recupEffectifsDegagementsDossier">
Reprendre les données d'une étude précédente
</button>
<?php endif ?>
Expand All @@ -23,3 +23,64 @@
]); ?>
</div>
</div>

<script type='text/javascript'>
$(document).ready(function() {
var dialogRecupEffectifsDegagements = $('<div style="display:none;"></div>').appendTo('body');

dialogRecupEffectifsDegagements.dialog({
title: "Reprise des données d'un dossier précédent",
modal: true,
autoOpen: false,
width: 1200,
height: 'auto',
buttons: [
{
text: 'Reprendre les effectifs et dégagements',
class: 'btn btn-success',
click: function() {
if ($('input[type=radio][name=dossierSelect]:checked').length == 1) {
$.ajax({
type: "POST",
url: "/dossier/recupeffectifsdegagements",
data: $("#selectionDossier").serialize(),
before: function(){
dialogRecupEffectifsDegagements.html("Veuillez patienter pendant la reprise des effectifs et dégagements <img src='/images/load.gif' />");
},
success: function(msg){
window.location='/dossier/effectifs-degagements-dossier/id/'+$("#idDossier").val();
}
});
} else {
return false;
}

return false;
}
},
{
text: 'Annuler',
class: 'btn',
click: function() {
$(this).html("");
$(this).dialog("close");
}
}
],
});

$(".recupEffectifsDegagementsDossier").live('click',function(){
$.ajax({
type: "POST",
url: "/dossier/formrecupeffectifsdegagements",
data: "&idDossier="+$("#idDossier").val(),
success: function(msg){
dialogRecupEffectifsDegagements.html(msg);
dialogRecupEffectifsDegagements.dialog("open");
}
});

return false;
});
})
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php if ($this->nbEtab != 1): ?>
Pour pouvoir utiliser cette fonctionnalité, le dossier ne doit concerner qu'un seul établissement
<?php else: ?>
<form name='selectionDossier' id='selectionDossier' >
<input type='hidden' name='idDossier' id='idDossier' value='<?= $this->idDossier; ?>' />
Sélectionnez le dossier pour lequel vous souhaitez reprendre les effectifs et dégagements

<?php if (count($this->etudes) === 0) : ?>
<div class='well well-large text-center'>
<p class='lead'>Il n'y a pas de dossier.</p>
<p>
<a href='<?= $this->url(array('controller' => 'dossier', 'action' => 'add', 'id_etablissement' => $this->etablissement['general']['ID_ETABLISSEMENT']), null, true) ?>' class='btn btn-large'>Ajouter un dossier</a>
</p>
</div>
<?php else: ?>
<div id="content_etudes_ets">
<?php if (count($this->etudes) > 0): ?>
<h4>Études</h4>
<ul class='recherche_liste'>
<?= $this->partialLoop('dossier/results/dossier.phtml', $this->etudes) ?>
</ul>
<?php endif ?>
</div>
<?php endif ?>
</form>
<?php endif ?>
102 changes: 51 additions & 51 deletions application/views/scripts/dossier/prescription.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -409,63 +409,63 @@ $(document).ready(function(){
return false;
});

//Récupération des prescriptions d'un autre dossier
var dialogRecupPresc = $('<div style="display:none;"></div>').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 <img src='/images/load.gif' />");
},
success: function(msg){
window.location='/dossier/prescription/id/'+$("#idDossier").val();
}
});
} else {
return false;
}
//Récupération des prescriptions d'un autre dossier
var dialogRecupPresc = $('<div style="display:none;"></div>').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 <img src='/images/load.gif' />");
},
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 = $('<div style="display:none;"></div>').appendTo('body');
Expand Down

0 comments on commit d3b0b40

Please sign in to comment.