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

195 lines
7.1 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Statistique.php';
require_once 'Modele/Police.php';
require_once 'Modele/Collegepolice.php';
require_once 'Controleur/ControleurAjaxstatsmaladiefichetechniqueadherentpdf.php';
require_once $_SESSION['dossierSociete'].'/Tarifs/Modele/Police_sodciete.php';
class ControleurAjaxstatsmaladiefichetechniquewhatsapppdf extends Controleur
{
private $detailsp;
private $college;
private $police;
private $statAdherent;
private $police_societe;
public function __construct() {
$this->detailsp = new Statistique();
$this->college = new Collegepolice();
$this->statAdherent = new ControleurAjaxstatsmaladiefichetechniqueadherentpdf();
$this->police = new Police();
$this->police_societe = new Police_sodciete();
}
public function index()
{
////////////////////////////////////////////
$idPolice = $this->requete->getParametreFormulaire("idPolice");
$idCollege = $this->requete->getParametreFormulaire("idCollege");
if( $idCollege ==""){
$idCollege = null;
}
$codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur");
$Chargement = $this->requete->getParametreFormulaire("Chargement");
$debutStat = $this->requete->getParametreDate("debutStat");
$finStat = $this->requete->getParametreDate("finStat");
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
$chargeravantapres = $this->requete->getParametreFormulaire("chargeravantapres");
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
$_SESSION['debutStat'] = $debutStat;
$_SESSION['finStat'] = $finStat;
$_SESSION['depenses'] = $depenses;
$p_datedebut = $_SESSION['debutStat'];
$p_datefin =$_SESSION['finStat'];
$p_garant = $codeGcAssureur;
$p_id = $entete['idPolice'] ;
$p_limite = $_SESSION['depenses'];
$p_id_college = $idCollege;
$p_id_clients = null;
$p_apporteur = null;
if(empty($entete) && !empty($idPolice)){
$police = $this->police->getPoliceId($idPolice);
$t_html =' <div id ="div_export_b" class="alert alert-danger"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("La période d'éffet de cette police est du ").dateLang($police['dateEffet'], $_SESSION['lang'])." au ".dateLang($police['dateFin'], $_SESSION['lang']).' </a> ';
$t_html .=' </div>';
echo $t_html;
exit();
}
$tousadherents = $this->detailsp->detaildepensefamilleass($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin, $p_limite);
if(empty($tousadherents)){
$t_html =' <div id ="div_export_b" class="alert alert-danger"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("Aucune donnée").' </a> ';
$t_html .=' </div>';
echo $t_html;
exit();
}
// $pdfone = new FPDF_Merge();
$pdfone = new FPDF_Protection();
$pdfone->SetAuthor('EBENE SOLUTIONS INFORMATIQUES');
$userPassword = '';
$ownerPassword = null;
$pdfone->SetProtection(['print'], $userPassword, $ownerPassword);
foreach($tousadherents as $statsAdherent){
$famille =$statsAdherent['adherent'];
$numeroAdherent =$statsAdherent['numeroAdherent'];
$fichier = $this->statAdherent->statsadherent($idPolice,$idCollege,$codeGcAssureur,$Chargement,$debutStat,$finStat,$depenses,$chargeravantapres,$famille,$numeroAdherent );
$pdfone->add($fichier);
}
$fichierall="Temp/TMP_KIT_STATISTIQUES"."_".uniqid().".pdf";
$pdfone->Output($fichierall);
$t_html =' <div id ="div_export_b"> ';
$t_html .=' <a class="btn btn-primary" style="font-size:15pt;width:48%;" href="'.$fichierall.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' ';
$t_html .=' <button class="btn btn-succses" style="font-size:15pt;width:48%;" onclick="javascript:envoiestatistiqueswhatsapp();" " target="_blank" > '._("TELECHARGER").' </button> ';
$t_html .=' </div>';
echo $t_html;
}
public function envoiewhatsapp()
{
$idPolice = $this->requete->getParametreFormulaire("idPolice");
$idCollege = $this->requete->getParametreFormulaire("idCollege");
if( $idCollege ==""){
$idCollege = null;
}
$codeGcAssureur = $this->requete->getParametreFormulaire("codeGcAssureur");
$Chargement = $this->requete->getParametreFormulaire("Chargement");
$debutStat = $this->requete->getParametreDate("debutStat");
$finStat = $this->requete->getParametreDate("finStat");
$depenses = $this->requete->getParametreFormulaire("depenses","numerique");
$chargeravantapres = $this->requete->getParametreFormulaire("chargeravantapres");
$entete = $this->detailsp->detailrapportspperiodepdfentete($idPolice);
$p_datedebut = $_SESSION['debutStat'];
$p_datefin =$_SESSION['finStat'];
$p_garant = $codeGcAssureur;
$p_id = $entete['idPolice'] ;
$p_limite = $_SESSION['depenses'];
$p_id_college = $idCollege;
$p_id_clients = null;
$p_apporteur = null;
if(empty($entete) && !empty($idPolice)){
$police = $this->police->getPoliceId($idPolice);
$t_html =' <div id ="div_export_b" class="alert alert-danger"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("La période d'éffet de cette police est du ").dateLang($police['dateEffet'], $_SESSION['lang'])." au ".dateLang($police['dateFin'], $_SESSION['lang']).' </a> ';
$t_html .=' </div>';
echo $t_html;
exit();
}
$tousadherents = $this->detailsp->detaildepensefamilleass($p_garant, $p_id_clients, $p_id, $p_id_college, $p_datedebut, $p_datefin, $p_limite);
foreach($tousadherents as $statsAdherent){
$famille =$statsAdherent['adherent'];
$numeroAdherent =$statsAdherent['numeroAdherent'];
$fichier="Temp/TMP_KIT_STATISTIQUES_FAMILLE"."_".$famille.".pdf";
if(is_file($fichier)){
$fichier="https://gestionnaire.vitalis-ci.com/Temp/TMP_KIT_STATISTIQUES_FAMILLE"."_".$famille.".pdf";
$params=array(
'token' => '5ujfcrqcc9qykwdq',
'to' => '2250152706497,',
'filename' => 'TMP_KIT_STATISTIQUES.pdf',
'document' => $fichier,
'caption' => 'Statistiques famille',
'priority' => '',
'referenceId' => '',
'nocache' => '',
'msgId' => '',
'mentions' => ''
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ultramsg.com/instance72717/messages/document",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($params),
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
}
}
$t_html =' <div id ="div_export_b" class="alert alert-info"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("Traitement terminé avec succes").' </a> ';
$t_html .=' </div>';
echo $t_html;
}
}