This commit is contained in:
KANE LAZENI 2026-01-03 12:42:19 +00:00
parent aba1d4fc3c
commit 2b73c85967
11 changed files with 464 additions and 1 deletions

View File

@ -0,0 +1,295 @@
<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Beneficiaire.php';
require_once 'Modele/Avenant.php';
class ControleurAjaximporterlisteassure extends Controleurrequete
{
private $beneficiaire;
private $avenant;
public function __construct()
{
$this->beneficiaire = new Beneficiaire();
$this->avenant = new Avenant();
}
public function index()
{
}
public function initimportermodele()
{
$idPolice = $_SESSION['idPolice_C'];
$avenants = $this->avenant->getAvenant($idPolice);
$this->genererVueAjax(array('avenants' => $avenants));
}
public function exportermodele()
{
$beneficiaires = $this->beneficiaire->getModeleAssures();
// Excel
$headerXLS = array
(
_('Catégorie'),
_('No Adhérent'),
_('No Famille'),
_('Nom'),
_('Prénoms'),
_('Lien Parenté'),
_('Nature Pièce'),
_('No Pièce'),
"Sex",
_('Groupe Sang'),
_('Naissance'),
_('Tél Portable'),
'email'
);
$dataXLS = array();
foreach ($beneficiaires as $beneficiaire)
{
$dataXLS[]=$beneficiaire;
}
$classeur = new PHPExcel();
$classeur->getProperties()->setCreator("INTER-SANTE");
$classeur->setActiveSheetIndex(0);
$feuille=$classeur->getActiveSheet();
$feuille->setTitle(_('MODELE ASSURES'));
$feuille->fromArray($headerXLS, NULL, 'A1', true);
$feuille->fromArray($dataXLS, NULL, 'A2', true);
//Forcer le téléchargement vers le navigateur;
$fichier = 'Temp/TEMPLATE_LISTE_ASSURE'."_".uniqid().".xlsx";
$writer = new PHPExcel_Writer_Excel2007($classeur);
$writer->save($fichier);
$t_html =' <div class="alert alert-success"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
public function importermodele()
{
$idAvenant = $this->requete->getParametreFormulaire("idAvenant");
$cheminFichier = $this->requete->getParametreFormulaire("cheminFichier");
$_SESSION['idAvenant_C'] = $idAvenant;
$this->beneficiaire->initIinsererLigneModeleAssure();
$dataXLS = array();
$fichier = "Temp/import/".$cheminFichier;
if (!file_exists($fichier))
{
$this->genererVueAjax(array('message_erreur_excel' => "Fichier introubable sur le serveur !", 'succes_impot_execl' => "0"));
exit();
}
$docXLS = new PHPExcel_Reader_Excel2007();
$Excel = $docXLS->load($fichier);
$Excel->setActiveSheetIndex(0);
$feuille=$Excel->getActiveSheet();
$derniereLigne = $feuille->getHighestRow();
$derniereColonne = $feuille->getHighestColumn();
$tableauExcel = $feuille->toArray(null, true, true, true);
for ($i = 2; $i <= $derniereLigne; $i++)
{
$categorie = trim($tableauExcel[$i]['A']);
$numeroAdherent = trim($tableauExcel[$i]['B']);
$noFamille = trim($tableauExcel[$i]['C']);
if ($noFamille<=" ")
{
$noFamille = "0";
}
$nom = trim($tableauExcel[$i]['D']);
$prenoms = trim($tableauExcel[$i]['E']);
$codeLienParente = trim($tableauExcel[$i]['F']);
$codeNaturePiece = trim($tableauExcel[$i]['G']);
$numeroPiece = trim($tableauExcel[$i]['H']);
$sexe = trim($tableauExcel[$i]['I']);
$codeGroupeSanguin = trim($tableauExcel[$i]['J']);
$dateNaissance = trim($tableauExcel[$i]['K']);
$telephonePortable = trim($tableauExcel[$i]['L']);
$email = trim($tableauExcel[$i]['M']);
$nomComplet = $nom . " " . $prenoms;
if ( ($categorie<=" ") && ($codeLienParente=="A"))
{
$this->genererVueAjax(array('message_erreur_excel' => $nomComplet . " => Pas de catégorie!", 'succes_impot_execl' => "0"));
exit();
}
$liste_liens = array("A", "C", "E", "O");
if (!in_array($codeLienParente, $liste_liens))
{
$this->genererVueAjax(array('message_erreur_excel' => $nomComplet . " => Revoir lien de parenté!", 'succes_impot_execl' => "0"));
exit();
}
$liste_sexes = array("M", "F");
if (!in_array($sexe, $liste_sexes))
{
$this->genererVueAjax(array('message_erreur_excel' => $nomComplet . " => Revoir le sexe!", 'succes_impot_execl' => "0"));
exit();
}
// Penser à gérer les erreurs de date
$this->beneficiaire->insererLigneModeleAssure($idAvenant, $categorie, $numeroAdherent,
$noFamille, $nom, $prenoms, $codeLienParente, $codeNaturePiece, $numeroPiece, $sexe,
$codeGroupeSanguin, $dateNaissance, $telephonePortable, $email);
/*
echo "Ligne ". $i . " => OK";
echo "<BR>";
*/
}
$this->beneficiaire->gererIncorporationSurFamExistante();
// Vérification de certaines erreurs :
// 1 => Si nouvelle famille sans Adhérent
$noFamilleSansAdherent = $this->beneficiaire->getadhimpfamillesansadherent();
if ($noFamilleSansAdherent>"0")
{
$this->genererVueAjax(array('message_erreur_excel' => "Famille " . $noFamilleSansAdherent . " => Adherent Principal manquant !", 'succes_impot_execl' => "0"));
exit();
}
// 2 => Si plus d'1 Adhérent dans une même famille
$noFamillePlusieursAdherent = $this->beneficiaire->getadhimpfamilleplusieursadherent();
if ($noFamillePlusieursAdherent>"0")
{
$this->genererVueAjax(array('message_erreur_excel' => "Famille " . $noFamillePlusieursAdherent . " => Plusieurs Adherents Principaux !", 'succes_impot_execl' => "0"));
exit();
}
// 3 => Incorporation sur une ancienne famille introuvable dans la police
$noFamilleExistantSansAdherent = $this->beneficiaire->getadhimpfamilleexistantsansadherent();
if ($noFamilleExistantSansAdherent>"0")
{
$this->genererVueAjax(array('message_erreur_excel' => "Famille " . $noFamilleExistantSansAdherent . " => Ancienne famille introuvable !", 'succes_impot_execl' => "0"));
exit();
}
$this->genererVueAjax(array('message_erreur_excel' => "Fichier temporaire extrait du serveur avec succes!", 'succes_impot_execl' => "1"));
exit();
}
//
public function traiterlignesimportees()
{
$idPolice = $_SESSION['idPolice_C'];
$avenants = $this->avenant->getAvenant($idPolice);
$this->genererVueAjax(array('avenants' => $avenants));
}
public function exclureligneimportee()
{
$idBeneficiairemodel = $this->requete->getParametreFormulaire("idBeneficiairemodel");
$exclure = $this->requete->getParametreFormulaire("exclure");
$this->beneficiaire->exclureligneimportee($idBeneficiairemodel, $exclure);
// $this->genererVueAjax();
}
public function calculerprimeimportee()
{
$this->beneficiaire->calculerprimeimportee();
}
public function afficheradherentimportee()
{
$idCollege = $this->requete->getParametreFormulaire("idCollege");
$adherents = $this->beneficiaire->getListeAdherentImportes($idCollege);
$adherents_college = $this->beneficiaire->getListeAdherentImportesCollege($idCollege);
$this->genererVueAjax(array('adherents' => $adherents, 'adherents_college' => $adherents_college));
}
public function ajouterunadherentaucollege()
{
$idBeneficiairemodel = $this->requete->getParametreFormulaire("idBeneficiairemodel");
$idCollege = $this->requete->getParametreFormulaire("idCollege");
$this->beneficiaire->ajouterunadherentaucollege($idBeneficiairemodel, $idCollege);
// $this->genererVueAjax();
}
public function retirerunadherentaucollege()
{
$idBeneficiairemodel = $this->requete->getParametreFormulaire("idBeneficiairemodel");
$this->beneficiaire->retirerunadherentaucollege($idBeneficiairemodel);
// $this->genererVueAjax();
}
public function incorpoerassuresimportes()
{
$this->beneficiaire->incorpoerassuresimportes();
}
public function ajoutertousadherentaucollege()
{
$idCollege = $this->requete->getParametreFormulaire("idCollege");
$this->beneficiaire->ajoutertousadherentaucollege($idCollege);
// $this->genererVueAjax();
}
public function ajoutersanscollegeadherentaucollege()
{
$idCollege = $this->requete->getParametreFormulaire("idCollege");
$this->beneficiaire->ajoutersanscollegeadherentaucollege($idCollege);
// $this->genererVueAjax();
}
public function retirertousadherentaucollege()
{
$idCollege = $this->requete->getParametreFormulaire("idCollege");
$this->beneficiaire->retirertousadherentaucollege($idCollege);
// $this->genererVueAjax();
}
public function majetape()
{
$this->beneficiaire->majetape();
}
}

View File

@ -1594,3 +1594,28 @@ function init_import_assures()
window.location.assign($("#racineWeb" ).val()+"Importassure/");
}
function exporter_modele_assure()
{
$('#div_form_upload').hide();
var div_export = $('#div_exporter_liste_assures');
div_export.html('<div style="padding-top:80px;"><img src="Bootstrap/images/loading.gif"/>&nbsp;&nbsp;<span style="font-size:15pt;">' + 'Veuillez patienter... / Please wait...' + '</span></div>');
$.ajax({
url: $("#racineWeb").val()+"Ajaximporterlisteassure/exportermodele/",
type: 'POST',
// data: donnees,
success: function(data)
{
div_export.html(data);
},
error : function(resultat, statut, erreur)
{
},
complete: function(data)
{
}
});
}

View File

@ -0,0 +1,102 @@
<div id="div_adherents_importes">
<div class="row">
<div id="div_adherents_importes_1" class="col-xs-6" >
<legend> <?= _("Familles hors du collège") ?> </legend>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:8pt;">
<thead>
<tr>
<th colspan="3" style='text-align:center'> <?= _("Catégoerie ou Collège") ?> </th>
<th colspan="2" style='text-align:center'> <?= _("No Famille") ?> </th>
<th colspan="2" style='text-align:center'> <?= _("Familles") ?> </th>
<th style='text-align:center'> => </th>
</tr>
<tr>
<th colspan="3"> <button type="button" style="font-size:10pt;" class="form-control btn btn-primary" onclick="javascript:ajouter_tous_adherent_importe_college();" > <?= _("Ajouter tous") . " ==>" ?> </button> </th>
<th colspan="2"> </th>
<th colspan="3"> <button type="button" style="font-size:10pt;" class="form-control btn btn-warning" onclick="javascript:ajouter_sans_college_adherent_importe_college();" > <?= _("Ajouter les sans collèges"). " ==>" ?> </button> </th>
</tr>
</thead>
<tbody>
<?php foreach ($adherents as $adherent):
$idBeneficiairemodel = $adherent['idBeneficiairemodel'];
$idCollege = $adherent['idCollege'];
?>
<tr valign="top">
<td align='center'><?= $this->nettoyer($adherent['categorie']) ?></td>
<?php if ($idCollege>'0'): ?>
<td align='center'><?= $this->nettoyer($adherent['libelleCollege']) ?></td>
<td align='center'><?= $this->nettoyer($adherent['codeProduit']) ?></td>
<?php else : ?>
<td align='center' style="background-color: yellow;"><?= $this->nettoyer($adherent['libelleCollege']) ?></td>
<td align='center' style="background-color: yellow;"><?= $this->nettoyer($adherent['codeProduit']) ?></td>
<?php endif; ?>
<td align='center'><?= $this->nettoyer($adherent['numeroAdherent']) ?></td>
<td align='center'><?= $this->nettoyer($adherent['noFamille']) ?></td>
<td><?= $this->nettoyer($adherent['nom']) ?></td>
<td><?= $this->nettoyer($adherent['prenoms']) ?></td>
<td align='center'> <input type="button" value="=>" onClick="javascript:ajouter_un_adherent_importe_college('<?=$idBeneficiairemodel?>');" ></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div id="div_adherents_importes_2" class="col-xs-6" >
<legend> <?= _("Familles du collège") ?> </legend>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:8pt;">
<thead>
<tr>
<th style='text-align:center'> <= </th>
<th colspan="3" style='text-align:center'> <?= _("Catégoerie ou Collège") ?> </th>
<th colspan="2" style='text-align:center'> <?= _("No Famille") ?> </th>
<th colspan="2" style='text-align:center'> <?= _("Familles") ?> </th>
</tr>
<tr>
<td colspan="8"> <button type="button" style="font-size:10pt;" class="form-control btn btn-danger" onclick="javascript:retirer_tous_adherent_importe_college();" > <?= "<== " . _("Retirer tous les membres de ce collège") ?> </button> </td>
</tr>
</thead>
<tbody>
<?php foreach ($adherents_college as $adherent_college):
$idBeneficiairemodel=$adherent_college['idBeneficiairemodel'];
$idCollege=$adherent_college['idCollege'];
?>
<tr valign="top">
<td align='center'> <input type="button" value="<=" onClick="javascript:retirer_un_adherent_importe_college('<?=$idBeneficiairemodel?>');" ></td>
<td align='center'><?= $this->nettoyer($adherent_college['categorie']) ?></td>
<td align='center'><?= $this->nettoyer($adherent_college['libelleCollege']) ?></td>
<td align='center'><?= $this->nettoyer($adherent_college['codeProduit']) ?></td>
<td align='center'><?= $this->nettoyer($adherent_college['numeroAdherent']) ?></td>
<td align='center'><?= $this->nettoyer($adherent_college['noFamille']) ?></td>
<td><?= $this->nettoyer($adherent_college['nom']) ?></td>
<td><?= $this->nettoyer($adherent_college['prenoms']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1 @@
OK ajouterunadherentaucollege

View File

@ -0,0 +1 @@
OK EXCLURE

View File

@ -0,0 +1,4 @@
<div id="div_erreur_excel" class="alert alert-danger" >
<H4> <?= $message_erreur_excel ?> </H4>
<input class="sr-only" type="text" id="succes_impot_execl" name="succes_impot_execl" value="<?= $succes_impot_execl ?>">
</div>

View File

@ -0,0 +1 @@
OK incorpoerassuresimportes

View File

@ -0,0 +1 @@
IMPORT TARIF MEICAMENT

View File

@ -0,0 +1,32 @@
<legend> <?= _("Sélectionner un avenant pour importation OLD") ?> </legend>
<table class="table table-striped table-bordered table-hover table-condensed table-responsive" style="font-size:10pt;">
<thead>
<tr>
<th style='text-align:center' > <?= _("Numéro") ?> </th>
<th style='text-align:center'> <?= _("Effet") ?> </th>
<th> <?= _("Libellé") ?> </th>
<th> <?= _("Commentaires") ?> </th>
<th> <?= _("Producteur") ?> </th>
<th style='text-align:center'> <?= _("Saisie") ?> </th>
<th style='text-align:center'> <?= _("Importer...") ?> </th>
</tr>
</thead>
<tbody>
<?php
foreach ($avenants as $avenant):
$idAvenant = $avenant['idAvenant'];
?>
<tr valign="top">
<td align='center'><?= $this->nettoyer($avenant['numeroAvenant']) ?></td>
<td align='center'><?= dateLang($this->nettoyer($avenant['dateEffet'])) ?></td>
<td><?= $this->nettoyer($avenant['libelleAvenant']) ?></td>
<td><?= $this->nettoyer($avenant['motifavenant']) ?></td>
<td><?= $this->nettoyer($avenant['utilisateur']) ?></td>
<td align='center'><?= dateheureLang($this->nettoyer($avenant['dateSysteme'])) ?></td>
<td> <button style='font-size:10pt;' type="button" class="form-control btn btn-info" onclick="javascript:importer_modele_assure(<?= $idAvenant ?>);"> <?= _("Importer...") ?> </button> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@ -0,0 +1 @@
OK retirerunadherentaucollege

View File

@ -595,7 +595,7 @@ $activeChildId = $menuData['child'];
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Application Scripts -->
<script src="/Js/fonctions.js?ver=2026.01.03.20"></script>
<script src="/Js/fonctions.js?ver=2026.01.03.21"></script>
<script type="text/javascript">
setInterval(function() {