/**
  * Edition de l'entete des journaux
  *
  * @return void
  */
 function editEntete()
 {
     $this->page++;
     $this->pdf->AddPage();
     $this->pdf->setFont($this->font, '', 10);
     $nom_journal = "";
     switch ($this->type_pdf) {
         case "paiement":
             $nom_journal = "Journal des paiements";
             break;
         case "debiteur":
             $nom_journal = "Journal de facturation";
             break;
         case "rappel":
             $nom_journal = "Journal rappels/contentieux";
             break;
         case "checklist":
             $definitive = $this->definitive ? "définitives" : "provisoires";
             $nom_journal = "Liste factures {$definitive} arrétées au " . CMbDT::transform("", CMbDT::date(), '%d/%m/%Y');
             break;
     }
     $this->editCell(10, 10, 70, CGroups::loadCurrent()->text);
     $this->pdf->Cell(160, "", $nom_journal, null, null, "C");
     $this->pdf->Cell(67, "", "Page: " . $this->page);
     $this->editCell(10, 15, 70, "Date : " . CMbDT::transform("", CMbDT::dateTime(), '%d/%m/%Y - %H:%M'));
     $this->editCell(240, 15, 70, "Numéro journal: " . $this->journal_id);
     //Les lignes
     $this->pdf->Line(5, 20, 293, 20);
     $this->pdf->Line(5, 30, 293, 30);
     $this->pdf->Line(5, 5, 5, 205);
     $this->pdf->Line(5, 5, 293, 5);
     $this->pdf->Line(293, 5, 293, 205);
     $this->pdf->Line(5, 205, 293, 205);
     $this->pdf->setFont($this->font, '', 9);
 }
 /**
  * Création du premier type d'en-tête possible d'un justificatif 
  * 
  * @return void
  */
 function ajoutEntete1()
 {
     $this->ajoutEntete2(1);
     $this->pdf->SetFillColor(255, 255, 255);
     $this->pdf->SetDrawColor(0);
     $this->pdf->Rect(10, 38, 180, 100);
     $_ref_assurance = "";
     $nom_entreprise = "";
     if ($this->facture->type_facture == "accident" && $this->facture->assurance_accident && $this->facture->_ref_assurance_accident->relation == "employeur") {
         $employeur = $this->facture->_ref_assurance_accident;
         $_ref_assurance = $employeur->num_assure;
         $nom_entreprise = $employeur->nom;
     }
     $loi = $this->facture->type_facture == "accident" ? "LAA" : "LAMal";
     $conf_cab = CAppUI::conf("tarmed coefficient pt_maladie", CGroups::loadCurrent());
     if ($this->facture->type_facture == "accident" && $this->facture->_coeff == $conf_cab) {
         $loi = "LAMal";
     }
     if ($this->facture->statut_pro == "invalide") {
         $loi = "LAI";
     }
     if ($this->facture->statut_pro == "militaire") {
         $loi = "AMF";
     }
     $assurance_patient = $this->destinataire[0];
     $assur_nom = "";
     if ($this->facture->_class != "CFactureCabinet" && $this->facture->dialyse && $this->facture->_ref_assurance_accident) {
         $assur_nom = $this->facture->_ref_assurance_accident->nom . " " . $this->facture->_ref_assurance_accident->prenom;
     }
     if (isset($assurance_patient->type_pec) && $assurance_patient->type_pec == "TS" && $this->type_rbt == "TG avec cession") {
         if (count($this->facture->_ref_reglements) && $this->type_pdf == "justif_TS") {
             $assur_nom = $this->patient->nom . " " . $this->patient->prenom;
         } else {
             $assur_nom = "{$assurance_patient->nom} {$assurance_patient->prenom}";
         }
         $assurance_patient = $this->patient;
     }
     $assur = array();
     $assur["civilite"] = isset($assurance_patient->civilite) ? ucfirst($this->patient->civilite) : "";
     $assur["nom"] = "{$assurance_patient->nom} {$assurance_patient->prenom}";
     $assur["adresse"] = "{$assurance_patient->adresse}";
     $assur["cp"] = "{$assurance_patient->cp} {$assurance_patient->ville}";
     $motif = $this->facture->type_facture;
     if ($this->facture->type_facture == "accident" && $this->facture->_coeff == $conf_cab) {
         $motif = "Accident (Caisse-Maladie)";
     }
     if ($this->facture->type_facture == "maladie" && in_array($this->facture->statut_pro, CFacture::$accident_lamal)) {
         $motif = "Accident";
     }
     $naissance = CMbDT::format($this->patient->naissance, "%d.%m.%Y");
     $colonnes = array(20, 28, 25, 25, 35, 50);
     if ($this->facture->_class == "CFactureCabinet") {
         $traitement = CMbDT::format($this->facture->_ref_first_consult->_date, "%d.%m.%Y") . " - ";
         $traitement .= CMbDT::format($this->facture->_ref_last_consult->_date, "%d.%m.%Y");
     } else {
         $traitement = CMbDT::format($this->facture->_ref_first_sejour->entree, "%d.%m.%Y") . " - ";
         $traitement .= CMbDT::format($this->facture->_ref_first_sejour->sortie, "%d.%m.%Y");
     }
     $name_rappel = $date_rappel = null;
     if (CAppUI::conf("dPfacturation CRelance use_relances")) {
         //$name_rappel = "Date rappel";
         //$date_rappel = CMbDT::date("+".CAppUI::conf("dPfacturation CRelance nb_days_first_relance")." DAY" , $this->facture->cloture);
         //$date_rappel = CMbDT::format($date_rappel, "%d.%m.%Y");
     }
     $date_cas = $this->facture->date_cas && $this->facture->type_facture == "accident" ? CMbDT::format($this->facture->date_cas, "%d.%m.%Y") : "";
     $ref_accident = $this->facture->ref_accident || $this->facture->statut_pro == "invalide" ? $this->facture->ref_accident : "";
     $ean2 = $this->group->ean;
     if ($this->facture->_class == "CFactureEtablissement" && $this->facture->_ref_last_sejour->_ref_last_operation) {
         $ean2 = $this->facture->_ref_last_sejour->_ref_last_operation->_ref_anesth->ean;
     }
     $num_fact = $this->facture->_id;
     if (CAppUI::conf("dPfacturation Other use_field_definitive") && !$this->facture->definitive) {
         $num_fact = "PROVISOIRE";
     }
     $see_diag_justificatif = CAppUI::conf("dPfacturation CEditPdf see_diag_justificatif", CGroups::loadCurrent());
     $msg_info = $see_diag_justificatif ? "U / Toute demande d'information est à adresser au chirurgien " . $this->praticien->_view : "";
     $lignes = array(array("Patient", "Nom", $this->patient->nom, null, "Assurance", $assur_nom), array("", "Prénom", $this->patient->prenom), array("", "Rue", $this->patient->adresse), array("", "NPA", $this->patient->cp, null, $assur["civilite"]), array("", "Localité", $this->patient->ville, null, $assur["nom"]), array("", "Date de naissance", $naissance, null, $assur["adresse"]), array("", "Sexe", strtoupper($this->patient->sexe), null, $assur["cp"]), array("", "Date cas", $date_cas), array("", "N° cas", $ref_accident), array("", "N° AVS", $this->patient->avs), array("", "N° assuré", $_ref_assurance), array("", "Nom entreprise", $nom_entreprise), array("", "Canton", CAppUI::conf("dPfacturation CEditPdf canton", CGroups::loadCurrent())), array("", "Copie", "Non"), array("", "Type de remb.", $this->type_rbt), array("", "Loi", $loi), array("", "N° contrat", ""), array("", "Motif traitement", $motif, null, "N° facture", $num_fact), array("", "Traitement", $traitement, null, "Date facture", CMbDT::format($this->facture->cloture, "%d.%m.%Y")), array("", "Rôle/ Localité", "-", null, $name_rappel, $date_rappel), array("Mandataire", "N° EAN/N° RCC", $this->praticien->ean . " - " . $this->praticien->rcc, null, $this->praticien->_view), array("Diagnostic", $msg_info), array("Liste EAN", "", "1/" . $this->praticien->ean . " 2/" . $ean2), array("Commentaire"));
     foreach ($lignes as $ligne) {
         $this->pdf->setXY(10, $this->pdf->getY() + 4);
         foreach ($ligne as $key => $value) {
             $this->pdf->Cell($colonnes[$key], "", $value);
         }
     }
     $this->pdf->Line(10, 119, 190, 119);
     $this->pdf->Line(10, 123, 190, 123);
     $this->pdf->Line(10, 127, 190, 127);
     $this->pdf->Line(10, 131, 190, 131);
 }