Fix: les apercus en PNG n'était pas supprimé si il y avait plusieurs pages

This commit is contained in:
Regis Houssin 2006-06-09 12:40:33 +00:00
parent 742eea08ca
commit 8179490359
3 changed files with 61 additions and 31 deletions

View File

@ -181,6 +181,8 @@ class Commande
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
commande_delete_preview($this->db, $this->id);
if (!dol_delete_file($file)) if (!dol_delete_file($file))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file); $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);

View 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; global $langs,$conf;
$com = new Commande($db,"",$propalid); $com = new Commande($db,"",$commandeid);
$com->fetch($propalid); $com->fetch($commandeid);
$client = new Societe($db); $client = new Societe($db);
$client->fetch($com->soc_id); $client->fetch($com->soc_id);
if ($conf->commande->dir_output) if ($conf->commande->dir_output)
{ {
$comref = sanitize_string($com->ref); $comref = sanitize_string($com->ref);
$dir = $conf->commande->dir_output . "/" . $comref ; $dir = $conf->commande->dir_output . "/" . $comref ;
$file = $dir . "/" . $comref . ".pdf.png"; $file = $dir . "/" . $comref . ".pdf.png";
$multiple = $file . ".";
if ( file_exists( $file ) && is_writable( $file ) )
{ for ($i = 0; $i < 20; $i++)
if ( ! unlink($file) ) {
{ $preview = $multiple.$i;
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
return 0; 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;
}
}
}
}
} }
?> ?>

View File

@ -205,18 +205,32 @@ function propale_delete_preview($db, $propalid)
if ($conf->propal->dir_output) if ($conf->propal->dir_output)
{ {
$propalref = sanitize_string($propal->ref); $propalref = sanitize_string($propal->ref);
$dir = $conf->propal->dir_output . "/" . $propalref ; $dir = $conf->propal->dir_output . "/" . $propalref ;
$file = $dir . "/" . $propalref . ".pdf.png"; $file = $dir . "/" . $propalref . ".pdf.png";
$multiple = $file . ".";
if ( file_exists( $file ) && is_writable( $file ) )
{ for ($i = 0; $i < 20; $i++)
if ( ! unlink($file) ) {
{ $preview = $multiple.$i;
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
return 0; 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;
}
}
}
}
} }
?> ?>