mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 07:32:32 +01:00
Qual: Mutualize code to delete previews
This commit is contained in:
@@ -174,10 +174,11 @@ function project_pdf_create($db, $object, $model,$outputlangs)
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($object,$outputlangs) > 0)
|
||||
{
|
||||
// on supprime l'image correspondant au preview
|
||||
project_delete_preview($db, $object->id);
|
||||
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
|
||||
// we delete preview files
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
dol_delete_preview($object);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -195,39 +196,4 @@ function project_pdf_create($db, $object, $model,$outputlangs)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param $db
|
||||
* @param $objectid
|
||||
* @return int
|
||||
*/
|
||||
function project_delete_preview($db, $objectid)
|
||||
{
|
||||
global $langs,$conf;
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
|
||||
$project = new Project($db);
|
||||
$project->fetch($objectid);
|
||||
$client = new Societe($db);
|
||||
$client->fetch($project->socid);
|
||||
|
||||
if ($conf->projet->dir_output.'/commande')
|
||||
{
|
||||
$projectRef = dol_sanitizeFileName($project->ref);
|
||||
$dir = $conf->projet->dir_output . "/" . $projectRef ;
|
||||
$file = $dir . "/" . $projectRef . ".pdf.png";
|
||||
|
||||
if ( file_exists( $file ) && is_writable( $file ) )
|
||||
{
|
||||
if ( ! dol_delete_file($file) )
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user