Can remove a supplier order

This commit is contained in:
Laurent Destailleur 2009-01-09 23:05:25 +00:00
parent 8d19da30f4
commit a8af3d474e
3 changed files with 16 additions and 17 deletions

View File

@ -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.

View File

@ -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.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print "</div>";

View File

@ -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
{