Пример #1
0
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
$where["facture_etablissement.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
// Initialisation du tableau de reglements
$reglement = new CReglement();
$recapReglement["total"] = array("nb_sejours" => "0", "reste_patient" => "0", "reste_tiers" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "nb_impayes_tiers" => "0", "nb_impayes_patient" => "0", "secteur1" => "0", "secteur2" => "0");
foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) {
    $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0");
}
// Reglements via les factures d'établissement
$where["cloture"] = "IS NOT NULL";
$where["facture_etablissement.patient_id"] = "IS NOT NULL";
$order = "ouverture, praticien_id";
//mbTrace(count($where));
$facture = new CFactureEtablissement();
$listFactures = $facture->loadGroupList($where, $order, null, "facture_id", $ljoin);
$listPlages = array();
foreach ($listFactures as $_facture) {
    /** @var CFacture $_facture*/
    $_facture->loadRefPatient();
    $_facture->loadRefPraticien();
    $_facture->loadRefsObjects();
    $_facture->loadRefsReglements();
    $_facture->loadRefsNotes();
    // Ajout de reglements
    $_facture->_new_reglement_patient = new CReglement();
    $_facture->_new_reglement_patient->setObject($_facture);
    $_facture->_new_reglement_patient->emetteur = "patient";
    $_facture->_new_reglement_patient->montant = $_facture->_du_restant_patient;
    $_facture->_new_reglement_tiers = new CReglement();
    $_facture->_new_reglement_tiers->setObject($_facture);