radiantproduction/Cron/Emaillimiteconsommation.php

90 lines
2.8 KiB
PHP

<?php
require_once 'Functions.php';
require_once 'Controleurrequete.php';
require_once 'Statistique.php';
class Emaillimiteconsommation
{
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->listepolicelimitesonsomail();
foreach ($polices as $police)
{
$dateAnalyse = dateFr($police['dateAnalyse']);
$idPolice = $police['idPolice'];
$email = $police['email'];
$limiteConsommation = $police['limiteConsommation'];
$alertLimiteConsommation = $police['alertLimiteConsommation'];
$rap_SP = $police['rap_SP'];
$this->envoyermail($idPolice, $dateAnalyse, $email, $limiteConsommation, $alertLimiteConsommation, $rap_SP);
}
}
public function envoyermail($idPolice, $dateAnalyse, $email, $limiteConsommation, $alertLimiteConsommation, $rap_SP)
{
$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) );
}
}
$obejt = "CONSUMPTION LIMIT ALERT";
$body = "Dear Esteemed Customer,
I trust this message finds you in good health and high spirits.
I am reaching out to you today to address a particular aspect of our contract that concerns additional premiums. This provision comes into play when the total consumptions reach $limiteConsommation of the net premium paid.
As of $dateAnalyse, our claims ratio stands at $rap_SP, and it appears that the risk of reaching $limiteConsommation, where an additional premium is required as per our agreement, is on the rise.
Our primary objective is to ensure you are adequately informed, enabling you to make well-informed and timely decisions.
Please be reminded that should the claims ratio reach $limiteConsommation before the contract end date, the additional premium will be computed based on the formula outlined in our agreement.
Should any questions arise, or further clarification be needed, please do not hesitate to reach out. We remain at your disposal to provide any assistance you may require.
Thank you for your attention to this matter.
Best regards,";
$body = convertirc($body);
$obejt = convertirc($obejt);
$mail_C->Subject = $obejt;
$mail_C->Body=$body;
if (!$mail_C->send())
{
// echo "Erreur mail : " . $mail_C->ErrorInfo;
}
else
{
// echo "Message envoyé!";
}
}
}
// echo '<br> <br> <br>';
$emailrapprtsp = new Emaillimiteconsommation();
$emailrapprtsp->excutercron();
// echo "Fin Tache Cron";