diff --git a/ChangeLog b/ChangeLog index 712a87e0ec19ce89447647d13dcf3db9603600f4..2c596f72f49acf27ecf22ec0da4bb2b1f0e392b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ For users: - New: Sort list of languages in combo box. - New: EMails links are show with function dol_print_email - New: Add graph report on number of entities in product statistics page. +- New: Can delete a supplier order whatever is its status. - Fix: Failed to go on the future view of bank transaction if there is no future bank transaction already wrote. - Fix: Bad ref in supplier list. diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 14f6c8e176e514a16f4fd2ee4019b7832cc55260..1724bfaab2f1819c9ff4da34d490afa35bde07ad 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr> * @@ -904,7 +904,7 @@ if ($id > 0) /** * Boutons actions */ - if ($user->societe_id == 0 && $commande->statut < 3 && $_GET['action'] <> 'editline') + if ($user->societe_id == 0 && $_GET['action'] != 'editline' && $_GET['action'] != 'delete') { print '<div class="tabsAction">'; @@ -953,12 +953,9 @@ if ($id > 0) } } - if ($commande->statut == 0) + if ($user->rights->fournisseur->commande->annuler) { - if ($user->rights->fournisseur->commande->creer) - { - print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=delete">'.$langs->trans("Delete").'</a>'; - } + print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=delete">'.$langs->trans("Delete").'</a>'; } print "</div>"; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index b8f7af024af97c6c5ca08bf68e5119ba19c1ab57..b01e88bba28e7d1ff8c3ed4de843c0a21219a9b5 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -301,7 +301,7 @@ class CommandeFournisseur extends Commande $statut = 6; $this->db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut; $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1"; @@ -508,7 +508,7 @@ class CommandeFournisseur extends Commande if ($user->rights->fournisseur->commande->approuver) { $this->db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 2"; $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1 ;"; @@ -545,7 +545,7 @@ class CommandeFournisseur extends Commande if ($error == 0) { $langs->load("other"); - + $subject = $langs->trans("EMailTextOrderApproved",$this->ref); $message = $langs->trans("Hello").",\n\n"; $message .= $langs->trans("EMailTextOrderApprovedBy",$this->ref,$user->fullname); @@ -975,8 +975,8 @@ class CommandeFournisseur extends Commande } /** - * \brief Supprime la commande - * + * \brief Delete an order + * \return int <0 if KO, >0 if OK */ function delete() { @@ -987,19 +987,20 @@ class CommandeFournisseur extends Commande $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =". $this->id ; + dol_syslog("FournisseurCommande::delete sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql) ) { $err++; } $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".$this->id; - $sql.= " AND fk_statut = 0;"; + dol_syslog("FournisseurCommande::delete sql=".$sql, LOG_DEBUG); if ($resql = $this->db->query($sql) ) { - if ($this->db->affected_rows($resql) <> 1) - { - $err++; - } + if ($this->db->affected_rows($resql) < 1) + { + $err++; + } } else {