237 lines
6.5 KiB
PHP
Executable File
237 lines
6.5 KiB
PHP
Executable File
<?php
|
|
require_once 'Functions.php';
|
|
|
|
class Cronenvoimailconsoparfamille
|
|
{
|
|
|
|
public function __construct() {
|
|
|
|
}
|
|
|
|
public function chargerconsoperiodefamille(){
|
|
require_once 'Statistique.php';
|
|
|
|
$this->detailsp = new Statistique();
|
|
|
|
$debutStat = date("Y-m-d", mktime(0,0,0,date("m")-1,1,date("Y")));
|
|
$finStat = date("Y-m-d", mktime(0,0,0,date("m"),0,date("Y")));
|
|
|
|
$consos = $this->detailsp->etatrapportspadherentperiode($debutStat, $finStat);
|
|
|
|
$nb = count($consos);
|
|
|
|
foreach ($consos as $v)
|
|
{
|
|
if ($v['email']>" "){
|
|
$this->lancemailpdf($v['idAdherent'], $v['email'], $debutStat, $finStat);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function lancemailpdf($idAdherent, $email, $debutStat, $finStat)
|
|
{
|
|
require_once 'Ebenegmail.php';
|
|
require_once 'Fpdf/fpdf_protection.php';
|
|
require_once 'Societeuser.php';
|
|
|
|
// $this->mail_C = $mail;
|
|
$this->mail_C = $_SESSION['c_mail'];
|
|
|
|
$this->ste = new Societeuser();
|
|
|
|
$societe = $this->ste->getparametressociete();
|
|
|
|
$entete = $this->detailsp->detailrapportspadhperiodepdfentete($idAdherent, $debutStat, $finStat);
|
|
|
|
$detailsps = $this->detailsp->detailrapportspadhperiodefacturepdf($idAdherent, $debutStat, $finStat);
|
|
|
|
// $pdf = new FPDF();
|
|
$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('Img/logo_societe.png',94,3,18);
|
|
|
|
$tp = 9;
|
|
$ht = 6;
|
|
|
|
$pdf->Ln(10);
|
|
|
|
$pdf->SetFont('Arial','BU',10);
|
|
|
|
// $pdf->AliasNbPages();
|
|
$pdf->Cell(0,6,_('DETAIL DES FACTURES FAMILLE'),0,1,'C',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$pdf->SetFont('Arial','B',7);
|
|
|
|
$pdf->Cell(0,5,_('Garant').' : '.$entete['garant'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_('Souscripteur').' : '.$entete['souscripteur'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_('Police').' No : '.$entete['numeroPolice'].' / '.$entete['libellePolice'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_(convertirc('Adhérent')).' Mle : '.$entete['numeroAdherent'].' / '.$entete['adherent'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_(convertirc('Période couverte')).' : '.dateLang($entete['dateEffetAdherent'], $_SESSION['lang']).' '._('au').' '.dateLang($entete['dateFinAdherent'], $_SESSION['lang']),0,1,'L',false);
|
|
$pdf->Cell(0,5,_(convertirc('Période Analyse')).' : '.dateLang($entete['debutAnalyse'], $_SESSION['lang']).' '._('au').' '.dateLang($entete['finAnalyse'], $_SESSION['lang']),0,1,'L',false);
|
|
$pdf->Cell(0,5,'Edition : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$hl=5;
|
|
|
|
$pdf->Cell(20,$hl,_('Matricule'),"1",0,'C');
|
|
$pdf->Cell(65,$hl,convertirc(_('Bénéficiaire')),"1",0,'C');
|
|
$pdf->Cell(15,$hl,"Date","1",0,'C');
|
|
$pdf->Cell(50,$hl,_('Prestataire'),"1",0,'C');
|
|
$pdf->Cell(15,$hl,_('Montant'),"1",0,'C');
|
|
$pdf->Cell(15,$hl,_('No Fact'),"1",1,'C');
|
|
|
|
$pdf->SetFont('Arial','I',6);
|
|
foreach ($detailsps as $detailsp)
|
|
{
|
|
$pdf->Cell(20,$hl,$detailsp['numeroBeneficiaire'],"1",0,'L');
|
|
$pdf->Cell(65,$hl,$detailsp['beneficiaire'],"1",0,'L');
|
|
$pdf->Cell(15,$hl,dateLang($detailsp['dateFacture'], $_SESSION['lang']),"1",0,'C');
|
|
$pdf->Cell(50,$hl,$detailsp['prestataire'],"1",0,'L');
|
|
$pdf->Cell(15,$hl,format_N($detailsp['montant']),"1",0,'C');
|
|
$pdf->Cell(15,$hl,$detailsp['facture'],"1",1,'C');
|
|
}
|
|
$pdf->SetFont('Arial','BI',6);
|
|
|
|
$pdf->Cell(150,$hl,"TOTAL","1",0,'C');
|
|
$pdf->Cell(15,$hl,format_N($detailsp['montantTotal']),"1",0,'C');
|
|
$pdf->Cell(15,$hl,"","1",1,'C');
|
|
|
|
$pdf->Ln(5);
|
|
|
|
$pdf->SetFont('Arial','BI', $tp);
|
|
|
|
if (est_anglophone())
|
|
{
|
|
$pdf->Cell(0,$ht,"Done at " . $societe['ville'].", on ".dateCouranteLang($_SESSION['lang']),0,1,'C',false);
|
|
}
|
|
else
|
|
{
|
|
$pdf->Cell(0,$ht,convertirc("Fait à ") . $societe['ville'].", le ".dateCouranteLang($_SESSION['lang']),0,1,'C',false);
|
|
}
|
|
|
|
$pdf->Ln(10);
|
|
|
|
$pdf->SetFont('Arial','BU', $tp);
|
|
|
|
$pdf->Cell(0,$ht,_(convertirc("L'Assuré")),0,1,'C',false);
|
|
|
|
$pdf->Cell(0,$ht,_("Le Souscripteur"),0,0,'L',false);
|
|
|
|
$pdf->Cell(0,$ht,_("Le Gestionnaire"),0,0,'R',false);
|
|
|
|
// DEBUT ENVOI DU MAIL AVEC PIECE JOINTE
|
|
|
|
$mail_C = $this->mail_C;
|
|
|
|
$mail_C->ClearAllRecipients();
|
|
$mail_C->clearAttachments();
|
|
|
|
$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();
|
|
}
|
|
}
|
|
|
|
if (est_anglophone())
|
|
{
|
|
$fichier="FAM_INVOICE_DETAIL_".$debutStat."_".$finStat."_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "FAMILY INVOICE DETAIL : ".$debutStat." TO ".$finStat;
|
|
|
|
$body = "Dear Customer,";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Hope this email find you well,";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Please find attached your consumption report by family for the period from ".$debutStat." to ".$finStat.'.';
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "We remain at your disposal and available for any additional information desired.";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Kind Regards.";
|
|
|
|
$altbody = "SEE ATTACHMENT";
|
|
}
|
|
else
|
|
{
|
|
$fichier="DETAIL_FACTURE_FAMILLE_".$debutStat."_".$finStat."_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "DETAIL DES FACTURES : ".$debutStat." AU ".$finStat;
|
|
|
|
$body = "Cher Client,";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Nous vous prions de trouver en pièce jointe votre rapport de consommations par famille pour la période du ".$debutStat." au ".$finStat.'.';
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Nous restons à votre écoute et disponible pour toute information complémentaire souhaitée.";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Portez-vous bien,";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Cordialement!";
|
|
|
|
$altbody = "VOIR PIECE JOINTE";
|
|
}
|
|
|
|
$obejt = $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é!";
|
|
}
|
|
|
|
// supprimons le fichier
|
|
unlink ($pj);
|
|
}
|
|
}
|
|
|
|
$envoimail = new Cronenvoimailconsoparfamille();
|
|
|
|
$envoimail->chargerconsoperiodefamille(); |