if (!isset($totaux["impute"]["dates"]["{$reglement->date}"])) {
                    $totaux["impute"]["dates"]["{$reglement->date}"] = array("count" => 0, "total" => 0.0);
                }
                $totaux["impute"]["dates"]["{$reglement->date}"]["count"]++;
                $totaux["impute"]["dates"]["{$reglement->date}"]["total"] += $reglement->montant;
            }
            if ($facture->_du_restant_patient - $reglement->montant > 0) {
                $results[$i]["warning"][] = "Paiement partiel";
            }
            // Dry run to check references
            if ($dryrun) {
                continue;
            }
            // Creation
            $existing = $reglement->_id;
            if ($msg = $reglement->store()) {
                CAppUI::setMsg($msg, UI_MSG_ERROR);
                $results[$i]["errors"][] = $msg;
                continue;
            }
            CAppUI::setMsg($existing ? "CReglement-msg-modify" : "CReglement-msg-create", UI_MSG_OK);
        }
    }
    fclose($fp);
}
CAppUI::callbackAjax('$("systemMsg").insert', CAppUI::getMsg());
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("results", $results);
$smarty->assign("totaux", $totaux);
$smarty->assign("facture_class", $facture_class);
 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;
 }
Esempio n. 3
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;
         }
     }
 }