/**
  * Création d'un item de facture pour un frais divers
  *
  * @param CFacture $facture la facture
  * @param string   $date    date à défaut
  *
  * @return string|null
  */
 function creationItemsFacture($facture, $date)
 {
     $this->loadRefType();
     $ligne = new CFactureItem();
     $ligne->libelle = $this->_ref_type->libelle;
     $ligne->code = $this->_ref_type->code;
     $ligne->type = $this->_class;
     $ligne->object_id = $facture->_id;
     $ligne->object_class = $facture->_class;
     $ligne->date = $date;
     $ligne->montant_base = $this->montant_base;
     $ligne->montant_depassement = $this->montant_depassement;
     $ligne->quantite = $this->quantite;
     $ligne->coeff = $this->coefficient;
     $msg = $ligne->store();
     return $msg;
 }
$items_delete = 0;
if (!$see) {
    //Suppression des lignes en trop
    foreach ($items_to_delete as $_item) {
        $item = new CFactureItem();
        if ($item->load($_item["factureitem_id"])) {
            $where = array();
            $where["factureitem_id"] = " != '" . $_item["factureitem_id"] . "'";
            $where["object_id"] = " = '" . $_item["object_id"] . "'";
            $where["object_class"] = " = '" . $_item["object_class"] . "'";
            $where["date"] = " = '" . $_item["date"] . "'";
            $where["type"] = " = '" . $_item["type"] . "'";
            $where["montant_base"] = " = '" . $_item["montant_base"] . "'";
            $where["montant_depassement"] = " = '" . $_item["montant_depassement"] . "'";
            $where["quantite"] = " = '" . $_item["quantite"] . "'";
            $new_item = new CFactureItem();
            $new_items = $new_item->loadList($where);
            if (count($new_items)) {
                foreach ($new_items as $_dell_item) {
                    if ($msg = $_dell_item->delete()) {
                        echo $msg;
                    } else {
                        $items_delete++;
                    }
                }
            }
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
 /**
  * Création d'un item de facture avec un code ccam
  * 
  * @param CFacture $facture La facture
  * @param string   $date    Date à défaut
  * 
  * @return string
  **/
 function creationItemsFacture($facture, $date)
 {
     $this->loadRefCodeCCAM();
     $ligne = new CFactureItem();
     $ligne->libelle = $this->_ref_code_ccam->libelleCourt;
     $ligne->code = "{$this->code_acte} {$this->modificateurs}";
     $ligne->type = $this->_class;
     $ligne->object_id = $facture->_id;
     $ligne->object_class = $facture->_class;
     $ligne->date = CMbDT::date($this->execution);
     $ligne->montant_base = $this->montant_base;
     $ligne->montant_depassement = $this->montant_depassement;
     $ligne->quantite = 1;
     $ligne->coeff = $facture->_coeff;
     if ($msg = $ligne->store()) {
         return $msg;
     }
     return null;
 }
Esempio n. 4
0
 /**
  * Redéfinition du delete
  *
  * @return void|string
  **/
 function delete()
 {
     if (count($this->_ref_reglements)) {
         return "Vous ne pouvez pas supprimer une facture ayant des règlements";
     }
     if (count($this->_ref_relances)) {
         return "Vous ne pouvez pas supprimer une facture ayant des relances";
     }
     if (CModule::getActive("dPfacturation")) {
         $where = array();
         $where["object_id"] = " = '{$this->_id}'";
         $where["object_class"] = " = '{$this->_class}'";
         $item = new CFactureItem();
         $items = $item->loadList($where);
         foreach ($items as $_item) {
             if ($msg = $_item->delete()) {
                 return $msg;
             }
         }
         $where = array();
         $where["facture_id"] = " = '{$this->_id}'";
         $where["facture_class"] = " = '{$this->_class}'";
         $where[] = "object_class = 'Sejour' OR object_class = 'CConsultation'";
         $liaison = new CFactureLiaison();
         $liaisons = $liaison->loadList($where);
         foreach ($liaisons as $lien) {
             if ($msg = $lien->delete()) {
                 return $msg;
             }
         }
     }
     // Standard delete
     if ($msg = parent::delete()) {
         return $msg;
     }
 }