Beispiel #1
0
 /**
  * Chargement des différents numéros de BVR de la facture
  *
  * @return void|string
  **/
 function loadNumerosBVR()
 {
     $use_tarmed = CModule::getActive("tarmed") && CAppUI::conf("tarmed CCodeTarmed use_cotation_tarmed");
     if ($use_tarmed && !count($this->_montant_factures_caisse)) {
         $this->_total_tarmed = 0;
         $this->_total_caisse = 0;
         $this->_autre_tarmed = 0;
         $this->loadTotaux();
         $montant_temporaire = $this->_total_tarmed * $this->_coeff + $this->_autre_tarmed;
         $montant_prem = CFacture::roundValue($montant_temporaire, $this->_no_round);
         $this->_total_caisse = CFacture::roundValue($this->_total_caisse, $this->_no_round);
         if ($montant_prem < 0) {
             $montant_prem = 0;
         }
         if ($this->_total_tarmed || $this->_autre_tarmed) {
             $this->_montant_factures_caisse[0] = sprintf("%.2f", $montant_prem - $this->remise);
         }
         if ($this->_total_caisse > 0) {
             $this->_montant_factures_caisse[1] = $this->_total_caisse;
         }
         $this->_montant_sans_remise = CFacture::roundValue($montant_prem + $this->_total_caisse, $this->_no_round);
         $this->_montant_avec_remise = CFacture::roundValue($this->_montant_sans_remise - $this->remise, $this->_no_round);
         if (count($this->_montant_factures) == 1) {
             $this->_montant_factures = $this->_montant_factures_caisse;
         } else {
             $this->_montant_factures_caisse = $this->_montant_factures;
         }
         if (!$this->_ref_praticien) {
             $this->loadRefPraticien();
         }
         // Le numéro de référence doit comporter 16 ou 27 chiffres avec la clé de controle
         $num = $this->_id;
         $nbcolonnes = 26 - strlen($this->_ref_praticien->debut_bvr);
         $num = sprintf("%0" . $nbcolonnes . "s", $num);
         $num = $this->_ref_praticien->debut_bvr . $num;
         $cle_ref = $this->getNoControle($num);
         $num = $num . $cle_ref;
         if (!$this->num_reference || $num != $this->num_reference) {
             $this->num_reference = $num;
             $this->store();
         }
         $genre = "01";
         if (!$this->_ref_praticien->adherent) {
             $this->_ref_praticien->adherent = "00000000";
         }
         $adherent = $this->loadNumAdherent($this->_ref_praticien->adherent);
         $adherent2 = $adherent["bvr"];
         foreach ($this->_montant_factures_caisse as $montant_facture) {
             $montant = sprintf('%010s', CFacture::roundValue($montant_facture, true) * 100);
             $cle = $this->getNoControle($genre . $montant);
             $this->_num_bvr[$montant_facture] = $genre . $montant . $cle . ">" . $this->num_reference . "+ " . $adherent2 . ">";
         }
     }
     return $this->_num_bvr;
 }
 /**
  * @see parent::fillTemplate()
  */
 function fillTemplate(&$template)
 {
     parent::fillLimitedTemplate($template);
 }
 /**
  * Edition du centre du justificatif
  *
  * @param int $cle_facture     clé de la facture
  * @param int $montant_facture montant de la facture
  *
  * @return void
  */
 function editCenterJustificatif($cle_facture, $montant_facture)
 {
     $this->loadAllElements();
     $this->pdf->AddPage();
     $pm = $pm_notcoeff = $pt = $pt_notcoeff = $medicaments = 0;
     $this->ajoutEntete1();
     $this->pdf->setFont($this->font, '', 8);
     $tailles_colonnes = array("Date" => 7, "Tarif" => 4, "Code" => 10, "Code réf" => 6, "Sé Cô" => 5, "Quantité" => 9, "Pt PM/Prix" => 8, "fPM" => 5, "VPtPM" => 6, "Pt PT" => 5, "fPT" => 4, "VPtPT" => 4, "E" => 2, "R" => 2, "P" => 2, "M" => 2, "Montant" => 10);
     $x = 0;
     $this->pdf->setX(15);
     foreach ($tailles_colonnes as $key => $value) {
         $this->editCell($this->pdf->getX() + $x, 140, $value, $key, "C");
         $x = $value;
     }
     $ligne = 0;
     $debut_lignes = 140;
     $nb_pages = 1;
     $montant_intermediaire = 0;
     $tab_actes = array("tarmed" => $this->facture->_ref_actes_tarmed, "caisse" => $this->facture->_ref_actes_caisse);
     foreach ($tab_actes as $keytab => $tab_acte) {
         foreach ($tab_acte as $acte) {
             $use_qte_null = CAppUI::conf("dPfacturation Other use_view_quantitynull");
             $qte_null = $acte->quantite != 0 && $use_qte_null || !$use_qte_null;
             $tab_tarmed = $cle_facture == 0 && $keytab == "tarmed";
             $tab_caisse = $cle_facture == 1 && !$acte->use_tarmed_bill || $cle_facture == 0 && $acte->type == "CActeCaisse" && $acte->use_tarmed_bill;
             if (($tab_tarmed || $keytab == "caisse" && $tab_caisse) && $qte_null) {
                 $ligne++;
                 $this->pdf->setXY(37, $debut_lignes + $ligne * 3);
                 //Traitement pour le bas de la page et début de la suivante
                 if ($this->pdf->getY() >= 265) {
                     $this->pdf->setFont($this->fontb, '', 8);
                     $this->editCell($this->pdf->getX(), $debut_lignes + $ligne * 3, 130, "Total Intermédiaire", "R");
                     $this->pdf->Cell(28, "", round($montant_intermediaire, 2), null, null, "R");
                     $this->pdf->setFont($this->font, '', 8);
                     $this->pdf->AddPage();
                     $nb_pages++;
                     $this->ajoutEntete2($nb_pages);
                     $this->editCell(10, $this->pdf->getY() + 4, $this->colonnes[0] + $this->colonnes[1], "Patient");
                     $this->pdf->Cell($this->colonnes[2], "", $this->patient->nom . " " . $this->patient->prenom . " " . $this->patient->naissance);
                     $this->pdf->Line(10, 42, 190, 42);
                     $this->pdf->Line(10, 38, 10, 42);
                     $this->pdf->Line(190, 38, 190, 42);
                     $ligne = 0;
                     $debut_lignes = 50;
                     $this->pdf->setXY(10, 0);
                 }
                 $this->pdf->setFont($this->fontb, '', 7);
                 $this->pdf->setXY(37, $debut_lignes + $ligne * 3);
                 $code = "001";
                 if ($keytab == "caisse") {
                     $code = $acte->code_caisse;
                 }
                 $this->pdf->Write("<b>", substr($acte->libelle, 0, 90));
                 $ligne++;
                 //Si le libelle est trop long
                 if (strlen($acte->libelle) > 90) {
                     $this->pdf->setXY(37, $debut_lignes + $ligne * 3);
                     $this->pdf->Write("<b>", substr($acte->libelle, 90));
                     $ligne++;
                 }
                 $x = 0;
                 $this->pdf->setX(15);
                 $this->pdf->setFont($this->font, '', 8);
                 foreach ($tailles_colonnes as $key => $largeur) {
                     $valeur = "";
                     $cote = "C";
                     switch ($key) {
                         case "Date":
                             $valeur = $acte->date;
                             $valeur = CMbDT::format($valeur, "%d.%m.%Y");
                             break;
                         case "Tarif":
                             $valeur = $code;
                             break;
                         case "Code réf":
                             $valeur = $acte->code_ref;
                             break;
                         case "Sé Cô":
                             $valeur = $acte->seance;
                             break;
                         case "Quantité":
                             $valeur = $acte->quantite;
                             break;
                         case "Pt PM/Prix":
                             $valeur = $acte->pm;
                             $cote = "R";
                             break;
                         case "fPM":
                             $valeur = $acte->coeff_pm;
                             break;
                         case "VPtPM":
                         case "VPtPT":
                             $valeur = $acte->coeff;
                             break;
                         case "Pt PT":
                             $valeur = $acte->pt;
                             $cote = "R";
                             break;
                         case "fPT":
                             $valeur = $acte->coeff_pt;
                             break;
                         case "Montant":
                             $this->pdf->setX($this->pdf->getX() + 3);
                             $valeur = sprintf("%.2f", $acte->montant_base * $acte->coeff * $acte->quantite);
                             $cote = "R";
                             break;
                         case "E":
                         case "R":
                             $valeur = "1";
                             break;
                         case "P":
                         case "M":
                             $valeur = "0";
                             break;
                     }
                     if ($key == "Code" && $acte->code != 10) {
                         $valeur = $acte->code;
                     }
                     $this->editCell($this->pdf->getX() + $x, $debut_lignes + $ligne * 3, $largeur, $valeur, $cote);
                     $x = $largeur;
                 }
                 $this_pt = $acte->pt * $acte->coeff_pt;
                 $this_pm = $acte->pm * $acte->coeff_pm;
                 if (round($acte->montant_base, 2) != round($this_pt + $this_pm, 2)) {
                     $this_pt = 0;
                     $this_pm = $acte->montant_base * $acte->coeff;
                 }
                 $this_pt *= $acte->quantite;
                 $this_pm *= $acte->quantite;
                 if ($acte->type == "CActeTarmed") {
                     $pt += $this_pt * $acte->coeff;
                     $pm += $this_pm * $acte->coeff;
                     $pt_notcoeff += $this_pt;
                     $pm_notcoeff += $this_pm;
                 } else {
                     if ($acte->code_caisse) {
                         $caisse = new CActeCaisse();
                         $caisse->code = $acte->code;
                         $caisse->loadRefPrestationCaisse();
                         if ($caisse->_ref_caisse_maladie->nom == "Medicament") {
                             $medicaments += $acte->montant_base;
                         }
                     }
                 }
                 $montant_intermediaire += $this_pt * $acte->coeff;
                 $montant_intermediaire += $this_pm * $acte->coeff;
             }
         }
     }
     $pt = sprintf("%.2f", $pt);
     $pm = sprintf("%.2f", $pm);
     $pm_notcoeff = sprintf("%.2f", $pm_notcoeff);
     $pt_notcoeff = sprintf("%.2f", $pt_notcoeff);
     $this->pdf->setFont($this->fontb, '', 8);
     $ligne = 265;
     $l = 35;
     $this->editCell(20, $ligne + 3, $l, "Tarmed PM", "R");
     $this->pdf->Cell($l, "", "{$pm} ({$pm_notcoeff})", null, null, "R");
     $this->editCell(20, $ligne + 6, $l, "Tarmed PT", "R");
     $this->pdf->Cell($l, "", "{$pt} ({$pt_notcoeff})", null, null, "R");
     $montant_facture = abs($montant_intermediaire - $montant_facture) <= 0.09 ? $montant_intermediaire : $montant_facture;
     $autre_temp = $cle_facture == 0 ? $montant_facture - $pm - $pt - $medicaments : $montant_facture;
     $autre_temp = sprintf("%.2f", $autre_temp);
     $autre = $autre_temp <= 0.05 ? 0.0 : $autre_temp;
     $this->editCell(80, $ligne + 3, $l, "Médicaments", "R");
     $this->pdf->Cell(20, "", sprintf("%.2f", $medicaments), null, null, "R");
     $this->editCell(80, $ligne + 6, $l, "Autres", "R");
     $this->pdf->Cell(20, "", sprintf("%.2f", $autre), null, null, "R");
     $this->editCell(20, $ligne + 9, $l, "Montant total/CHF", "R");
     $this->pdf->Cell(20, "", sprintf("%.2f", $montant_intermediaire), null, null, "R");
     $acompte = sprintf("%.2f", $this->facture->_reglements_total_patient);
     $this->editCell(80, $ligne + 9, $l, "Acompte", "R");
     $this->pdf->Cell(20, "", "" . $acompte, null, null, "R");
     $total_temp = $montant_intermediaire - $this->facture->_reglements_total_patient;
     $total = $total_temp < 0 ? 0.0 : $total_temp;
     $this->editCell(130, $ligne + 9, $l, "Montant dû", "R");
     $this->pdf->Cell(20, "", CFacture::roundValue($total, $this->facture->_no_round), null, null, "R");
 }