201 lines
5.7 KiB
PHP
Executable File
201 lines
5.7 KiB
PHP
Executable File
<?php
|
|
require_once 'Functions.php';
|
|
require_once 'Controleurrequete.php';
|
|
require_once 'Statistique.php';
|
|
|
|
class Emailrapprtsp
|
|
{
|
|
private $rapportsp;
|
|
private $mail_C;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->rapportsp = new Statistique();
|
|
require_once 'Ebenegmail.php';
|
|
$this->mail_C = $mail;
|
|
}
|
|
|
|
public function excutercron()
|
|
{
|
|
$polices = $this->rapportsp->listepolicerapportspmail();
|
|
|
|
foreach ($polices as $police)
|
|
{
|
|
$dateAnalyse = $police['dateAnalyse'];
|
|
$idPolice = $police['idPolice'];
|
|
$email = $police['email'];
|
|
|
|
$this->detailrapportsppdf($idPolice, $dateAnalyse, $email);
|
|
}
|
|
}
|
|
|
|
public function detailrapportsppdf($idPolice, $dateAnalyse, $email)
|
|
{
|
|
$entete = $this->rapportsp->detailrapportsppdfentete($idPolice, $dateAnalyse);
|
|
|
|
$detailsps = $this->rapportsp->detailrapportsppdf($idPolice, $dateAnalyse);
|
|
|
|
$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->SetFont('Arial','BU',10);
|
|
|
|
// $pdf->AliasNbPages();
|
|
$pdf->Cell(0,6,$entete['nomAssureur'] . " : " . _("RAPPORT SINISTRE A PRIME PAR FAMILLE"),0,1,'C',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$pdf->SetFont('Arial','B',7);
|
|
|
|
$pdf->Cell(0,5,_('Souscripteur').' : '.$entete['souscripteur'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_('No Police').' : '.$entete['numeroPolice'],0,1,'L',false);
|
|
$pdf->Cell(0,5,'E-mail : '.$email,0,1,'L',false);
|
|
$pdf->Cell(0,5,_(convertirc('Période couverte')).' : '.$entete['dateEffetPolice'].' '._('au').' '.$entete['dateFinPolice'],0,1,'L',false);
|
|
$pdf->Cell(0,5,_('Date Analyse').' : '.$entete['dateAnalyse'],0,0,'L',false);
|
|
$pdf->Cell(0,5,'Edition : '.heureCouranteLang($_SESSION['lang']),0,1,'R',false);
|
|
|
|
$pdf->Ln(2);
|
|
|
|
$hl=5;
|
|
|
|
$pdf->Cell(60,$hl,convertirc(_('Adhérent')),"1",0,'C');
|
|
$pdf->Cell(15,$hl,convertirc(_('Date Effet')),"1",0,'C');
|
|
$pdf->Cell(10,$hl,convertirc(_('Jours')),"1",0,'C');
|
|
$pdf->Cell(25,$hl,convertirc(_('Prime An')),"1",0,'C');
|
|
$pdf->Cell(25,$hl,convertirc(_('Prim Acq')),"1",0,'C');
|
|
$pdf->Cell(25,$hl,convertirc(_('Sinistres')),"1",0,'C');
|
|
$pdf->Cell(20,$hl,convertirc("Ratio"),"1",1,'C');
|
|
|
|
$pdf->SetFont('Arial','I',7);
|
|
foreach ($detailsps as $detailsp)
|
|
{
|
|
$pdf->Cell(60,$hl,convertirc($detailsp['adherent']),"1",0,'L');
|
|
$pdf->Cell(15,$hl,$detailsp['dateEffetAdherent'],"1",0,'C');
|
|
$pdf->Cell(10,$hl,$detailsp['duree_acq'],"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['primeAnnuelle']),"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['primeAcquise']),"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['sinistres']),"1",0,'C');
|
|
$pdf->Cell(10,$hl,$detailsp['rapportSp'],"1",0,'C');
|
|
$pdf->Cell(10,$hl,$detailsp['rapportSpAn'],"1",1,'C');
|
|
}
|
|
$pdf->SetFont('Arial','BI',7);
|
|
|
|
$pdf->Cell(85,$hl,convertirc("TOTAL"),"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['primeAnnuelleTotal']),"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['primeAcquiseTotal']),"1",0,'C');
|
|
$pdf->Cell(25,$hl,format_N($detailsp['sinistresTotal']),"1",0,'C');
|
|
$pdf->Cell(10,$hl,$detailsp['rapportSpTotal'],"1",0,'C');
|
|
$pdf->Cell(10,$hl,$detailsp['rapportSpTotalAn'],"1",1,'C');
|
|
|
|
// 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) );
|
|
}
|
|
}
|
|
|
|
if (est_anglophone())
|
|
{
|
|
$fichier="SUMMARY_END_".$dateAnalyse."_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "SUMMARY END : ".$dateAnalyse;
|
|
|
|
$body = convertirc("Dear Customer,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Hope this email find you well,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= convertirc("Attached file is claims report of your staff from starting date up to ".$dateAnalyse).'.';
|
|
|
|
$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="RAPPORT_SP_".$dateAnalyse."_".uniqid().".pdf";
|
|
$pdf->Output($fichier,"F");
|
|
|
|
$obejt = "RAPPORT AU : ".$dateAnalyse;
|
|
|
|
$body = convertirc("Cher Client,");
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Nous vous prions de trouver en pièce jointe votre rapport de consommations par famille à la date du ".$dateAnalyse.'.';
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "Vous pouvez partager ces informations avec tout le monde et si vous avez besoin de précisions";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "N'hésitez pas à nous contacter pour plus de détails.";
|
|
|
|
$body .= "<br/> <br/>";
|
|
|
|
$body .= "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);
|
|
}
|
|
}
|
|
|
|
// echo '</BR>'; echo '</BR>';
|
|
|
|
$emailrapprtsp = new Emailrapprtsp();
|
|
$emailrapprtsp->excutercron();
|
|
// echo "Fin Tache Cron";
|