diff --git a/ChangeLog b/ChangeLog index 712a87e0ec1..2c596f72f49 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 14f6c8e176e..1724bfaab2f 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2008 Regis Houssin * @@ -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 '
'; @@ -953,12 +953,9 @@ if ($id > 0) } } - if ($commande->statut == 0) + if ($user->rights->fournisseur->commande->annuler) { - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("Delete").''; - } + print ''.$langs->trans("Delete").''; } print "
"; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index b8f7af024af..b01e88bba28 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 {