Add TODO to refuse delete if there is payments

This commit is contained in:
Laurent Destailleur 2009-06-04 21:29:19 +00:00
parent 118f418074
commit 56f1ba6e1b
2 changed files with 67 additions and 53 deletions

View File

@ -936,6 +936,9 @@ class Facture extends CommonObject
dol_syslog("Facture::delete rowid=".$rowid, LOG_DEBUG); dol_syslog("Facture::delete rowid=".$rowid, LOG_DEBUG);
// TODO Test if there is at least on payment. If yes, refuse to delete.
$error=0;
$this->db->begin(); $this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'fa_pr WHERE fk_facture = '.$rowid; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'fa_pr WHERE fk_facture = '.$rowid;

View File

@ -359,6 +359,15 @@ class FactureFournisseur extends Facture
*/ */
function delete($rowid) function delete($rowid)
{ {
global $user,$langs,$conf;
if (! $rowid) $rowid=$this->id;
dol_syslog("FactureFournisseur::delete rowid=".$rowid, LOG_DEBUG);
// TODO Test if there is at least on payment. If yes, refuse to delete.
$error=0;
$this->db->begin(); $this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
@ -369,7 +378,9 @@ class FactureFournisseur extends Facture
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
dol_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG); dol_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG);
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) if (! $resql2) $error++;
if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;