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

278 lines
10 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Reglement.php';
require_once 'Modele/Prestataire.php';
class ControleurAjaximprimercourierreglementcpt extends Controleurrequete
{
private $reglement;
private $prestataire;
public function __construct()
{
$this->reglement = new Reglement();
$this->prestataire = new Prestataire();
}
public function index()
{
$codePrestataire = $this->requete->getParametreFormulaire("codePrestataire");
$codeTypePrestataire = $this->requete->getParametreFormulaire("codeTypePrestataire");
$datedebut = $this->requete->getParametreDate("datedebut");
$datefin = $this->requete->getParametreDate("datefin");
$pdf = new FPDF_Protection();
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = '';
$ownerPassword = null;
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
if ($codePrestataire== ''){
$codePrestataire = null ;
}
if ($codeTypePrestataire== ''){
$codeTypePrestataire = null ;
}
$prestataires = $this->reglement->getprestatairereglementcpt($codePrestataire,$datedebut,$datefin,$codeTypePrestataire);
foreach ($prestataires as $prestataire){
//ajout 23/06/2023
$codePrestataire = $prestataire['codePrestataire'];
$idReglement = $prestataire['idReglement'];
$codeMois = $prestataire['codeMois'];
$codeExercice = $prestataire['codeExercice'];
$numeroDecompte = $prestataire['numeroDecompte'];
$numeroLotDecompte = $prestataire['numeroDecompte'];
$prestations = $this->reglement->getprestataionreglementcpt($codePrestataire,$numeroDecompte);
$motifrejets = $this->reglement->getmotifcourriercpt($codePrestataire,$datedebut,$datefin);
$reglement = $this->reglement->getreglement($idReglement);
// fin
/*
$prestations = $this->reglement->getprestataionreglementcpt($codePrestataire,$datedebut,$datefin);
$motifrejets = $this->reglement->getmotifcourriercpt($codePrestataire,$datedebut,$datefin );
$reglement = $this->reglement->getreglement($idReglement );
*/
$pdf->AddPage();
$pdf->AliasNbPages();
$ht=10;
$lg=60;
$pdf->SetMargins(10, 10, 10) ;
$pdf->Image($_SESSION['lienLogo'], 10, 3, 20);
$pdf->SetFont('Arial', 'B', 7);
//$pdf->SetY(10);
// $pdf->SetFont('Arial', '', 7);
// $pdf->Cell(0, 5, 'Edition du : '.heureCouranteLang($_SESSION['lang']), 0, 1, 'R', false);
$pdf->Ln(2);
$pdf->SetFont('Arial', 'B', 13);
$pdf->SetFont('Arial','B', 15);
$pdf->SetY(20);
// $pdf->Cell(0,10,convertirc($_SESSION['nomSociete'] ),1,1,'C',false);
$pdf->SetFont('Arial','BU', 15);
$pdf->SetFontSize(14);
$pdf->Cell(0,10,convertirc(_(strtoupper($reglement['prestataire']))),0,1,'C',false);
$pdf->Ln(5);
$pdf->SetFont('Arial','B', 11);
$pdf->Cell(50,10,convertirc(_("No Lot Decompte")),0,0,'L',false);
$pdf->SetFont('Arial','I',11);
$pdf->Cell(50,10,convertirc(': '.$reglement['numeroLotDecompte']),0,1,'L');
$pdf->SetFont('Arial','B', 11);
$pdf->Cell(50,10,convertirc(_("No Decompte")),0,0,'L',false);
$pdf->SetFont('Arial','I',11);
$pdf->Cell(50,10,convertirc(': '.$reglement['numeroDecompte']),0,1,'L');
$pdf->Cell(0,10,convertirc($_SESSION['villeSociete'].', le ').dateLang($_SESSION['dateAnalyse_C'],$_SESSION['lang']),0,1,'C',false);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(20,10,convertirc('OBJET :'),0,0,'L',false);
$pdf->SetFont('Arial','B', 12);
// highlight_string("<?php\n\$datas =\n" . var_export($_SESSION , true) . ";\n>");
if (est_anglophone())
{
$pdf->Cell(180,10,convertirc('Réglement des prestations de : '.$reglement['periodeEng']),0,1,'L',false);
}
else
{
$pdf->Cell(180,10,convertirc('Réglement des prestations de '.$reglement['periode']),0,1,'L',false);
}
$pdf->Ln(2);
$pdf->SetFont('Arial','', 10);
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
$pdf->Cell(10,10,convertirc('Madame, Monsieur '),0,1,'L',false);
$pdf->Cell(180,10,convertirc('Nous vous prions de trouver ci-dessous le détail des réglements effectués.'),0,1,'L',false);
$pdf->SetFont('Arial','B', 11);
$pdf->Ln(2);
$pdf->Cell(95,10,convertirc(_("Garant")),0,0,'L',false);
$pdf->Cell(15,10,"",0,0,'C',false);
$pdf->Cell(25,10,convertirc(_("Facture")),0,0,'R',false);
$pdf->Cell(25,10,convertirc(_("Réclamé")),0,0,'R',false);
$pdf->Cell(30,10,convertirc(_("Réglé")),0,1,'R',false);
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
$pdf->SetFont('Arial','', 9);
$MontantApayerTotal=0;
foreach ($prestations as $prestation) {
$pdf->Cell(95,6,convertirc(_($prestation['Garant'])),0,0,'L',false);
$pdf->Cell(15,6,'---',0,0,'C',false);
$pdf->Cell(25,6,convertirc(_($prestation['nbFactures'])),0,0,'R',false);
$pdf->Cell(25,6,convertirc(format_N($prestation['montantReclamer'])),0,0,'R',false);
$pdf->Cell(30,6,convertirc(format_N($prestation['montantApayer'])),0,1,'R',false);
$MontantApayerTotal = $MontantApayerTotal + $prestation['montantApayer'];
}
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(40,8,convertirc(_("Mode de reglement")),0,0,'L',false);
$pdf->Cell(30,8,convertirc(_("Référence")),0,0,'C',false);
$pdf->Cell(30,8,convertirc(_("Banque")),0,0,'C',false);
$pdf->Cell(60,8,convertirc(_("Solde :")),0,0,'R',false);
$pdf->Cell(30,8,convertirc(format_N($MontantApayerTotal)),0,1,'R',false);
$pdf->Cell(40,8,convertirc(_($prestation['modeR'])),0,0,'L',false);
$pdf->Cell(30,8,convertirc(_($prestation['Reference'])),0,0,'C',false);
$pdf->Cell(30,8,convertirc(_($prestation['Banque'])),0,0,'C',false);
$pdf->Cell(60,8,convertirc(_("Montant préfinancé :")),0,0,'R',false);
$pdf->Cell(30,8,"0",0,1,'R',false);
$pdf->Cell(130,8,convertirc(_()),0,0,'L',false);
$pdf->Cell(30,8,convertirc(_("Retenue BNC :")),0,0,'R',false);
$pdf->Cell(30,8,"0",0,1,'R',false);
$pdf->Cell(130,8,convertirc(_()),0,0,'L',false);
$pdf->Cell(30,8,convertirc(_("Retenue Avance :")),0,0,'R',false);
$pdf->Cell(30,8,"0",0,1,'R',false);
$pdf->Cell(130,8,convertirc(_()),0,0,'L',false);
$pdf->Cell(30,8,convertirc(_("Net à payer :")),0,0,'R',false);
$pdf->Cell(30,8,convertirc(format_N($MontantApayerTotal)),0,1,'R',false);
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
$pdf->Ln(3);
$pdf->SetFont('Arial','B', 10);
$pdf->MultiCell(190,6,convertirc("Vous en souhaitant bonne réception, veuillez agréer, Madame, Monsieur, l'expression de nos sentiments distingués ."),0,false);
$pdf->MultiCell(190,6,convertirc("NB : Vous trouverez le détail du paiement sur notre plateforme (VISUEL/CONSULTATION DES DECOMPTES)."),0,false);
$pdf->Ln(8);
$pdf->SetFont('Arial','B', 11);
$pdf->Cell(130,6,convertirc(_("Paiement à l'ordre de :")),0,0,'L',false);
$pdf->Cell(25,6,"",0,0,'R',false);
$pdf->Cell(25,6,convertirc(_("Service Comptabilité")),0,1,'R',false);
$pdf->Cell(130,6,convertirc(_($reglement['prestataire'])),0,0,'L',false);
$pdf->Cell(25,6,"",0,0,'R',false);
$pdf->Cell(25,6,"",0,1,'R',false);
$pdf->Ln(30);
// highlight_string("<?php\n\$datas =\n" . var_export($motifrejets, true) . ";\n>");
if (!empty($motifrejets)){
$pdf->AddPage('L');
$pdf->SetFont('Arial','BU', 15);
$pdf->SetFontSize(14);
$pdf->Cell(0,10,convertirc(_(strtoupper("Details regularisations"))),0,1,'C',false);
$pdf->Ln(5);
$pdf->SetFont('Arial','B', 11);
$pdf->Cell(50,10,convertirc(_("No Lot Decompte")),0,0,'L',false);
$pdf->SetFont('Arial','I',11);
$pdf->Cell(50,10,convertirc(': '.$reglement['numeroLotDecompte']),0,1,'L');
$pdf->SetFont('Arial','B', 11);
$pdf->Cell(50,10,convertirc(_("No Decompte")),0,0,'L',false);
$pdf->SetFont('Arial','I',11);
$pdf->Cell(50,10,convertirc(': '.$reglement['numeroDecompte']),0,1,'L');
$pdf->SetFont('Arial','B', 12);
$pdf->Ln(2);
$pdf->SetFont('Arial','', 10);
$pdf->SetFont('Arial','B', 11);
$pdf->Ln(2);
$pdf->SetFillColor(245,245,245);
$pdf->Cell(15,10,convertirc(_("Bon No")),0,0,'L',TRUE);
$pdf->Cell(36,10,convertirc(_("No Bénéficiaire")),0,0,'L',TRUE);
$pdf->Cell(70,10,convertirc(_("Bénéficiaire")),0,0,'C',TRUE);
$pdf->Cell(19,10,convertirc(_("Réclamé")),0,0,'R',TRUE);
$pdf->Cell(19,10,convertirc(_("Exclu")),0,0,'R',TRUE);
$pdf->Cell(19,10,convertirc(_("A payer")),0,0,'R',TRUE);
$pdf->Cell(100,10,convertirc(_("Observation")),0,1,'L',TRUE);
$pdf->SetFont('Arial','', 10);
foreach ($motifrejets as $motifrejet) {
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(15,7,convertirc(_($motifrejet['numeroBon'])),0,0,'C',false);
$pdf->SetFont('Arial','', 10);
$pdf->Cell(36,7,convertirc(_($motifrejet['numeroBeneficiaire'])),0,0,'C',false);
$pdf->Cell(70,7,convertirc(_($motifrejet['beneficiaire'])),0,0,'L',false);
$pdf->Cell(19,7,convertirc(format_N($motifrejet['reclamer'])),0,0,'R',false);
$pdf->Cell(19,7,convertirc(format_N($motifrejet['montantExclues'])),0,0,'R',false);
$pdf->Cell(19,7,convertirc(format_N($motifrejet['Apayer'])),0,0,'R',false);
//$pdf->Cell(70,10,convertirc(_($motifrejet['MotifExclusion'])),0,0,'L',false);
$pdf->MultiCell(100,7,convertirc(strtoupper($motifrejet['MotifExclusion'])),0,false);
}
$pdf->Cell(0,0,convertirc(_()),1,1,'C',false);
}
$pdf->AddPage();
}
$fichier="Temp/TMP_Courrier_de_reglement"."_".uniqid().".pdf";
$pdf->Output($fichier,"F");
$t_html =' <div id ="div_wait" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
}
}