Fix: les apercus en PNG n'tait pas supprim si il y avait plusieurs pages
This commit is contained in:
parent
4dbe1334fe
commit
7ae375b291
@ -182,7 +182,7 @@ class Commande
|
||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
commande_delete_preview($this->db, $this->id);
|
||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
|
||||
@ -211,7 +211,12 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Supprime l'image de prévisualitation, pour le cas de régénération de commande
|
||||
\param db objet base de donnée
|
||||
\param commandeid id de la commande à effacer
|
||||
\param commanderef référence de la commande si besoin
|
||||
*/
|
||||
function commande_delete_preview($db, $commandeid, $commanderef='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
@ -222,9 +227,7 @@ function commande_delete_preview($db, $commandeid, $commanderef='')
|
||||
$com->fetch($commandeid);
|
||||
$commanderef = $com->ref;
|
||||
}
|
||||
//$client = new Societe($db);
|
||||
//$client->fetch($com->soc_id);
|
||||
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
$comref = sanitize_string($commanderef);
|
||||
|
||||
@ -194,25 +194,39 @@ function propale_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
\brief Supprime l'image de prévisualitation, pour le cas de régénération de propal
|
||||
\param db objet base de donnée
|
||||
\param propalid id de la propal à effacer
|
||||
\param propalref référence de la propal si besoin
|
||||
*/
|
||||
function propale_delete_preview($db, $propalid)
|
||||
function propale_delete_preview($db, $propalid, $propalref='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
global $langs,$conf;
|
||||
|
||||
$propal = new Propal($db,"",$propalid);
|
||||
$propal->fetch($propalid);
|
||||
$propal->fetch_client();
|
||||
|
||||
if ($conf->propal->dir_output)
|
||||
{
|
||||
$propalref = sanitize_string($propal->ref);
|
||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||
$file = $dir . "/" . $propalref . ".pdf.png";
|
||||
$multiple = $file . ".";
|
||||
if (!$propalref)
|
||||
{
|
||||
$propal = new Propal($db,"",$propalid);
|
||||
$propal->fetch($propalid);
|
||||
$propalref = $propal->ref;
|
||||
}
|
||||
|
||||
if ($conf->propal->dir_output)
|
||||
{
|
||||
$propref = sanitize_string($propalref);
|
||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||
$file = $dir . "/" . $propalref . ".pdf.png";
|
||||
$multiple = $file . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if ( file_exists( $preview ) && is_writable( $preview ) )
|
||||
{
|
||||
@ -222,15 +236,8 @@ function propale_delete_preview($db, $propalid)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! unlink($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -1478,12 +1478,41 @@ class Propal
|
||||
*/
|
||||
function delete($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
// On efface le répertoire du pdf
|
||||
$propalref = sanitize_string($this->ref);
|
||||
if ($conf->propal->dir_output)
|
||||
{
|
||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||
$file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
propale_delete_preview($this->db, $this->id, $this->ref);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("Suppression de la proposition $this->id par $user->fullname ($user->id)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user