$fact->loadRefPraticien();
        $fact->loadRefsReglements();
        $fact->isRelancable();
    }
    $journal_pdf->editJournal(false);
    $journal_pdf->type_pdf = "checklist";
    $journal_pdf->definitive = $definitive;
    $journal_pdf->editJournal(false);
    if (!$facture_id) {
        if ($definitive) {
            foreach ($factures as $_facture) {
                if (!$_facture->definitive) {
                    $_facture->definitive = 1;
                    if ($msg = $_facture->store()) {
                        mbLog($msg);
                    }
                }
            }
        }
        unset($_GET["suppressHeaders"]);
    }
}
if ($type_pdf == "relance") {
    $relance = new CRelance();
    $relance->load($relance_id);
    if ($relance->_id) {
        $facture_pdf->factures = array($relance->loadRefFacture());
    }
    $facture_pdf->relance = $relance;
    $facture_pdf->editRelance();
}
 }
 if (count($factures)) {
     $nb_generate_pdf_relance = CAppUI::conf("dPfacturation CRelance nb_generate_pdf_relance");
     $facture_pdf = new CEditPdf();
     $facture_pdf->pdf = new CMbPdf('P', 'mm');
     $facture_pdf->pdf->setPrintHeader(false);
     $facture_pdf->pdf->setPrintFooter(false);
     $facture_pdf->font = "vera";
     $facture_pdf->fontb = $facture_pdf->font . "b";
     $nb_fact = 0;
     foreach ($factures as $_facture) {
         $nb_fact++;
         if ($nb_fact > $nb_generate_pdf_relance) {
             continue;
         }
         $relance = new CRelance();
         $relance->object_id = $_facture->_id;
         $relance->object_class = $_facture->_class;
         if ($msg = $relance->store()) {
             return $msg;
         }
         $facture_pdf->facture = $_facture;
         $facture_pdf->patient = $facture_pdf->facture->loadRefPatient();
         $facture_pdf->facture->_ref_patient->loadRefsCorrespondantsPatient();
         $facture_pdf->praticien = $facture_pdf->facture->loadRefPraticien();
         $facture_pdf->facture->loadRefAssurance();
         $facture_pdf->function_prat = $facture_pdf->praticien->loadRefFunction();
         $facture_pdf->group = $facture_pdf->function_prat->loadRefGroup();
         $facture_pdf->relance = $relance;
         $facture_pdf->editRelanceEntete();
         $facture_pdf->editBVR($facture_pdf->relance->_montant);
示例#3
0
        $fact = $_reglement->loadRefFacture();
        $fact->loadRefsReglements();
        if (!$fact->_id) {
            unset($journal_pdf->reglements[$_reglement->_id]);
        } elseif ($type == "all-paiement") {
            $_reglement->lock = "1";
            if ($msg = $_reglement->store()) {
                mbTrace($msg);
            }
        }
    }
}
if ($type == "rappel") {
    $where["date"] = "BETWEEN '{$date_min}' AND '{$date_max}'";
    $where["object_class"] = " = 'CFactureEtablissement'";
    $relance = new CRelance();
    $journal_pdf->relances = $relance->loadList($where, "statut, poursuite");
    foreach ($journal_pdf->relances as $_relance) {
        /** @var CRelance $_relance */
        $fact = $_relance->loadRefFacture();
        $fact->loadRefsObjects();
        $fact->loadRefPatient();
        $fact->loadRefPraticien();
        $fact->loadRefsReglements();
        $fact->isRelancable();
        if (!$fact->_id) {
            unset($journal_pdf->relances[$_relance->_id]);
        }
    }
}
if ($type == "debiteur") {
示例#4
0
 /**
  * Redéfinition du store
  *
  * @return void|string
  **/
 function store()
 {
     $this->completeField("numero", "group_id");
     if (!$this->group_id) {
         $this->group_id = CGroups::loadCurrent()->_id;
     }
     if ($this->_id && $this->_duplicate) {
         $this->_duplicate = null;
         if ($msg = $this->duplicate()) {
             return $msg;
         }
         $this->annule = 1;
         $this->definitive = 1;
     }
     if (!$this->cloture && $this->fieldModified("cloture") && count($this->_ref_reglements)) {
         return "Vous ne pouvez pas décloturer une facture ayant des règlements";
     }
     if (!$this->cloture && $this->fieldModified("cloture") && count($this->_ref_relances)) {
         return "Vous ne pouvez pas décloturer une facture ayant des relances";
     }
     $create_lignes = false;
     if (!$this->_id && CAppUI::conf("dPfacturation " . $this->_class . " use_auto_cloture")) {
         $this->cloture = CMbDT::date();
         $create_lignes = true;
     }
     //Si on cloture la facture création des lignes de la facture
     //Si on décloture on les supprime
     if ($this->cloture && $this->fieldModified("cloture") && !$this->_old->cloture) {
         $create_lignes = true;
     } elseif (!$this->cloture && $this->fieldModified("cloture")) {
         //Suppression des tous les items de la facture
         $this->loadRefsItems();
         foreach ($this->_ref_items as $item) {
             /** @var CFactureItem $item*/
             $item->delete();
         }
         $this->facture = 0;
     }
     // Etat des règlement à propager sur les consultations
     if ($this->fieldModified("patient_date_reglement") || $this->fieldModified("tiers_date_reglement")) {
         $this->loadRefsConsultation();
         foreach ($this->_ref_consults as $_consultation) {
             $_consultation->patient_date_reglement = $this->patient_date_reglement;
             $_consultation->tiers_date_reglement = $this->tiers_date_reglement;
             if ($msg = $_consultation->store()) {
                 return $msg;
             }
         }
         if ($this->isRelancable() && $this->_ref_last_relance->_id) {
             $this->_ref_last_relance->etat = $this->patient_date_reglement ? "regle" : "emise";
             $this->_ref_last_relance->store();
         }
     }
     $_object_id = null;
     $_object_class = null;
     //Lors de la validation de la cotation d'une consultation
     if ($this->_consult_id) {
         $consult = new CConsultation();
         $consult->load($this->_consult_id);
         $consult->loadRefPlageConsult();
         // Si la facture existe déjà on la met à jour
         $where = array();
         $ljoin = array();
         $plage = $consult->_ref_plageconsult;
         if (CAppUI::conf("ref_pays") == 2) {
             $where["patient_id"] = "= '{$consult->patient_id}'";
             $where["praticien_id"] = "= '" . ($plage->pour_compte_id ? $plage->pour_compte_id : $plage->chir_id) . "'";
             $where["cloture"] = "IS NULL";
         } else {
             $table = $consult->sejour_id ? "facture_etablissement" : "facture_cabinet";
             $ljoin["facture_liaison"] = "facture_liaison.facture_id = {$table}.facture_id";
             $where["facture_liaison.object_id"] = " = '{$this->_consult_id}'";
             $where["facture_liaison.object_class"] = " = 'CConsultation'";
             $where["facture_liaison.facture_class"] = " = '{$this->_class}'";
             $where["numero"] = " = '{$this->numero}'";
         }
         //Si la facture existe déjà
         if ($this->loadObject($where, null, "facture_id", $ljoin)) {
             //Dans le cas Suisse
             if (CAppUI::conf("ref_pays") == 2 && CModule::getActive("dPfacturation")) {
                 $ligne = new CFactureLiaison();
                 $ligne->facture_id = $this->_id;
                 $ligne->facture_class = $this->_class;
                 $ligne->object_id = $this->_consult_id;
                 $ligne->object_class = 'CConsultation';
                 if (!$ligne->loadMatchingObject()) {
                     $ligne->store();
                 }
             }
         } else {
             // Sinon on la crée
             $this->ouverture = CMbDT::date();
             $this->patient_id = $consult->patient_id;
             $this->praticien_id = $plage->pour_compte_id ? $plage->pour_compte_id : $plage->chir_id;
             $this->type_facture = $consult->pec_at == 'arret' ? "accident" : "maladie";
             if (CAppUI::conf("dPfacturation {$this->_class} use_auto_cloture")) {
                 $this->cloture = CMbDT::date();
                 $create_lignes = true;
             }
             if ($this->numero > 1 && !count($consult->loadRefsFraisDivers(1)) && count($consult->loadRefsFraisDivers($this->numero)) && $consult->du_tva) {
                 $frais = 0;
                 foreach ($consult->loadRefsFraisDivers($this->numero) as $_frais) {
                     $frais += $_frais->montant_base;
                 }
                 $this->du_patient = $frais + $consult->du_tva;
                 $this->du_tva = $consult->du_tva;
                 $this->taux_tva = $consult->taux_tva;
             }
         }
         $_object_id = $this->_consult_id;
         $_object_class = "CConsultation";
     }
     //Lors de la création d'une facture de séjour
     if ($this->_sejour_id) {
         $_object_id = $this->_sejour_id;
         $_object_class = "CSejour";
     }
     $this->completeField("assurance_maladie", "assurance_accident", "type_facture");
     if ($this->type_facture != "accident" && $this->assurance_accident) {
         $this->assurance_accident = "";
     }
     if ($this->type_facture != "maladie" && $this->assurance_maladie) {
         $this->assurance_maladie = "";
     }
     // Standard store
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($_object_id) {
         $ligne = new CFactureLiaison();
         $ligne->facture_id = $this->_id;
         $ligne->facture_class = $this->_class;
         $ligne->object_id = $_object_id;
         $ligne->object_class = $_object_class;
         if (!$ligne->loadMatchingObject()) {
             $ligne->store();
         }
     }
     if ($create_lignes) {
         $this->creationLignesFacture();
     }
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage dPfacturation
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @version    $Revision$
 */
CCanDo::checkEdit();
$relance_id = CValue::get("relance_id");
$relance = new CRelance();
$relance->load($relance_id);
// Creation du template
$smarty = new CSmartyDP();
$smarty->assign("relance", $relance);
$smarty->display("vw_edit_relance.tpl");