Fix: Can remove a sending sheet.

This commit is contained in:
Laurent Destailleur 2009-04-05 19:30:37 +00:00
parent b104a84992
commit 8b72727684
2 changed files with 33 additions and 23 deletions

View File

@ -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();

View File

@ -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 '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
}
if ($expedition->brouillon && $user->rights->expedition->supprimer)
if ($user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$expedition->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}