production/Controleur/ControleurAjaximprimerrecucaisse.php
2025-12-02 11:29:44 +00:00

285 lines
10 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Societes/'.$_SESSION['codeSociete'].'/Etats/TbRecucaisse.php';
require_once 'Societes/'.$_SESSION['codeSociete'].'/Etats/Pdfentete.php';
require_once 'Societes/'.$_SESSION['codeSociete'].'/Etats/Societeuser.php';
// require_once 'Societes/'.$_SESSION['codeSociete'].'/Etats/Etrecucaisse.php';
require_once 'Modele/Encaissementgarant.php';
require_once 'Modele/Detailencaissementgarant.php';
class ControleurAjaximprimerrecucaisse extends Controleurrequete
{
private $etrecu;
private $societeuser;
private $encaissement;
private $detailencaissement;
public function __construct()
{
$this->etrecu = new TbRecucaisse();
$this->societeuser = new Societeuser();
$this->encaissement = new Encaissementgarant();
$this->detailencaissement = new Detailencaissementgarant();
}
public function index()
{
$idEncaissement = $this->requete->getParametreFormulaire("idEncaissement");
$etrecu = $this->etrecu->recuAimprimer($idEncaissement);
$etdetailrecus = $this->etrecu->detailsrecuAimprimer($idEncaissement);
$societeuser = $this->societeuser->getSocieteuser($_SESSION['codeSociete']);
$pdf = new Pdfentete('P','mm','A4');
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = $_SESSION['motPassPdf'];
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
$pdf->SetMargins(15, 15, 15) ;
$pdf->SetFont('Arial','',15);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Sety(20);
$pdf->SetX(60);
$pdf->Cell(100,12,convertirc($societeuser['nomSociete']),1,1,'C',false);
$pdf->SetFontSize(7);
$pdf->Cell(0,5,'Edition : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
$pdf->SetFontSize(8);
$pdf->Cell(0,5,convertirc('Tel : '.$societeuser['telephoneSociete']),0,1,'C',false);
$pdf->Cell(0,5,convertirc(_("Adresse Post") . " : " . $societeuser['adressePostSociete']),0,1,'C',false);
$pdf->Cell(0,5,convertirc(_("Registre Commerce") . " : " . $societeuser['registreCommerce']),0,1,'C',false);
$pdf->SetFontSize(15);
$pdf->Ln(5);
$pdf->Cell(0,12,convertirc(_("RECU ENCAISSEMENT") . " No : " . $etrecu['numeroEncaissement']),1,1,'C',false);
$pdf->SetFontSize(8);
$pdf->Cell(40,6,convertirc(_('Reçu de')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.$etrecu['nomTireur']),0,1,'L');
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('La somme de')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.format_N($etrecu['montant'])." ".$_SESSION['devise_C']),0,1,'L');
$pdf->SetFont('Arial','',8);
$pdf->SetFont('Arial','I',8);
$pdf->Cell(0,6, convetirEnLettre($etrecu['montant'], $_SESSION['lang'])." ".$_SESSION['devise_C'],1,1,'C');
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('Mode Paiement')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
if (est_anglophone())
{
$pdf->Cell(100,6,convertirc(': '.$etrecu['modepaiementEng']),0,1,'L');
}
else
{
$pdf->Cell(100,6,convertirc(': '.$etrecu['modepaiement']),0,1,'L');
}
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('Référence paiement')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.$etrecu['referencePaiement']),0,1,'L');
$pdf->SetFont('Arial','BU',8);
$pdf->Cell(0,6,convertirc(_("Polices payées")." : "),0,1,'L',false);
$pdf->SetFont('Arial','',8);
$hl=5;
$pdf->SetFont('Arial','B',8);
$pdf->Cell(85,$hl,convertirc(_('Client')),"1",0,'C');
$pdf->Cell(25,$hl,convertirc(_('No Police')),"1",0,'C');
$pdf->Cell(15,$hl,convertirc(_('Quit')),"1",0,'C');
$pdf->Cell(18,$hl,convertirc(_('Effet')),"1",0,'C');
$pdf->Cell(18,$hl,convertirc(_('Echéance')),"1",0,'C');
$pdf->Cell(20,$hl,convertirc(_("Montant")),"1",1,'C');
$pdf->SetFont('Arial','I',8);
foreach ($etdetailrecus as $detailencaissement)
{
$pdf->Cell(85,$hl,convertirc($detailencaissement['nomClient']),"1",0,'L');
$pdf->Cell(25,$hl,convertirc($detailencaissement['numeroPolice']),"1",0,'C');
$pdf->Cell(15,$hl,convertirc($detailencaissement['numeroQuittance']),"1",0,'C');
$pdf->Cell(18,$hl,convertirc(dateFr($detailencaissement['dateEffet'])),"1",0,'C');
$pdf->Cell(18,$hl,convertirc(dateFr($detailencaissement['dateEcheance'])),"1",0,'C');
$pdf->Cell(20,$hl,format_N($detailencaissement['primeTtc']),"1",1,'C');
}
$pdf->SetFont('Arial','',8);
$pdf->SetFontSize(10);
$pdf->SetY(-60);
$pdf->Cell(0,10,convertirc(_('Fait à').' '.$_SESSION['villeSociete'].', le ').dateFr($etrecu['dateCre']),0,1,'C',false);
$pdf->SetFont('','U');
$pdf->Cell(0,10,convertirc(_('La caisse').' : '.$etrecu['caissiere']),0,0,'C',false);
// création du fichier
$uniqid = uniqid();
$to_upload="Temp/TMP_recu_caisse_$uniqid.pdf";
$fichierTemp="Temp/$uniqid.pdf";
$pdf->Output($fichierTemp,"F");
// $fichier = pdf_to_image($fichierTemp, $to_upload, $uniqid, "0"); // => Pour cnvertir en image => eviter la cibversion en Word
$fichier = $fichierTemp;
$t_html =' <div id ="div_export_a" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
public function garant()
{
$idEncaissement = $this->requete->getParametreFormulaire("idEncaissement");
$etrecu = $this->etrecu->recuGarantAimprimer($idEncaissement);
$etdetailrecus = $this->etrecu->detailsrecuGarantAimprimer($idEncaissement);
$societeuser = $this->societeuser->getSocieteuser($_SESSION['codeSociete']);
$pdf = new Pdfentete();
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = $_SESSION['motPassPdf'];
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
$pdf->SetMargins(15, 15, 15) ;
$pdf->SetFont('Arial','',15);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Sety(20);
$pdf->SetX(60);
$pdf->Cell(100,12,convertirc($societeuser['nomSociete']),1,1,'C',false);
$pdf->SetFontSize(7);
$pdf->Cell(0,5,'Edition : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
$pdf->SetFontSize(8);
$pdf->Cell(0,5,convertirc('Tel : '.$societeuser['telephoneSociete']),0,1,'C',false);
$pdf->Cell(0,5,convertirc(_("Adresse Post") . " : " . $societeuser['adressePostSociete']),0,1,'C',false);
$pdf->Cell(0,5,convertirc(_("Registre Commerce") . " : " . $societeuser['registreCommerce']),0,1,'C',false);
$pdf->SetFontSize(15);
$pdf->Ln(5);
$pdf->Cell(0,12,convertirc(_("RECU ENCAISSEMENT GARANT") . " No : " . $etrecu['numeroEncaissementImprime']),1,1,'C',false);
$pdf->SetFontSize(8);
$pdf->Cell(40,6,convertirc(_('Reçu de')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.$etrecu['nomTireur']),0,1,'L');
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('La somme de')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.format_N($etrecu['montant'])." ".$_SESSION['devise_C']),0,1,'L');
$pdf->SetFont('Arial','',8);
$pdf->SetFont('Arial','I',8);
$pdf->Cell(0,6, convetirEnLettre($etrecu['montant'], $_SESSION['lang'])." ".$_SESSION['devise_C'],1,1,'C');
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('Mode Paiement')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
if (est_anglophone())
{
$pdf->Cell(100,6,convertirc(': '.$etrecu['modepaiementEng']),0,1,'L');
}
else
{
$pdf->Cell(100,6,convertirc(': '.$etrecu['modepaiement']),0,1,'L');
}
$pdf->SetFont('Arial','',8);
$pdf->Cell(40,6,convertirc(_('Références paiement')),0,0,'L',false);
$pdf->SetFont('Arial','BI',8);
$pdf->Cell(100,6,convertirc(': '.$etrecu['referencePaiement']),0,1,'L');
$pdf->SetFont('Arial','BU',8);
$pdf->Cell(0,6,convertirc(_("Factures payées")." : "),0,1,'L',false);
$pdf->SetFont('Arial','',8);
$hl=5;
$pdf->SetFont('Arial','B',8);
$pdf->Cell(36,$hl,convertirc(_('Groupe')),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(_('No')),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(_('Date Facture')),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(_('Type Facture')),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(_('Encaissement')),"1",1,'C');
$pdf->SetFont('Arial','I',8);
foreach ($etdetailrecus as $v)
{
$pdf->Cell(36,$hl,convertirc($v['numeroGroupeFactureImprime']),"1",0,'C');
$pdf->Cell(36,$hl,convertirc($v['numeroFactureImprime']),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(dateLang($v['dateFacture'])),"1",0,'C');
$pdf->Cell(36,$hl,convertirc($v['typefacturationgarant']),"1",0,'C');
$pdf->Cell(36,$hl,convertirc(format_N($v['montantTtc'])),"1",1,'C');
}
$pdf->SetFont('Arial','',8);
$pdf->SetFontSize(10);
$pdf->SetY(-60);
$pdf->Cell(0,10,convertirc(_('Fait à').' '.$_SESSION['villeSociete'].', le ').dateFr($etrecu['dateSysteme']),0,1,'C',false);
$pdf->SetFont('','U');
$pdf->Cell(0,10,convertirc(_('La caisse').' : '.$etrecu['caissiere']),0,0,'C',false);
// création du fichier
$uniqid = uniqid();
$to_upload="Temp/TMP_recu_caisse_$uniqid.pdf";
$fichierTemp="Temp/$uniqid.pdf";
$pdf->Output($fichierTemp,"F");
// $fichier = pdf_to_image($fichierTemp, $to_upload, $uniqid, "0"); // => Pour cnvertir en image => eviter la cibversion en Word
$fichier = $fichierTemp;
$t_html =' <div id ="div_export_a" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
public function garantpop()
{
$idEncaissement = $this->requete->getParametreFormulaire("idEncaissement");
$encaissement = $this->encaissement->getEncaissementId($idEncaissement);
$detailencaissements = $this->detailencaissement->getDetailsEncaissement($idEncaissement);
$this->genererVueAjax(array(
'encaissement' => $encaissement,
'detailencaissements' => $detailencaissements
));
}
}