diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 443beb988fd..9058ffc040f 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -529,36 +529,45 @@ class Expedition extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id;
if ( $this->db->query($sql) )
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."co_exp WHERE rowid = ".$this->id;
if ( $this->db->query($sql) )
{
- $this->db->commit();
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id;
+ if ( $this->db->query($sql) )
+ {
+ $this->db->commit();
- // On efface le répertoire de pdf provisoire
- $expref = sanitizeFileName($this->ref);
- if ($conf->expedition->dir_output)
- {
- $dir = $conf->expedition->dir_output . "/" . $expref ;
- $file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf";
- if (file_exists($file))
+ // On efface le répertoire de pdf provisoire
+ $expref = sanitizeFileName($this->ref);
+ if ($conf->expedition->dir_output)
{
- if (!dol_delete_file($file))
+ $dir = $conf->expedition->dir_output . "/" . $expref ;
+ $file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf";
+ if (file_exists($file))
{
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
- return 0;
- }
- }
- if (file_exists($dir))
- {
- if (!dol_delete_dir($dir))
- {
- $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
- return 0;
+ if (!dol_delete_file($file))
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
+ return 0;
+ }
+ }
+ if (file_exists($dir))
+ {
+ if (!dol_delete_dir($dir))
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
+ return 0;
+ }
}
}
+ return 1;
}
- return 1;
- }
+ else
+ {
+ $this->db->rollback();
+ return -3;
+ }
+ }
else
{
$this->db->rollback();
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 099b380ab99..61926dd3913 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -59,6 +59,7 @@ if ($user->societe_id > 0)
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal
$origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal
+
/*
* Actions
*/
@@ -831,7 +832,7 @@ else
print ''.$langs->trans("DeliveryOrder").'';
}
- if ($expedition->brouillon && $user->rights->expedition->supprimer)
+ if ($user->rights->expedition->supprimer)
{
print ''.$langs->trans("Delete").'';
}