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(); $smarty->assign("factures", $factures);
/** * 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; } }