442 lines
14 KiB
PHP
442 lines
14 KiB
PHP
<?php
|
|
require_once 'Framework/Controleur.php';
|
|
require_once 'Modele/Menuvueutilisateur.php';
|
|
require_once 'Modele/Beneficiaire.php';
|
|
require_once 'Modele/Ouinon.php';
|
|
require_once 'Modele/Familleacte.php';
|
|
require_once 'Modele/Detailtarifacte.php';
|
|
require_once 'Modele/Menuvueutilisateur.php';
|
|
require_once 'Modele/Raisonconsultation.php';
|
|
require_once 'Modele/Bonpec.php';
|
|
require_once 'Modele/Medecin.php';
|
|
require_once 'Modele/Garantiesbaremepriseencharge.php';
|
|
|
|
class ControleurFichebeneficiaire extends Controleur {
|
|
private $menuvue;
|
|
|
|
private $beneficiaire;
|
|
private $garantie;
|
|
private $familleacte;
|
|
private $raison;
|
|
private $bonpec;
|
|
private $medecin;
|
|
private $detail;
|
|
private $oui_non;
|
|
|
|
public function __construct() {
|
|
$this->menuvue = new Menuvueutilisateur();
|
|
$this->menuvue->getMenuVue('Fichebeneficiaire');
|
|
|
|
$this->beneficiaire = new Beneficiaire();
|
|
$this->garantie = new Garantiesbaremepriseencharge();
|
|
|
|
$codePrestataire = $_SESSION['p_codePrestataire_C'];
|
|
$codeTypePrestation = "CONS";
|
|
|
|
$this->familleacte = (new Familleacte())->getListe($codeTypePrestation);
|
|
$this->detail = new Detailtarifacte();
|
|
// $this->raison = (new Raisonconsultation())->getListe();
|
|
$this->raison = (new Raisonconsultation());
|
|
$this->bonpec = new Bonpec();
|
|
|
|
|
|
$this->medecin = new Medecin();
|
|
|
|
$this->oui_non = new Ouinon();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
$codeSociete = $this->requete->getSession()->getAttribut('p_codeSociete');
|
|
|
|
$idBeneficiaire = $_SESSION['p_idBeneficiaire_C'];
|
|
|
|
|
|
$this->beneficiaire->getModeBiometrie();
|
|
|
|
$beneficiaire = $this->beneficiaire->getContexteBeneficiaireId($idBeneficiaire);
|
|
|
|
$referencementpolice = $this->beneficiaire->getReferencementPolice($_SESSION['p_idPolice_C']);
|
|
|
|
$prestataireReference = $this->beneficiaire->getReferencementPrestataire($_SESSION['p_codePrestataire_C']);
|
|
|
|
$idAdherent = $_SESSION['p_idAdherent_C'];
|
|
|
|
// A enlever après
|
|
$_SESSION['p_lienServeur'] = $_SESSION['p_lienPrestation_C'];
|
|
|
|
$referencer = $this->oui_non->getListe();
|
|
|
|
$avecReferencement = $referencementpolice['avecReferencement'];
|
|
|
|
$tauxAvecReferencement = $referencementpolice['tauxAvecReferencement'];
|
|
$tauxSansReferencement = $referencementpolice['tauxSansReferencement'];
|
|
|
|
$date = date('Y-m-d');
|
|
$dateRef = $beneficiaire['dateReference'];
|
|
|
|
$_SESSION['dateReference'] = $dateRef;
|
|
|
|
$referecementPossible = $this->beneficiaire->getReferencementPossible();
|
|
|
|
// 22-11-2022
|
|
$agemaxipediatrie = $this->beneficiaire->getagemaxipediatrie();
|
|
|
|
$parametreNombreFeuilleGratuitJour = $this->beneficiaire->getnombrefeuillegratuitejournee();
|
|
$nombreFeuilleGratuite = $this->beneficiaire->comptefeuillegratuitejournee();
|
|
|
|
$bool = true;
|
|
|
|
$codeGarantie = "CON";
|
|
//09-01-2023
|
|
$tmDerogation = $this->beneficiaire->getTmDerogation($codeGarantie);
|
|
|
|
//01-03-2022
|
|
$this->garantie->getsourcebaremegarantienew($idBeneficiaire, $codeGarantie, $date);
|
|
|
|
if (!empty($dateRef)){
|
|
|
|
$diff = abs(strtotime($dateRef) - strtotime($date));
|
|
$years = floor($diff / (365*60*60*24));
|
|
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
|
|
|
|
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
|
|
|
|
|
|
if($days > $beneficiaire['dureeCode']){
|
|
$this->beneficiaire->reinitCodeReference($idBeneficiaire);
|
|
$bool = true;
|
|
}else{
|
|
$bool = false;
|
|
}
|
|
}
|
|
|
|
|
|
if($prestataireReference=="1"){
|
|
if($avecReferencement=="1"){
|
|
if($bool==true){
|
|
$tm = 100-$tauxSansReferencement;
|
|
}else{
|
|
$tm = 100-$tauxAvecReferencement;
|
|
}
|
|
}else{
|
|
if($tmDerogation == "1000"){
|
|
|
|
$tm = $this->detail->ticketModerateurDefinitif($codeGarantie,"", $date);
|
|
}else{
|
|
$tm = $tmDerogation;
|
|
}
|
|
}
|
|
}else
|
|
{
|
|
if($avecReferencement=="1"){
|
|
if($bool==true){
|
|
$tm = 100-$tauxSansReferencement;
|
|
}else{
|
|
$tm = 100-$tauxAvecReferencement;
|
|
}
|
|
}else{
|
|
|
|
if($tmDerogation == "1000"){
|
|
|
|
$tm = $this->detail->ticketModerateurDefinitif($codeGarantie,"", $date);
|
|
|
|
}else{
|
|
$tm = $tmDerogation;
|
|
}
|
|
}
|
|
}
|
|
|
|
$_SESSION['p_tm_C'] = $tm;
|
|
$_SESSION['p_tauxdecouverture_C'] = 100 - $tm;
|
|
|
|
$okReferencement = $this->requete->getParametreFormulaire("id");
|
|
|
|
$_SESSION['p_okReferencement_C'] =$okReferencement;
|
|
|
|
|
|
$codeTypePrestation = "CONS";
|
|
$codePrestataire = $_SESSION['p_codePrestataire_C'];
|
|
$codeTypeBon = "CONS";
|
|
|
|
$acte = array();
|
|
|
|
//$referencementpolice = $this->beneficiaire->getReferencementPolice($_SESSION['p_idPolice_C']);
|
|
|
|
$nbBonsCons = $this->bonpec->getNbBonPrestataireDisponible($codePrestataire, $codeTypeBon);
|
|
$codeGestionBon = $this->bonpec->getCodeGestionBon($codeTypeBon);
|
|
$typeGestionbon = $this->bonpec->getGestionBon($codeGestionBon);
|
|
$dureeVieBon = $this->bonpec->getDureeVie($codeTypeBon);
|
|
|
|
//$situation = $this->acte->getSituationActeBeneficiaire($codeActe);
|
|
|
|
$_SESSION['p_okId'] = "1";
|
|
|
|
$this->detail->settmtypeprestation($codeTypePrestation);
|
|
|
|
|
|
//$prestataireReference = $this->beneficiaire->getReferencementPrestataire($_SESSION['p_codePrestataire_C']);
|
|
|
|
$dernierCentre = $this->beneficiaire->getdernierCentreConsultation();
|
|
|
|
$reference = $this->beneficiaire->getCodeReferencementBeneficiaire();
|
|
|
|
//var_dump($dernierCentre);die();
|
|
|
|
$medecins = array(); //$this->medecin->getpraticiensprestataire($codePrestataire);
|
|
//var_dump($medecins);
|
|
|
|
$derniereDateConsultation = $_SESSION['p_derniereDateConsultation'];
|
|
|
|
if(is_null($derniereDateConsultation)){
|
|
$dureeDerniereConsultation = "";
|
|
}else{
|
|
$dureeDerniereConsultation = ceil(abs(strtotime($date) - strtotime($derniereDateConsultation)) / 86400);
|
|
}
|
|
|
|
$numeroBeneficiaire = $_SESSION['p_numeroBeneficiaire_C'];
|
|
|
|
$bonNonLivrePha = $this->beneficiaire->getordonnancenon_livre($numeroBeneficiaire);
|
|
|
|
$nuit = $this->beneficiaire->estNuitOuFerie();
|
|
|
|
$this->beneficiaire->prestation_possible();
|
|
|
|
$acte = $this->medecin->getactesconsultation();
|
|
|
|
$specialite = array();
|
|
|
|
$sexe = $beneficiaire['sexe'];
|
|
$raison = $this->raison->getraisonconsultation($sexe);
|
|
|
|
$this->genererVue(array(
|
|
'beneficiaire' => $beneficiaire,
|
|
'referencementpolice' => $referencementpolice,
|
|
'referencer' => $referencer,
|
|
'prestataireReference' => $prestataireReference,
|
|
'tm' => $tm,
|
|
'referecementPossible' => $referecementPossible,
|
|
'agemaxipediatrie' => $agemaxipediatrie,
|
|
'reference' => $reference,
|
|
'typeGestionbon' => $typeGestionbon,
|
|
'familleacte' => $this->familleacte,
|
|
'acte' => $acte,
|
|
//'raison' => $this->raison,
|
|
'raison' => $raison,
|
|
'dernierCentre' => $dernierCentre,
|
|
'medecins' => $medecins,
|
|
'nbBonsCons' => $nbBonsCons,
|
|
'codeGestionBon' => $codeGestionBon,
|
|
'nombreFeuilleGratuite' => $nombreFeuilleGratuite,
|
|
'dureeVieBon' => $dureeVieBon,
|
|
'dureeDerniereConsultation' => $dureeDerniereConsultation,
|
|
'parametreNombreFeuilleGratuitJour' => $parametreNombreFeuilleGratuitJour,
|
|
'bonNonLivrePha' => $bonNonLivrePha,
|
|
'nuit' => $nuit,
|
|
'acte' => $acte,
|
|
'specialite' => $specialite
|
|
));
|
|
}
|
|
|
|
public function ebeneenregistrerface()
|
|
{
|
|
$_SESSION['p_messageFace'] = "";
|
|
$compare_face = $_POST['compare_face'];
|
|
$del_face = $_POST['del_face'];
|
|
|
|
if(isset($_POST['image_face']))
|
|
{
|
|
$_SESSION['p_okId_face'] = "-1";
|
|
$_SESSION['p_okId'] = "-1";
|
|
|
|
$path = "Temp/";
|
|
$extension = "jpeg";
|
|
|
|
$data = $_POST['image_face'];
|
|
|
|
$data = str_replace('data:image/jpeg;base64,', '', $data);
|
|
|
|
$data = base64_decode($data);
|
|
|
|
$username = $_SESSION['p_numeroBeneficiaire_C'];
|
|
|
|
$date = date('YmdHis');
|
|
$file_name = "img_v_".$date.uniqid().".".$extension;
|
|
$chemin = $path.$file_name;
|
|
|
|
file_put_contents($chemin, $data);
|
|
|
|
$rand = rand(1,1000000);
|
|
$nomImage = $username."_".$rand.'.'. $extension;
|
|
$nomImageCrypte_0 = $username."_".$rand.'.bin';
|
|
$nomImageCrypte = $_SESSION['p_lienPhotoFace'] . $nomImageCrypte_0;
|
|
|
|
if ($compare_face=="1")
|
|
{
|
|
if($del_face=="1")
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('3');
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('2');
|
|
}
|
|
|
|
require_once 'Framework/Faceebene.php';
|
|
|
|
$sourceImage = $chemin;
|
|
$targetImage = $_SESSION['p_photoAssureCrypte'];
|
|
|
|
try
|
|
{
|
|
$result = $client->compareFaces
|
|
(
|
|
[
|
|
'SimilarityThreshold' => 80,
|
|
'SourceImage' => [
|
|
'Bytes' => file_get_contents($sourceImage)
|
|
],
|
|
'TargetImage' => [
|
|
//'Bytes' => file_get_contents($targetImage)
|
|
'Bytes' => base64_decode($targetImage)
|
|
],
|
|
]
|
|
);
|
|
|
|
$faceMatches = count($result['FaceMatches']);
|
|
if ($faceMatches==0)
|
|
{
|
|
$_SESSION['p_messageFace'] = "Les faces ne correspondent pas! / The faces do not match!";
|
|
$this->beneficiaire->resultat_traitement_face($username, '0', $_SESSION['p_messageFace']);
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['p_messageFace'], 'msgErreur' => $_SESSION['p_messageFace'], 'photo_succes' => "0"));
|
|
}
|
|
elseif ($del_face=="1")
|
|
{
|
|
$motif = $_POST['motif'];
|
|
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', $motif);
|
|
|
|
$idBeneficiaire = $_SESSION['p_idBeneficiaire_C'];
|
|
$this->beneficiaire->supprimerPhoto($idBeneficiaire);
|
|
$this->beneficiaire->unregisterface($username, $motif);
|
|
$_SESSION['p_messageFace'] = "Face supprimée pour motif : $motif / Face removed for reason : $motif";
|
|
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['p_messageFace'], 'photo_succes' => "1"));
|
|
$_SESSION['p_lienPhoto_C']="";
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
|
|
|
$_SESSION['p_okId_face'] = "1";
|
|
$_SESSION['p_messageFace'] = "Face confirmée! / Face confirmed!";
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['p_messageFace'], 'msgErreur' => $_SESSION['p_messageFace'], 'photo_succes' => "1"));
|
|
}
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
// echo 'Message: ' .$e->getMessage();
|
|
// exit();
|
|
$msgErreur = $e->getMessage();
|
|
$_SESSION['p_messageFace'] = "Un problème lors du traitement! / A problem during treatment!";
|
|
|
|
$this->beneficiaire->resultat_traitement_face($username, '9', $msgErreur);
|
|
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['p_messageFace'], 'msgErreur' => $_SESSION['p_messageFace'], 'photo_succes' => "0"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('1');
|
|
|
|
$cheminNew = $_SESSION['p_lienPhotoFace'] . $nomImage;
|
|
|
|
$_SESSION['p_okId_face'] = "1";
|
|
|
|
// réduction de la taille de l'immage
|
|
$infosImg = getimagesize($chemin);
|
|
$src = $chemin;
|
|
$imgtype = image_type_to_mime_type($infosImg[2]);
|
|
|
|
switch ($imgtype)
|
|
{
|
|
case 'image/jpeg':
|
|
$source_image = imagecreatefromjpeg($src);
|
|
break;
|
|
case 'image/jpg':
|
|
$source_image = imagecreatefromjpeg($src);
|
|
break;
|
|
case 'image/png':
|
|
$source_image = imagecreatefrompng($src);
|
|
break;
|
|
}
|
|
|
|
$width = imagesx($source_image);
|
|
$desired_width = $width;
|
|
if ($desired_width > $_SESSION['p_largeurPhoto'])
|
|
{
|
|
$desired_width = $_SESSION['p_largeurPhoto'];
|
|
}
|
|
$height = imagesy($source_image);
|
|
|
|
$desired_height = floor($height * ($desired_width / $width));
|
|
|
|
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
|
|
|
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
|
|
|
if(imagejpeg($virtual_image, $cheminNew, -1))
|
|
{
|
|
encryptImage($cheminNew, $nomImageCrypte);
|
|
|
|
unlink($cheminNew);
|
|
|
|
$this->beneficiaire->registerface($username);
|
|
|
|
$idBeneficiaire = $_SESSION['p_idBeneficiaire_C'];
|
|
// $this->beneficiaire->changerPhoto($idBeneficiaire, $nomImage);
|
|
$this->beneficiaire->changerPhoto($idBeneficiaire, $nomImageCrypte_0);
|
|
|
|
$_SESSION['p_messageFace'] = "Enrôlement effectué avec succès! / Enrollment completed successfully!!";
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['p_messageFace'], 'msgErreur' => $_SESSION['p_messageFace'], 'photo_succes' => "1"));
|
|
}
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
|
}
|
|
unlink($chemin);
|
|
}
|
|
}
|
|
|
|
public function confirmerotp()
|
|
{
|
|
if ($this->requete->existeParametre("otpValue"))
|
|
{
|
|
$login = $_SESSION['p_login'];
|
|
$otpValueSaisi = $this->requete->getParametre("otpValue");
|
|
|
|
$otpArray = $this->beneficiaire->get_otp_value();
|
|
|
|
$otpValueRequis = $otpArray['otpValue'];
|
|
$idOtpprestation = $otpArray['idOtpprestation'];
|
|
|
|
// if ( ($otpValueSaisi==$otpValueRequis) && (strlen($otpValueSaisi)=='6') )
|
|
if ( (password_verify($otpValueSaisi, $otpValueRequis)) && (strlen($otpValueSaisi)=='6') )
|
|
{
|
|
$this->beneficiaire->maj_otp($idOtpprestation, '1'); // validé
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->maj_otp($idOtpprestation, '9'); // incorrect
|
|
}
|
|
|
|
$this->rediriger("Fichebeneficiaire");
|
|
}
|
|
}
|
|
|
|
public function envoyerotp()
|
|
{
|
|
$otpValue = mt_rand(100000, 999999);
|
|
$this->beneficiaire->envoyer_otp($otpValue);
|
|
$this->rediriger("Fichebeneficiaire");
|
|
}
|
|
} |