radiantproduction/Controleur/ControleurCreeradherentfamiliale.php

160 lines
6.8 KiB
PHP

<?php
require_once 'Framework/Controleur.php';
require_once 'Modele/Adherent.php';
require_once 'Modele/Collegepolice.php';
require_once 'Modele/Menuvueutilisateur.php';
require_once 'Modele/Beneficiaire.php';
require_once 'Modele/Naturepiece.php';
require_once 'Modele/Sexe.php';
require_once 'Modele/Pays.php';
require_once 'Modele/Situationfamille.php';
require_once 'Modele/Groupesanguin.php';
require_once 'Modele/Avenant.php';
require_once 'Modele/Ouinon.php';
require_once 'Modele/Ville.php';
require_once 'Modele/Localite.php';
require_once 'Modele/Client.php';
require_once 'Modele/Typeecheancier.php';
require_once 'Modele/Adherent_temp.php';
require_once 'Societes/'.$_SESSION['codeSociete'].'/Tarifs/Modele/Tarif.php';
class ControleurCreeradherentfamiliale extends Controleur
{
private $adherent;
private $beneficiaire;
private $naturepiece;
private $sexe;
private $pays;
private $situationfamille;
private $groupesanguin;
private $tarif;
private $college;
private $avenant;
private $ouinon;
private $client;
private $ville;
private $localite;
private $typeecheancier;
private $adherent_temp;
public function __construct()
{
$this->menuvue = new Menuvueutilisateur();
$this->menuvue->getMenuVue('Creeradherentfamiliale');
$this->adherent = new Adherent();
$this->beneficiaire = new Beneficiaire();
$this->naturepiece = (new Naturepiece())->getListe();
$this->sexe = (new Sexe())->getListe();
$this->situationfamille = (new Situationfamille())->getListe();
$this->pays = new Pays();
$this->groupesanguin = (new Groupesanguin())->getListe();
$this->tarif = new Tarif();
$this->college = (new Collegepolice())->getListe($_SESSION['idPolice_C']);
$this->collegepolice = new Collegepolice();
$this->avenant = (new Avenant())->getListeEnCours($_SESSION['idPolice_C']);
$this->ouinonprorata = (new Ouinon())->getListe();
$this->ville = new Ville();
$this->localite = new Localite();
$this->client = new Client();
$this->typeecheancier = new Typeecheancier();
$this->adherent_temp = new Adherent_temp();
}
public function index()
{
$idClient = $_SESSION['idClient_C'];
$client = $this->client->getClientId($idClient);
$codeSociete = $_SESSION['codeSociete'];
$codePays = $client['codePays'];
$codeVille = $client['codeVille'];
$codeLocalite = $client['codeLocalite'];
$pays = $this->pays->getListe($codePays);
$ville = $this->ville->getListe($codePays);
$localite = $this->localite->getListe($codePays, $codeVille);
$idPolice = $_SESSION['idPolice_C'];
$ville = $this->ville->getListe($codePays);
$localite = $this->localite->getListe($codePays, $codeVille);
$typeecheancier = $this->typeecheancier->getListe();
$dernierIdCollege = $this->collegepolice->fn_get_college_familiale($idPolice);
$_SESSION['dernierIdCollege'] = $dernierIdCollege;
$adherent_temp = $this->adherent->initadherentfamilialie_temp();
$idCollege = $_SESSION['dernierIdCollege'];
// $idAvenant = $_SESSION['dernierIdAvenant'];
$dateEntree = $_SESSION['dernierDateAvenant'];
$codeCommercial = $_SESSION['codeApporteur_C'];
$user = $_SESSION['login'];
$primeBase = $adherent_temp['primeBase'];
$codeTypeEcheancier = $adherent_temp['codeTypeEcheancier'];
$primes_adherent_temp = $this->adherent_temp->recapadherentfamilialetemp($idCollege, $dateEntree, $primeBase, $codeTypeEcheancier);
$this->genererVue(array('adherent_temp' => $adherent_temp, 'college' => $this->college,
'naturepiece' => $this->naturepiece, 'sexe' => $this->sexe, 'pays' => $pays, 'situationfamille' => $this->situationfamille,
'groupesanguin' => $this->groupesanguin, 'avenant' => $this->avenant, 'ouinonprorata' => $this->ouinonprorata, 'ville' => $ville,
'localite' => $localite, 'codePays' => $codePays, 'codeVille' => $codeVille, 'codeLocalite' => $codeLocalite,
'typeecheancier' => $typeecheancier, 'primes_adherent_temp' => $primes_adherent_temp));
}
public function ajouteradherent()
{
$idPolice = $_SESSION['idPolice_C'];
$racineNoAdherent = $this->requete->getSession()->getAttribut('racineNoAdherent');
$codeSociete = $this->requete->getSession()->getAttribut('codeSociete');
$idCollege = $this->requete->getParametre("idCollege");
$idPolice = $this->requete->getParametre("idPolice");
$numeroPolice = $this->requete->getParametre("numeroPolice");
$nom = $this->requete->getParametre("nom");
$prenoms = $this->requete->getParametreFormulaire("prenoms");
$codeNaturePiece = $this->requete->getParametre("codeNaturePiece");
$numeroPiece = $this->requete->getParametreFormulaire("numeroPiece");
$sexe = $this->requete->getParametreFormulaire("sexe");
$dateNaissance = $this->requete->getParametreDate("dateNaissance");
$codeGroupeSanguin = $this->requete->getParametreFormulaire("codeGroupeSanguin");
$codeSituationFamille = $this->requete->getParametreFormulaire("codeSituationFamille");
$nombreEnfants = $this->requete->getParametreFormulaire("nombreEnfants");
$adresseGeo = $this->requete->getParametreFormulaire("adresseGeo");
$adressePostale = $this->requete->getParametreFormulaire("adressePostale");
$codePays = $this->requete->getParametre("codePays");
$telephonFixe = $this->requete->getParametreFormulaire("telephonFixe");
$telephonePortable = $this->requete->getParametreFormulaire("telephonePortable");
$email = $this->requete->getParametreFormulaire("email");
$dateEntree = $this->requete->getParametreDate("dateEntree");
$idAvenant = $this->requete->getParametre("idAvenant");
$codeLocalite = $this->requete->getParametre("codeLocalite");
$user = $this->requete->getSession()->getAttribut('login');
$dateCre = date("Y-m-d");
$nom = strtoupper($nom);
$prenoms = ucwords($prenoms);
$dernierIdAdherent = $this->adherent->ajouteradherentfamilialie($idPolice, $idCollege, $nom, $prenoms, $codeNaturePiece, $numeroPiece, $sexe,
$dateNaissance, $codeGroupeSanguin, $codeSituationFamille, $nombreEnfants, $adresseGeo, $adressePostale,
$codePays, $telephonFixe, $telephonePortable, $email, $dateEntree, $user, $idAvenant, $codeLocalite) ;
$idBeneficiaire = $this->beneficiaire->ajouterAdherentfamilialie($dernierIdAdherent);
// On va calculuer la prime
$codeLienParente = "A";
$idAdherent = $dernierIdAdherent;
$_SESSION['idAdherent_C'] = $idAdherent;
$_SESSION['idBeneficiaire_C'] = $idBeneficiaire;
// On actualise le contexte : NbAdh et NbAss
$idPolice = $_SESSION['idPolice_C'];
$this->adherent->getNbassure($idPolice);
$this->rediriger("Ficheadherentfamiliale/".$idAdherent);
}
}