Ajout suppression des pdf provisoire si on supprime la commande, le bordereau d'expdition
ou le bon de livraison avant sa validation
This commit is contained in:
parent
936773b18e
commit
c5a5f07e7b
@ -1845,6 +1845,8 @@ class Commande
|
||||
*/
|
||||
function delete()
|
||||
{
|
||||
global $conf, $lang;
|
||||
|
||||
$err = 0;
|
||||
$this->db->begin();
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = $this->id ;";
|
||||
@ -1864,6 +1866,30 @@ class Commande
|
||||
{
|
||||
$err++;
|
||||
}
|
||||
|
||||
// On efface le répertoire de pdf provisoire
|
||||
$comref = sanitize_string($this->ref);
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($err == 0)
|
||||
{
|
||||
|
||||
@ -521,6 +521,31 @@ class Expedition
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On efface le répertoire de pdf provisoire
|
||||
$expref = sanitize_string($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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
||||
@ -123,7 +123,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
if ($user->rights->expedition->supprimer )
|
||||
{
|
||||
$expedition = new Expedition($db);
|
||||
$expedition->id = $_GET["id"];
|
||||
$expedition->fectch($_GET["id"]);
|
||||
$expedition->delete();
|
||||
Header("Location: liste.php");
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
if ($user->rights->expedition->livraison->supprimer )
|
||||
{
|
||||
$livraison = new Livraison($db);
|
||||
$livraison->id = $_GET["id"];
|
||||
$livraison->fetch($_GET["id"]);
|
||||
$expedition_id = $_GET["expid"];
|
||||
$livraison->delete();
|
||||
if ($conf->expedition->enabled)
|
||||
|
||||
@ -521,6 +521,31 @@ class Livraison
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On efface le répertoire de pdf provisoire
|
||||
$livref = sanitize_string($this->ref);
|
||||
if ($conf->livraison->dir_output)
|
||||
{
|
||||
$dir = $conf->livraison->dir_output . "/" . $livref ;
|
||||
$file = $conf->livraison->dir_output . "/" . $livref . "/" . $livref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user