<?php
namespace App\Controller;
use App\Entity\PersonCivil;
use App\Entity\Application;
use App\Entity\CheckQr;
use App\Entity\Device;
use App\Entity\PersonAppIdentity;
use App\Entity\PersonAuthHistory;
use App\Form\PersonCivilType;
use App\Repository\ApplicationRepository;
use App\Repository\PersonAuthHistoryRepository;
use App\Repository\PersonRepository;
use App\Repository\PersonCivilRepository;
use App\Repository\CheckQrRepository;
use App\Repository\PersonAppIdentityRepository;
use App\Repository\DeviceRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\String\Slugger\SluggerInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;
use App\API\SqrApi as SqrApi;
use Google\Auth\Credentials\ServiceAccountCredentials;
Use Google\Auth\HttpHandler\HttpHandlerFactory;
/**
* @Route("/person/civil")
*/
class PersonCivilController extends AbstractController
{
/**
* @Route("/", name="app_person_civil_index", methods={"GET"})
*/
public function index(PersonCivilRepository $personCivilRepository): Response
{
return $this->render('person_civil/index.html.twig', [
'person_civils' => $personCivilRepository->findAll(),
]);
}
/**
* @Route("/get/IDO/info", name="app_person_civil_ido_get_json", methods={"GET", "POST"})
*/
public function indexJson(Request $request, PersonCivilRepository $personCivilRepository): Response
{
$referenceUser = $request->get('referenceUser');
$action = empty($request->get('action'))? "IDO" : $request->get('action'); // IDO, EMAIL, PHONE default IDO
if(!empty($referenceUser))
{
switch ($action)
{
case 'IDO':
$personCivil = $personCivilRepository->findOneBySqr($referenceUser); //OK
break;
case 'EMAIL':
$personCivil = $personCivilRepository->findOneBy(['email'=>$referenceUser]); //OK
break;
case 'PHONE':
$personCivil = $personCivilRepository->findOneBy(['phone'=>$referenceUser]); //OK
break;
case 'NOMS':
$personCivil = $personCivilRepository->findOneBy(['firstName'=>$referenceUser]); // OK
break;
/*case 'IDA':
$personCivil = $personCivilRepository->findOneBy(['phone'=>$referenceUser]); // NOK
break;
case 'PSEUDO':
$personCivil = $personCivilRepository->findOneBy(['phone'=>$referenceUser]); // NOK
break;*/
default:
# code...
break;
}
if($personCivil)
{
$userDta [] =
[
'civility'=>$personCivil->getCivility(),
'abisIdentificationJson'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->getAbisIdentificationJson(),
'firstName'=>$personCivil->getFirstName(),
'lastName'=>$personCivil->getLastName(),
'dateOfBirth'=>$personCivil->getDateOfBirth()->format("d/m/Y"),
'placeOfBirth'=>$personCivil->getPlaceOfBirth(),
'email'=>$personCivil->getEmail(),
'phone'=>$personCivil->getPhone(),
'typeOfIdentificationDocument'=>$personCivil->getTypeOfIdentificationDocument(),
'identificationDocumentNumber'=>$personCivil->getIdentificationDocumentNumber(),
'dateOfIssue'=>$personCivil->getDateOfIssue(),
'dateOfExpirationIssue'=>$personCivil->getDateOfExpirationIssue(),
'dateOfProrogation'=>$personCivil->getDateOfProrogation(),
'dateOfExpirationProrogation'=>$personCivil->getDateOfExpirationProrogation(),
'dateCreated'=>$personCivil->getDateCreated()->format("d/m/Y H:i:s"),
'selfie_link'=>"uploads/kyvala/enrolment/".$personCivil->getCheckQr()->getPersonBiometrics()[0]->getFace(),
'signature_link'=>"uploads/kyvala/enrolment/".$personCivil->getSignature(),
'officeStamp_link'=>"uploads/kyvala/enrolment/".$personCivil->getOfficeStamp(),
'nominativeStamp_link'=>"uploads/kyvala/enrolment/".$personCivil->getNominativeStamp(),
'officeStampAndSignature_link'=>"uploads/kyvala/enrolment/".$personCivil->getOfficeStampAndSignature(),
'nominativeStampAndSignature_link'=>"uploads/kyvala/enrolment/".$personCivil->getNominativeStampAndSignature(),
'initials_link'=>"uploads/kyvala/enrolment/".$personCivil->getInitials(),
'IDO'=>$personCivil->getCheckQr()->getNumero(),
'isEnrolled'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isIsEnrolled(),
'isDoublon'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isIsDoublon(),
'abisEncounterId'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->getAbisEncounterId(),
'isPouceGauche'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isPouceGauche(),
'isPouceDroit'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isPouceDroit(),
'isIndexDroit'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isIndexDroit(),
'isIndexGauche'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isIndexGauche(),
'isMajeurDroit'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isMajeurDroit(),
'isMajeurGauche'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isMajeurGauche(),
'isAnnulaireDroit'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isAnnulaireDroit(),
'isAnnulaireGauche'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isAnnulaireGauche(),
'isAuriculaireGauche'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isAuriculaireGauche(),
'isAuriculaireDroit'=>$personCivil->getCheckQr()->getPersonBiometrics()[0]->isAuriculaireDroit(),
];
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>"Utilisateur retrouvé avec succès",
'userData'=>$userDta
);
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"L'identifiant ne correspond à aucun utilisateur...",
);
}
/*
$person = $personRepository->findOneBySqr($referenceUser);
if($person)
{
$personCivils = $personCivilRepository->findBy(['person'=>$person]);
if ($personCivils)
{
$tabEnrol = [];
foreach ($personCivils as $key)
{
$tabEnrol [] =
[
'civility'=>$key->getCivility(),
'firstName'=>$key->getFirstName(),
'lastName'=>$key->getLastName(),
'dateOfBirth'=>$key->getDateOfBirth()->format("d/m/Y"),
'placeOfBirth'=>$key->getPlaceOfBirth(),
'email'=>$key->getEmail(),
'phone'=>$key->getPhone(),
'typeOfIdentificationDocument'=>$key->getTypeOfIdentificationDocument(),
'identificationDocumentNumber'=>$key->getIdentificationDocumentNumber(),
'dateOfIssue'=>$key->getDateOfIssue(),
'dateOfExpirationIssue'=>$key->getDateOfExpirationIssue(),
'dateOfProrogation'=>$key->getDateOfProrogation(),
'dateOfExpirationProrogation'=>$key->getDateOfExpirationProrogation(),
'dateCreated'=>$key->getDateCreated()->format("d/m/Y H:i:s"),
'referenceKyvala'=>$key->getCheckQr()->getNumero()
];
}
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>count($personCivils). " enregistrement recupérés avec succès...",
'enrolement'=>$tabEnrol
);
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Aucun enregistrement disponible pour cet utilisateur...",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Aucun utilisateur retrouvé avec cet identifiant...",
);
}*/
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Paramètres requis manquants..",
);
}
return new JsonResponse($return);
}
/*Fonction permettant de vérifier l'existance d'utilisateur dans la table personAppIdentity avec la clé d'un projet et l'email et le num tel */
/**
* @Route("/user/person/app/identity/check", name="app_person_civil_check_user_identity", methods={"GET", "POST"})
*/
public function checkUserIdentityJson(Request $request, PersonAppIdentityRepository $personAppIdentityRepository, ApplicationRepository $applicationRepository): Response
{
if($_POST)
{
$appKey = $request->get("app_key");
$email = $request->get("email");
$telephone = $request->get("telephone");
//$pivot = $request->get("pivot");//TOKEN TELEPHONE EMAIL
if(!empty($email) && !empty($appKey) && !empty($telephone))
{
$application = $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
if($application)
{
$personAppIdTelephone = $personAppIdentityRepository->findOneBy(['telephone'=>$telephone, 'application'=>$application]);
$personAppIdEmail = $personAppIdentityRepository->findOneBy(['email'=>$email, 'application'=>$application]);
if(!empty($personAppIdTelephone) || !empty($personAppIdEmail))
{
$return = array(
'Etat' =>'SUCCESS',
'Message' =>'Utilisateur retrouvé avec succès',
);
}else
{
$return = array(
'Etat' =>'CORRECT',
'Message' =>"Utilisateur introuvable. Veuillez procéder à l'enrôlement...",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Vous n'avez pas l'autorisation pour cette requette",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Paramètres requis manquants",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"La méthode d'envoie ne correspond pas aux attentes",
);
}
return new JsonResponse($return);
}
/*Fonction permettant à un utilisateur de s'authentifier par le biais de son telephone, email ou son token*/
/**
* @Route("/check/user/token/json", name="app_person_civil_check_user_token", methods={"GET", "POST"})
*/
public function checkUserTokenJson(Request $request, PersonAppIdentityRepository $personAppIdentityRepository, DeviceRepository $deviceRepository, ContainerInterface $container,CheckQrRepository $checkQrRepository, PersonAuthHistoryRepository $personAuthHistoryRepository, ApplicationRepository $applicationRepository): Response
{
if($_POST)
{
$appKey = $request->get("app_key");
$login = $request->get("login");
$pivot = $request->get("pivot");//TOKEN TELEPHONE EMAIL IDO
$pin = $request->get("pin");
$deviceId = $request->get("deviceId");
$token = $request->get("deviceToken");
$batteryState = $request->get("batteryState");
$isBatteryPlugIn = $request->get("isBatteryPlugIn");
$package = $request->get("packageName");
$version = $request->get("appVersion");
$appLongitude = $request->get("appLongitude");
$appLatitude = $request->get("appLatitude");
$source = $request->get("source");
$fs = new Filesystem();
//$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
$fs->appendToFile('identyLog.txt', "\r\n ".date("d-m-Y H:i:s").' : '.json_encode($_POST));
if(!empty($login) && !empty($appKey) && !empty($pivot))
{
$application = $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
if($application)
{
$fs = new Filesystem();
//$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
$fs->appendToFile('EventLogFilesConnect.txt', "\r\n ".date("d-m-Y H:i:s").' : '.json_encode($_POST));
switch ($pivot)
{
case 'TOKEN':
$personAppId = $personAppIdentityRepository->findOneBy(['token'=>$login, 'application'=>$application]);
break;
case 'TELEPHONE':
$personAppId = $personAppIdentityRepository->findOneBy(['telephone'=>$login, 'application'=>$application]);
break;
case 'EMAIL':
$personAppId = $personAppIdentityRepository->findOneBy(['email'=>$login, 'application'=>$application]);
break;
case 'IDO':
// working here
$qr = $checkQrRepository->findOneBy(['numero'=>$login]);
if($qr)
{
$personAppId = $personAppIdentityRepository->findOneBy(['userReference'=>$qr, 'application'=>$application]);
// si l'utilisateur n'est pas encore enregistré dans la table de connexion AppPersonIdentity, on le crée
if(empty($personAppId))
{
if($source != "WEB")
{
// device infos persist
$device = new Device();
$device->setDeviceInfo($deviceId);
$device->setDeviceToken($token);
$device->setGpsLatitude($appLatitude);
$device->setGpsLongitude($appLongitude);
$device->setBatteryState($batteryState);
$device->setIsBatteryPlugIn($isBatteryPlugIn);
$device->setPackage($package);
$device->setAppVersion($version);
$deviceRepository->add($device, false);
}
$personAppId = new PersonAppIdentity();
$personAppId->setApplication($application);
$personAppId->setTelephone($qr->getPersonCivil()[0]->getPhone());
$personAppId->setEmail($qr->getPersonCivil()[0]->getEmail());
$personAppId->setPin($pin);
$personAppId->setUserReference($qr);
if($source != "WEB")
{
$personAppId->setToken($token);
$personAppId->setDevice($device);
}
// method to flush
$personAppIdentityRepository->add($personAppId, false);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"L'IDO ne correspond à aucun utilisateur...",
);
}
break;
default:
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Le PIVOT ne correspond à aucune option disponible...",
);
return new JsonResponse($return);
break;
}
if(!empty($personAppId))
{
$cle = $this->getParameter('api_key');
$piece = 'User login';
$proprietaire = $personAppId->getUserReference()->getPersonCivil()[0]->fullName();
$post = array(
'cle' => $cle,
'pieceqr'=> $piece,
'proprietaire' => $proprietaire,
);
$api = new SqrApi($container);
$res = $api->callAPI($post);
//dump($res);die;
if($res[0])
{
$qr = $res[0]->qr;
$num = $res[0]->niu;
$checkqr = new CheckQr();
$checkqr->setLibelle($qr);
$checkqr->setNumero($num);
//$checkqr->setChemin($newname);
// method to flush
$checkQrRepository ->add($checkqr, false);
//$personRepository->add($person, true);
//////////////////////////////////////////////////////////////
try
{
if($source != "WEB")
{
// device infos persist
$device = new Device();
$device->setDeviceInfo($deviceId);
$device->setDeviceToken($token);
$device->setGpsLatitude($appLatitude);
$device->setGpsLongitude($appLongitude);
$device->setBatteryState($batteryState);
$device->setIsBatteryPlugIn($isBatteryPlugIn);
$device->setPackage($package);
$device->setAppVersion($version);
$deviceRepository->add($device, false);
//on met à jour le token.
$personAppId->setToken($token);
}
$personAppIdentityRepository->add($personAppId, false);
$personAuthHistory = new PersonAuthHistory();
$personAuthHistory->setPersonAppIdentity($personAppId);
$personAuthHistory->setCheckQr($checkqr);
if($source != "WEB")
{
$personAuthHistory->setDevice($device);
}
$personAuthHistory->setPivot($pivot);
$personAuthHistory->setLogin($login);
$personAuthHistoryRepository->add($personAuthHistory, true);
$return = array(
'Etat' =>'SUCCESS',
'Message' =>'Utilisateur retrouvé avec succès',
'nom'=>$personAppId->getUserReference()->getPersonCivil()[0]->getFirstName(),
'prenom'=>$personAppId->getUserReference()->getPersonCivil()[0]->getLastName(),
'selfie_link'=>"uploads/kyvala/enrolment/".$personAppId->getUserReference()->getPersonBiometrics()[0]->getFace(),
'signature_link'=>"uploads/kyvala/enrolment/".$personAppId->getUserReference()->getPersonCivil()[0]->getSignature(),
'IDO'=>$personAppId->getUserReference()->getNumero(),
'isPouceGauche'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isPouceGauche(),
'isPouceDroit'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isPouceDroit(),
'isIndexDroit'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isIndexDroit(),
'isIndexGauche'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isIndexGauche(),
'isMajeurDroit'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isMajeurDroit(),
'isMajeurGauche'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isMajeurGauche(),
'isAnnulaireDroit'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isAnnulaireDroit(),
'isAnnulaireGauche'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isAnnulaireGauche(),
'isAuriculaireGauche'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isAuriculaireGauche(),
'isAuriculaireDroit'=>$personAppId->getUserReference()->getPersonBiometrics()[0]->isAuriculaireDroit(),
'sqr'=>$num,
'pin'=>$personAppId->getPin(),
//'gsDateGenerationCrypto'=>$person->getDateCreated()->format("d/m/Y h:i:s")
'gsDateGenerationCrypto'=>$personAppId->getUserReference()->getPersonCivil()[0]->getDateCreated()->format("d/m/Y h:i:s")
);
} catch (\Throwable $error)
{
//not actions
$fs = new Filesystem();
//$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
$fs->appendToFile('log/Connection/Exceptions/'.date("Y")."/".date("d-m-Y").'/EventLogFiles.txt', "\r\n ".date("d-m-Y H:i:s").' : '.$error);
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Une erreur est survenue lors de l'opération. Veuillez essayer ultérieurement SVP",
'error'=>$error,
);
}
//////////////////////////////////////////////////////////////
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"L'API SQR n'a pas repondu. Veuillez essayer à nouveau",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Utilisateur introuvable. Veuillez vérifier votre identifiant...",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Vous n'avez pas l'autorisation pour cette requette",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Paramètres requis manquants ici..",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"La méthode d'envoie ne correspond pas aux attentes",
);
}
return new JsonResponse($return);
}
/**
* @Route("/new", name="app_person_civil_new", methods={"GET", "POST"})
*/
public function new(Request $request, PersonCivilRepository $personCivilRepository): Response
{
$personCivil = new PersonCivil();
$form = $this->createForm(PersonCivilType::class, $personCivil);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$personCivilRepository->add($personCivil, true);
return $this->redirectToRoute('app_person_civil_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('person_civil/new.html.twig', [
'person_civil' => $personCivil,
'form' => $form,
]);
}
/** ///save/etat/civil/data/json
* @Route("/new/json", name="app_person_civil_new_json", methods={"GET", "POST"})
*/
public function newJson(Request $request, PersonCivilRepository $personCivilRepository, SluggerInterface $slugger, ContainerInterface $container, CheckQrRepository $checkQrRepository, PersonRepository $personRepository, ApplicationRepository $applicationRepository, PersonAppIdentityRepository $personAppIdentityRepository, DeviceRepository $deviceRepository ): Response
{
if($_POST)
{
// device info
$deviceId = $request->get("deviceId");
$token = $request->get("deviceToken");
$batteryState = $request->get("batteryState");
$isBatteryPlugIn = $request->get("isBatteryPlugIn");
$package = $request->get("packageName");
$version = $request->get("appVersion");
$appLongitude = $request->get("appLongitude");
$appLatitude = $request->get("appLatitude");
$personCivil = new PersonCivil();
$sqrRef = $request->get("sqr");//référence sqr
$referenceUser = $request->get("referenceUser");//référence de l'utilisateur
$appKey = $request->get("app_key");
$pin = $request->get("pin");
$civilite = $request->get("civilite");
$nom = $request->get("nom");
$prenom = $request->get("prenom");
$dateNaissance = new \DateTime($request->get("dateNaissance"));
$lieuNaissance = $request->get("lieuNaissance");
$nationalite = $request->get("nationalite");
$numeroTelephone = $request->get("numeroTelephone");
$adresseEmail = $request->get("adresseEmail");
$typeDocumentIdentite = $request->get("typeDocumentIdentite");
$numeroDocumentIdentite = $request->get("numeroDocumentIdentite");
if(!empty($request->get("dateDelivrancedocument"))){
$dateDelivrancedocument = new \DateTime($request->get("dateDelivrancedocument"));
}else{
$dateDelivrancedocument=null;
}
if(!empty($request->get("dateExpirationDelivranceDocument"))){
$dateExpirationDelivranceDocument = new \DateTime($request->get("dateExpirationDelivranceDocument"));
}else{
$dateExpirationDelivranceDocument=null;
}
if(!empty($request->get("dateProrogationDocument"))){
$dateProrogationDocument = new \DateTime($request->get("dateProrogationDocument"));
}else{
$dateProrogationDocument=null;
}
if(!empty($request->get("dateExpirationProrogationDocument"))){
$dateExpirationProrogationDocument = new \DateTime($request->get("dateExpirationProrogationDocument"));
}else{
$dateExpirationProrogationDocument = null;
}
$enrolmentToken = $request->get("enrolmentToken");
$enrolmentUid = $request->get("enrolmentUid");
$enrolmentId = $request->get("enrolmentId");
$enrolmentSource = $request->get("enrolmentSource");
$checkQr = $checkQrRepository->findOneBy(['numero'=>$sqrRef]);
if($checkQr)
{
$qrDoublon = $personCivilRepository->findOneBy(['checkQr'=>$checkQr]);
if(!$qrDoublon)
{
/** @var UploadedFile $documentIdentiteRecto */
$documentIdentiteRecto = $request->files->get('documentIdentiteRecto');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($documentIdentiteRecto)
{
$originalFilename = pathinfo($documentIdentiteRecto->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$documentIdentiteRecto->guessExtension();
// Move the file to the directory where brochures are stored
try {
$documentIdentiteRecto->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personCivil->setPictureFrontOfIdentificationDocument($sqrRef.'/'.$newFilename);
}
/** @var UploadedFile $documentIdentiteVerso */
$documentIdentiteVerso = $request->files->get('documentIdentiteVerso');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($documentIdentiteVerso)
{
$originalFilename = pathinfo($documentIdentiteVerso->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$documentIdentiteVerso->guessExtension();
// Move the file to the directory where brochures are stored
try {
$documentIdentiteVerso->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personCivil->setPictureBackOfIdentificationDocument($sqrRef.'/'.$newFilename);
}
/** @var UploadedFile $officeStampAndSignature */
$planLocalisation = $request->files->get('planLocalisation');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($planLocalisation)
{
$originalFilename = pathinfo($planLocalisation->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$planLocalisation->guessExtension();
// Move the file to the directory where brochures are stored
try {
$planLocalisation->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personCivil->setPictureOfLocalisation($sqrRef.'/'.$newFilename);
}
/** @var UploadedFile $signature */
$signature = $request->files->get('signature');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($signature)
{
$originalFilename = pathinfo($signature->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$signature->guessExtension();
// Move the file to the directory where they must be stored
try {
$signature->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$personCivil->setSignature($sqrRef.'/'.$newFilename);
}
try
{
if (!empty($nom))
{
if(!empty($referenceUser))
{
$person = $personRepository->findOneBySqr($referenceUser);
if($person)
{
$personCivil->setPerson($person);
}
}
// On enregistre les paramètres de connexion de l'utilisateur dans la table personappidentity pour de futur connexion
if(!empty($appKey))
{
$application = $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
if($application)
{
// device infos persist
$device = new Device();
$device->setDeviceInfo($deviceId);
$device->setDeviceToken($token);
$device->setGpsLatitude($appLatitude);
$device->setGpsLongitude($appLongitude);
$device->setBatteryState($batteryState);
$device->setIsBatteryPlugIn($isBatteryPlugIn);
$device->setPackage($package);
$device->setAppVersion($version);
$deviceRepository->add($device, false);
$personAppIdentity = new PersonAppIdentity();
$personAppIdentity->setApplication($application);
$personAppIdentity->setTelephone($numeroTelephone);
$personAppIdentity->setEmail($adresseEmail);
$personAppIdentity->setPin($pin);
$personAppIdentity->setUserReference($checkQr);
$personAppIdentity->setToken($token);
$personAppIdentity->setDevice($device);
// method to flush
$personAppIdentityRepository->add($personAppIdentity, false);
}else
{
$otherMsg = "La clé envoyé ne correspond à aucun message";
}
}
$personCivil->setCivility($civilite);
$personCivil->setFirstName($nom);
$personCivil->setLastName($prenom);
$personCivil->setDateOfBirth($dateNaissance);
$personCivil->setPlaceOfBirth($lieuNaissance);
$personCivil->setNationality($nationalite);
$personCivil->setPhone($numeroTelephone);
$personCivil->setEmail($adresseEmail);
$personCivil->setTypeOfIdentificationDocument($typeDocumentIdentite);
$personCivil->setIdentificationDocumentNumber($numeroDocumentIdentite);
$personCivil->setDateOfIssue($dateDelivrancedocument);
$personCivil->setDateOfExpirationIssue($dateExpirationDelivranceDocument);
$personCivil->setDateOfProrogation($dateProrogationDocument);
$personCivil->setDateOfExpirationProrogation($dateExpirationProrogationDocument);
$personCivil->setEnrolmentUid($enrolmentUid);
$personCivil->setEnrolmentId($enrolmentId);
$personCivil->setEnrolmentSource($enrolmentSource);
$personCivil->setFirebaseToken($enrolmentToken);
$personCivil->setFirebasePlateform("MOBILE");
$personCivil->setAdresse("");
// spécifier qu'il s'agit d'un enrolement complet
$personCivil->setStatus(1);
$personCivil->setCheckQr($checkQr);
// method to flush
$personCivilRepository->add($personCivil, true);
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>"Votre enregistrement a été effectué avec succès",
'transaction_id'=> $enrolmentId,
'transaction_uid'=> $enrolmentUid,
'transaction_source'=>$enrolmentSource,
'sqr'=>$sqrRef,
);
/*
// send notification to Firebase
if(!empty($personCivil->getFirebaseToken()))
{
$this->ParamsWithSendPushNotification($personCivil->getFirebaseToken(),"Votre enrôlement",$civilite." ".$prenom." ".$nom.", Bienvenu(e) sur KYVALA ! Votre enrôlement a été effectué avec succès sous la référence SQR : ".$sqrRef.", Merci de conserver cette référence pour la suite de vos opérations");
}
*/
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Paramètres requis manquants",
);
}
} catch (\Throwable $error)
{
//not actions
$fs = new Filesystem();
//$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
$fs->appendToFile('log/Enrôlement/Exceptions/'.date("Y")."/".date("d-m-Y").'/EventLogFilesBio.txt', "\r\n ".date("d-m-Y H:i:s")." Enrollement exception : ".$error);
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Une erreur est survenue lors de l'opération. Veuillez essayer ultérieurement SVP",
'error'=>$error,
);
}
//////////////////////////////////////////////////////////////
}else
{
$return = array(
'Etat' =>'FAILED',
'Message' =>"Ces informations sont déjà enregistrées dans la base de donnée sous la référence ".$sqrRef,
);
}
}else
{
$return = array(
'Etat' =>'FAILED',
'Message' =>$sqrRef. "Une erreur est survenue lors de l'enregistrement, aucun enregistrement ne correspond à la référence...",
);
}
}else
{
$return = array(
'Etat' =>'FAILED',
'Message' =>"La méthode d'envoie ne correspond pas aux attentes",
);
}
//$fs1 = new Filesystem();
//$fs1->appendToFile('log/Enrôlement/'.date("Y")."/".date("d-m-Y").'/BiometricsFiles.txt', "\r\n ".json_encode($return));
return new JsonResponse($return);
}
/**
* @Route("/update/signatures/files", name="app_person_civil_update_signatures", methods={"GET", "POST"})
*/
public function updateSignatures(Request $request, PersonCivilRepository $personCivilRepository, SluggerInterface $slugger ): Response
{
if($_POST)
{
// device info
$userIdo = $request->get("userIdo");
$personIdentified = $personCivilRepository->findOneBySqr($userIdo);
if($personIdentified)
{
/** @var UploadedFile $signature */
$signature = $request->files->get('signature');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($signature)
{
$originalFilename = pathinfo($signature->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$signature->guessExtension();
// Move the file to the directory where they must be stored
try {
$signature->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$personIdentified->setSignature($userIdo.'/'.$newFilename);
}
/** @var UploadedFile $officeStamp */
$officeStamp = $request->files->get('officeStamp');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($officeStamp)
{
$originalFilename = pathinfo($officeStamp->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$officeStamp->guessExtension();
// Move the file to the directory where brochures are stored
try {
$officeStamp->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personIdentified->setOfficeStamp($userIdo.'/'.$newFilename);
}
/** @var UploadedFile $nominativeStamp */
$nominativeStamp = $request->files->get('nominativeStamp');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($nominativeStamp)
{
$originalFilename = pathinfo($nominativeStamp->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$nominativeStamp->guessExtension();
// Move the file to the directory where brochures are stored
try {
$nominativeStamp->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personIdentified->setNominativeStamp($userIdo.'/'.$newFilename);
}
/** @var UploadedFile $officeStampAndSignature */
$officeStampAndSignature = $request->files->get('officeStampAndSignature');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($officeStampAndSignature)
{
$originalFilename = pathinfo($officeStampAndSignature->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$officeStampAndSignature->guessExtension();
// Move the file to the directory where brochures are stored
try {
$officeStampAndSignature->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personIdentified->setOfficeStampAndSignature($userIdo.'/'.$newFilename);
}
/** @var UploadedFile $nominativeStampAndSignature */
$nominativeStampAndSignature = $request->files->get('nominativeStampAndSignature');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($nominativeStampAndSignature)
{
$originalFilename = pathinfo($nominativeStampAndSignature->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$nominativeStampAndSignature->guessExtension();
// Move the file to the directory where brochures are stored
try {
$nominativeStampAndSignature->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personIdentified->setNominativeStampAndSignature($userIdo.'/'.$newFilename);
}
/** @var UploadedFile $initials */
$initials = $request->files->get('initials');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($initials)
{
$originalFilename = pathinfo($initials->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$initials->guessExtension();
// Move the file to the directory where brochures are stored
try {
$initials->move(
$this->getParameter('kyvala_directory').'/'.$userIdo,
$newFilename
);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
$personIdentified->setInitials($userIdo.'/'.$newFilename);
}
// method to flush
$personCivilRepository->add($personIdentified, true);
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>"Vos informations ont été modifié avec succès",
'ido'=>$userIdo,
'signature_link'=>empty($personIdentified->getSignature()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getSignature() ,
'officeStamp_link'=>empty($personIdentified->getOfficeStamp()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getOfficeStamp(),
'nominativeStamp_link'=>empty($personIdentified->getNominativeStamp()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getNominativeStamp(),
'officeStampAndSignature_link'=>empty($personIdentified->getOfficeStampAndSignature()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getOfficeStampAndSignature(),
'nominativeStampAndSignature_link'=>empty($personIdentified->getNominativeStampAndSignature()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getNominativeStampAndSignature(),
'initials_link'=>empty($personIdentified->getInitials()) ? null : "uploads/kyvala/enrolment/".$personIdentified->getInitials(),
);
/*
} catch (\Throwable $error)
{
//not actions
$fs = new Filesystem();
//$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
$fs->appendToFile('log/Enrôlement/Exceptions/'.date("Y")."/".date("d-m-Y").'/EventLogFilesBio.txt', "\r\n ".date("d-m-Y H:i:s")." Enrollement exception : ".$error);
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Une erreur est survenue lors de l'opération. Veuillez essayer ultérieurement SVP",
'error'=>$error,
);
}*/
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Cet IDO n'est associé à aucun individu enrolé. Veuillez vérifier et essayer à nouveau",
);
}
}else
{
$return = array(
'Etat' =>'FAILED',
'Message' =>"La méthode d'envoie ne correspond pas aux attentes",
);
}
//$fs1 = new Filesystem();
//$fs1->appendToFile('log/Enrôlement/'.date("Y")."/".date("d-m-Y").'/BiometricsFiles.txt', "\r\n ".json_encode($return));
return new JsonResponse($return);
}
/**
* @Route("/save/user/from/ido/json", name="app_person_civil_save_from_ido", methods={"GET", "POST"})
*/
public function newUserFromIDOJson(Request $request, PersonCivilRepository $personCivilRepository, SluggerInterface $slugger, ContainerInterface $container, CheckQrRepository $checkQrRepository, PersonRepository $personRepository, ApplicationRepository $applicationRepository, PersonAppIdentityRepository $personAppIdentityRepository, DeviceRepository $deviceRepository ): Response
{
if($_POST)
{
// device info
$deviceId = $request->get("deviceId");
$token = $request->get("deviceToken");
$batteryState = $request->get("batteryState");
$isBatteryPlugIn = $request->get("isBatteryPlugIn");
$package = $request->get("packageName");
$version = $request->get("appVersion");
$appLongitude = $request->get("appLongitude");
$appLatitude = $request->get("appLatitude");
//user info
$appKey = $request->get("app_key");
$telephone = $request->get("telephone");
$email = $request->get("email");
$pin = $request->get("pin");
$ido = $request->get("ido");
$checkQr = $checkQrRepository->findOneBy(['numero'=>$ido]);
if($checkQr)
{
if (!empty($appKey) && !empty($telephone) && !empty($pin) && !empty($email))
{
// On enregistre les paramètres de connexion de l'utilisateur dans la table personappidentity pour de futur connexion
if(!empty($appKey))
{
$application = $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
if($application)
{
$personAppI = $personAppIdentityRepository->findOneBy(['application'=>$application, 'telephone'=>$telephone, 'email'=>$email, 'userReference'=>$checkQr]);
if(empty($personAppI))
{
// device infos persist
$device = new Device();
$device->setDeviceInfo($deviceId);
$device->setDeviceToken($token);
$device->setGpsLatitude($appLatitude);
$device->setGpsLongitude($appLongitude);
$device->setBatteryState($batteryState);
$device->setIsBatteryPlugIn($isBatteryPlugIn);
$device->setPackage($package);
$device->setAppVersion($version);
$deviceRepository->add($device, false);
$personAppIdentity = new PersonAppIdentity();
$personAppIdentity->setApplication($application);
$personAppIdentity->setTelephone($telephone);
$personAppIdentity->setEmail($email);
$personAppIdentity->setPin($pin);
$personAppIdentity->setUserReference($checkQr);
$personAppIdentity->setToken($token);
$personAppIdentity->setDevice($device);
// method to flush
$personAppIdentityRepository->add($personAppIdentity, true);
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>"Votre compte as été crée avec succès !!!",
'IDO'=>$ido,
);
}else{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Un compte existe déjà avec les informations relatif à cet application, ce numéro de téléphone et cet email. !!!",
'IDO'=>$ido,
);
}
}else
{
$otherMsg = "La clé d'application envoyé ne correspond à aucun projet";
}
}
/*
$return = array(
'Etat' =>'SUCCESS' ,
'Message' =>"Votre compte as été crée avec succès !!!",
'IDO'=>$ido,
);*/
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"Paramètres requis manquants",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>$sqrRef. "Une erreur est survenue lors de l'enregistrement, aucun enregistrement ne correspond à la référence IDO...",
);
}
}else
{
$return = array(
'Etat' =>'FAILED' ,
'Message' =>"La méthode d'envoie ne correspond pas aux attentes",
);
}
return new JsonResponse($return);
}
/**
* @Route("/{id}", name="app_person_civil_show", methods={"GET"})
*/
public function show(PersonCivil $personCivil): Response
{
return $this->render('person_civil/show.html.twig', [
'person_civil' => $personCivil,
]);
}
/**
* @Route("/{id}/edit", name="app_person_civil_edit", methods={"GET", "POST"})
*/
public function edit(Request $request, PersonCivil $personCivil, PersonCivilRepository $personCivilRepository): Response
{
$form = $this->createForm(PersonCivilType::class, $personCivil);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$personCivilRepository->add($personCivil, true);
return $this->redirectToRoute('app_person_civil_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('person_civil/edit.html.twig', [
'person_civil' => $personCivil,
'form' => $form,
]);
}
/**
* @Route("/{id}", name="app_person_civil_delete", methods={"POST"})
*/
public function delete(Request $request, PersonCivil $personCivil, PersonCivilRepository $personCivilRepository): Response
{
if ($this->isCsrfTokenValid('delete'.$personCivil->getId(), $request->request->get('_token'))) {
$personCivilRepository->remove($personCivil, true);
}
return $this->redirectToRoute('app_person_civil_index', [], Response::HTTP_SEE_OTHER);
}
//notifications push avec paramètres
public function ParamsWithSendPushNotification($user_notification_token,$title,$message)
{
//https://www.youtube.com/watch?v=YHniUsrmX9Y
$fs = new Filesystem();
$credential = new ServiceAccountCredentials(
"https://www.googleapis.com/auth/firebase.messaging",
json_decode(file_get_contents
("kyvala-45525-firebase-adminsdk-cxpp5-cf78b66d72.json"),true)
);
$token = $credential->fetchAuthToken(HttpHandlerFactory::build());
$accessToken = $token['access_token'];
$ch = curl_init("https://fcm.googleapis.com/v1/projects/kyvala-45525/messages:send");
curl_setopt($ch, CURLOPT_HTTPHEADER,[
'Content-Type: application/json',
'Authorization: ' . 'Bearer ' .$accessToken
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"message": {
"token":"'.$user_notification_token.'",
"notification": {
"title":"'.$title.'",
"body":"'.$message.'",
"image":"http://poc.kyvala.com/uploads/TOKEN/Token-logo-avec-fond.png"
}
}
}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
if (curl_errno($ch))
{
print "Error: " . curl_error($ch);
$fs->appendToFile('EventLogNotification.txt', "\r\n ".date("d-m-Y H:i:s")." : deviceToken :".$user_notification_token.", Title: ".$title.", Notification: ".$message.", Error: ".json_encode(curl_error($ch)));
exit();
}else
{
$json = json_decode($response, true);
}
// Show me the result
curl_close($ch);
//dump($season_data);
$fs->appendToFile('EventLogNotification.txt', "\r\n ".date("d-m-Y H:i:s")." : DeviceToken :".$user_notification_token.", Title: ".$title.", Notification: ".$message.", Retours: ".json_encode($response));
// return a JSON object to caller
return $json;
}
public function createCryptographe(Request $request, SluggerInterface $slugger)
{
$sqrRef = $request->get('ref');
$nom = $request->get('nom');
$prenom = $request->get('prenom');
$telephone = $request->get('telephone');
$nationalite = $request->get('nationalite');
$dateNaiss = $request->get('dateNaiss');
$lieuNaiss = $request->get('lieuNaiss');
$email = $request->get('email');
$demog = $nom.','.$prenom.','.$telephone.','.$nationalite.','.$dateNaiss.','.$lieuNaiss.','.$email;
$fs = new Filesystem();
$fs->appendToFile($this->getParameter('kyvala_directory').'/'.$sqrRef.'/demog.txt', "\r\n ".$demog);
/** @var UploadedFile $pos1 */
$pos1 = $request->files->get('fpr1');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos1)
{
$originalFilename = pathinfo($pos1->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos1->guessExtension();
//dump($newFilename);die;
// Move the file to the directory where they must be stored
try {
$pos1->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
//dump($newFilename);die;
//$img = \file_get_contents("http://my.kyvala.com/uploads/kyvala/enrolment/".$newFilename);
$fpr1 = $this->getParameter('kyvala_directory')."/".$newFilename;
}
/** @var UploadedFile $pos2 */
$pos2 = $request->files->get('fpr2');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos2)
{
$originalFilename = pathinfo($pos2->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos2->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos2->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpr2 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos3 */
$pos3 = $request->files->get('fpr3');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos3)
{
$originalFilename = pathinfo($pos3->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos3->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos3->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpr3 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos4 */
$pos4 = $request->files->get('fpr4');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos4)
{
$originalFilename = pathinfo($pos4->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos4->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos4->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpr4 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos5 */
$pos5 = $request->files->get('fpr5');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos5)
{
$originalFilename = pathinfo($pos5->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos5->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos5->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpr5 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos6 */
$pos6 = $request->files->get('fpl1');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos6)
{
$originalFilename = pathinfo($pos6->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos6->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos6->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpl1 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos7 */
$pos7 = $request->files->get('fpl2');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos7)
{
$originalFilename = pathinfo($pos7->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos7->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos7->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpl2 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos8 */
$pos8 = $request->files->get('fpl3');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos8)
{
$originalFilename = pathinfo($pos8->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos8->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos8->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpl3 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos9 */
$pos9 = $request->files->get('fpl4');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos9)
{
$originalFilename = pathinfo($pos9->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos9->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos9->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpl4 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $pos10 */
$pos10 = $request->files->get('fpl5');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($pos10)
{
$originalFilename = pathinfo($pos10->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$pos10->guessExtension();
// Move the file to the directory where they must be stored
try {
$pos10->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
} catch (FileException $e)
{
// ... handle exception if something happens during file upload
}
$fpl5 = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
/** @var UploadedFile $face */
$face = $request->files->get('face');
// this condition is needed because the 'brochure' field is not required
// so the PDF file must be processed only when a file is uploaded
if ($face)
{
$originalFilename = pathinfo($face->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$face->guessExtension();
// Move the file to the directory where they must be stored
try {
$face->move(
$this->getParameter('kyvala_directory').'/'.$sqrRef,
$newFilename
);
}catch (FileException $e)
{
//... handle exception if something happens during file upload
}
$face = $this->getParameter('kyvala_directory').'/'.$sqrRef.'/'.$newFilename;
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://eval-idencode.tech5.tech/v1/enroll',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('face_image'=> new \CURLFILE($face),'pipeline'=> new \CURLFILE($this->getParameter('kyvala_directory').'/pipeline-with-fp-CR.txt'),'demog'=> new \CURLFILE($this->getParameter('kyvala_directory').'/'.$sqrRef.'/demog.txt'),'finger_image_r1'=> new \CURLFILE($fpr1),'finger_image_r2'=> new \CURLFILE($fpr2),'finger_image_r3'=> new \CURLFILE($fpr3),'finger_image_r4'=> new \CURLFILE($fpr4),'finger_image_r5'=> new \CURLFILE($fpr5),'finger_image_l1'=> new \CURLFILE($fpl1),'finger_image_l2'=> new \CURLFILE($fpl2),'finger_image_l3'=> new \CURLFILE($fpl3),'finger_image_l4'=> new \CURLFILE($fpl4),'finger_image_l5'=> new \CURLFILE($fpl5)),
));
$response = curl_exec($curl);
//On écris le retours de la fonction dans le log
$fs->appendToFile($this->getParameter('kyvala_directory').'/'.$sqrRef.'/cryptoGenerationLog.txt', "\r\n ".$response);
$response = json_decode($response,true);
curl_close($curl);
//echo $response;
return $response;
}
}