src/Controller/PersonBioVerificationController.php line 503

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\PersonBioVerification;
  4. use App\Entity\CheckQr;
  5. use App\Entity\Device;
  6. use App\Repository\ApplicationRepository;
  7. use App\Repository\DeviceRepository;
  8. use App\Repository\PersonCivilRepository;
  9. use App\Repository\CheckQrRepository;
  10. use App\Form\PersonBioVerificationType;
  11. use App\Repository\PersonBioVerificationRepository;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use Symfony\Component\Filesystem\Filesystem;
  17. use Google\Auth\Credentials\ServiceAccountCredentials;
  18. Use Google\Auth\HttpHandler\HttpHandlerFactory;
  19. use Symfony\Component\HttpFoundation\JsonResponse;
  20. use Psr\Container\ContainerInterface;
  21. use App\API\SqrApi as SqrApi;
  22. use App\API\Tech5DigitalApi as Tech5DigitalApi;
  23. use Symfony\Component\String\Slugger\SluggerInterface;
  24. /**
  25.  * @Route("/person/bio/verification")
  26.  */
  27. class PersonBioVerificationController extends AbstractController
  28.     //Cette fonction Manipule la table Person Bio Verification pour initier une vérification biométrique
  29.     /**
  30.      * @Route("/initiate", name="app_person_bio_verification_initiate", methods={"GET", "POST"})
  31.     */
  32.     public function initiateVerification(Request $requestPersonBioVerificationRepository $personBioVerificationRepositoryPersonCivilRepository $personCivilRepositoryCheckQrRepository $checkQrRepositoryContainerInterface $containerSluggerInterface $sluggerApplicationRepository $applicationRepository): Response
  33.     {
  34.         $notificationTitle $request->get("notificationTitle");
  35.         $notificationMessage $request->get("notificationMessage");
  36.         //$notificationToken = $request->get("notificationToken");
  37.         $title $request->get("title");
  38.         $appKey $request->get("appKey");
  39.         $ido $request->get("ido");
  40.         $process $request->get("process");
  41.         
  42.         if (!empty($appKey) &&!empty($ido) && !empty($process)  && !empty($notificationMessage)  && !empty($notificationTitle))
  43.         {
  44.             $application $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
  45.             $requesterPersonCivil $personCivilRepository->findOneBySqr($ido); // IDO vérifieur 
  46.             if(!empty($application))
  47.             {
  48.                 if(!empty($requesterPersonCivil))
  49.                 {
  50.                     $cle $this->getParameter('api_key');
  51.                     $piece 'New Verification';
  52.                     $proprietaire "API Root user";
  53.                     $post = array(
  54.                         'cle' => $cle,
  55.                         'pieceqr'=> $piece,
  56.                         'proprietaire' => $proprietaire,
  57.                     );
  58.                     $api = new SqrApi($container);
  59.                     $res $api->callAPI($post);
  60.                     
  61.                     if($res[0]) // si SQR a repondu, on utilise sa référence et on stock
  62.                     {
  63.                         $qr $res[0]->qr;
  64.                         $num $res[0]->niu;
  65.                         
  66.                         $checkqr = new CheckQr();
  67.                         $checkqr->setLibelle($qr);
  68.                         $checkqr->setNumero($num);
  69.                         // method to flush
  70.                         $checkQrRepository ->add($checkqrfalse);
  71.                         $personBioVerification = new PersonBioVerification();
  72.                         /** @var UploadedFile $file */            
  73.                         $fich $request->files->get('file');
  74.                         //This condition is needed because the 'brochure' field is not required
  75.                         //So the PDF file must be processed only when a file is uploaded
  76.                         if ($fich
  77.                         {
  78.                             $originalFilename pathinfo($fich->getClientOriginalName(), PATHINFO_FILENAME);
  79.                             //This is needed to safely include the file name as part of the URL
  80.                             $safeFilename $slugger->slug($originalFilename);
  81.                             $newFilename $safeFilename.'-'.uniqid().'.'.$fich->guessExtension();
  82.                             $extension $fich->guessExtension();
  83.                             // Move the file to the directory where they must be stored
  84.                             
  85.                             try {
  86.                                 $fich->move(
  87.                                     $this->getParameter('file_directory'),
  88.                                     $newFilename
  89.                                 );
  90.                             } catch (FileException $e
  91.                             {
  92.                                 // ... handle exception if something happens during file upload
  93.                             }
  94.                                          
  95.                             $personBioVerification->setFile($newFilename);
  96.                         }  
  97.                         
  98.                         $personBioVerification->setTitle($title);
  99.                         $personBioVerification->setNotificationTitle($notificationTitle);
  100.                         $personBioVerification->setNotificationMessage($notificationMessage);
  101.                         $personBioVerification->setApplication($application);
  102.                         $personBioVerification->setCheckQr($checkqr);
  103.                         $personBioVerification->setUserReference($requesterPersonCivil->getCheckQr());
  104.                         $personBioVerification->setProcess($process);
  105.                         $personBioVerificationRepository->add($personBioVerificationtrue);
  106.                         $return = array(
  107.                             'Etat' =>'SUCCESS',
  108.                             'Message' =>"Demande d'authentification biométrique enregistré avec succès !!!",
  109.                             'process'=>$process,
  110.                             'référenceDemande'=>$num,
  111.                         );
  112.                         
  113.                     }else
  114.                     {
  115.                         $return = array(
  116.                             'Etat' =>'FAILED' 
  117.                             'Message' =>"L'API SQR n'a pas repondu. Veuillez essayer à nouveau"
  118.                         );
  119.                     }   
  120.                 }else
  121.                 {
  122.                     $return = array(
  123.                         'Etat' =>'FAILED' 
  124.                         'Message' =>"L'IDO de l'utilisateur à identifier est non conforme..."
  125.                     );  
  126.                 }     
  127.             }else
  128.             {
  129.                 $return = array(
  130.                     'Etat' =>'FAILED' 
  131.                     'Message' =>"La clé de l'application est incorrecte !!!"
  132.                 );  
  133.             }                  
  134.         }else
  135.         {
  136.             $return = array(
  137.                 'Etat' =>'FAILED',
  138.                 'Message' =>"Paramètres requis manquants !!!"
  139.             );
  140.         }
  141.        return new JsonResponse($return);
  142.     } 
  143.     //Cette fonction Manipule la table Person bio verification en cas d'echec ou succès d'une vérification biométrique
  144.     /**
  145.      * @Route("/new/verify", name="app_person_bio_verification_new_verify_json", methods={"GET", "POST"})
  146.     */
  147.     public function newVerify(Request $requestSluggerInterface $slugger,  PersonBioVerificationRepository $personBioVerificationRepositoryPersonCivilRepository $personCivilRepositoryDeviceRepository $deviceRepositoryCheckQrRepository $checkQrRepositoryContainerInterface $containerApplicationRepository $applicationRepository): Response
  148.     {        
  149.         $transactionReference $request->get("transactionReference"); 
  150.         $appKey $request->get("appKey"); // Référence de la transaction de signature
  151.         if (!empty($appKey))// vérification de la présence de la clé app dans la requette
  152.         {
  153.             if (!empty($transactionReference))// vérification de la présence de la référence de validation biométrique dans la requette
  154.             {
  155.                 $personBioVerif $personBioVerificationRepository->findOneBySqr($transactionReference);
  156.                 if($personBioVerif)// vérification de l'existence de la référence de la transaction si existant en base ou pas
  157.                 {
  158.                     if($personBioVerif->getStatus() == 0)// vérification du statut de la transaction si déjà traitée ou pas
  159.                     {
  160.                         //to save newFilename
  161.                         $cle $this->getParameter('api_key');
  162.                         $piece 'Compare Fp TOKEN';
  163.                         $proprietaire "API Root user";
  164.                         $post = array(
  165.                             'cle' => $cle,
  166.                             'pieceqr'=> $piece,
  167.                             'proprietaire' => $proprietaire,
  168.                         );
  169.                         $api = new SqrApi($container);
  170.                         $res $api->callAPI($post);
  171.                         
  172.                         if($res[0]) // si SQR a repondu, on utilise sa référence et on stock
  173.                         {
  174.                             $qr $res[0]->qr;
  175.                             $num $res[0]->niu;
  176.                             
  177.                             $checkqr = new CheckQr();
  178.                             $checkqr->setLibelle($qr);
  179.                             $checkqr->setNumero($num);
  180.                             //$checkqr->setChemin($newname);
  181.                             // method to flush
  182.                             $checkQrRepository ->add($checkqrfalse);
  183.                             //$personRepository->add($person, true);
  184.                             //////////////////////////////////////////////////////////////
  185.                             try 
  186.                             {
  187.                                 $tech5DigitalApi = new Tech5DigitalApi($container);// Added for AIS 9
  188.                                 $resltTab $tech5DigitalApi->getAndSaveFingerPrintsFromRequestObjects($request$slugger$num);
  189.                                 
  190.                                 if($resltTab['isPosAvailable'] == "true"// on vérifie si au moins une empreinte a été envoyé.
  191.                                 {                        
  192.                                     if($resltTab['Etat'] == "SUCCESS"// on vérifie si l'extraction et la tranformation des FP en base64 s'est bien passé
  193.                                     {                                            
  194.                                         $fst = new Filesystem();
  195.                                         $device $resltTab['device'];
  196.                                         
  197.                                         $deviceRepository->add($devicefalse);
  198.                                         $personBioVerif->setDevice($device);// on stock les informations du périphérique qui as effectué la requette
  199.                                         //extract finger base 64 data from object
  200.                                         //$resultExtractFpFromObject = $this->extractFingerBase_64_DataFromObject($personBiotrics, $personBiotrics->getCheckQr()->getNumero() /*, $slugger*/);
  201.                                         //$personBiotrics->setAbisFingerJson($resultExtractFpFromObject);
  202.                                         
  203.                                         /// generate template
  204.                                         $resultTemplateCreation $tech5DigitalApi->createTemplateWithJson($resltTab['t5Abis'], $num);                                
  205.                                         $personBioVerif->setFingerJson($resultTemplateCreation); // save template creation
  206.                                         
  207.                                         $fst->appendToFile('log/personBioVerification/'.date("Y")."/".date("d-m-Y").'/personBioVerification.txt'"\r\n ".date("d-m-Y H:i:s")." - result Template creation : ".json_encode($resultTemplateCreation));
  208.                                 
  209.                                         // end create template.
  210.                                         
  211.                                         $bio $personBioVerif->getUserReference()->getPersonBiometrics()[0];// on recupère les empreintes de l'utilisateur à identifier.
  212.                                         //$bio = $bioAuthHistory->getBioAuth()->getUserReference()->getPersonBiometrics()[0];// on recupère les empreintes de l'utilisateur à identifier.
  213.                                         $fing json_encode($resultTemplateCreation['finger_data']['live_scan_plain']);
  214.                                         $fing json_decode($fing,true);
  215.                                         
  216.                                         $rslt $tech5DigitalApi->verificationfingerTemplateCurlUpdated($bio$num$fing); // TECH5 abis 9 UPDATE
  217.                                         
  218.                                         // Verification to ABIS server
  219.                                         $personBioVerif->setVerificationStatus($rslt);// store verification result
  220.                                         // End verification of ABIS Server
  221.                                         $fst->appendToFile('log/personBioVerification/'.date("Y")."/".date("d-m-Y").'/personBioVerification.txt'"\r\n ".date("d-m-Y H:i:s")." - response : ".json_encode($rslt));
  222.                                 
  223.                                         
  224.                                         $fingRslt null;
  225.                                         if($rslt["fingerScore"] && $rslt["fingerScore"] > 16)// on valide le score supérieur à 16
  226.                                         {
  227.                                             $fingRslt "True";                                    
  228.                                             $personBioVerif->setStatus(1);                       
  229.                                             //$personBioVerif->setFile($newFilename);
  230.                                             $personBioVerif->setDateSign(new \Datetime());
  231.                                             
  232.                                             $personBioVerif->setScore($rslt["fingerScore"]);
  233.                                             $personBioVerificationRepository->add($personBioVeriftrue);
  234.                                             
  235.                                             $return = array(
  236.                                                 'Etat' =>'SUCCESS',
  237.                                                 'Message' =>'vérification effectuée avec succès !!!',
  238.                                                 'process'=>$personBioVerif->getProcess(),
  239.                                                 'request_reference'=>$num,
  240.                                                 'transaction_reference'=>$personBioVerif->getCheckQr()->getNumero(),
  241.                                                 'finger_compare_result'=>$fingRslt,
  242.                                                 'score'=>$rslt["fingerScore"]
  243.                                             );
  244.                                             // send notification                                            
  245.                                             $devce $resltTab['device'];//get notification object.
  246.                                             if(!empty($devce->getDeviceToken()))//
  247.                                             {
  248.                                                 //$tech5DigitalApi->sendNotif($devce->getDeviceToken(),$personBioVerif->getNotificationMessage(),$personBioVerif->getNotificationTitle());
  249.                                                 $this->sendNotif($devce->getDeviceToken(),$personBioVerif->getNotificationMessage(),$personBioVerif->getNotificationTitle());
  250.                                             }
  251.                                             
  252.                                         }else // tout score inférieur à 16 est echec
  253.                                         {
  254.                                             $fingRslt "False";
  255.                                             //$personMeetingMember->setStatus(2);
  256.                                             $return = array(
  257.                                                 'Etat' =>'FAILED',
  258.                                                 'Message' =>"Le match des empreintes a échoué.",
  259.                                                 'process'=>$personBioVerif->getProcess(),
  260.                                                 'request_reference'=>$num,
  261.                                                 'transaction_reference'=>$personBioVerif->getCheckQr()->getNumero(),
  262.                                                 'finger_compare_result'=>$fingRslt,
  263.                                                 'score'=>$rslt["fingerScore"]
  264.                                             );
  265.                                         }
  266.                                         
  267.                                     }else
  268.                                     {
  269.                                         $return = array(
  270.                                             'Etat' =>'FAILED',
  271.                                             'Message' =>"Une erreur est survenue lors de l'enregistrement des empreintes",
  272.                                         );
  273.                                     }
  274.                                 }else
  275.                                 {
  276.                                     $return = array(
  277.                                         'Etat' =>'FAILED',
  278.                                         'Message' =>"Aucune empreinte n'a été transmise pour comparaison. Veuillez reprendre le processus.",
  279.                                     );
  280.                                 }
  281.                             } catch (\Throwable $error
  282.                             {
  283.                                 //not actions
  284.                                 $fs = new Filesystem();
  285.                                 //$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
  286.                                 $fs->appendToFile('log/personBioVerification/Exceptions/'.date("Y")."/".date("d-m-Y").'/personBioVerification.txt'"\r\n ".date("d-m-Y H:i:s")." - exception : ".$error);
  287.                                 $return = array(
  288.                                     'Etat' =>'FAILED' 
  289.                                     'Message' =>"Une erreur est survenue lors de l'opération. Veuillez essayer ultérieurement SVP"
  290.                                     'error'=>$error,
  291.                                 );
  292.                             }
  293.                             //////////////////////////////////////////////////////////////
  294.                             
  295.                         }else
  296.                         {
  297.                             $return = array(
  298.                                 'Etat' =>'FAILED' 
  299.                                 'Message' =>"L'API SQR n'a pas repondu. Veuillez essayer à nouveau"
  300.                             );
  301.                         }     
  302.                     }else{
  303.                         $return = array(
  304.                             'Etat' =>'FAILED' 
  305.                             'Message' =>"Cette demande a déjà été traitée et n'est plus disponible..."
  306.                         );  
  307.                     }                    
  308.                 }else
  309.                 {
  310.                     $return = array(
  311.                         'Etat' =>'FAILED',
  312.                         'Message' =>"La référence ne correspond à aucune transaction de demande de validation crée"
  313.                     );  
  314.                 }
  315.             }else
  316.             {
  317.                 $return = array(
  318.                     'Etat' =>'FAILED',
  319.                     'Message' =>"La référence de la vérification biométrique est absente..."
  320.                 );
  321.             }
  322.         }else
  323.         {
  324.             $return = array(
  325.                 'Etat' =>'FAILED',
  326.                 'Message' =>"La clé d'autorisation de l'application est absente..."
  327.             );
  328.         }
  329.         
  330.        return new JsonResponse($return);
  331.     }
  332.     /**
  333.      * @Route("/update/status", name="app_person_bio_verification_update_status", methods={"GET", "POST"})
  334.      */
  335.     public function updateAuthenticationStatus(Request $requestPersonBioVerificationRepository $personBioVerificationRepository): Response
  336.     {
  337.         $authReference $request->get("validationReference");//project transaction reference
  338.         $status $request->get("status");//Statut de la vérification biométrique
  339.         $appKey $request->get("appKey");//clé de l'application autorisant la mise  jour            
  340.         if($authReference && $status && $appKey)
  341.         {
  342.            $personbioVerification $personBioVerificationRepository->findOneBySqr($authReference);
  343.             $statusTab = [/*"1","2",*/"3","4"]; // Real status tabs 1 ok 2 denied 3 warning 4 fraud
  344.             if(in_array($status$statusTabtrue)) 
  345.             {
  346.                 if($personbioVerification)
  347.                 {
  348.                     if($personbioVerification->getStatus() ==0)
  349.                     {
  350.                         $personbioVerification->setStatus($status);
  351.                         $personBioVerificationRepository->add($personbioVerificationtrue);
  352.                         $return = array(
  353.                             'Etat' => 'SUCCESS',
  354.                             'Message' => "Le résultat de votre demande a été transmis avec succès sur ".$personbioVerification->getApplication()->getName(),
  355.                             'authentication_status' => $personbioVerification->getUserAccess(),
  356.                             'transactionReferene'=>$personbioVerification->getCheckQr()->getNumero(),
  357.                         );
  358.                     }else
  359.                     {
  360.                         $return = array(
  361.                             'Etat' =>'FAILED' 
  362.                             'Message' =>"La transaction a déjà été traitée et ne peut plus être mis à jour..."
  363.                         );
  364.                     }
  365.                 }else
  366.                 {
  367.                     $return = array(
  368.                         'Etat' =>'FAILED' 
  369.                         'Message' =>"La référence n'est associé à aucune transaction en cours..."
  370.                     );
  371.                 }
  372.             }else
  373.             {
  374.                 $return = array(
  375.                     'Etat' =>'FAILED' 
  376.                     'Message' =>"Le statut à mettre à jour n'est pas conforme..."
  377.                 );
  378.             }
  379.         
  380.         }else
  381.         {
  382.             $return = array(
  383.                 'Etat' =>'FAILED' 
  384.                 'Message' =>"Paramètres requis manquants !!!"
  385.             );
  386.         }
  387.         
  388.        return new JsonResponse($return);
  389.     }
  390.     //get user validation history per project and per user.    
  391.     /**
  392.      * @Route("/get/validations/history", name="app_person_bio_verification_history", methods={"GET", "POST"})
  393.      */
  394.     public function getVerificationHistory(Request $requestPersonBioVerificationRepository $personBioVerificationRepository): Response
  395.     {
  396.         $userIdo $request->get("userIdo");
  397.         $appKey $request->get("appKey");
  398.         $action =  $request->get("action");// HOLDER APPLICATION
  399.         if(!empty($userIdo) && !empty($appKey) && !empty($action))
  400.         {            
  401.             $tabPersonBioVerificationHistories = array();
  402.             switch ($action
  403.             {
  404.                 case 'HOLDER':
  405.                     $personBioVerificationHistories $personBioVerificationRepository->findVerificationByUser($userIdo);
  406.                     break;
  407.                 case 'APPLICATION':
  408.                     $personBioVerificationHistories $personBioVerificationRepository->findVerificationByApplicationPass($appKey);
  409.                     break;                
  410.                 default:
  411.                     $return = array(
  412.                             'Etat' =>'FAILED' 
  413.                             'Message' =>"L'action ne correspond à aucun attendu !!!"
  414.                         );
  415.                     return new JsonResponse($return);                    
  416.                     break;
  417.             }
  418.             
  419.             $nb count($personBioVerificationHistories);
  420.             //dump($personBioVerificationHistories);die;
  421.             if($personBioVerificationHistories)
  422.             {
  423.                 foreach ($personBioVerificationHistories as $key
  424.                 {
  425.                    $tabPersonBioVerificationHistories [] = 
  426.                     [
  427.                         'objet'=>$key->getTitle(),
  428.                         'transactionReferene'=>$key->getCheckQr()->getNumero(),
  429.                         'userIdo'=>$key->getUserReference()->getNumero(),
  430.                         'civility'=>$key->getUserReference()->getPersonCivil()[0]->getCivility(),
  431.                         'firstName'=>$key->getUserReference()->getPersonCivil()[0]->getFirstName(),
  432.                         'lastName'=>$key->getUserReference()->getPersonCivil()[0]->getLastName(),
  433.                         'application'=>$key->getApplication()->getName(),
  434.                         'fichier'=>empty($key->getfile())? null "uploads/kyvala/fichier/".$key->getfile(),
  435.                         'statut'=>$key->getUserAccess(),
  436.                         'score'=>$key->getScore(),
  437.                         'dateEnregistrement'=>$key->getDateCreated()->format("d/m/Y H:i:s"),
  438.                         'dateSignature'=>empty($key->getDateCreated()) ? null $key->getDateCreated()->format("d/m/Y H:i:s"),
  439.                     ];
  440.                 }
  441.                 $return = array(
  442.                     'Etat' => 'SUCCESS',
  443.                     'Message' => "Historique recupérés avec succès...",
  444.                     'nb' => $nb,
  445.                     'records'=>$tabPersonBioVerificationHistories,
  446.                 );
  447.             }else{
  448.                 $return = array(
  449.                     'Etat' => 'SUCCESS',
  450.                     'Message' => "Aucun historique disponible pour ce critère de recherche...",
  451.                     'nb' => $nb,
  452.                     'records'=>$tabPersonBioVerificationHistories,
  453.                 );
  454.             }
  455.         }else
  456.         {
  457.             $return = array(
  458.                 'Etat' =>'FAILED' 
  459.                 'Message' =>"Paramètres requis manquants !!!"
  460.             );
  461.         }
  462.         
  463.        return new JsonResponse($return);
  464.     }
  465.     // Ce end point permet à une application de vérifier le statut de la demande de d'authentification biométrique.
  466.     /**
  467.      * @Route("/check/status/authentication", name="app_person_bio_verification_check_status", methods={"GET", "POST"})
  468.      */
  469.     public function checkAuthenticationStatus(Request $requestPersonBioVerificationRepository $personBioVerificationRepositoryApplicationRepository $applicationRepository): Response
  470.     {
  471.         $validationReference $request->get("validationReference");//project transaction reference
  472.         $appKey $request->get("appKey");// project unique key
  473.         if (!empty($validationReference) && !empty($appKey)) 
  474.         {
  475.             $application $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
  476.             if($application)
  477.             {
  478.                 $personBioVerification $personBioVerificationRepository->findOneBySqr($validationReference);
  479.                 if($personBioVerification)
  480.                 {
  481.                     $return = array(
  482.                         'Etat' => 'SUCCESS',
  483.                         'Message' => "Enregistrement recupérée avec succès...",
  484.                         'objet'=>$personBioVerification->getTitle(),
  485.                         'transactionReferene'=>$personBioVerification->getCheckQr()->getNumero(),
  486.                         'userIdo'=>$personBioVerification->getUserReference()->getNumero(),
  487.                         'civility'=>$personBioVerification->getUserReference()->getPersonCivil()[0]->getCivility(),
  488.                         'firstName'=>$personBioVerification->getUserReference()->getPersonCivil()[0]->getFirstName(),
  489.                         'lastName'=>$personBioVerification->getUserReference()->getPersonCivil()[0]->getLastName(),
  490.                         'application'=>$personBioVerification->getApplication()->getName(),
  491.                         'fichier'=>empty($personBioVerification->getfile())? null "uploads/kyvala/fichier/".$personBioVerification->getfile(),
  492.                         'statut'=>$personBioVerification->getUserAccess(),
  493.                         'score'=>$personBioVerification->getScore(),
  494.                         'dateEnregistrement'=>$personBioVerification->getDateCreated()->format("d/m/Y H:i:s"),
  495.                         'dateSignature'=>empty($personBioVerification->getDateSign()) ? null $personBioVerification->getDateSign()->format("d/m/Y H:i:s"),
  496.                         'isPouceGauche'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isPouceGauche(),
  497.                         'isPouceDroit'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isPouceDroit(),
  498.                         'isIndexDroit'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isIndexDroit(),
  499.                         'isIndexGauche'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isIndexGauche(),
  500.                         'isMajeurDroit'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isMajeurDroit(),
  501.                         'isMajeurGauche'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isMajeurGauche(),
  502.                         'isAnnulaireDroit'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isAnnulaireDroit(),
  503.                         'isAnnulaireGauche'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isAnnulaireGauche(),
  504.                         'isAuriculaireGauche'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isAuriculaireGauche(),
  505.                         'isAuriculaireDroit'=>$personBioVerification->getUserReference()->getPersonBiometrics()[0]->isAuriculaireDroit(),
  506.                     );
  507.                 }else
  508.                 {
  509.                     $return = array(
  510.                         'Etat' =>'FAILED' 
  511.                         'Message' =>"La référence n'est associé à aucune transaction..."
  512.                     );
  513.                 }
  514.             }else
  515.             {
  516.                 $return = array(
  517.                     'Etat' =>'FAILED' 
  518.                     'Message' =>"Vous n'avez pas l'autorisation pour cette requette"
  519.                 );
  520.             }
  521.         }else
  522.         {
  523.             $return = array(
  524.                 'Etat' =>'FAILED' 
  525.                 'Message' =>"Paramètres requis manquants"
  526.             );
  527.         }
  528.         
  529.        return new JsonResponse($return);
  530.     }
  531.     private function sendNotif($user_notification_token,$title,$message)
  532.     {
  533.         //https://www.youtube.com/watch?v=YHniUsrmX9Y
  534.         $fs = new Filesystem();
  535.         $credential = new ServiceAccountCredentials(
  536.             "https://www.googleapis.com/auth/firebase.messaging",
  537.             json_decode(file_get_contents
  538.             ("kyvala-45525-firebase-adminsdk-cxpp5-cf78b66d72.json"),true)
  539.         );
  540.         $token $credential->fetchAuthToken(HttpHandlerFactory::build());
  541.         $accessToken $token['access_token'];
  542.         $ch curl_init("https://fcm.googleapis.com/v1/projects/kyvala-45525/messages:send");
  543.         curl_setopt($chCURLOPT_HTTPHEADER,[
  544.             'Content-Type: application/json',
  545.             'Authorization: ' 'Bearer ' .$accessToken
  546.         ]);
  547.         //"uploads/kyvala/fichier/".$key->getLogo() logo-sans-fond.png
  548.         ////"image":"http://poc.kyvala.com/uploads/TOKEN/Token-logo-avec-fond.png"
  549.         curl_setopt($chCURLOPT_POSTFIELDS'{
  550.             "message": {
  551.                 "token":"'.$user_notification_token.'",
  552.                 "notification": {
  553.                     "title":"'.$title.'",
  554.                     "body":"'.$message.'",                    
  555.                     "image":"http://poc.kyvala.com/uploads/Logo/logo-sans-fond.png"
  556.                 }
  557.             }
  558.         }');
  559.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  560.         curl_setopt($chCURLOPT_VERBOSEtrue);
  561.         $response curl_exec($ch);
  562.         
  563.         if (curl_errno($ch)) 
  564.         {
  565.             print "Error: " curl_error($ch);
  566.             $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)));
  567.             exit();
  568.         }else
  569.         {
  570.             $json json_decode($responsetrue);
  571.         }
  572.         // Show me the result
  573.         curl_close($ch);
  574.         //dump($season_data);
  575.         
  576.         $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));
  577.         // return a JSON object to caller
  578.         return $json;
  579.     }
  580.         
  581.     // @Route("/", name="app_person_bio_verification_index", methods={"GET"}) 
  582.     /*
  583.     public function index(PersonBioVerificationRepository $personBioVerificationRepository): Response
  584.     {
  585.         return $this->render('person_bio_verification/index.html.twig', [
  586.             'person_bio_verifications' => $personBioVerificationRepository->findAll(),
  587.         ]);
  588.     }
  589.     */
  590.     //@Route("/new", name="app_person_bio_verification_new", methods={"GET", "POST"})
  591.     /*
  592.     public function new(Request $request, PersonBioVerificationRepository $personBioVerificationRepository): Response
  593.     {
  594.         $personBioVerification = new PersonBioVerification();
  595.         $form = $this->createForm(PersonBioVerificationType::class, $personBioVerification);
  596.         $form->handleRequest($request);
  597.         if ($form->isSubmitted() && $form->isValid()) {
  598.             $personBioVerificationRepository->add($personBioVerification, true);
  599.             return $this->redirectToRoute('app_person_bio_verification_index', [], Response::HTTP_SEE_OTHER);
  600.         }
  601.         return $this->renderForm('person_bio_verification/new.html.twig', [
  602.             'person_bio_verification' => $personBioVerification,
  603.             'form' => $form,
  604.         ]);
  605.     }*/
  606.     
  607.     // @Route("/{id}", name="app_person_bio_verification_show", methods={"GET"})
  608.     /* 
  609.     public function show(PersonBioVerification $personBioVerification): Response
  610.     {
  611.         return $this->render('person_bio_verification/show.html.twig', [
  612.             'person_bio_verification' => $personBioVerification,
  613.         ]);
  614.     }
  615.     */
  616.     
  617.     // @Route("/{id}/edit", name="app_person_bio_verification_edit", methods={"GET", "POST"})
  618.      /*
  619.     public function edit(Request $request, PersonBioVerification $personBioVerification, PersonBioVerificationRepository $personBioVerificationRepository): Response
  620.     {
  621.         $form = $this->createForm(PersonBioVerificationType::class, $personBioVerification);
  622.         $form->handleRequest($request);
  623.         if ($form->isSubmitted() && $form->isValid()) {
  624.             $personBioVerificationRepository->add($personBioVerification, true);
  625.             return $this->redirectToRoute('app_person_bio_verification_index', [], Response::HTTP_SEE_OTHER);
  626.         }
  627.         return $this->renderForm('person_bio_verification/edit.html.twig', [
  628.             'person_bio_verification' => $personBioVerification,
  629.             'form' => $form,
  630.         ]);
  631.     }
  632.     */
  633.     
  634.     // @Route("/{id}", name="app_person_bio_verification_delete", methods={"POST"})
  635.     /* 
  636.     public function delete(Request $request, PersonBioVerification $personBioVerification, PersonBioVerificationRepository $personBioVerificationRepository): Response
  637.     {
  638.         if ($this->isCsrfTokenValid('delete'.$personBioVerification->getId(), $request->request->get('_token'))) {
  639.             $personBioVerificationRepository->remove($personBioVerification, true);
  640.         }
  641.         return $this->redirectToRoute('app_person_bio_verification_index', [], Response::HTTP_SEE_OTHER);
  642.     }
  643.     */
  644. }