223 lines
6.7 KiB
PHP
Executable File
223 lines
6.7 KiB
PHP
Executable File
<?php
|
|
require_once 'Framework/Controleurrequete.php'; // OK
|
|
require_once 'Modele/Statistique.php';
|
|
|
|
class ControleurAjaxdetailrapportspperiodefacturemail extends Controleur
|
|
{
|
|
private $detailsp;
|
|
private $mail_C;
|
|
|
|
public function __construct() {
|
|
$this->detailsp = new Statistique();
|
|
require_once 'Framework/Ebenegmail.php';
|
|
$this->mail_C = $mail;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
|
|
$debutStat = $_SESSION['debutStat'];
|
|
|
|
$finStat = $_SESSION['finStat'];
|
|
|
|
$idPolice = $this->requete->getParametreFormulaire("idPolice");
|
|
|
|
$email = $this->requete->getParametreFormulaire("emailRapport");
|
|
|
|
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
|
|
|
|
$detailsps = $this->detailsp->detailrapportspperiodefacturepdf($idPolice);
|
|
|
|
$pdf = new FPDF_Protection();
|
|
$pdf->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
|
|
$userPassword = '';
|
|
$ownerPassword = null;
|
|
$pdf->SetProtection(['print'], $userPassword, $ownerPassword);
|
|
|
|
$pdf->AliasNbPages();
|
|
$pdf->AddPage();
|
|
|
|
$pdf->SetMargins(15, 15, 15) ;
|
|
$pdf->Image($_SESSION['lienLogo'],94,3,18);
|
|
|
|
$pdf->Ln(10);
|
|
|
|
$pdf->SetFont('Arial','BU',10);
|
|
|
|
// $pdf->AliasNbPages();
|
|
$pdf->Cell(0,6,convertirc(_("RAPPORT CONSOMMATION DETAIL PAR FACTURES")),0,1,'C',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$pdf->SetFont('Arial','B',7);
|
|
$pdf->Cell(0,5,convertirc(_('Garant').' : '.$entete['garant']),0,1,'L',false);
|
|
$pdf->Cell(0,5,convertirc(_('Souscripteur').' : '.$entete['souscripteur']),0,1,'L',false);
|
|
$pdf->Cell(0,5,convertirc(_('Police').' No : '.$entete['numeroPolice'].' / '.$entete['libellePolice']),0,1,'L',false);
|
|
$pdf->Cell(0,5,convertirc(_('Période couverte').' : '.dateLang($entete['dateEffetPolice'], $_SESSION['lang']).' '._('au').' '.dateLang($entete['dateFinPolice'], $_SESSION['lang'])),0,1,'L',false);
|
|
$pdf->Cell(0,5,convertirc(_('Periode Analyse').' : '.dateLang($entete['debutAnalyse'], $_SESSION['lang']).' '._('au').' '.dateLang($entete['finAnalyse'], $_SESSION['lang'])),0,0,'L',false);
|
|
$pdf->Cell(0,5,'Edition : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$hl=5;
|
|
|
|
$pdf->Cell(11,$hl,convertirc(_('Mle')),"1",0,'C');
|
|
$pdf->Cell(45,$hl,convertirc(_('Adhérent')),"1",0,'C');
|
|
$pdf->Cell(45,$hl,convertirc(_('Bénéficiaire')),"1",0,'C');
|
|
$pdf->Cell(15,$hl,convertirc("Date"),"1",0,'C');
|
|
$pdf->Cell(40,$hl,convertirc(_('Prestataire')),"1",0,'C');
|
|
$pdf->Cell(14,$hl,convertirc(_('Montant')),"1",0,'C');
|
|
$pdf->Cell(10,$hl,convertirc(_('No Fac')),"1",1,'C');
|
|
|
|
$pdf->SetFont('Arial','I',6);
|
|
foreach ($detailsps as $detailsp)
|
|
{
|
|
$pdf->Cell(11,$hl,convertirc($detailsp['numeroAdherent']),"1",0,'C');
|
|
$pdf->Cell(45,$hl,convertirc(substr($detailsp['adherent'], 0, 33)),"1",0,'L');
|
|
$pdf->Cell(45,$hl,convertirc(substr($detailsp['beneficiaire'], 0,33)),"1",0,'L');
|
|
$pdf->Cell(15,$hl,convertirc(dateLang($detailsp['dateFacture'], $_SESSION['lang'])),"1",0,'C');
|
|
$pdf->Cell(40,$hl,convertirc(substr($detailsp['prestataire'], 0, 30)),"1",0,'L');
|
|
// $pdf->Cell(36,$ht,convertirc(substr($facture['souscripteur'], 0, 30)),1,0,'L',false);
|
|
$pdf->Cell(14,$hl,format_N($detailsp['montant']),"1",0,'C');
|
|
$pdf->Cell(10,$hl,convertirc($detailsp['facture']),"1",1,'C');
|
|
}
|
|
$pdf->SetFont('Arial','BI',6);
|
|
|
|
$pdf->Cell(156,$hl,convertirc("TOTAL"),"1",0,'C');
|
|
$pdf->Cell(14,$hl,format_N($detailsp['montantTotal']),"1",0,'C');
|
|
$pdf->Cell(10,$hl,"","1",1,'C');
|
|
|
|
$pdf->Ln(5);
|
|
|
|
$pdf->SetFont('Arial','BI', $tp);
|
|
|
|
if (est_anglophone())
|
|
{
|
|
$pdf->Cell(0,$ht,convertirc("Done at " . $_SESSION['villeSociete'].", on ".dateCouranteLang($_SESSION['lang'])),0,1,'C',false);
|
|
}
|
|
else
|
|
{
|
|
$pdf->Cell(0,$ht,convertirc("Fait à " . $_SESSION['villeSociete'].", le ".dateCouranteLang($_SESSION['lang'])),0,1,'C',false);
|
|
}
|
|
|
|
$pdf->Ln(10);
|
|
|
|
$pdf->SetFont('Arial','BU', $tp);
|
|
|
|
$pdf->Cell(0,$ht,convertirc(_("Le Souscripteur")),0,0,'L',false);
|
|
|
|
$pdf->Cell(0,$ht,convertirc(_("Le Gestionnaire")),0,0,'R',false);
|
|
|
|
|
|
|
|
// DEBUT ENVOI DU MAIL AVEC PIECE JOINTE
|
|
|
|
$mail_C = $this->mail_C;
|
|
|
|
$mail_C->ClearAllRecipients();
|
|
$mail_C->clearAttachments();
|
|
|
|
// pour envoi à moi seul
|
|
// $email = "kanelazeni@gmail.com";
|
|
// fin envoi à moi seul
|
|
|
|
$addr = explode(';', $email);
|
|
|
|
foreach ($addr as $ad)
|
|
{
|
|
if(tester_une_adresse_email($ad))
|
|
{
|
|
$mail_C->AddAddress(trim($ad) );
|
|
}
|
|
else
|
|
{
|
|
// echo "Veuillez revoir cette adresse PHP : " . $ad;
|
|
// exit();
|
|
}
|
|
}
|
|
|
|
// $mail_C->AddCC("lkane@ebene.info");
|
|
if (est_anglophone())
|
|
{
|
|
// $fichier="Temp/DET_FAC_".$idPolice."_".$dateAnalyse."_".uniqid().".pdf";
|
|
$fichier="Temp/DETAILS_OF_".$debutStat."_".$finStat."_".uniqid().".pdf";
|
|
// $fichier="CONSO_FAM_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "DETAILS OF ".$debutStat." TO ".$finStat;
|
|
|
|
$body = convertirc("Dear Customer,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Hope this email find you well,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Please find attached your detailed consumption report by invoice and by family on the date ".$debutStat." to ".$finStat).'.';
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("You can share those informations with every one and if any more clarification do not hesitate to contact us for more details.");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Kind Regards.");
|
|
|
|
$altbody = "SEE ATTACHMENT";
|
|
}
|
|
else
|
|
{
|
|
$fichier="Temp/DETAIL_FACTURE_".$debutStat."_".$finStat."_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "DETAIL DES FACTURES DU ".$debutStat." AU ".$finStat;
|
|
|
|
$body = convertirc("Cher Client,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Nous vous prions de trouver en pièce jointe votre rapport de consommations détaillé par facture et par famille à la date du ".$debutStat." au ".$finStat).'.';
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Vous pouvez partager ces informations avec tout le monde et si vous avez besoin de précisions,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("N'hésitez pas à nous contacter pour plus de détails.");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Cordialement!");
|
|
|
|
$altbody = "VOIR PIECE JOINTE";
|
|
}
|
|
|
|
$obejt = convertirc($obejt);
|
|
|
|
$pj = $fichier;
|
|
|
|
$mail_C->Subject = $obejt;
|
|
|
|
$mail_C->AltBody = $altbody;
|
|
$mail_C->Body=$body;
|
|
|
|
$mail_C->addAttachment($pj);
|
|
|
|
if (!$mail_C->send())
|
|
{
|
|
// echo "Erreur mail : " . $mail_C->ErrorInfo;
|
|
}
|
|
else
|
|
{
|
|
// echo "Message envoyé!";
|
|
}
|
|
|
|
// FIN ENVOI DU MAIL AVEC PIECE JOINTE
|
|
|
|
// supprimons le fichier
|
|
unlink ($pj);
|
|
}
|
|
} |