prestation/Controleur/ControleurAjaximprimerbonmedicament.php
2026-07-01 21:19:36 +00:00

244 lines
9.5 KiB
PHP

<?php
require_once 'Framework/Controleurrequete.php'; // OK
require_once 'Modele/Prescription.php';
require_once 'Modele/Detailprescription.php';
require_once $_SESSION['p_dossierSociete'].'/Html2pdf/lib/html2pdf.php';
class ControleurAjaximprimerbonmedicament extends Controleurrequete
{
private $prescription;
private $detailprescription;
public function __construct() {
$this->prescription = new Prescription();
$this->detailprescription = new Detailprescription();
}
public function index()
{
$numeroPrescription = $_SESSION['p_numeroPrescription_C'];
$numeroFeuilleMaladie = $_SESSION['p_numeroFeuilleMaladie_C'];
$prescription = $this->prescription->getprescription($numeroPrescription);
$detailprescriptions = $this->detailprescription->getdetailprescriptionbon($numeroPrescription);
$consultation = $this->detailprescription->getdetailconsultation($numeroFeuilleMaladie);
$ticketModerateur = $this->detailprescription->getticketmoderateurconsultation($_SESSION['p_idCollege_C']);
$libelleConsultation = $this->detailprescription->getlibelleconsultation($consultation['codeActe']);
//var_dump($libelleConsultation);
$devise = " ".$_SESSION['p_devise_C'];
if($ticketModerateur > "100"){
$tm = $ticketModerateur.$devise;
}else{
$tm = $ticketModerateur." %";
}
$pdf = new FPDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$ht=10;
$hc=6;
$hl=12;
$pdf->SetMargins(10, 10, 10) ;
// Logo
$pdf->Image($_SESSION['p_dossierSociete'].'/Logos/logo_societe.png',10,35,50);
$pdf->Ln(2);
$pdf->SetFont('Arial','', 7);
$pdf->Cell(0,$ht,convertirc(' Edité le '.heureCouranteLang($_SESSION['p_lang'])),0,1,'R',false);
$pdf->Cell(55);
$pdf->SetFont('Arial','B', 13);
$pdf->Cell(135,$ht,convertirc("BON DE PRISE EN CHARGE CONSULTATION N° : ".$_SESSION['p_numeroBonConsultation_C']),0,1,'C',false);
$pdf->Cell(55);
$pdf->SetFont('Arial','UI', 12);
$pdf->Cell(35,$ht,convertirc(_('N° MATRICULE')),'LT',0,'C',false);
$pdf->Cell(35,$ht,convertirc(_('DIRECTION')),'LT',0,'C',false);
$pdf->Cell(30,$ht,convertirc(_('SERVICE')),'LT',0,'C',false);
$pdf->Cell(35,$ht,convertirc(_('N° CARTE')),'LTR',1,'C',false);
$pdf->SetFont('Arial','I', 12);
$pdf->SetY(38);
$pdf->SetX(65);
$pdf->Cell(35,$ht,convertirc(_('Agent')),'L',0,'C',false);
$pdf->Cell(35,$ht,convertirc(_('Adhérent')),'L',0,'C',false);
$pdf->Cell(30,$ht,convertirc(_('Adhérent')),'L',0,'C',false);
$pdf->Cell(35,$ht,convertirc(_('Malade')),'LR',1,'C',false);
$pdf->Cell(55);
$pdf->SetFont('Arial','B', 14);
$pdf->Cell(35,$ht,convertirc($_SESSION['p_numeroAdherent_C']),'LB',0,'C',false);
$pdf->Cell(35,$ht,convertirc(_('')),'LB',0,'C',false);
$pdf->Cell(30,$ht,convertirc(_('')),'LB',0,'C',false);
$pdf->Cell(35,$ht,convertirc($_SESSION['p_numeroBeneficiaire_C']),'LBR',1,'C',false);
$pdf->SetFont('Arial','UI', 9);
$pdf->Cell(25,$ht,convertirc(_("Adhérent")),'LT',0,'L',false);
$pdf->SetFont('Arial','B', 9);
$pdf->Cell(67,$ht,convertirc(": ".substr($_SESSION['p_adherent_C'],0,50)),'T',0,'L',false);
$pdf->SetFont('Arial','UI', 8);
$pdf->Cell(27,$ht,convertirc(_('Naissance')),'LT',0,'C',false);
$pdf->Cell(30,$ht,convertirc(_('Statut')),'LT',0,'C',false);
$pdf->Cell(41,$ht,convertirc(_('RESERVE AU PRATICIEN')),'LTR',1,'C',false);
$pdf->SetFont('Arial','UI', 9);
$pdf->Cell(25,$ht,convertirc(_("Malade")),'LB',0,'L',false);
$pdf->SetFont('Arial','B', 9);
$pdf->Cell(67,$ht,convertirc(": ".substr($_SESSION['p_beneficiaire_C'],0,50)),'B',0,'L',false);
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(27,$ht,convertirc(dateFr($_SESSION['p_dateNaissance_C'])),'LB',0,'C',false);
if($_SESSION['p_lienparente_C'] == "Assure"){
$statut = "Agent";
}else{
$statut = $_SESSION['p_lienparente_C'];
}
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(30,$ht,convertirc($statut),'LB',0,'C',false);
$pdf->Cell(41,$ht,convertirc(_('')),'LR',1,'C',false);
$pdf->SetFont('Arial','I', 8);
$pdf->Cell(54,$ht,convertirc(_("")),'L',0,'L',false);
$pdf->SetFont('Arial','UI', 8);
$pdf->Cell(35,$ht,convertirc(_("TICKET MODERATEUR")),'L',0,'C',false);
$pdf->SetFont('Arial','UI', 8);
$pdf->Cell(30,$ht,convertirc(_("COUT DE L'ACTE")),'L',0,'C',false);
$pdf->Cell(30,$ht,convertirc(_('PART EMPLOYEUR')),'L',0,'C',false);
$pdf->Cell(41,$ht,convertirc(_('')),'LR',1,'C',false);
$pdf->SetFont('Arial','I', 9);
$pdf->Cell(54,$ht,convertirc(_("")),'L',0,'L',false);
$pdf->SetFont('Arial','B', 10);
/*
$pdf->SetY(70);
$pdf->SetX(64);
*/
$pdf->Cell(35,$ht,convertirc($consultation['codeActe'].": ".$tm),'LB',0,'C',false);
$pdf->Cell(30,$ht,convertirc(format_N($consultation['valeurActe']).$devise),'LB',0,'C',false);
$pdf->Cell(30,$ht,convertirc(format_N($consultation['montantArembourser']).$devise),'LB',0,'C',false);
$pdf->Cell(41,$ht,convertirc(_('')),'LR',1,'C',false);
$pdf->SetFont('Arial','IU', 9);
$pdf->Cell(54,$ht,convertirc(_("")),'L',0,'L',false);
$pdf->Cell(95,$ht,convertirc(_("DESIGNATION DE L'ACTE")),'L',0,'C',false);
$pdf->SetFont('Arial','UI', 8);
$pdf->Cell(41,$ht,convertirc(_('')),'LR',1,'C',false);
$pdf->Image($_SESSION['p_lienPrestation_C'].'/Bootstrap_new/images/schema_dent.png',12,82,50);
$pdf->Cell(54,$ht,convertirc(_("")),'LB',0,'L',false);
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(95,$ht,convertirc($libelleConsultation),'LB',0,'C',false);
$pdf->Cell(41,$ht,convertirc(_('')),'LBR',1,'C',false);
/*
$pdf->SetFont('Arial','IB', 10);
$pdf->Cell(190,$hc,convertirc(_('CSD + AR + Pharmacie : 20%')),'LBR',1,'C',false);
*/
$pdf->Cell(10,$hl,convertirc(_('N°')),'LBR',0,'C',false);
$pdf->Cell(70,$hl,convertirc(_('PRESCRIPTION')),'LBR',0,'C',false);
$pdf->Cell(50,$hl,convertirc(_('POSOLOGIE')),'LBR',0,'C',false);
$pdf->Cell(19,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(21,$hl,convertirc(_('')),'LBR',1,'C',false);
$i = 0;
foreach ($detailprescriptions as $v){
$i++;
$pdf->SetFont('Arial','', 8);
$pdf->Cell(10,$hl,convertirc($i),'LBR',0,'C',false);
$pdf->Cell(70,$hl,convertirc(substr($v['libelleMedicament'],0,58)),'BR',0,'L',false);
$pdf->Cell(50,$hl,convertirc($v['posologie']),'BR',0,'L',false);
$pdf->Cell(19,$hl,convertirc(_("0").$v['quantite']),'BR',0,'C',false);
/*
$pdf->Cell(20,$hl,convertirc(format_N($v['valeurActe'])),1,0,'C',false);
$pdf->Cell(21,$hl,convertirc(format_N($v['fraisReel'])),1,1,'C',false);
*/
$pdf->Cell(20,$hl,convertirc(_('')),1,0,'C',false);
$pdf->Cell(21,$hl,convertirc(_('')),1,1,'C',false);
//$fraisReel += $v['fraisReel'];
//$aPayerTotal += $aPayer;
}
$nbreMedocs = count($detailprescriptions);
while($nbreMedocs < $_SESSION['p_nbMedicamentMax'])
{
$nbreMedocs++;
$pdf->Cell(10,$hl,convertirc($nbreMedocs),'LBR',0,'C',false);
$pdf->Cell(70,$hl,convertirc(_('')),'BR',0,'L',false);
$pdf->Cell(50,$hl,convertirc(_('')),'BR',0,'L',false);
$pdf->Cell(19,$hl,convertirc(_('')),'BR',0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('')),1,0,'C',false);
$pdf->Cell(21,$hl,convertirc(_('')),1,1,'C',false);
}
$pdf->SetFont('Arial','B', 9);
$pdf->Cell(50,$hc,convertirc(_('MONTANT PHARMACIE')),'LBR',0,'C',false);
$pdf->Cell(30,$hc,convertirc(_('REMISE')),'LBR',0,'C',false);
$pdf->Cell(40,$hc,convertirc(_('PART')),'LBR',0,'C',false);
$pdf->SetFont('Arial','I', 9);
$pdf->Cell(70,$hc,convertirc(_('Fourni le.............................Signature et cachet')),'LR',1,'L',false);
$pdf->Cell(50,$hc,convertirc(_('')),'LR',0,'C',false);
$pdf->Cell(30,$hc,convertirc(_('')),'LR',0,'C',false);
$pdf->SetFont('Arial','I', 8);
$pdf->Cell(20,$hc,convertirc(_('ASSURE 20%')),'LBR',0,'C',false);
$pdf->Cell(20,$hc,convertirc(_('CNPS 80%')),'LBR',0,'C',false);
$pdf->Cell(70,$hc,convertirc(_('')),'LR',1,'L',false);
$pdf->Cell(50,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(30,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('')),'LBR',0,'C',false);
$pdf->Cell(70,$hl,convertirc(_('')),'LBR',1,'L',false);
$pdf->SetY(65);
$pdf->SetX(160);
$pdf->SetFont('Arial','BI', 8);
$pdf->Cell(41,$hc,convertirc(_('Code')),0,1,'L',false);
$pdf->SetX(160);
$pdf->Cell(41,$hc,convertirc(_('Date')),0,1,'L',false);
$pdf->SetX(160);
$pdf->Cell(41,$hc,convertirc(_('Cachet et signature')),0,1,'L',false);
$pdf->SetY(117);
$pdf->SetX(140);
$pdf->SetFont('Arial','B', 10);
$pdf->Cell(19,$hl,convertirc(_('Quantité')),0,0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('Prix')),0,0,'C',false);
$pdf->Cell(21,$hl,convertirc(_('Montant')),0,0,'C',false);
$pdf->SetY(122);
$pdf->SetX(140);
$pdf->SetFont('Arial','', 10);
$pdf->Cell(19,$hl,convertirc(_('')),0,0,'C',false);
$pdf->Cell(20,$hl,convertirc(_('Unitaire')),0,0,'C',false);
$pdf->Cell(21,$hl,convertirc(_('Total')),0,0,'C',false);
$fichier="Temp/TMP_facture_definitive"."_".uniqid().".pdf";
$pdf->Output($fichier,"F");
$t_html =' <div id ="div_export_b" class="alert alert-info style="text-align: center;"> ';
$t_html .=' <a style="font-size:15pt;" href="'.$fichier.'" target="_blank" > '._("TELECHARGER").' </a> ';
$t_html .=' </div ';
echo $t_html;
exit();
}
}