$where["reglement.date"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max} 23:59:59'";
// Filtre sur les modes de paiement
if ($filter->_mode_reglement) {
    $where["reglement.mode"] = "= '{$filter->_mode_reglement}'";
}
// Filtre sur les praticiens
$chir_id = CValue::getOrSession("chir");
$listPrat = CConsultation::loadPraticiensCompta($chir_id);
// Chargement des règlements via les factures
$ljoin["facture_cabinet"] = "reglement.object_id = facture_cabinet.facture_id";
if (!$all_group_compta) {
    $where["facture_cabinet.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
}
$where["facture_cabinet.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
$where["reglement.object_class"] = " = 'CFactureCabinet'";
$reglement = new CReglement();
/** @var CReglement[] $reglements */
$reglements = $reglement->loadList($where, " facture_cabinet.facture_id, reglement.date", null, null, $ljoin);
$reglement = new CReglement();
// Calcul du récapitulatif
// Initialisation du tableau de reglements
$recapReglement["total"] = array("nb_consultations" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "secteur1" => "0", "secteur2" => "0", "secteur3" => "0", "du_tva" => "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");
}
$listReglements = array();
$listConsults = array();
$factures = CStoredObject::massLoadFwdRef($reglements, "object_id");
$patients = CStoredObject::massLoadFwdRef($factures, "patient_id");
CStoredObject::massCountBackRefs($factures, "notes");
foreach ($reglements as $_reglement) {
<?php

/**
 * $Id:$
 *
 * @package    Mediboard
 * @subpackage Cabinet
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision:$
 */
CCanDO::checkEdit();
// Chargement du reglement
$reglement = new CReglement();
$reglement->load(CValue::get("reglement_id"));
if ($reglement->_id) {
    $reglement->loadRefsNotes();
    $object = $reglement->loadTargetObject(true);
} else {
    $object = mbGetObjectFromGet("object_class", "object_id", "object_guid");
    $reglement->setObject($object);
    $reglement->date = "now";
    $reglement->emetteur = CValue::get("emetteur");
    $reglement->mode = CValue::get("mode");
    $reglement->montant = CValue::get("montant");
}
// Chargement des banques
$banque = new CBanque();
$banques = $banque->loadList(null, "nom");
/** @var CFactureCabinet $facture */
$facture = $object;
 function mapAndStorePayment(DOMNode $node, CFactureCabinet $facture, CIdSante400 $idex)
 {
     $reglement = new CReglement();
     $reglement->load($idex->object_id);
     // Recherche du règlement si pas retrouvé par son idex
     $reglement->setObject($facture);
     $reglement->date = $this->getDatePayment($node) . " 00:00:00";
     $amount_paid = $this->getAmountPaid($node);
     $reglement->montant = $amount_paid;
     $direction = $this->getDirection($node);
     if ($direction == "-") {
         $reglement->montant = $reglement->montant * -1;
     }
     $reglement->emetteur = "tiers";
     $reglement->mode = "autre";
     $reglement->loadOldObject();
     if ($reglement->_old && round($reglement->montant, 3) == round($reglement->_old->montant, 3)) {
         return $reglement;
     }
     // Mise à jour du montant (du_tiers) de la facture
     $value = $reglement->_old ? $reglement->montant - $reglement->_old->montant : $reglement->montant;
     // Acquittement de la facture associée ?
     if ($msg = $reglement->store()) {
         return $msg;
     }
     // Gestion de l'idex
     if (!$idex->object_id) {
         $idex->object_id = $reglement->_id;
     }
     $idex->last_update = CMbDT::dateTime();
     if ($msg = $idex->store()) {
         return $msg;
     }
     if ($direction != "+") {
         return $reglement;
     }
     return $reglement;
 }
 if (!$results[$i]["reference"]) {
     $results[$i]["errors"][] = "Le numéro de référence n'est pas défini";
 } else {
     /* @var CFactureEtablissement $facture*/
     $facture = new $facture_class();
     $facture->num_reference = $results[$i]["reference"];
     $facture->loadMatchingObject();
     if (!$facture->_id) {
         //Facture introuvable
         $results[$i]["errors"][] = "Extourne";
     }
     $facture->loadRefPatient();
     $facture->loadRefsObjects();
     $facture->loadRefsReglements();
     $facture->loadRefsRelances();
     $reglement = new CReglement();
     $reglement->mode = "BVR";
     $reglement->object_id = $facture->_id;
     $reglement->object_class = $facture->_class;
     $reglement->reference = $results[$i]["reference"];
     $reglement->emetteur = "patient";
     $date = $results[$i]["date_depot"];
     $reglement->date = "20" . substr($date, 0, 2) . "-" . substr($date, 2, 2) . "-" . substr($date, 4, 2) . " 00:00:00";
     $results[$i]["date_depot"] = CMbDT::date($reglement->date);
     $date = $results[$i]["date_traitement"];
     $results[$i]["date_traitement"] = CMbDT::date("20" . substr($date, 0, 2) . "-" . substr($date, 2, 2) . "-" . substr($date, 4, 2));
     $date = $results[$i]["date_inscription"];
     $results[$i]["date_inscription"] = CMbDT::date("20" . substr($date, 0, 2) . "-" . substr($date, 2, 2) . "-" . substr($date, 4, 2));
     $montant = $results[$i]["montant"];
     $results[$i]["montant"] = sprintf("%.2f", substr($montant, 0, 8) . "." . substr($montant, 8, 2));
     $reglement->montant = $results[$i]["montant"];
Exemple #5
0
$nbRemise = 0;
// Montant total des cheques
$montantTotal = 0;
$where = array();
$ljoin = array();
// Chargement des règlements via les factures
$ljoin["facture_cabinet"] = "facture_cabinet.facture_id = reglement.object_id";
$where["object_class"] = " = 'CFactureCabinet'";
$where['facture_cabinet.praticien_id'] = "= '{$praticien->_id}'";
if (!$all_group_compta) {
    $where["facture_cabinet.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
}
$where['reglement.mode'] = "= 'cheque' ";
$where['reglement.date'] = "BETWEEN '{$date_min}' AND '{$date_max} 23:59:59' ";
$order = "reglement.date ASC";
$reglement = new CReglement();
$reglements = $reglement->loadList($where, $order, null, "reglement.reglement_id", $ljoin);
// Chargements des consultations
$montantTotal = 0.0;
foreach ($reglements as $_reglement) {
    /** @var CReglement $_reglement*/
    $_reglement->loadTargetObject()->loadRefPatient();
    $_reglement->loadRefBanque();
    $montantTotal += $_reglement->montant;
}
$nbRemise = count($reglements);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("praticien", $praticien);
$smarty->assign("reglements", $reglements);
$smarty->assign("date", CMbDT::date());
Exemple #6
0
 /**
  * Duplication de la facture
  *
  * @return void|string
  **/
 function duplicate()
 {
     /** @var CFacture $new*/
     $new = new $this->_class();
     $new->cloneFrom($this);
     if ($msg = $new->store()) {
         return $msg;
     }
     $liaison = new CFactureLiaison();
     $liaison->facture_id = $this->_id;
     $liaison->facture_class = $this->_class;
     $liaison->loadMatchingObject();
     $new_liaison = new CFactureLiaison();
     $new_liaison->cloneFrom($liaison, $new->_id);
     if ($msg = $new_liaison->store()) {
         return $msg;
     }
     $this->loadRefsReglements();
     foreach ($this->_ref_reglements as $reglement) {
         // Clonage
         $new_reglement = new CReglement();
         foreach ($reglement->getProperties() as $name => $value) {
             $new_reglement->{$name} = $value;
         }
         // Enregistrement
         $new_reglement->_id = null;
         $new_reglement->object_id = $new->_id;
         if ($msg = $new_reglement->store()) {
             return $msg;
         }
     }
     $this->loadRefsRelances();
     foreach ($this->_ref_relances as $relance) {
         // Clonage
         $new_relance = new CRelance();
         foreach ($relance->getProperties() as $name => $value) {
             $new_relance->{$name} = $value;
         }
         // Enregistrement
         $new_relance->_id = null;
         $new_relance->object_id = $new->_id;
         if ($msg = $new_relance->store()) {
             return $msg;
         }
     }
 }
$prat_id = CValue::get("prat_id");
$date_min = CValue::get("_date_min");
$date_max = CValue::get("_date_max");
$journal_pdf = new CEditJournal();
$journal_pdf->type_pdf = $type == "all-paiement" ? "paiement" : $type;
$journal_pdf->date_min = $date_min;
$journal_pdf->date_max = $date_max;
$where = array();
if ($type == "paiement" || $type == "all-paiement") {
    if ($type == "all-paiement") {
        $where["lock"] = " = '0'";
    } else {
        $where["date"] = "BETWEEN '{$date_min} 00:00:00' AND '{$date_max} 23:59:00'";
    }
    $where["object_class"] = " = 'CFactureEtablissement'";
    $reglement = new CReglement();
    $journal_pdf->reglements = $reglement->loadList($where, "debiteur_id, debiteur_desc, date");
    foreach ($journal_pdf->reglements as $_reglement) {
        /** @var CReglement $_reglement */
        $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);
            }
        }
    }
}