284 lines
8.4 KiB
PHP
Executable File
284 lines
8.4 KiB
PHP
Executable File
<?php
|
|
require_once 'Framework/Controleur.php';
|
|
require_once 'Modele/Menuvueutilisateur.php';
|
|
require_once 'Modele/Beneficiaire.php';
|
|
require_once 'Modele/Police.php';
|
|
require_once 'Modele/Garantieadherent.php';
|
|
require_once 'Modele/Pbeneficiaire.php';
|
|
require_once 'Modele/Lienparente.php';
|
|
require_once 'Modele/Naturepiece.php';
|
|
require_once 'Modele/Sexe.php';
|
|
|
|
require 'vendor/autoload.php';
|
|
use Aws\Rekognition\RekognitionClient;
|
|
|
|
class ControleurPrestations extends Controleur {
|
|
private $beneficiaire;
|
|
private $garantieadherent;
|
|
private $pbeneficiaire;
|
|
private $lienparente;
|
|
|
|
public function __construct() {
|
|
$this->menuvue = new Menuvueutilisateur();
|
|
$this->menuvue->getMenuVue('Prestations');
|
|
|
|
$this->beneficiaire = new Beneficiaire();
|
|
$this->police = new Police();
|
|
$this->garantieadherent = new Garantieadherent();
|
|
|
|
$this->pbeneficiaire = new Pbeneficiaire();
|
|
|
|
$this->liensubstitut = (new Lienparente())->getListeSubstitut();
|
|
$this->naturepiece = (new Naturepiece())->getListe();
|
|
$this->sexe = (new Sexe())->getListe();
|
|
|
|
$_SESSION['modeDevis'] = "0";
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$id = $this->requete->getParametre("id");
|
|
$idBeneficiaire = $id;
|
|
|
|
$this->beneficiaire->getModeBiometrie();
|
|
|
|
$this->beneficiaire->getContexteBeneficiaireId($id);
|
|
$idPolice = $_SESSION['idPolice_C'];
|
|
$this->police->getContextePoliceId($idPolice);
|
|
|
|
$beneficiaire = $this->pbeneficiaire->getContexteBeneficiaireIdPrest($idBeneficiaire);
|
|
|
|
$idAdherent = $_SESSION['idAdherent_C'];
|
|
|
|
// $garantieadherents = $this->garantieadherent->getGarantieAdherent($idAdherent);
|
|
$garantieadherents = $this->garantieadherent->getGarantieBeneficiaire($idBeneficiaire);
|
|
|
|
// A enlever après
|
|
$_SESSION['lienServeur'] = $_SESSION['lienProduction_C'];
|
|
|
|
$this->beneficiaire->controlerplafondbeneficiaireannuel($idBeneficiaire);
|
|
|
|
$limite_beneficiaire = $this->garantieadherent->getLimitesBeneficiaire($idBeneficiaire);
|
|
|
|
$limite_adherent = $this->garantieadherent->getLimitesAdherent($idAdherent);
|
|
|
|
$this->genererVue(array('beneficiaire' => $beneficiaire, 'garantieadherents' => $garantieadherents,
|
|
'liensubstitut' => $this->liensubstitut, 'naturepiece' => $this->naturepiece, 'sexe' => $this->sexe,
|
|
'limite_beneficiaire' => $limite_beneficiaire, 'limite_adherent' => $limite_adherent));
|
|
}
|
|
|
|
public function ebeneenregistrerface()
|
|
{
|
|
$_SESSION['messageFace'] = "";
|
|
$compare_face = $_POST['compare_face'];
|
|
$del_face = $_POST['del_face'];
|
|
|
|
if(isset($_POST['image_face']))
|
|
{
|
|
$_SESSION['okId_face'] = "-1";
|
|
$_SESSION['okId'] = "-1";
|
|
|
|
$path = "Temp/";
|
|
$extension = "jpeg";
|
|
|
|
$data = $_POST['image_face'];
|
|
|
|
$data = str_replace('data:image/jpeg;base64,', '', $data);
|
|
|
|
$data = base64_decode($data);
|
|
|
|
$username = $_SESSION['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;
|
|
|
|
if ($compare_face=="1")
|
|
{
|
|
if($del_face=="1")
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('3');
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('2');
|
|
}
|
|
|
|
$arrgs = [
|
|
'credentials' => [
|
|
/*
|
|
'key' => 'AKIARKWWQN5L3CY26JXS',
|
|
'secret' => 'Mo613SKHaBKSH+IMPoMObafFiavN7kRqgp56gePX',
|
|
*/
|
|
/*
|
|
'key' => 'AKIARKWWQN5LZYQYF5HJ',
|
|
'secret' => '8dI1CAe+/vMsOJXs11Gv+nSQGMZiRCr0nIeEFS1H',
|
|
*/
|
|
'key' => 'AKIA2O2PTXQ7XN5OATO3',
|
|
'secret' => 'Rzq5mKG80tqfePQYF6iFZ5AMCM/bY2l6i5IxxLzL',
|
|
],
|
|
'version' => 'latest',
|
|
'region' => 'us-west-2'
|
|
// 'region' => 'Oregon'
|
|
// 'region' => 'eu-west-1'
|
|
|
|
];
|
|
/*
|
|
regions
|
|
us-east-2
|
|
us-east-1
|
|
us-west-1
|
|
us-west-2
|
|
af-south-1
|
|
ap-east-1
|
|
ap-south-2
|
|
ap-southeast-3
|
|
ap-southeast-4
|
|
ap-south-1
|
|
ap-northeast-3
|
|
ap-northeast-2
|
|
ap-southeast-1
|
|
ap-southeast-2
|
|
ap-northeast-1
|
|
ca-central-1
|
|
eu-central-1
|
|
eu-west-1
|
|
eu-west-2
|
|
eu-south-1
|
|
eu-west-3
|
|
eu-south-2
|
|
eu-north-1
|
|
eu-central-2
|
|
me-south-1
|
|
me-central-1
|
|
sa-east-1
|
|
us-gov-east-1
|
|
us-gov-west-1
|
|
*/
|
|
|
|
$client = new RekognitionClient($arrgs);
|
|
|
|
$sourceImage = $chemin;
|
|
$targetImage = $_SESSION['dossierPhoto_C'].$_SESSION['dossierSociete'].'/Photos/'.$_SESSION['lienPhoto_C'];
|
|
|
|
try
|
|
{
|
|
$result = $client->compareFaces
|
|
(
|
|
[
|
|
'SimilarityThreshold' => 80,
|
|
'SourceImage' => [
|
|
'Bytes' => file_get_contents($sourceImage)
|
|
],
|
|
'TargetImage' => [
|
|
'Bytes' => file_get_contents($targetImage)
|
|
],
|
|
]
|
|
);
|
|
|
|
$faceMatches = count($result['FaceMatches']);
|
|
if ($faceMatches==0)
|
|
{
|
|
$_SESSION['messageFace'] = "Les faces ne correspondent pas! / The faces do not match!";
|
|
$this->beneficiaire->resultat_traitement_face($username, '0', $_SESSION['messageFace']);
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0"));
|
|
}
|
|
elseif ($del_face=="1")
|
|
{
|
|
$motif = $_POST['motif'];
|
|
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', $motif);
|
|
|
|
|
|
$idBeneficiaire = $_SESSION['idBeneficiaire_C'];
|
|
$this->beneficiaire->supprimerPhoto($idBeneficiaire);
|
|
$this->beneficiaire->unregisterface($username, $motif);
|
|
$_SESSION['messageFace'] = "Face supprimée pour motif : $motif / Face removed for reason : $motif";
|
|
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
|
$_SESSION['lienPhoto_C']="";
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
|
|
|
$_SESSION['okId_face'] = "1";
|
|
$_SESSION['messageFace'] = "Face confirmée! / Face confirmed!";
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
|
}
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
// echo 'Message: ' .$e->getMessage();
|
|
// exit();
|
|
$msgErreur = $e->getMessage();
|
|
$_SESSION['messageFace'] = "Un problème lors du traitement! / A problem during treatment!";
|
|
|
|
$this->beneficiaire->resultat_traitement_face($username, '9', $msgErreur);
|
|
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$this->beneficiaire->init_traiterlaface('1');
|
|
|
|
$cheminNew = $_SESSION['lienPhotoFace'] . $nomImage;
|
|
|
|
$_SESSION['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['largeurPhoto'])
|
|
{
|
|
$desired_width = $_SESSION['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))
|
|
// if (imagejpeg($virtual_image, $cheminNew, 60))
|
|
{
|
|
$this->beneficiaire->registerface($username);
|
|
|
|
$idBeneficiaire = $_SESSION['idBeneficiaire_C'];
|
|
$this->beneficiaire->changerPhoto($idBeneficiaire, $nomImage);
|
|
|
|
$_SESSION['messageFace'] = "Enrôlement effectué avec succès! / Enrollment completed successfully!!";
|
|
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
|
}
|
|
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
|
}
|
|
unlink($chemin);
|
|
}
|
|
}
|
|
|
|
} |