<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Pdf_Conge extends CI_Controller {

    function __construct() {
        parent::__construct();
    }
    
    public function index($id){

      include 'pdfinclude/fpdf/mc_table.php';
      include 'pdfinclude/fpdf/pdf_config.php';

      $infoconge=$this->Model->getRequeteOne('SELECT ID_EMPLOYE FROM `conge_demande_conge` WHERE conge_demande_conge.ID_DEMANDE_CONGE = '.$id.'');
      $info_conge=$this->Model->getRequeteOne('SELECT rh_responsabilite.DESCRIPTION AS FONCTION,ID_EXERCICE_SUIVANT, DATE_SYSTEME_DEMANDE, conge_credit.ID_EXERCICE AS ID_EXERCICE_CREDIT, conge_demande_conge.ID_EXERCICE AS ID_EXERCICE_DEMANDE,NB_JOURS_ACCORDE, ID_EXERCICE_PRECEDENT, DATE_DEBUT_CONGE_ACCORDE, DATE_FIN_CONGE_ACCORDE, organigramme_section.DESCRIPTION AS SECTION, organigramme_service.DESCRIPTION AS SERVICE, organigramme_direction.DESCRIPTION DIRECTION, rh_employe.NOM,  conge_demande_conge.ID_TYPE_CONGE, rh_employe.PRENOM, rh_employe.SIGNATURE, conge_credit.ID_CREDIT, conge_credit.NB_JOURS_CREDITE, conge_credit.NB_JOURS_RESTANT, config_exercice.DESCRIPTION AS EXERCICE, config_type_conge.NOM_CONGE FROM `conge_demande_conge` JOIN config_exercice ON config_exercice.ID_EXERCICE = conge_demande_conge.ID_EXERCICE LEFT JOIN conge_credit ON conge_credit.ID_EXERCICE = conge_demande_conge.ID_EXERCICE LEFT JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_demande_conge.ID_EMPLOYE LEFT JOIN organigramme_direction ON organigramme_direction.ID_DIRECTION = conge_demande_conge.ID_DIRECTION LEFT JOIN organigramme_service ON organigramme_service.ID_SERVICE = conge_demande_conge.ID_SERVICE LEFT JOIN organigramme_section ON organigramme_section.ID_SECTION = conge_demande_conge.ID_SECTION JOIN config_type_conge ON config_type_conge.ID_TYPE_CONGE = conge_demande_conge.ID_TYPE_CONGE LEFT JOIN rh_employe_affectation ON rh_employe_affectation.ID_EMPLOYE = rh_employe.ID_EMPLOYE JOIN rh_responsabilite ON rh_responsabilite.ID_RESPONSABILITE = rh_employe_affectation.ID_RESPONSABILITE WHERE 1 AND conge_demande_conge.ID_DEMANDE_CONGE = '.$id.'  AND conge_credit.ID_EMPLOYE = '.$infoconge['ID_EMPLOYE'].'');


      $bs=base_url().'conge/Demande_Conge_Det/detail/'.$id;
      $this->notifications->generateQrcode(utf8_decode($bs),'Conge_'.$id);
      $qrcode_name = 'Conge_'.$id.'.png';

      
     

      $urlpass = base_url();
      $elementspas = explode("/", $urlpass);
      $nouveau_urlpass = null ;
        $indicepass = sizeof($elementspas);
        for ($i = 0; $i < ($indicepass - 2); $i++) {
            $nouveau_urlpass .=$elementspas[$i] . '/';
        }

      // $logo_banque='dist/logo_pdf.png';
     

      $pdf = new PDF_CONFIG('P','mm','A4');
      $pdf->addPage();
      $pdf->Ln(20);
      $pdf->SetFont('Arial','B',15);

      // $pdf->SetX(10);
      $pdf->Cell(190,5,utf8_decode(strtoupper('DEMANDE DE CONGE')),0,1,'C');
      
      $pdf->SetFont('Arial','',10);
      $pdf->Ln(4);
      $pdf->SetX(10);
      $pdf->Cell(55,6,utf8_decode('Nom'),0,0,'L');
      $pdf->Cell(100,6,utf8_decode(':'.$info_conge['NOM'].' '),0,1,'L');
      $pdf->Cell(55,6,utf8_decode('Prénom'),0,0,'L');
      $pdf->Cell(100,6,utf8_decode(':'.$info_conge['PRENOM'].' '),0,1,'L');

  
      if ($info_conge['DIRECTION'] != NULL) {
          $pdf->Cell(55,6,utf8_decode('Direction'),0,0,'L');
          $pdf->Cell(100,6,utf8_decode(':'.$info_conge['DIRECTION'].''),0,1,'L');
      }

      if ($info_conge['SERVICE'] != NULL) {
          $pdf->Cell(55,6,utf8_decode('Service'),0,0,'L');
          $pdf->Cell(100,6,utf8_decode(':'.$info_conge['SERVICE'].''),0,1,'L');
      }

      if ($info_conge['SECTION'] != NULL) {
          $pdf->Cell(55,6,utf8_decode('Section'),0,0,'L');
          $pdf->Cell(100,6,utf8_decode(':'.$info_conge['SECTION'].''),0,1,'L');
      }
      



      $pdf->Cell(55,6,utf8_decode('Fonction'),0,0,'L');
      $pdf->Cell(100,6,utf8_decode(':'.$info_conge['FONCTION'].''),0,1,'L');
      $pdf->Cell(55,6,utf8_decode('Période de congé'),0,0,'L');
      $pdf->Cell(100,6,utf8_decode(':'.$info_conge['DATE_DEBUT_CONGE_ACCORDE'].' - '.$info_conge['DATE_FIN_CONGE_ACCORDE'].' ('.$info_conge['NB_JOURS_ACCORDE'].' jours)'),0,1,'L');
 
      $pdf->Ln(4);
      $pdf->Cell(55,6,utf8_decode('Type de congé'),0,0,'L');

      if ($info_conge['ID_TYPE_CONGE'] == 1) {
        $pdf->SetFont('Arial','B',15);
        $pdf->Cell(8,6,utf8_decode('X'),1,0,'C');
        $pdf->SetFont('Arial','',10);
      }
      else{
          $pdf->Cell(8,6,utf8_decode(' '),1,0,'L');
      }
      
      $pdf->Cell(100,6,utf8_decode('Congé annuel '),0,1,'L');
      $pdf->Cell(55,6,utf8_decode(''),0,0,'L');

      if ($info_conge['ID_TYPE_CONGE'] == 2) {
        $pdf->SetFont('Arial','B',15);
        $pdf->Cell(8,6,utf8_decode('X'),1,0,'C');
        $pdf->SetFont('Arial','',10);
      }
      else{
          $pdf->Cell(8,6,utf8_decode(' '),1,0,'L');
      }
      $pdf->Cell(100,6,utf8_decode('Congé de circonstance'),0,1,'L');
      $pdf->Cell(55,6,utf8_decode(''),0,0,'L');
      // $pdf->Cell(8,6,utf8_decode(' '),1,0,'L');
      if ($info_conge['ID_TYPE_CONGE'] != 1 && $info_conge['ID_TYPE_CONGE'] != 2) {
        $pdf->SetFont('Arial','B',15);
        $pdf->Cell(8,6,utf8_decode('X'),1,0,'C');
        $pdf->SetFont('Arial','',10);
      }
      else{
          $pdf->Cell(8,6,utf8_decode(' '),1,0,'L');
      }

      
      if ($info_conge['ID_TYPE_CONGE'] != 1 && $info_conge['ID_TYPE_CONGE'] != 2) {
        $pdf->Cell(100,6,utf8_decode('Autres : '.$info_conge['NOM_CONGE'].' '),0,1,'L');
      }
      else{
          $pdf->Cell(100,6,utf8_decode('Autres : '),0,1,'L');
      }

      $pdf->Ln(5);
      $pdf->Cell(10,6,utf8_decode('Le'),0,0,'L');
      $pdf->Cell(10,6,utf8_decode($info_conge['DATE_SYSTEME_DEMANDE']),0,1,'L');
      $pdf->Cell(10,4,utf8_decode(''),0,0,'L');
      $pdf->Cell(20,0,utf8_decode(''),1,1,'L');

        $urlpass = base_url();
        $elementspas = explode("/", $urlpass);
       $nouveau_urlpass = null ;
        $indicepass = sizeof($elementspas);
        for ($i = 0; $i < ($indicepass - 2); $i++) {
            $nouveau_urlpass .=$elementspas[$i] . '/';
        }
      
      $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$info_conge['SIGNATURE'].'',55,110,0,30);
      $pdf->Ln(10);
      $pdf->Cell(45,6,utf8_decode('Signature du demandeur '),0,0,'L');
      $pdf->Cell(45,6,utf8_decode(''),0,1,'L');
      $pdf->Cell(45,6,utf8_decode(''),0,0,'L');
      $pdf->Cell(100,0,utf8_decode(''),1,1,'L');
     

      $pdf->Ln(10);
      $pdf->Cell(190,0,utf8_decode(' '),1,1,'L');
      $pdf->Ln(5);

      $pdf->Cell(55,8,utf8_decode('Visa du Service Administration '),0,1,'L');
      $pdf->Cell(55,0,utf8_decode(''),1,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');


      
      
        if ($info_conge['ID_EXERCICE_PRECEDENT'] != NULL) {
          // $autre_ex = ' Null';
          $olddata=$this->Model->getRequeteOne('SELECT conge_demande_conge.NB_JOURS_RESTANT_PRECEDENT, conge_demande_conge.NB_JOURS_DUS_PRECEDEMENT, conge_demande_conge.NB_JOURS_RESTANT_PRECEDENT_ACTUELLEMT, config_exercice.DESCRIPTION FROM conge_demande_conge JOIN config_exercice ON config_exercice.ID_EXERCICE = conge_demande_conge.ID_EXERCICE_PRECEDENT WHERE conge_demande_conge.ID_EXERCICE_PRECEDENT = '.$info_conge['ID_EXERCICE_PRECEDENT'].' AND conge_demande_conge.ID_DEMANDE_CONGE = '.$id.' '); 

      $NBRESTANT = $info_conge['NB_JOURS_ACCORDE']-$olddata['NB_JOURS_RESTANT_PRECEDENT'];
      $NNBRESTANT = $olddata['NB_JOURS_DUS_PRECEDEMENT'] - $NBRESTANT;
      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs demandés : '.$info_conge['NB_JOURS_ACCORDE'].' Jrn dont '.$NBRESTANT.' Jrn en '.$info_conge['EXERCICE'].' et '.$olddata['NB_JOURS_RESTANT_PRECEDENT'].' en '.$olddata['DESCRIPTION'] ),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');
      $pdf->Cell(70,5,utf8_decode('- Nombre de jrs de congés dus : '.$info_conge['NB_JOURS_CREDITE'].' jrs en '.$info_conge['EXERCICE'].' et '.$olddata['NB_JOURS_DUS_PRECEDEMENT'].' jrs en '.$olddata['DESCRIPTION'].'' ),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');      
      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs de congés restants : '.$olddata['NB_JOURS_RESTANT_PRECEDENT_ACTUELLEMT'].' jours en '.$olddata['DESCRIPTION'].' et '.$NNBRESTANT.' jours en '.$info_conge['EXERCICE'].' '),0,1,'L');
          
        }

        else if ($info_conge['ID_EXERCICE_SUIVANT'] != NULL){
          // $autre_ex = ' Not Null';
          $newdata=$this->Model->getRequeteOne('SELECT conge_demande_conge.NB_JOURS_SUIVANT_PRECEDENT, conge_demande_conge.NB_JOURS_DUS_SUIVANT, conge_demande_conge.NB_JOURS_RESTANT_SUIVANT_ACTUELLEMT, config_exercice.DESCRIPTION FROM conge_demande_conge JOIN config_exercice ON config_exercice.ID_EXERCICE = conge_demande_conge.ID_EXERCICE_SUIVANT WHERE conge_demande_conge.ID_EXERCICE_SUIVANT = '.$info_conge['ID_EXERCICE_SUIVANT'].' AND conge_demande_conge.ID_DEMANDE_CONGE = '.$id.' '); 

          // print_r($info_conge);
          // exit();
      // $NBRESTANT = $info_conge['NB_JOURS_ACCORDE']-$newdata['NB_JOURS_SUIVANT_PRECEDENT'];
      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs demandés : '.$info_conge['NB_JOURS_ACCORDE'].' Jrn en '.$info_conge['EXERCICE'] ),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');
      $pdf->Cell(70,5,utf8_decode('- Nombre de jrs de congés dus : '.$info_conge['NB_JOURS_CREDITE'].' jrs en '.$info_conge['EXERCICE'].' et '.$newdata['NB_JOURS_DUS_SUIVANT'].' jrs en '.$newdata['DESCRIPTION'].'' ),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');      
      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs de congés restants : '.$newdata['NB_JOURS_RESTANT_SUIVANT_ACTUELLEMT'].' jours en '.$newdata['DESCRIPTION'].' et '.$info_conge['NB_JOURS_RESTANT'].' jours en '.$info_conge['EXERCICE'].' '),0,1,'L');
        }
        
        else{
          // $autre_ex = ' Not Null';
          
      

      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs demandés : '.$info_conge['NB_JOURS_ACCORDE'].' Jrn '),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');
      $pdf->Cell(70,5,utf8_decode('- Nombre de jrs de congés dus : '.$info_conge['NB_JOURS_CREDITE'].' jrs '.$info_conge['EXERCICE'].''),0,1,'L');
      $pdf->Cell(15,5,utf8_decode(''),0,0,'L');      
      $pdf->Cell(55,5,utf8_decode('- Nombre de jrs de congés restants : '.$info_conge['NB_JOURS_RESTANT'].' jours '.$info_conge['EXERCICE'].' '),0,1,'L');
        }




      


      

      $traite_un=$this->Model->getRequeteOne('SELECT rh_employe.NOM, rh_employe.PRENOM,rh_employe.SIGNATURE, conge_traitement_conge.DATE_TRAITEMENT, conge_traitement_conge.ID_DIRECTION, conge_traitement_conge.ID_DEPARTEMENT, conge_traitement_conge.ID_SERVICE, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.STATUS_CONGE, conge_status_conge.DESCRIPTION, conge_status_conge.ID_NIVEAUX FROM `conge_traitement_conge` JOIN conge_status_conge ON conge_traitement_conge.STATUS_CONGE = conge_status_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT WHERE 1 AND ID_NIVEAUX = 5 AND conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ');

      if (!empty($traite_un)) {
      $pdf->Ln(5);
      $pdf->Cell(10,8,utf8_decode('Le '),0,0,'L');
      $pdf->Cell(10,8,utf8_decode($traite_un['DATE_TRAITEMENT']),0,1,'L');
      $pdf->Cell(10,8,utf8_decode('Signature du Chef de Service Administration '),0,1,'L');
      $pdf->Cell(10,8,utf8_decode($traite_un['NOM'].' '.$traite_un['PRENOM']),0,1,'L');
      $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$traite_un['SIGNATURE'].'',30,195,0,25);
      $pdf->Ln(10);
      $pdf->Cell(50,0,utf8_decode(''),1,1,'L');
      }
      // else{
        
      // }

      
      
      
      $pdf->Ln(10);
      $pdf->Cell(190,0,utf8_decode(' '),1,1,'L');
      
      $refus=$this->Model->getRequeteOne('SELECT conge_traitement_conge.DATE_TRAITEMENT, rh_employe.NOM, rh_employe.PRENOM, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.COMMENTAIRE FROM conge_traitement_conge JOIN conge_status_conge ON conge_status_conge.STATUS_CONGE = conge_traitement_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT WHERE 1 AND conge_status_conge.REFUS = 1 AND conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ORDER BY conge_traitement_conge.ID_TRAITEMENT_CONGE DESC');
      if (!empty($refus)) {
        $pdf->Ln(5);
      $pdf->Cell(100,6,utf8_decode('Congé Refuse par '.$refus['NOM'].' '.$refus['PRENOM'].' le '.$refus['DATE_TRAITEMENT'].''),0,1,'L');
      $pdf->Cell(100,6,utf8_decode('Motif: '.$refus['COMMENTAIRE'].''),0,1,'L');
      $pdf->Cell(55,6,utf8_decode(''),0,0,'L');
      $pdf->Ln(5);
      }
      



      // $pdf->Cell(90,5,utf8_decode('Accordé le'),0,0,'L');
      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');
      // $pdf->Cell(90,5,utf8_decode('Refusé le'),0,1,'L');
      // // $pdf->Ln(10);
      // $pdf->Cell(100,5,utf8_decode(''),0,0,'L');
      // $pdf->Cell(90,5,utf8_decode('Motif:'),0,1,'L');
      // // $pdf->Ln(2);
      // $pdf->Cell(100,0,utf8_decode(''),0,0,'L');
      // $pdf->Cell(90,0,utf8_decode(''),1,1,'L');
      $pdf->Ln(15);
      $pdf->SetFont('Arial','B',10);

      $signature=$this->Model->getRequete('SELECT rh_employe.NOM, rh_employe.PRENOM,rh_employe.SIGNATURE, conge_traitement_conge.DATE_TRAITEMENT, conge_traitement_conge.ID_DIRECTION, conge_traitement_conge.ID_DEPARTEMENT, conge_traitement_conge.ID_SERVICE, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.STATUS_CONGE, conge_status_conge.DESCRIPTION, conge_status_conge.ID_NIVEAUX, config_user.PROFIL_ID, config_profil.DESCRIPTION FROM `conge_traitement_conge` JOIN conge_status_conge ON conge_traitement_conge.STATUS_CONGE = conge_status_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT JOIN config_user ON config_user.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT JOIN config_profil ON config_profil.PROFIL_ID = config_user.PROFIL_ID WHERE conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ORDER BY DATE_TRAITEMENT DESC LIMIT 2');

      $signature = array_reverse($signature);

      if (!empty($signature)) {
        foreach ($signature as $signat) {
      // $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$signat['SIGNATURE'].'',15,245,0,15);
      $pdf->Cell(90,5,utf8_decode($signat['NOM'].' '.$signat['PRENOM'].' ('.$signat['DATE_TRAITEMENT'].')'),0,0,'L');
      // $pdf->Cell(90,5,utf8_decode($signat['NOM'].''),0,1,'L');
      // $pdf->Cell(90,5,utf8_decode($signat['DESCRIPTION'].''),0,0,'L');
      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');

      
        }
      
      }
      $pdf->Cell(90,5,utf8_decode(''),0,1,'L');

      if (!empty($signature)) {
        foreach ($signature as $signat) {
      // $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$signat['SIGNATURE'].'',15,245,0,15);
      // $pdf->Cell(90,5,utf8_decode($signat['NOM'].' '.$signat['PRENOM'].' ('.$signat['DATE_TRAITEMENT'].')'),0,0,'L');
      
      $pdf->Cell(90,5,utf8_decode($signat['DESCRIPTION'].''),0,0,'L');
      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');

      
        }
      
      }

      $pdf->Cell(90,5,utf8_decode(''),0,1,'L');

      // $array = [1, 2, 3, 4, 5];
      // $premiers = $signature['DESCRIPTION'][0];
      // echo $premiers;
      // print_r($signature);
      // $secondIdEmployeTraitant = $signature[0]['DESCRIPTION'];
      // $secondIdEmployeTraitant = $signature[1]['DESCRIPTION'];

      $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$signature[0]['SIGNATURE'].'',15,245,0,15);
      $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$signature[1]['SIGNATURE'].'',120,245,0,15);

      // echo $secondIdEmployeTraitant;
      // exit();

      // $signature=$this->Model->getRequete('SELECT rh_employe.NOM, rh_employe.PRENOM,rh_employe.SIGNATURE, conge_traitement_conge.DATE_TRAITEMENT, conge_traitement_conge.ID_DIRECTION, conge_traitement_conge.ID_DEPARTEMENT, conge_traitement_conge.ID_SERVICE, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.STATUS_CONGE, conge_status_conge.DESCRIPTION, conge_status_conge.ID_NIVEAUX, config_user.PROFIL_ID, config_profil.DESCRIPTION FROM `conge_traitement_conge` JOIN conge_status_conge ON conge_traitement_conge.STATUS_CONGE = conge_status_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT JOIN config_user ON config_user.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT JOIN config_profil ON config_profil.PROFIL_ID = config_user.PROFIL_ID WHERE conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ORDER BY DATE_TRAITEMENT DESC LIMIT 2');

      

      
      // print_r($signature);

      // exit();
      
      // if (!empty($signature)) {
      //   foreach ($signature as $signat) {
      // $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$signat['SIGNATURE'].'',15,245,0,15);
      // // $pdf->Cell(90,5,utf8_decode($signat['NOM'].' '.$signat['PRENOM'].' ('.$signat['DATE_TRAITEMENT'].')'),0,0,'L');
      
      // // $pdf->Cell(90,5,utf8_decode($signat['DESCRIPTION'].''),0,0,'L');
      // // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');

      
      //   }
      
      // }
      
      // $traite_deux=$this->Model->getRequeteOne('SELECT rh_employe.NOM, rh_employe.PRENOM,rh_employe.SIGNATURE, conge_traitement_conge.DATE_TRAITEMENT, conge_traitement_conge.ID_DIRECTION, conge_traitement_conge.ID_DEPARTEMENT, conge_traitement_conge.ID_SERVICE, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.STATUS_CONGE, conge_status_conge.DESCRIPTION, conge_status_conge.ID_NIVEAUX, config_user.PROFIL_ID FROM `conge_traitement_conge` JOIN conge_status_conge ON conge_traitement_conge.STATUS_CONGE = conge_status_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT JOIN config_user ON config_user.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT WHERE 1 AND ID_NIVEAUX = 3 AND conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ');

      // if (!empty($traite_deux)) {
      // $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$traite_deux['SIGNATURE'].'',15,245,0,15);
      
      // $pdf->Cell(90,5,utf8_decode($traite_deux['NOM'].' '.$traite_deux['PRENOM'].' ('.$traite_deux['DATE_TRAITEMENT'].')'),0,0,'L');
      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');
      // }
      
      

      // $traite_troix=$this->Model->getRequeteOne('SELECT rh_employe.NOM, rh_employe.PRENOM,rh_employe.SIGNATURE, conge_traitement_conge.DATE_TRAITEMENT, conge_traitement_conge.ID_DIRECTION, conge_traitement_conge.ID_DEPARTEMENT, conge_traitement_conge.ID_SERVICE, conge_traitement_conge.ID_EMPLOYE_TRAITANT, conge_traitement_conge.STATUS_CONGE, conge_status_conge.DESCRIPTION, conge_status_conge.ID_NIVEAUX FROM `conge_traitement_conge` JOIN conge_status_conge ON conge_traitement_conge.STATUS_CONGE = conge_status_conge.STATUS_CONGE JOIN rh_employe ON rh_employe.ID_EMPLOYE = conge_traitement_conge.ID_EMPLOYE_TRAITANT WHERE 1 AND ID_NIVEAUX = 4 AND conge_traitement_conge.ID_DEMANDE_CONGE = '.$id.' ');

      // if (!empty($traite_troix)) {

      // $pdf->Image(''.$nouveau_urlpass.'uploads/signatures/'.$traite_troix['SIGNATURE'].'',120,245,0,15);
      
      // $pdf->Cell(90,5,utf8_decode($traite_troix['NOM'].' '.$traite_troix['PRENOM'].' ('.$traite_troix['DATE_TRAITEMENT'].')'),0,0,'L');
      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');

      // if (!empty($traite_deux)) {
      //   if($traite_deux['PROFIL_ID'] == 2){
      //     $pdf->Cell(90,5,utf8_decode(''),0,1,'L');
      //     $pdf->Cell(90,5,utf8_decode('DIRECTEUR TECHNIQUE'),0,0,'L');
      //   }
      //   else {
      //     $pdf->Cell(90,5,utf8_decode(''),0,1,'L');
      //     $pdf->Cell(90,5,utf8_decode('DIRECTEUR ADMINISTRATIVE FINANCIER'),0,0,'L');
      //   }
        
      // }

      // $pdf->Cell(10,5,utf8_decode(''),0,0,'L');
      // $pdf->Cell(90,5,utf8_decode('DIRECTEUR GENERAL'),0,1,'L');
      // }
   

      if(file_exists(FCPATH . 'uploads/QRCODE/'.$qrcode_name)){
        $pdf->Image(FCPATH . 'uploads/QRCODE/'.$qrcode_name,85,250,25,0);
        // $this->db->set('PATH_QRCODE',$qrcode_name);
        // $this->db->where('id',$passport['id']);
        // $this->db->update('requests');
      }
     

      $pdf->Output('pdf_conge_'.$id.'.pdf','I');

    }


    

    
}
