Fix: les apercus en PNG n'tait pas supprim si il y avait plusieurs pages
This commit is contained in:
parent
742eea08ca
commit
8179490359
@ -181,6 +181,8 @@ class Commande
|
||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
commande_delete_preview($this->db, $this->id);
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||
|
||||
@ -212,29 +212,43 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
}
|
||||
|
||||
|
||||
function commande_delete_preview($db, $propalid)
|
||||
function commande_delete_preview($db, $commandeid)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
$com = new Commande($db,"",$propalid);
|
||||
$com->fetch($propalid);
|
||||
$com = new Commande($db,"",$commandeid);
|
||||
$com->fetch($commandeid);
|
||||
$client = new Societe($db);
|
||||
$client->fetch($com->soc_id);
|
||||
$client->fetch($com->soc_id);
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
$comref = sanitize_string($com->ref);
|
||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||
$file = $dir . "/" . $comref . ".pdf.png";
|
||||
|
||||
if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
$comref = sanitize_string($com->ref);
|
||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||
$file = $dir . "/" . $comref . ".pdf.png";
|
||||
$multiple = $file . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if ( file_exists( $preview ) && is_writable( $preview ) )
|
||||
{
|
||||
if ( ! unlink($preview) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -205,18 +205,32 @@ function propale_delete_preview($db, $propalid)
|
||||
|
||||
if ($conf->propal->dir_output)
|
||||
{
|
||||
$propalref = sanitize_string($propal->ref);
|
||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||
$file = $dir . "/" . $propalref . ".pdf.png";
|
||||
|
||||
if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
$propalref = sanitize_string($propal->ref);
|
||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||
$file = $dir . "/" . $propalref . ".pdf.png";
|
||||
$multiple = $file . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if ( file_exists( $preview ) && is_writable( $preview ) )
|
||||
{
|
||||
if ( ! unlink($preview) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user