Example #1
0
 /**
  * Redefinition du store
  * 
  * @return void|string
  **/
 function store()
 {
     if (!$this->_id && $this->object_class && $this->object_id) {
         $this->_ref_object = new $this->object_class();
         $this->_ref_object->load($this->object_id);
         $this->_ref_object->loadRefPatient();
         $this->_ref_object->loadRefPraticien();
         $this->_ref_object->loadRefsObjects();
         $this->_ref_object->loadRefsReglements();
         $this->_ref_object->loadRefsRelances();
         $this->date = CMbDT::date();
         $this->du_patient = $this->_ref_object->_du_restant_patient + $this->_ref_object->_reglements_total_patient;
         $this->du_tiers = $this->_ref_object->_du_restant_tiers + $this->_ref_object->_reglements_total_tiers;
         $der_relance = $this->_ref_object->_ref_last_relance;
         if ($der_relance->_id) {
             if ($der_relance->statut == "inactive") {
                 return "La derniere relance est inactive";
             }
             if ($der_relance->etat != "regle") {
                 $this->numero = $der_relance->numero + 1;
                 $der_relance->etat = "renouvelle";
                 $der_relance->store();
             } else {
                 return "La derniere relance est reglee";
             }
         }
         if (!$this->numero) {
             $this->numero = 1;
         }
         switch ($this->numero) {
             case "1":
                 $this->du_patient += CAppUI::conf("dPfacturation CRelance add_first_relance");
                 $this->statut = "first";
                 break;
             case "2":
                 $this->du_patient += CAppUI::conf("dPfacturation CRelance add_second_relance");
                 $this->statut = "second";
                 break;
             case "3":
                 $this->du_patient += CAppUI::conf("dPfacturation CRelance add_third_relance");
                 $this->statut = "third";
                 break;
         }
     }
     // Standard store
     if ($msg = parent::store()) {
         return $msg;
     }
 }
Example #2
0
$where["ouverture"] = "BETWEEN '{$date_min}' AND '{$date_max}'";
$where["facture_cabinet.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat));
$facture = new CFactureCabinet();
$list_taux = explode("|", CAppUI::conf("dPcabinet CConsultation default_taux_tva"));
foreach ($list_taux as $taux) {
    $where["taux_tva"] = " = '{$taux}'";
    $factures = $facture->loadGroupList($where, "ouverture, praticien_id");
    $taux_factures[$taux] = $factures;
}
$total_tva = 0;
$nb_factures = 0;
foreach ($taux_factures as $taux => $factures) {
    $nb_factures += count($factures);
    $total = $totalht = $totalttc = $totalst = 0;
    foreach ($factures as $facture) {
        $facture->loadRefPatient();
        $facture->loadRefPraticien();
        $facture->loadRefsObjects();
        $facture->loadRefsReglements();
        $total += $facture->du_tva;
        $totalht += $facture->_montant_avec_remise - $facture->du_tva;
        $totalttc += $facture->_montant_avec_remise;
        $totalst += $facture->_secteur3;
    }
    $taux_factures[$taux] = array();
    $taux_factures[$taux]["count"] = count($factures);
    $taux_factures[$taux]["total"] = $total;
    $taux_factures[$taux]["factures"] = $factures;
    $taux_factures[$taux]["totalst"] = $totalst;
    $taux_factures[$taux]["totalht"] = $totalht;
    $taux_factures[$taux]["totalttc"] = $totalttc;