<?php
namespace App\Services;
use Symfony\Component\DependencyInjection\Tests\Fixtures\StdClassDecorator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormError;
use GuzzleHttp\Client;
use App\Entity\User;
use App\Entity\Membership;
use App\Entity\Dic;
use App\Entity\Fic;
use App\Entity\Ba;
use Symfony\Component\HttpFoundation\RequestStack;
// Import the Twig Environment
use Twig\Environment;
use setasign\Fpdi\Fpdi;
class GenerateDocuments
{
private $container;
private $twig;
protected $fileUploader;
private $yousignApi;
private $yousignUrl;
private $yousignUi;
private $yousignUiConditions;
/**
* Constructor
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container, $yousignApi, $yousignUrl, $yousignUi, $yousignUiConditions, EntityManagerInterface $entityManager, \Swift_Mailer $mailer, Environment $twig, \Knp\Snappy\Pdf $knpSnappy, FileUploader $fileUploader)
{
$this->container = $container;
$this->mailer = $mailer;
$this->em = $entityManager;
$this->twig = $twig;
$this->knpSnappy = $knpSnappy;
$this->fileUploader = $fileUploader;
$this->yousignApi = $yousignApi['yousignApi'];
$this->yousignUrl = $yousignUrl['yousignUrl'];
$this->yousignUi = $yousignUi['yousignUi'];
$this->yousignUiConditions = $yousignUiConditions['yousignUiConditions'];
}
public function generateFic($customer)
{
$fic = $customer->getCurrentMemberships()->getFic();
$ficFileName = "fic-no-sign.pdf";
$ficFullPath = $this->fileUploader->getTargetDirectory() . "/" . $customer->getId() . "/" . $ficFileName;
//If file exist
if (file_exists($ficFullPath)) {
//Remove last file
unlink($ficFullPath);
}
/*
$this->knpSnappy->setOption('page-size', 'A4');
$this->knpSnappy->setOption('encoding', 'UTF-8');
$this->knpSnappy->setOption('zoom', '1.62');
$this->knpSnappy->setOption('margin-left', '0');
$this->knpSnappy->setOption('margin-right', '0');
$this->knpSnappy->setOption('margin-top', '5');
$this->knpSnappy->setOption('margin-bottom', '5');
$this->knpSnappy->setOption('dpi', '96');
$this->knpSnappy->generateFromHtml(
$this->twig->render(
'membership/pdf/ficView.html.twig',
array(
'fic' =>
)
),
$ficFullPath
);
*/
//Valid checkbox
$fic->setReconnaisConnaissanceFic(true);
$fic->setAttesteRecuInformationDetaillee(true);
$fic->setAttesteRecuDicEtReglement(true);
$fic->setReconnaisPreconisationsAdaptees(true);
$this->em->persist($fic);
$this->em->flush();
// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
if($customer->getAdherentDistributeur() == 0){
$numberPagesSource = $pdf->setSourceFile("default/FIC_2024.pdf");
}
else{
$numberPagesSource = $pdf->setSourceFile("default/FIC_2024_distributeur.pdf");
}
for ($i = 1; $i <= $numberPagesSource ; $i++) {
if($i > 1){
$pdf->AddPage();
}
// import page
$tplId = $pdf->importPage($i);
$pdf->useTemplate($tplId, 0, 0);
//Global pages
$font = "Helvetica";
$fontSizeText = 11;
$fontSizeChecked = 14;
$pdf->setFont($font, null, 10);
switch ($i) {
case '1':
break;
case '2':
//Sexe
if($fic->getSex() === "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.6, 155.6, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(29.4, 155.6, 'X');
}
//Name
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(65.6, 160, $this->decode($fic->getNom())." ".$this->decode($fic->getPrenom()));
//Naissance année
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(50.4, 166.6, $this->formatString($fic->getDateDeNaissance()->format("d")));
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(58.8, 166.6, $this->formatString($fic->getDateDeNaissance()->format("m")));
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(67.2, 166.6, $this->formatString($fic->getDateDeNaissance()->format("Y")));
//Lieu naissance
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(83.3, 166.7, $this->decode($fic->getLieuDeNaissance()));
//Nationalité
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(30, 172.4, $this->decode($fic->getNationalite()));
//Résidence fiscal FR
if($fic->isAdresseFiscaleResidenceFrance() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(51.1, 195.3, 'X');
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(64.6, 195.3, 'X');
}
//adresse fiscale
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(34.1, 201, $this->decode($fic->getAdresseFiscale()));
//code postale fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(32.1, 207, $this->formatString($fic->getAdresseFiscaleCodePostal()));
//ville fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(59, 206.6, $this->decode($fic->getAdresseFiscaleVille()));
//pays fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(147, 207, $this->decode($fic->getAdresseFiscalePays()));
//adresse postale
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(53, 212.5, $this->decode($fic->getAdressePostale()));
//code postale
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(32.1, 218.6, $this->formatString($fic->getAdresseCodePostal()));
//ville
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(58.5, 218.6, $this->decode($fic->getAdresseVille()));
//pays
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(147, 218.6, $this->decode($fic->getAdressePays()));
//téléphone
$pdf->setFont($font, null, 11.3);
$pdf->Text(38.6, 224.7, $this->formatString($customer->getPhonePrefix()));
$phone = $customer->getPhone();
$phone = str_replace("(", "", $phone);
$phone = str_replace(")", "", $phone);
$phone = str_replace(" ", "", $phone);
$pdf->Text(51.4, 224.7, $this->formatString($phone));
if($fic->getTelFix()){
//téléphone fixe
$pdf->setFont($font, null, 11.3);
$pdf->Text(116.6, 224.7, $this->formatString($fic->getTelFixPrefix()));
$phoneFixe = $fic->getTelFix();
$phoneFixe = str_replace("(", "", $phoneFixe);
$phoneFixe = str_replace(")", "", $phoneFixe);
$phoneFixe = str_replace(" ", "", $phoneFixe);
$pdf->Text(129.4, 224.7, $this->formatString($phoneFixe));
}
//email
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(22, 230.4, $this->decode($fic->getEmail()));
//J'accepte 1
if($fic->isAcceptRecevoirDocumentGarantieEmail() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 242.9, 'X');
}
if($fic->isAcceptPropositionCommercialEmail() == false){
//J'accepte 2
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(145.6, 249.5, 'X');
}
else{
//Je refuse 2
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(159.3, 249.5, 'X');
}
if($fic->isAcceptPropositionCommercialTelephone() == false){
//J'accepte 3
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(145.4, 255.5, 'X');
}
else{
//Je refuse 3
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(159.4, 255.5, 'X');
}
break;
case '3':
//Politiquement exposé
if($fic->isPersonnePolitiquementExposee() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(119.8, 43.9, 'X');
if($fic->getPersonnePolitiquementExposeeType() === "0"){
//Politiquement exposé votre fonction
$pdf->setFont($font, null, 8);
$pdf->Text(103.4, 71.3, $this->decode($fic->getPersonnePolitiquementExposeeMaFonction()));
}
else{
//Politiquement exposé famille nom
/*
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(93, 75.7, $this->decode($fic->getPersonnePolitiquementExposeeEntourageNom()));
*/
//Politiquement exposé famille fonction
$pdf->setFont($font, null, 8);
$pdf->Text(57.6, 82, $this->decode($fic->getPersonnePolitiquementExposeeEntourageFonction()));
//Politiquement exposé famille lien
$pdf->setFont($font, null, 8);
$pdf->Text(67.3, 88.2, $this->decode($fic->getPersonnePolitiquementExposeeEntourageLien()));
}
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(133.4, 43.9, 'X');
}
//Situation familiale
if($fic->getSituationFamilliale() === "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(14, 107.4, 'X');
}
else if($fic->getSituationFamilliale() === "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(35.8, 107.4, 'X');
}
else if($fic->getSituationFamilliale() === "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(57.3, 107.4, 'X');
}
else if($fic->getSituationFamilliale() === "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(88.8, 107.4, 'X');
}
else if($fic->getSituationFamilliale() === "4"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(113.7, 107.4, 'X');
}
else if($fic->getSituationFamilliale() === "5"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(137.2, 107.4, 'X');
}
//Nombre d'enfant
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(38.6, 113.1, $fic->getNombreEnfant());
//Nombre d'enfant à charge
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(109.5, 113.6, $fic->getNombreEnfantCharge());
//Situation professionnelle
$pdf->setFont($font, null, 11.2);
$pdf->Text(51.7, 131.7, $this->formatString($fic->getProfessionCspCategory()));
$pdf->setFont($font, null, 11.2);
$pdf->Text(105.6, 131.7, $this->formatString($fic->getProfessionCspSousCategory()));
//Avez vous titre de reconnaissance nation
if($fic->isReconnaisanceNation() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(117.9, 138, 'X');
if($fic->getDateReconnaisanceNation()){
//Avez vous titre de reconnaissance nation année
$pdf->setFont($font, null, 11.4);
$pdf->Text(65.9, 144, $this->formatString($fic->getDateReconnaisanceNation()->format("Y")));
}
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(134, 138, 'X');
}
/*
if($fic->getProtectionJuridique() === "0" || $fic->getProtectionJuridique() === "1" || $fic->getProtectionJuridique() === "2" || $fic->getProtectionJuridique() === "3"){
//Régime légal de protection ?
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(84.6, 165.8, 'X');
//Régime légal de protection choix
if($fic->getProtectionJuridique() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 182.4, 'X');
}
else if($fic->getProtectionJuridique() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(32.6, 182.4, 'X');
}
else if($fic->getProtectionJuridique() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(54.7, 182.4, 'X');
}
else if($fic->getProtectionJuridique() == "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(94, 182.4, 'X');
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(111.9, 182.2, $this->decode($fic->getProtectionJuridiqueOther()));
}
//Mineur
if($fic->getProtectionJuridiqueMineur() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(26.4, 191.2, 'X');
}
else if($fic->getProtectionJuridiqueMineur() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(71.4, 191.2, 'X');
}
else if($fic->getProtectionJuridiqueMineur() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(93.5, 191.2, 'X');
}
}
*/
//Force "Non"
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(100.2, 165.8, 'X');
break;
case '4':
//Estimation patrimoine net
if($fic->getEvaluationPatrimoine() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.7, 101.9, 'X');
}
else if($fic->getEvaluationPatrimoine() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(34.2, 101.9, 'X');
}
else if($fic->getEvaluationPatrimoine() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(71.8, 101.9, 'X');
}
else if($fic->getEvaluationPatrimoine() == "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(110, 101.9, 'X');
}
else if($fic->getEvaluationPatrimoine() == "4"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(150.7, 101.9, 'X');
}
//Composition patrimoine
foreach ($fic->getEvaluationPatrimoineComposition() as $composition) {
switch ($composition) {
case '0':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.5, 118.9, 'X');
break;
case '1':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(60.8, 118.9, 'X');
break;
case '2':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(105.7, 118.9, 'X');
break;
case '4':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.5, 125.9, 'X');
break;
case '3':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(49.8, 125.9, 'X');
break;
case '5':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(89.1, 125.9, 'X');
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(105, 125.9, $this->decode($fic->getEvaluationPatrimoineCompositionOther()));
break;
default:
// code...
break;
}
}
//Ressource financiere perçue n-1
if($fic->getRevenusNetMensuelsFoyer() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.5, 147.8, 'X');
}
else if($fic->getRevenusNetMensuelsFoyer() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(37.6, 147.8, 'X');
}
else if($fic->getRevenusNetMensuelsFoyer() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(80, 147.8, 'X');
}
else if($fic->getRevenusNetMensuelsFoyer() == "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(123.7, 147.8, 'X');
}
//Composition de foyer fiscal
foreach ($fic->getRevenusNetMensuelsFoyerComposition() as $composition) {
switch ($composition) {
case '0':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.6, 165.5, 'X');
break;
case '1':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(55, 165.5, 'X');
break;
case '2':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(87.3, 165.5, 'X');
break;
case '3':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(110, 165.5, 'X');
break;
case '4':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(141.1, 165.5, 'X');
break;
case '5':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.6, 171.8, 'X');
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(28.8, 171.5, $this->decode($fic->getRevenusNetMensuelsFoyerCompositionOther()));
break;
default:
// code...
break;
}
}
//Part de revenu
if($fic->getPartChargeReguliere() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.6, 193, 'X');
}
else if($fic->getPartChargeReguliere() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(33, 193, 'X');
}
else if($fic->getPartChargeReguliere() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(67, 193, 'X');
}
else if($fic->getPartChargeReguliere() == "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(101, 193, 'X');
}
//Expérience financière
if($fic->getNiveauConnaissanceRetraite() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 226.5, 'X');
}
else if($fic->getNiveauConnaissanceRetraite() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 235.1, 'X');
}
else if($fic->getNiveauConnaissanceRetraite() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 243.8, 'X');
}
break;
case '5':
//Objectifs principaux
foreach ($fic->getObjectifsPricipaux() as $objectif) {
switch ($objectif) {
case '0':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(14, 54.8, 'X');
break;
case '1':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(56.2, 54.8, 'X');
break;
case '2':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(112.2, 54.8, 'X');
break;
case '3':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(14, 62, 'X');
break;
case '4':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(61.7, 62, 'X');
break;
case '5':
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(101.8, 62, 'X');
break;
default:
// code...
break;
}
}
//Temps fond placé
if($fic->getObjectifsTempsFonds() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 84.3, 'X');
}
else if($fic->getObjectifsTempsFonds() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(46.2, 84.3, 'X');
}
else if($fic->getObjectifsTempsFonds() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(75, 84.3, 'X');
}
//Montant initial
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(130, 100.3, $fic->getObjectifsMontantIntial());
//Placement pra raport au patromoine (%)
if($fic->getObjectifsPlacementSurPatrimoineTotal() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 117.2, 'X');
}
else if($fic->getObjectifsPlacementSurPatrimoineTotal() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(41.2, 117.2, 'X');
}
else if($fic->getObjectifsPlacementSurPatrimoineTotal() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(68.3, 117.2, 'X');
}
else if($fic->getObjectifsPlacementSurPatrimoineTotal() == "3"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(93.8, 116.9, 'X');
}
//Date souhaité
/*
$pdf->setFont($font, null, 22);
$pdf->Text(87.4, 131, $this->formatString($fic->getGarantieDateSouhaite()->format("d")));
$pdf->setFont($font, null, 22);
$pdf->Text(104, 131, $this->formatString($fic->getGarantieDateSouhaite()->format("m")));
$pdf->setFont($font, null, 22);
$pdf->Text(120.1, 131, $this->formatString($fic->getGarantieDateSouhaite()->format("Y")));
*/
//Nos recommendations
if($fic->getSouscrireRetraiteMutualistePourConstituer() == "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 189.4, 'X');
}
else if($fic->getSouscrireRetraiteMutualistePourConstituer() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 198.7, 'X');
}
else if($fic->getSouscrireRetraiteMutualistePourConstituer() == "2"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 207.5, 'X');
}
break;
case '6':
//Votre choix
if($fic->isJacceptePreconisation()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 50.2, 'X');
}
if($fic->isSouscrireAutreContrat()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.2, 60.1, 'X');
}
break;
case '7':
//Vos déclarations
if($fic->isReconnaisConnaissanceFic()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 61.9, 'X');
}
if($fic->isAttesteRecuInformationDetaillee()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 73.4, 'X');
}
if($fic->isAttesteRecuDicEtReglement()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 84.9, 'X');
}
if($fic->isReconnaisPreconisationsAdaptees()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.3, 96.5, 'X');
}
break;
case '8':
break;
default:
// code...
break;
}
}
//Third parameter : ISO-8859-1 (false) or UTF-8 (true) > default : false
$pdf->Output('F', $ficFullPath);
return $ficFileName;
}
public function generateBa($customer)
{
$baFileName = "ba-no-sign.pdf";
$baFullPath = $this->fileUploader->getTargetDirectory() . "/" . $customer->getId() . "/" . $baFileName;
//If file exist
if (file_exists($baFullPath)) {
//Remove last file
unlink($baFullPath);
}
$ba = $customer->getCurrentMemberships()->getBa();
//Valid checkbox
if($ba->getJaiDemandeAttributionDe()){
$ba->setEngageFournirCopieTitreAttribue(true);
}
else{
$ba->setEngageFournirCopieTitreAttribue(false);
}
$ba->setReconnaisEtreInforme(true);
$ba->setConnaissanceDesStatuts(true);
$ba->setReconnaisRenoncer30Jours(true);
$ba->setReconnaisAvoirPrisConnaissance(true);
$this->em->persist($ba);
$this->em->flush();
// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$numberPagesSource = $pdf->setSourceFile("default/BA_2024.pdf");
for ($i = 1; $i <= $numberPagesSource ; $i++) {
if($i > 1){
$pdf->AddPage();
}
// import page
$tplId = $pdf->importPage($i);
$pdf->useTemplate($tplId, 0, 0);
//Global pages
$font = "Helvetica";
$fontSizeText = 11;
$fontSizeChecked = 11;
$pdf->setFont($font, null, 10);
switch ($i) {
case '3':
//Numéro adhérent
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(38.2, 55.5, $ba->getNumeroAdherent());
//code conseiller
$pdf->setFont($font, null, 10.5);
$pdf->Text(171.7, 55.7, $this->formatString($customer->getSeller()->getCodeConseiller()));
//Vente distance
if($ba->getVenteADistance()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(45.9, 70.6, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(62, 70.6, 'X');
}
//Nom conseiller
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(46.5, 76.7, $this->decode($customer->getSeller()->getFirstName())." ".$this->decode($customer->getSeller()->getLastName()));
//Téléphone conseiller
$pdf->setFont($font, null, 11.4);
$phone = $customer->getSeller()->getPhone();
$phone = str_replace("(", "", $phone);
$phone = str_replace(")", "", $phone);
$phone = str_replace(" ", "", $phone);
$pdf->Text(43.3, 83, $this->formatString($phone));
//Numéro adhérent distributeur
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(56, 89.4, $customer->getAdherentDistributeur());
//Siren
$pdf->setFont($font, null, 11.6);
$pdf->Text(139, 89.6, $this->formatString($customer->getSeller()->getNumeroSiren()));
//Sex
if($ba->getSex() === "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(39.5, 118.9, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(53, 118.8, 'X');
}
//Nom et prénoms
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(65.4, 124.4, $this->decode($ba->getNom())." ".$this->decode($ba->getPrenom()));
//Date naissance
$pdf->setFont($font, null, 11);
$pdf->Text(49.8, 129.3, $this->formatString($ba->getDateDeNaissance()->format("d")));
$pdf->setFont($font, null, 11);
$pdf->Text(58.3, 129.3, $this->formatString($ba->getDateDeNaissance()->format("m")));
$pdf->setFont($font, null, 11);
$pdf->Text(66.7, 129.3, $this->formatString($ba->getDateDeNaissance()->format("Y")));
//Lieu de naissance
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(82, 129.2, $this->decode($ba->getLieuDeNaissance()));
//Sécurité social
$pdf->setFont($font, null, 12.2);
$pdf->Text(24.8, 134.6, $this->formatString($ba->getNumeroSS(), "ss"));
$pdf->setFont($font, null, 12.2);
$pdf->Text(79.7, 134.6, $this->formatString($ba->getCleNumeroSS()));
//Nationnalité
$pdf->setFont($font, null, 9);
$pdf->Text(30.9, 139, $this->decode($ba->getNationalite()));
//Type identité
$typeIdentite = "";
switch ($ba->getTypeDePieceIdentite()) {
case 0:
$typeIdentite = "Carte d'identité";
break;
case 1:
$typeIdentite = "Passeport";
break;
case 2:
$typeIdentite = "Titre de séjour";
break;
default:
$typeIdentite = "Carte d'identité";
break;
}
$pdf->setFont($font, null, 11);
$pdf->Text(69.2, 144.3, $this->decode($typeIdentite));
//Green card ?
if($ba->isGreenCard()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(124.1, 150.2, 'X');
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(137, 150.2, 'X');
}
//Residence fiscale ?
if($ba->isResidenceFrance() == "1"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(77.1, 155.1, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(90, 155.1, 'X');
//Numéro fiscal
$pdf->setFont($font, null, 11.6);
$pdf->Text(147.4, 159.8, $this->formatString($ba->getResidenceIdentificationFiscalPays()));
}
//adresse fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(36, 164.8, $this->decode($ba->getFiscaleAddress()));
//Code postal fiscal
$pdf->setFont($font, null, 11.2);
$pdf->Text(32.1, 170.1, $this->formatString($ba->getFiscaleCodePostal()));
//Ville fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(58.2, 169.8, $this->decode($ba->getFiscaleVille()));
//Pays fiscal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(146, 169.8, $this->decode($ba->getFiscalePays()));
//Adresse postale
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(52, 174.9, $this->decode($ba->getNumeroDeVoie()));
//POSTALE
//Code postal fiscal
$pdf->setFont($font, null, 11.2);
$pdf->Text(32.1, 180.1, $this->formatString($ba->getCodePostal()));
//Ville postal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(58.2, 180.1, $this->decode($ba->getVille()));
//Pays postal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(146, 180.1, $this->decode($ba->getPays()));
//Téléphone
$pdf->setFont($font, null, 11.3);
$pdf->Text(39.8, 189.9, $this->formatString($customer->getPhonePrefix()));
$pdf->setFont($font, null, 11.3);
$phone = $customer->getPhone();
$phone = str_replace("(", "", $phone);
$phone = str_replace(")", "", $phone);
$phone = str_replace(" ", "", $phone);
$pdf->Text(52.2, 189.9, $this->formatString($phone));
//Email
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(25, 185, $ba->getEmail());
if($ba->getTelFix()){
//téléphone fixe
$pdf->setFont($font, null, 11.3);
$pdf->Text(114.6, 189.9, $this->formatString($ba->getTelFixPrefix()));
$phoneFixe = $ba->getTelFix();
$phoneFixe = str_replace("(", "", $phoneFixe);
$phoneFixe = str_replace(")", "", $phoneFixe);
$phoneFixe = str_replace(" ", "", $phoneFixe);
$pdf->Text(127, 189.9, $this->formatString($phoneFixe));
}
//J'accepte 1
if($ba->isAcceptRecevoirDocumentGarantieEmail() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 202.7, 'X');
}
//J'accepte 2 Oui
if($ba->isAcceptPropositionCommercialEmail() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(145.2, 207.7, 'X');
}
else{
//J'accepte 2 Non
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(159.1, 207.7, 'X');
}
//J'accepte 3 Oui
if($ba->isAcceptPropositionCommercialTelephone() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(145.2, 212.6, 'X');
}
else{
//J'accepte 3 Non
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(159.2, 212.6, 'X');
}
//Situation famille
switch ($ba->getSituationFamilliale()) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.7, 224.8, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(34.8, 224.8, 'X');
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(55.8, 224.8, 'X');
break;
case 3:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(86.6, 224.8, 'X');
break;
case 4:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(110.8, 224.8, 'X');
break;
case 5:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(132.3, 224.8, 'X');
break;
default:
// code...
break;
}
//Situation pro
$pdf->setFont($font, null, 11.2);
$pdf->Text(51.7, 237.1, $this->formatString($ba->getProfessionCspCategory()));
$pdf->setFont($font, null, 11.2);
$pdf->Text(105.2, 237.1, $this->formatString($ba->getProfessionCspSousCategory()));
//Titulaire de
if($ba->getTitulaireDe()){
foreach($ba->getTitulaireDe() as $titulaireDe){
switch ($titulaireDe) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 260.1, 'X');
//Date obtention 1
$pdf->setFont($font, null, 11.2);
$pdf->Text(138.8, 259.1, $this->formatString($ba->getDateCarteCombattant()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(147.1, 259.1, $this->formatString($ba->getDateCarteCombattant()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(155.3, 259.1, $this->formatString($ba->getDateCarteCombattant()->format("Y")));
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 265.1, 'X');
//Date obtention 2
$pdf->setFont($font, null, 11.2);
$pdf->Text(138.8, 264.3, $this->formatString($ba->getDateReconnaisanceNation()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(147.1, 264.3, $this->formatString($ba->getDateReconnaisanceNation()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(155.3, 264.3, $this->formatString($ba->getDateReconnaisanceNation()->format("Y")));
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 270, 'X');
//Date obtention 3
$pdf->setFont($font, null, 11.2);
$pdf->Text(162, 269.2, $this->formatString($ba->getDateTranscriptionMention()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(170.4, 269.2, $this->formatString($ba->getDateTranscriptionMention()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(178.7, 269.2, $this->formatString($ba->getDateTranscriptionMention()->format("Y")));
break;
default:
// code...
break;
}
}
}
//Conflit concerné
if($ba->getConflitConcerne()){
foreach($ba->getConflitConcerne() as $conflitConcerne){
switch ($conflitConcerne) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 284.1, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(61.3, 284.1, 'X');
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(80.5, 284.1, 'X');
break;
case 3:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(99.7, 284.1, 'X');
break;
case 4:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(118.3, 284.1, 'X');
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(143, 284.2, $this->decode($ba->getConflitOpexDescription()));
break;
default:
// code...
break;
}
}
}
break;
case '4':
//conflit concerné OU -> J'ai demandé l'attributiond de
if($ba->getJaiDemandeAttributionDe()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 21.5, 'X');
}
//conflit concerné OU -> Titres
if($ba->getJaiDemandeAttributionDe()){
foreach($ba->getJaiDemandeAttributionDe() as $demandeAttributionDe){
switch ($demandeAttributionDe) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 27.1, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(51.6, 27.1, 'X');
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(110.7, 27.1, 'X');
break;
default:
// code...
break;
}
}
}
//Je m'engage
if($ba->isEngageFournirCopieTitreAttribue()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13, 51, 'X');
}
//date effet adhesion
if($ba->getDateEffetAdhesion()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(49.4, 89.4, $this->formatString($ba->getDateEffetAdhesion()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(57.8, 89.4, $this->formatString($ba->getDateEffetAdhesion()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(66.2, 89.4, $this->formatString($ba->getDateEffetAdhesion()->format("Y")));
}
//age adhesion
if($ba->getAgeAdhesion()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(115.2, 89.4, $this->formatString($ba->getAgeAdhesion()));
}
//date liquidation
if($ba->getDateDeLiquidation()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(46.2, 95, $this->formatString($ba->getDateDeLiquidation()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(54.5, 95, $this->formatString($ba->getDateDeLiquidation()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(63, 95, $this->formatString($ba->getDateDeLiquidation()->format("Y")));
}
//taux majoration rente
$tauxMajoration = $this->container->get('translator')->trans('ba.majoration-rente-v2.'.$ba->getMajorationRente(), domain: 'global');
$pdf->setFont($font, null, 11.2);
$pdf->Text(128.8, 95.2, $this->formatString($tauxMajoration));
//taux majoration rente part 2
/*
$pdf->setFont($font, null, 11.2);
$pdf->Text(136.2, 95.2, $this->formatString($tauxMajoration));
*/
//Option
if($ba->getOptionCapital() == 0){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 132.5, 'X');
}
else if($ba->getOptionCapital() == 1){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 137.4, 'X');
}
else if($ba->getOptionCapital() == 2){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 142.4, 'X');
}
//montant intial versement
$initialVersement = $ba->getVersementInitial();
if(ctype_digit($ba->getVersementInitial())) {
$initialVersement = round($ba->getVersementInitial(), 2);
$initialVersement = str_replace(".", ",", $initialVersement);
} else {
$initialVersement = strval($ba->getVersementInitial()).",00";
}
$initialVersementNumber = strlen($initialVersement);
$space = 0;
if($initialVersementNumber < 8){
for($iNumber = 1; $iNumber <= (8 - $initialVersementNumber); $iNumber++){
$space = $space + 3.2;
}
}
$pdf->setFont($font, null, 11);
$pdf->Text(79.9 + $space, 162.3, $this->formatString($initialVersement));
//versement initial fiscalement OUI / NON
if($ba->isVersementInitialDeduit()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(95.4, 182.9, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(107.8, 182.8, 'X');
}
//Mode de paiement
switch ($ba->getMoyenDeVersement()) {
case 0:
// code...
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 193.5, 'X');
break;
case 3:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 198.4, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 207.2, 'X');
break;
default:
// code...
break;
}
//versement programmé OUI / NON
if($ba->isVersementProgramme()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(88.6, 234.6, 'X');
//montant programmé versement
$programmeVersement = $ba->getMontantVersementPeriodique();
if(ctype_digit($ba->getMontantVersementPeriodique())) {
$programmeVersement = round($ba->getMontantVersementPeriodique(), 2);
$programmeVersement = str_replace(".", ",", $programmeVersement);
} else {
$programmeVersement = strval($ba->getMontantVersementPeriodique()).",00";
}
$programmeVersementNumber = strlen($programmeVersement);
$space = 0;
if($programmeVersementNumber < 8){
for($iNumber = 1; $iNumber <= (8 - $programmeVersementNumber); $iNumber++){
$space = $space + 3.2;
}
}
$pdf->setFont($font, null, 11);
$pdf->Text(29.9 + $space, 239.8, $this->formatString($programmeVersement));
/* part2
$pdf->setFont($font, null, 11.2);
$pdf->Text(48.1, 239.8, '0 0');
*/
//montant programmé a compter du
$pdf->setFont($font, null, 11.2);
$pdf->Text(95, 239.8, $this->formatString($ba->getDateACompterDu()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(103.8, 239.8, $this->formatString($ba->getDateACompterDu()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(112.2, 239.8, $this->formatString($ba->getDateACompterDu()->format("Y")));
//montant programmé préiodicité
switch ($ba->getPeriodicite()) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(30.8, 245.9, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(50.8, 245.9, 'X');
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(72.5, 245.9, 'X');
break;
case 3:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(95, 245.9, 'X');
break;
default:
// code...
break;
}
//montant programmé jour du mois
switch ($ba->getVersementProgrammePeriodiciteJourDuMois()) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.7, 251.2, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(40.5, 251.2, 'X');
break;
default:
// code...
break;
}
//montant programmé indexation annuelle
switch ($ba->getIndexationAnnuelle()) {
case 0:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(43.7, 256.9, 'X');
break;
case 1:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(56.4, 256.9, 'X');
break;
case 2:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(68.2, 256.9, 'X');
break;
case 3:
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(80.5, 256.9, 'X');
break;
default:
// code...
break;
}
//montant programmé traitement fiscal
if($ba->isVersementProgrammeDeduit()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(111.3, 278, 'X');
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(123.2, 278, 'X');
}
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(100.6, 234.6, 'X');
}
break;
case '5':
//Origine fond 1 fondContratEpargne
if($ba->isFondContratEpargne()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.2, 66.4, 'X');
if($ba->getFondContratEpargneDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(33.5, 71, $this->formatString($ba->getFondContratEpargneDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(41.9, 71, $this->formatString($ba->getFondContratEpargneDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(50.4, 71, $this->formatString($ba->getFondContratEpargneDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 68.3, $ba->getfondContratEpargneNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 67.3, $this->decode($ba->getFondContratEpargneDescription()));
}
//Origine fond 2
if($ba->isFondContratPartSociete()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.2, 86.6, 'X');
if($ba->getFondContratPartSocieteDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(34.5, 91.2, $this->formatString($ba->getFondContratPartSocieteDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(42.7, 91.2, $this->formatString($ba->getFondContratPartSocieteDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(51.2, 91.2, $this->formatString($ba->getFondContratPartSocieteDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 88.3, $ba->getFondContratPartSocieteNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 87.3, $this->decode($ba->getFondContratPartSocieteDescription()));
}
//Origine fond 3
if($ba->isFondContratHeritage()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.2, 107, 'X');
if($ba->getFondContratHeritageDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(33.1, 109.4, $this->formatString($ba->getFondContratHeritageDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(41.5, 109.4, $this->formatString($ba->getFondContratHeritageDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(49.9, 109.4, $this->formatString($ba->getFondContratHeritageDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 108.5, $ba->getFondContratHeritageNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 108.5, $this->decode($ba->getFondContratHeritageDescription()));
}
//Origine fond 4
if($ba->isFondContratImmobilier()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.2, 127, 'X');
if($ba->getFondContratImmobilierDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(33.5, 129.3, $this->formatString($ba->getFondContratImmobilierDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(41.7, 129.3, $this->formatString($ba->getFondContratImmobilierDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(50.2, 129.3, $this->formatString($ba->getFondContratImmobilierDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 128, $ba->getFondContratImmobilierNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 127, $this->decode($ba->getFondContratImmobilierDescription()));
}
//Origine fond 5 fondContratRevenuPro
if($ba->isFondContratRevenuPro()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.4, 146.4, 'X');
if($ba->getFondContratRevenuProDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(33.5, 149.2, $this->formatString($ba->getFondContratRevenuProDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(41.7, 149.2, $this->formatString($ba->getFondContratRevenuProDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(50.2, 149.2, $this->formatString($ba->getFondContratRevenuProDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 147.5, $ba->getFondContratRevenuProNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 146.4, $this->decode($ba->getFondContratRevenuProDescription()));
}
//Origine fond 6
if($ba->isFondContratAutre()){
$pdf->setFont($font, null, 14);
$pdf->Text(16.4, 166.8, 'X');
if($ba->getFondContratAutreDate()){
$pdf->setFont($font, null, 11.2);
$pdf->Text(33.5, 169, $this->formatString($ba->getFondContratAutreDate()->format("d")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(41.7, 169, $this->formatString($ba->getFondContratAutreDate()->format("m")));
$pdf->setFont($font, null, 11.2);
$pdf->Text(50.2, 169, $this->formatString($ba->getFondContratAutreDate()->format("Y")));
}
$pdf->setFont($font, null, 18);
$pdf->Text(81.7, 168, $ba->getFondContratAutreNumber());
$pdf->setFont($font, null, 8);
$pdf->Text(126.1, 166.8, $this->decode($ba->getFondContratAutreDescription()));
}
//Atteste sur l'honneur 1
if($ba->getJattesteTitulaireGarantieRetraite() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 204.1, 'X');
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 209.8, 'X');
}
foreach($ba->getOtherContracts() as $otherContactKey => $otherContact){
switch ($otherContactKey) {
case 0:
//Autre contrat 1
$pdf->setFont($font, null, 8);
$pdf->Text(15.1, 245.1, $this->decode($otherContact->getOrganisme()));
$pdf->setFont($font, null, 8);
$pdf->Text(53.6, 245.1, $this->decode($otherContact->getAdresse()));
$pdf->setFont($font, null, 9.2);
$pdf->Text(126.8, 245.1, $this->formatString($otherContact->getDateAdhesion()->format("d/m/Y")));
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(170.3, 245.1, $this->decode($otherContact->getMontantAnnuel()));
break;
case 1:
//Autre contrat 2
$pdf->setFont($font, null, 8);
$pdf->Text(15.1, 261.5, $this->decode($otherContact->getOrganisme()));
$pdf->setFont($font, null, 8);
$pdf->Text(53.6, 261.5, $this->decode($otherContact->getAdresse()));
$pdf->setFont($font, null, 9.2);
$pdf->Text(126.8, 261.5, $this->formatString($otherContact->getDateAdhesion()->format("d/m/Y")));
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(170.3, 261.5, $this->decode($otherContact->getMontantAnnuel()));
break;
default:
// code...
break;
}
}
break;
case '6':
$benefOtherActive = false;
//Type clause
if($ba->isTypeBeneficiaires() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 41.5, 'X');
}
else if($ba->isTypeBeneficiaires() == true && $ba->isTypeBeneficiairesClauseNotariee() == false){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 82.7, 'X');
$benefOtherActive = true;
}
else {
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 64.7, 'X');
//notaire adresse
$pdf->setFont($font, null, 8);
$pdf->Text(56.7, 68.5, $this->decode($ba->getTypeBeneficiairesClauseNotarieeCoordonnees()));
}
break;
case '7':
//Type clause
if($ba->isReconnaisEtreInforme()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 16.1, 'X');
}
if($ba->isConnaissanceDesStatuts()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 25.9, 'X');
}
if($ba->isReconnaisRenoncer30Jours()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 42.3, 'X');
}
if($ba->isReconnaisAvoirPrisConnaissance()){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(12.9, 54.9, 'X');
}
break;
case '9':
if($benefOtherActive){
//Benef sex
if($ba->getSex() === "0"){
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(54.6, 45.6, 'X');
}
else{
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(35, 45.6, 'X');
}
//Benef nom
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(22.7, 51.4, $this->decode($ba->getNom()));
//Benef prénom
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(85.6, 51.4, $this->decode($ba->getPrenom()));
//Benef adresse
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(37.3, 58, $this->decode($ba->getFiscaleAddress()));
//Benef code postal
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(33.3, 63.8, $this->formatString($ba->getFiscaleCodePostal()));
//Benef ville
$pdf->setFont($font, null, $fontSizeText);
$pdf->Text(65.4, 63.5, $this->decode($ba->getFiscaleVille()));
//Benef Je désigne
$pdf->setFont($font, null, $fontSizeChecked);
$pdf->Text(13.1, 72.3, 'X');
$showCell = 0;
foreach($ba->getBeneficiaires() as $keyBenef => $beneficiaire){
switch ($keyBenef) {
case 0:
// code...
//Benef ligne 1
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(106.9);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 1:
//Benef ligne 2
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 126.8, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 131.3, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(121.5);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 2:
//Benef ligne 3
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 143.1, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 147.6, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(137.7);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 3:
//Benef ligne 4
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 159.4, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 164, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(153.9);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 4:
//Benef ligne 5
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 175.8, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 180.3, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(170.3);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 5:
//Benef ligne 6
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 192.1, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 196.6, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(186.8);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
case 6:
//Benef ligne 7
if($beneficiaire->getConditional() == "et"){
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 208.4, 'X');
}
else{
$pdf->setFont($font, null, 9);
$pdf->Text(16.3, 212.9, 'X');
}
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(30.4);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getNomUsage()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(54.3);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getNom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(77.9);
$pdf->MultiCell(21.5, 2, $this->decode($beneficiaire->getPrenom()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(102.1);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getAdresse()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(126.5);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getDateDeNaissance()->format("d/m/Y"))."\n".$this->decode($beneficiaire->getLieuDeNaissance()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(150.7);
$pdf->MultiCell(21, 2, $this->decode($beneficiaire->getLienParente()), $showCell, 'C', 0);
$pdf->setFont($font, null, 6);
$pdf -> SetY(203);
$pdf -> SetX(174.9);
$pdf->MultiCell(20.5, 2, $this->decode($beneficiaire->getPart()."%"), $showCell, 'C', 0);
break;
default:
// code...
break;
}
}
}
break;
default:
// code...
break;
}
}
$pdf->Output('F', $baFullPath);
return $baFileName;
}
public function formatString($stringLetters, $typeFormat = "default"){
$string = "";
$forNumber = 1;
$tabString = str_split($stringLetters);
foreach ($tabString as $keyLetter => $stringLetter) {
if($keyLetter > 0){
$string .= " ";
}
$string .= $stringLetter;
switch ($typeFormat) {
case 'iban':
if($forNumber == 4 && count($tabString) != ($keyLetter + 1)){
$string .= " ";
$forNumber = 0;
}
break;
case 'ss':
if($keyLetter == 0 || $keyLetter == 2 || $keyLetter == 4 || $keyLetter == 6 || $keyLetter == 9){
$string .= " ";
}
break;
default:
// code...
break;
}
$forNumber++;
}
return $string;
}
public function decode($value)
{
// convert from utf8 to latin1
return mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8');
}
}