$pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 0 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 1 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 2 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 3 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row['start_heure']), 'LR', 0, 'R');
                         $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row['end_heure']), 'LR', 0, 'R');
                         $pdf->Ln();
                     } else {
                         if ($row['start_heure'] != '00:00') {
                             $mon_texte .= ($row['nature'] == 0 ? "G" : "A") . ": " . $row['login'] . " " . $row['start_heure'] . "h-" . $mon_item[0]['end_heure'] . "h(J+1) \n";
                             $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($row['ma_date2']), 'LR', 0, 'C');
                             $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row['nature'] == 0 ? "garde" : "astreinte"), 'LR', 0, 'R');
                             $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 0 ? "X" : ""), 'LR', 0, 'R');
                             $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 1 ? "X" : ""), 'LR', 0, 'R');
                             $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 2 ? "X" : ""), 'LR', 0, 'R');
                             $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 3 ? "X" : ""), 'LR', 0, 'R');
                             $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row['start_heure']), 'LR', 0, 'R');
                             $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($mon_item[0]['end_heure'] . "(J+1)"), 'LR', 0, 'R');
                             $pdf->Ln();
                         }
                     }
                 }
             }
         }
     }
     // Trait de terminaison
     $pdf->Cell(array_sum($w), 0, '', 'T');
     $pdf->Ln(20);
 }
 $mon_url = '../sauvegarde/clinique/planning/' . $_SESSION['login'] . '/planning_' . requetemysql::gestion_string_norm($_POST['date_debut2']) . "_" . requetemysql::gestion_string_norm($_POST['date_fin2']) . uniqid() . '.pdf';
 //$pdf->Output($mon_url, F);
Exemple #2
0
 /**
  * print_result
  * print a pdf file wich contain schedule of the shift
  *
  * @param array $arr : 
  * @param array $arr['agenda'] schedule with param (login, job, job2, ma_date, date_debut, date_fin)
  * @param array $arr['team'] team with param (login, nom, adresse, code, commune, tel1, tel2, mail)
  * @param int $arr['choix_affichage'] choice concerning date in the schedule : 1 for put date j+1 2 for split date 1 to midnight 1 after
  * @param int $arr['cas_affichage'] choice concerning the goal : 1 for global schedule, 2 for global schedule and all schedule of member, 3 for distinct member schedule
  * @param string $arr['date_debut'] date of the begin of the selected month format : DD/MM/YYYY
  * @param string $arr['date_fin'] date of the end of the selected month format : DD/MM/YYYY
  * @param string $arr['date_debut2'] date of the begin of the selected month format : DD_MM_YYYY
  * @param string $arr['date_fin2'] date of the end of the selected month format : DD_MM_YYYY
  * @param int $arr['date_debut3'] date of the begin of the selected month format : millisecond unix
  * @param int $arr['date_fin3'] date of the end of the selected month format : millisecond unix
  * @param array $arr['liste_jour'] list of day name and order
  * @param string $arr['login'] login name for distinct member schedule search
  * @return json json of ok
  */
 public static function print_result($arr)
 {
     try {
         require 'fpdf/fpdf.php';
         require 'fpdi/fpdi.php';
         $choix_affichage = $arr['choix_affichage'];
         $filename = 'planning/';
         if (!file_exists($filename)) {
             if (!mkdir($filename, 0755, true)) {
                 die('Echec lors de la création des répertoires...');
             }
         }
         $pdf = new FPDF();
         $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000));
         $date_debut_o = $date_debut;
         $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000));
         $planning2 = $arr['agenda'];
         while ($date_debut < $date_fin) {
             if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) {
                 $pdf->AddPage();
                 $pdf->SetFont('Times', '', 12);
                 $pdf->Cell(90);
                 $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
                 if (isset($_SESSION['login2'])) {
                     $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L');
                 } else {
                     $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L');
                 }
                 $pdf->SetFont('Times', '', 18);
                 $pdf->SetFillColor(153, 153, 153);
                 $pdf->SetTextColor(0, 0, 0);
                 $pdf->SetDrawColor(153, 153, 153);
                 $pdf->SetLineWidth(0.3);
                 $pdf->SetFont('', 'B');
                 if ($arr['cas_affichage'] == 1) {
                     $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT5 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
                 } else {
                     if ($arr['cas_affichage'] == 2) {
                         $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT6 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
                     } else {
                         if ($arr['cas_affichage'] == 3) {
                             $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT7 . " " . requetemysql::gestion_string_maj(htmlentities($_POST['login'])) . " :" . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
                         }
                     }
                 }
                 $pdf->SetFont('Times', '', 10);
                 // Largeurs des colonnes
                 $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7);
                 $header = $arr['liste_jour'];
                 $hauteur = 3;
                 $x2 = $pdf->GetY();
                 // En-tête
                 for ($i = 0; $i < count($header); $i++) {
                     $pdf->SetXY($w[$i] * $i + 10, $x2);
                     $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C');
                     if ($header[$i]["valeur"] == date("w", $date_debut)) {
                         $case_vide = $i - 1;
                     }
                 }
                 $pdf->Ln();
                 $x2 = $pdf->GetY();
                 if ($case_vide >= 0) {
                     for ($i = 0; $i <= $case_vide; $i++) {
                         $pdf->SetXY($w[$i] * $i + 10, $x2);
                         $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C');
                     }
                 }
                 $x3 = ($case_vide + 1) * $w[$i] + 10;
                 $max_y = 0;
             }
             // Données
             $pdf->SetFont('Times', '', 8);
             $trouve = false;
             $mon_texte = date("d", $date_debut) . "\n";
             foreach ($planning2 as $row) {
                 if ($date_debut == $row->ma_date / 1000) {
                     $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure');
                     if ($arr['cas_affichage'] == 1 || $arr['cas_affichage'] == 2) {
                         if ($choix_affichage == 2) {
                             $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                         } else {
                             if ($choix_affichage == 1) {
                                 if (count($mon_item) == 0 && $row->start_heure != '00:00') {
                                     $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                                 } else {
                                     if ($row->start_heure != '00:00') {
                                         $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n";
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($row->login == $arr['login']) {
                             if ($choix_affichage == 2) {
                                 $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "-" . $row->end_heure . " \n";
                             } else {
                                 if ($choix_affichage == 1) {
                                     if (count($mon_item) == 0 && $row->start_heure != '00:00') {
                                         $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                                     } else {
                                         if ($row->start_heure != '00:00') {
                                             $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n";
                                         }
                                     }
                                 }
                             }
                         } else {
                             //		$mon_texte .= ($row['nature']==0 ? "G" : "A").": ".$row->start_heure."-".$row->end_heure." \n" ;
                         }
                     }
                     $trouve = true;
                 }
             }
             if ($trouve == true) {
                 $pdf->SetXY($x3, $x2);
                 $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false);
                 $max_y2 = $pdf->GetY();
                 if ($max_y2 > $max_y) {
                     $max_y = $max_y2;
                 }
             }
             if ($trouve == false) {
                 $pdf->SetXY($x3, $x2);
                 $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false);
                 $max_y2 = $pdf->GetY();
                 if ($max_y2 > $max_y) {
                     $max_y = $max_y2;
                 }
             }
             if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) {
                 $x2 = $max_y;
                 $x2 += $hauteur;
                 $x3 = 10;
                 $max_y = 0;
             } else {
                 $x3 += $w[0];
             }
             $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut));
         }
         if ($arr['cas_affichage'] == 2) {
             foreach ($arr['team'] as $row2) {
                 $row2->login;
                 $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000));
                 $date_debut_o = $date_debut;
                 $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000));
                 $planning2 = $arr['agenda'];
                 while ($date_debut < $date_fin) {
                     if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) {
                         if (isset($_SESSION['login2'])) {
                             $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login'])));
                             if (empty($info_veto)) {
                                 throw new Exception("Erreur dans la recherche des informations sur le vétérinaire");
                             } else {
                                 $info_veto = json_decode($info_veto, true);
                             }
                         }
                         $info_veto2 = $row2;
                         $pdf->AddPage();
                         $pdf->Image('../images/logo/essai1.jpg', 10, 6, 30);
                         if (isset($_SESSION['login2'])) {
                             $pdf->SetFont('Times', '', 18);
                             $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
                             $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
                             $pdf->SetX((210 - $w) / 2);
                             $pdf->Cell($w, 7, $titre3, 0, 'C');
                             $pdf->Ln();
                             $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
                             $pdf->SetX((210 - $w) / 2);
                             $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
                             $pdf->Ln();
                             $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
                             $pdf->SetX((210 - $w) / 2);
                             $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
                             $pdf->Ln();
                             $pdf->SetFont('Times', '', 12);
                             $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
                             $pdf->SetX((210 - $w) / 2);
                             $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
                             $pdf->Ln(15);
                         }
                         $pdf->Cell(90);
                         $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj($info_veto2->nom) . "\n" . requetemysql::gestion_string_norm($info_veto2->adresse) . "\n" . requetemysql::gestion_string_norm($info_veto2->code) . ' ' . requetemysql::gestion_string_norm($info_veto2->commune), 0, 'C');
                         $pdf->Ln(25);
                         $pdf->Cell(90);
                         $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
                         if (isset($_SESSION['login2'])) {
                             $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L');
                         } else {
                             $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L');
                         }
                         $pdf->SetFont('Times', '', 18);
                         $pdf->SetFillColor(153, 153, 153);
                         $pdf->SetTextColor(0, 0, 0);
                         $pdf->SetDrawColor(153, 153, 153);
                         $pdf->SetLineWidth(0.3);
                         $pdf->SetFont('', 'B');
                         $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT7 . " " . requetemysql::gestion_string_maj(htmlentities($row2->login)) . " :" . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
                         $pdf->SetFont('Times', '', 10);
                         // Largeurs des colonnes
                         $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7);
                         $header = $arr['liste_jour'];
                         $hauteur = 3;
                         $x2 = $pdf->GetY();
                         // En-tête
                         for ($i = 0; $i < count($header); $i++) {
                             $pdf->SetXY($w[$i] * $i + 10, $x2);
                             $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C');
                             if ($header[$i]["valeur"] == date("w", $date_debut)) {
                                 $case_vide = $i - 1;
                             }
                         }
                         $pdf->Ln();
                         $x2 = $pdf->GetY();
                         if ($case_vide >= 0) {
                             for ($i = 0; $i <= $case_vide; $i++) {
                                 $pdf->SetXY($w[$i] * $i + 10, $x2);
                                 $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C');
                             }
                         }
                         $x3 = ($case_vide + 1) * $w[$i] + 10;
                         $max_y = 0;
                     }
                     // Données
                     $pdf->SetFont('Times', '', 8);
                     $trouve = false;
                     $mon_texte = date("d", $date_debut) . "\n";
                     foreach ($planning2 as $row) {
                         if ($date_debut == $row->ma_date / 1000) {
                             $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure');
                             if ($row->login == $row2->login) {
                                 if ($choix_affichage == 2) {
                                     $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "-" . $row->end_heure . " \n";
                                 } else {
                                     if ($choix_affichage == 1) {
                                         if (count($mon_item) == 0 && $row->start_heure != '00:00') {
                                             $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                                         } else {
                                             if ($row->start_heure != '00:00') {
                                                 $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n";
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 //		$mon_texte .= ($row['nature']==0 ? "G" : "A").": ".$row->start_heure."-".$row->end_heure." \n" ;
                             }
                             $trouve = true;
                         }
                     }
                     if ($trouve == true) {
                         $pdf->SetXY($x3, $x2);
                         $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false);
                         $max_y2 = $pdf->GetY();
                         if ($max_y2 > $max_y) {
                             $max_y = $max_y2;
                         }
                     }
                     if ($trouve == false) {
                         $pdf->SetXY($x3, $x2);
                         $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false);
                         $max_y2 = $pdf->GetY();
                         if ($max_y2 > $max_y) {
                             $max_y = $max_y2;
                         }
                     }
                     if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) {
                         $x2 = $max_y;
                         $x2 += $hauteur;
                         $x3 = 10;
                         $max_y = 0;
                     } else {
                         $x3 += $w[0];
                     }
                     $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut));
                 }
             }
         }
         if ($arr['cas_affichage'] == 3) {
             $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000));
             $date_debut_o = $date_debut;
             $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000));
             while ($date_debut < $date_fin) {
                 if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) {
                     $pdf->AddPage();
                     $pdf->SetFont('Times', '', 12);
                     $pdf->Cell(90);
                     $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
                     if (isset($_SESSION['login2'])) {
                         $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L');
                     } else {
                         $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L');
                     }
                     $pdf->SetFont('Times', '', 18);
                     $pdf->SetFillColor(153, 153, 153);
                     $pdf->SetTextColor(0, 0, 0);
                     $pdf->SetDrawColor(153, 153, 153);
                     $pdf->SetLineWidth(0.3);
                     $pdf->SetFont('', 'B');
                     $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT10 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
                     $pdf->SetFont('Times', '', 10);
                     // Largeurs des colonnes
                     $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7);
                     $hauteur = 3;
                     $x2 = $pdf->GetY();
                     // En-tête
                     for ($i = 0; $i < count($header); $i++) {
                         $pdf->SetXY($w[$i] * $i + 10, $x2);
                         $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C');
                         if ($header[$i]["valeur"] == date("w", $date_debut)) {
                             $case_vide = $i - 1;
                         }
                     }
                     $pdf->Ln();
                     $x2 = $pdf->GetY();
                     if ($case_vide >= 0) {
                         for ($i = 0; $i <= $case_vide; $i++) {
                             $pdf->SetXY($w[$i] * $i + 10, $x2);
                             $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C');
                         }
                     }
                     $x3 = ($case_vide + 1) * $w[$i] + 10;
                     $max_y = 0;
                 }
                 // Données
                 $pdf->SetFont('Times', '', 8);
                 $trouve = false;
                 $mon_texte = date("d", $date_debut) . "\n";
                 foreach ($planning2 as $row) {
                     if ($date_debut == $row->ma_date / 1000) {
                         $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure');
                         if ($choix_affichage == 2) {
                             $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                         } else {
                             if ($choix_affichage == 1) {
                                 if (count($mon_item) == 0 && $row->start_heure != '00:00') {
                                     $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n";
                                 } else {
                                     if ($row->start_heure != '00:00') {
                                         $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n";
                                     }
                                 }
                             }
                         }
                         $trouve = true;
                     }
                 }
                 if ($trouve == true) {
                     $pdf->SetXY($x3, $x2);
                     $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false);
                     $max_y2 = $pdf->GetY();
                     if ($max_y2 > $max_y) {
                         $max_y = $max_y2;
                     }
                 }
                 if ($trouve == false) {
                     $pdf->SetXY($x3, $x2);
                     $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false);
                     $max_y2 = $pdf->GetY();
                     if ($max_y2 > $max_y) {
                         $max_y = $max_y2;
                     }
                 }
                 if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) {
                     $x2 = $max_y;
                     $x2 += $hauteur;
                     $x3 = 10;
                     $max_y = 0;
                 } else {
                     $x3 += $w[0];
                 }
                 $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut));
             }
             if (isset($_SESSION['login2'])) {
                 $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login'])));
                 if (empty($info_veto)) {
                     throw new Exception("Erreur dans la recherche des informations sur le vétérinaire");
                 } else {
                     $info_veto = json_decode($info_veto, true);
                 }
             }
             $var_tempo = $arr['login'];
             $info_veto2 = array_values(array_filter($arr['team'], function ($var) use($var_tempo) {
                 return $var->login == $var_tempo;
             }));
             //		var_error_log($info_veto2[0]);
             $pdf->AddPage();
             $pdf->Image('../images/logo/essai1.jpg', 10, 6, 30);
             if (isset($_SESSION['login2'])) {
                 $pdf->SetFont('Times', '', 18);
                 $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
                 $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, $titre3, 0, 'C');
                 $pdf->Ln();
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
                 $pdf->Ln();
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
                 $pdf->Ln();
                 $pdf->SetFont('Times', '', 12);
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
                 $pdf->Ln(15);
             }
             $pdf->Cell(90);
             $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj($info_veto2[0]->nom) . "\n" . requetemysql::gestion_string_norm($info_veto2[0]->adresse) . "\n" . requetemysql::gestion_string_norm($info_veto2[0]->code) . ' ' . requetemysql::gestion_string_norm($info_veto2[0]->commune), 0, 'C');
             $pdf->Ln(25);
             $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
             if (isset($_SESSION['login2'])) {
                 $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . $_SESSION['login2']), 0, 'L');
             } else {
                 $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT23), 0, 'L');
             }
             $pdf->SetFont('Times', '', 18);
             $pdf->SetFillColor(153, 153, 153);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetDrawColor(153, 153, 153);
             $pdf->SetLineWidth(0.3);
             $pdf->SetFont('', 'B');
             $pdf->MultiCell(0, 12, utf8_decode("Liste des gardes et des astreintes qui sont attribuées à :" . requetemysql::gestion_string_maj(htmlentities($arr['login'])) . " sur la période du :" . requetemysql::gestion_string_norm($_POST['date_debut']) . " au " . requetemysql::gestion_string_norm($_POST['date_fin'])), 0, '', true);
             $pdf->SetFont('Times', '', 12);
             // Largeurs des colonnes
             $w = array(190 / 6, 190 / 7, 190 / 10, 190 / 10, 190 / 10, 190 / 10, 190 / 7, 190 / 7);
             $header = array(utf8_decode(TXT_CHARGEMENT_EXPORT25), utf8_decode(TXT_CHARGEMENT_EXPORT26), utf8_decode("jour sem"), utf8_decode("nuit sem"), utf8_decode("nuit we"), utf8_decode("jour we"), utf8_decode('heure de début'), utf8_decode('heure de fin'));
             // En-tête
             for ($i = 0; $i < count($header); $i++) {
                 $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
             }
             $pdf->Ln();
             // Données
             $pdf->SetFont('Times', '', 8);
             foreach ($planning2 as $row) {
                 if ($row->login == $arr['login']) {
                     $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure');
                     if ($choix_affichage == 2) {
                         $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C');
                         $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R');
                         $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R');
                         $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R');
                         $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row->end_heure), 'LR', 0, 'R');
                         $pdf->Ln();
                     } else {
                         if ($choix_affichage == 1) {
                             if (count($mon_item) == 0 && $row->start_heure != '00:00') {
                                 $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C');
                                 $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R');
                                 $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R');
                                 $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R');
                                 $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R');
                                 $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R');
                                 $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R');
                                 $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row->end_heure), 'LR', 0, 'R');
                                 $pdf->Ln();
                             } else {
                                 if ($row->start_heure != '00:00') {
                                     //		$mon_texte .= ($row->nature==0 ? "G" : "A").": ".$row->login." ".$row->start_heure."h-".$mon_item[0]->end_heure."h(J+1) \n" ;
                                     $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C');
                                     $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R');
                                     $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R');
                                     $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R');
                                     $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R');
                                     $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R');
                                     $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R');
                                     $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($mon_item[0]->end_heure . "(J+1)"), 'LR', 0, 'R');
                                     $pdf->Ln();
                                 }
                             }
                         }
                     }
                 }
             }
             // Trait de terminaison
             $pdf->Cell(array_sum($w), 0, '', 'T');
             $pdf->Ln(20);
         }
         if ($arr['cas_affichage'] == 3) {
             $mon_url = $filename . $arr['login'] . '_planning_' . requetemysql::gestion_string_norm($arr['date_debut2']) . "_" . requetemysql::gestion_string_norm($arr['date_fin2']) . uniqid() . '.pdf';
         } else {
             $mon_url = $filename . 'planning_' . requetemysql::gestion_string_norm($arr['date_debut2']) . "_" . requetemysql::gestion_string_norm($arr['date_fin2']) . uniqid() . '.pdf';
         }
         //$pdf->Output($mon_url, F);
         $pdf->Output('../' . $mon_url, F);
         return json_encode($mon_url);
     } catch (Exception $e) {
         return 'Exception -> ';
         var_dump($e->getMessage());
     }
 }