diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 62591e8251c..adcb74a7178 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1763,7 +1763,7 @@ class Propal extends CommonObject $file = $conf->propale->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; if (file_exists($file)) { - propale_delete_preview($this->db, $this->id, $this->ref); + dol_delete_preview($this); if (!dol_delete_file($file)) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e40ef308228..7ce4770e607 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2342,7 +2342,7 @@ class Commande extends CommonObject $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; if (file_exists($file)) // We must delete all files before deleting directory { - dol_delete_preview($object); + dol_delete_preview($this); if (!dol_delete_file($file)) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 717a6ba4ec4..1ac34878050 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -726,7 +726,15 @@ function dol_delete_preview($object) global $langs,$conf; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if ($object->element == 'commande') $dir = $conf->commande->dir_output; + if ($object->element == 'commande') $dir = $conf->commande->dir_output; + elseif ($object->element == 'propal') $dir = $conf->propale->dir_output; + elseif ($object->element == 'ficheinter') $dir = $conf->ficheinter->dir_output; + elseif ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; + elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; + elseif ($object->element == 'project') $dir = $conf->projet->dir_output; + elseif ($object->element == 'delivery') $dir = $conf->livraison->dir_output; + elseif ($object->element == 'facture') $dir = $conf->facture->dir_output; + elseif ($object->element == 'don') $dir = $conf->don->dir_output; if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; $refsan = dol_sanitizeFileName($object->ref); @@ -762,6 +770,58 @@ function dol_delete_preview($object) return 1; } +/** +* Create a meta file with document file into same directory. +* This should allow rgrep search +* +* @param Object $object Object +* @return void +*/ +function dol_meta_create($object) +{ + global $langs,$conf; + + $object->fetch_thirdparty(); + + if ($conf->facture->dir_output) + { + $facref = dol_sanitizeFileName($object->ref); + $dir = $conf->facture->dir_output . "/" . $facref ; + $file = $dir . "/" . $facref . ".meta"; + + if (! is_dir($dir)) + { + create_exdir($dir); + } + + if (is_dir($dir)) + { + $nblignes = count($object->lines); + $client = $object->client->nom . " " . $object->client->address . " " . $object->client->cp . " " . $object->client->ville; + $meta = "REFERENCE=\"" . $object->ref . "\" + DATE=\"" . dol_print_date($object->date,'') . "\" + NB_ITEMS=\"" . $nblignes . "\" + CLIENT=\"" . $client . "\" + TOTAL_HT=\"" . $object->total_ht . "\" + TOTAL_TTC=\"" . $object->total_ttc . "\"\n"; + + for ($i = 0 ; $i < $nblignes ; $i++) + { + //Pour les articles + $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\" + ITEM_" . $i . "_UNIT_PRICE=\"" . $object->lines[$i]->price . "\" + ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\" + ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\" + "; + } + } + $fp = fopen($file,"w"); + fputs($fp,$meta); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } +} /** * Get and save an upload file (for example after submitting a new file a mail form). diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 02c25f41f61..eeb7771e853 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -173,12 +173,11 @@ function don_create($db, $id, $message, $modele, $outputlangs) $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($id,$outputlangs) > 0) { - // Success. We build meta file - don_meta_create($db, $id); - // et on supprime l'image correspondant au preview - don_delete_preview($db, $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 @@ -196,34 +195,4 @@ function don_create($db, $id, $message, $modele, $outputlangs) } } -/** - * \brief Cree un meta fichier a cote de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay�e ou compliqu�e � g�rer ... avec un rgrep c'est vite fait bien fait [eric seigne - * \param db Objet base de donnee - * \param donid Id du don a creer - * \param message Message - */ -function don_meta_create($db, $donid, $message="") -{ - global $langs,$conf; - - $don = new Don($db); - $don->id=$donid; - $don->fetch($donid); -} - - -/** - * \brief Supprime l'image de previsualitation, pour le cas de r�g�n�ration de facture - * \param db Objet base de donnee - * \param donid Id du don - */ -function don_delete_preview($db, $donid) -{ - global $langs,$conf; - - $don = new Don($db); - $don->id=$donid; - $don->fetch($donid); -} - ?> diff --git a/htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php index 1a637144546..2ba0f1883b8 100644 --- a/htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php +++ b/htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php @@ -116,8 +116,10 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs) if ($obj->write_file($object, $outputlangs) > 0) { $outputlangs->charset_output=$sav_charset_output; - // on supprime l'image correspondant au preview - //expedition_delete_preview($db, $id); + + // we delete preview files + //require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + //dol_delete_preview($object); return 1; } else diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index d50a9ecac1b..386fc2e5feb 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -209,13 +209,15 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) { - // Success in building document. We build meta file. - facture_meta_create($db, $object->id); - // et on supprime l'image correspondant au preview - facture_delete_preview($db, $object->id); - $outputlangs->charset_output=$sav_charset_output; + // We delete old preview + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + dol_delete_preview($object); + + // Success in building document. We build meta file. + dol_meta_create($object); + // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); @@ -240,93 +242,4 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide } } -/** - * Create a meta file with document file into same directory. - * This should allow rgrep search - * - * @param db Objet base de donnee - * @param facid Id de la facture a creer - * @param message Message - */ -function facture_meta_create($db, $facid, $message="") -{ - global $langs,$conf; - - $fac = new Facture($db); - $fac->fetch($facid); - $fac->fetch_thirdparty(); - - if ($conf->facture->dir_output) - { - $facref = dol_sanitizeFileName($fac->ref); - $dir = $conf->facture->dir_output . "/" . $facref ; - $file = $dir . "/" . $facref . ".meta"; - - if (! is_dir($dir)) - { - create_exdir($dir); - } - - if (is_dir($dir)) - { - $nblignes = count($fac->lines); - $client = $fac->client->nom . " " . $fac->client->address . " " . $fac->client->cp . " " . $fac->client->ville; - $meta = "REFERENCE=\"" . $fac->ref . "\" - DATE=\"" . dol_print_date($fac->date,'') . "\" - NB_ITEMS=\"" . $nblignes . "\" - CLIENT=\"" . $client . "\" - TOTAL_HT=\"" . $fac->total_ht . "\" - TOTAL_TTC=\"" . $fac->total_ttc . "\"\n"; - - for ($i = 0 ; $i < $nblignes ; $i++) - { - //Pour les articles - $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $fac->lines[$i]->qty . "\" - ITEM_" . $i . "_UNIT_PRICE=\"" . $fac->lines[$i]->price . "\" - ITEM_" . $i . "_TVA=\"" .$fac->lines[$i]->tva_tx . "\" - ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($fac->lines[$i]->desc)) . "\" - "; - } - } - $fp = fopen($file,"w"); - fputs($fp,$meta); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } -} - - -/** - * Supprime l'image de previsualitation, pour le cas de regeneration de facture - * - * @param db objet base de donnee - * @param facid id de la facture a creer - */ -function facture_delete_preview($db, $facid) -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $fac = new Facture($db); - $fac->fetch($facid); - - if ($conf->facture->dir_output) - { - $facref = dol_sanitizeFileName($fac->ref); - $dir = $conf->facture->dir_output . "/" . $facref ; - $file = $dir . "/" . $facref . ".pdf.png"; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file,1) ) - { - return 0; - } - } - } - - return 1; -} - ?> \ No newline at end of file diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index a7b4617f000..3fd79795420 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -197,57 +197,4 @@ function fichinter_create($db, $object, $modele='', $outputlangs='') } } -/** - * Deletes the image preview, in case of regeneration - * @param db database object - * @param fichinterid id to delete - * @param fichinterref reference if needed - */ -function fichinter_delete_preview($db, $fichinterid, $fichinterref='') -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - if (!$fichinterref) - { - $fichinter = new Fichinter($db); - $fichinter->fetch($fichinterid); - $fichinterref = $fichinter->ref; - } - - if ($conf->ficheinter->dir_output) - { - $fichinterref = dol_sanitizeFileName($fichinterref); - $dir = $conf->ficheinter->dir_output . "/" . $fichinterref ; - $file = $dir . "/" . $fichinterref . ".pdf.png"; - $multiple = $file . "."; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file,1) ) - { - $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 ) ) - { - if ( ! dol_delete_file($preview,1) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); - return 0; - } - } - } - } - } - - return 1; -} - ?> \ No newline at end of file diff --git a/htdocs/core/modules/livraison/modules_livraison.php b/htdocs/core/modules/livraison/modules_livraison.php index ff3009c9d06..1fa7e17b7ae 100644 --- a/htdocs/core/modules/livraison/modules_livraison.php +++ b/htdocs/core/modules/livraison/modules_livraison.php @@ -172,10 +172,11 @@ function delivery_order_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 - delivery_order_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 @@ -193,33 +194,4 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='') } } - -function delivery_order_delete_preview($db, $deliveryid) -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $delivery = new Livraison($db,"",$deliveryid); - $delivery->fetch($deliveryid); - $client = new Societe($db); - $client->fetch($delivery->socid); - - if ($conf->livraison->dir_output) - { - $deliveryref = dol_sanitizeFileName($delivery->ref); - $dir = $conf->livraison->dir_output . "/" . $deliveryref ; - $file = $dir . "/" . $deliveryref . ".pdf.png"; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file,1) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$file); - return 0; - } - } - } - - return 1; -} ?> diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index a61b6301931..412b18af406 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -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; -} ?> diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index 10480c1d3d9..f726b63727e 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -205,8 +205,10 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) { $outputlangs->charset_output=$sav_charset_output; - // on supprime l'image correspondant au preview - propale_delete_preview($db, $object->id); + + // we delete preview files + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + dol_delete_preview($object); // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -239,57 +241,4 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, } } -/** - * Delete preview files - * @param db objet base de donnee - * @param propalid id de la propal a effacer - * @param propalref reference de la propal si besoin - */ -function propale_delete_preview($db, $propalid, $propalref='') -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - if (!$propalref) - { - $propal = new Propal($db,"",$propalid); - $propal->fetch($propalid); - $propalref = $propal->ref; - } - - if ($conf->propale->dir_output) - { - $propalref = dol_sanitizeFileName($propalref); - $dir = $conf->propale->dir_output . "/" . $propalref ; - $file = $dir . "/" . $propalref . ".pdf.png"; - $multiple = $file . "."; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file,1) ) - { - $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 ) ) - { - if ( ! unlink($preview) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); - return 0; - } - } - } - } - } - - return 1; -} ?> diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index aab5c6b2d9e..a45a2d8b958 100755 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -98,10 +98,11 @@ function supplier_invoice_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 - supplier_invoice_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 @@ -119,38 +120,4 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs) } } -/** - * Delete preview files - * @param $db - * @param $objectid - * @return int - */ -function supplier_invoice_delete_preview($db, $objectid) -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $comfourn = new FactureFournisseur($db); - $comfourn->fetch($objectid); - $client = new Societe($db); - $client->fetch($comfourn->socid); - - if ($conf->fournisseur->dir_output.'/facture') - { - $comfournref = dol_sanitizeFileName($comfourn->ref); - $dir = $conf->facture->dir_output . "/" . $comfournref ; - $file = $dir . "/" . $comfournref . ".pdf.png"; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$file); - return 0; - } - } - } - - return 1; -} ?> diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index e7d06c4192a..95e0423e5db 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -199,8 +199,10 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedeta if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0) { $outputlangs->charset_output=$sav_charset_output; - // on supprime l'image correspondant au preview - supplier_order_delete_preview($db, $object->id); + + // we delete preview files + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + dol_delete_preview($object); return 1; } else @@ -225,62 +227,4 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedeta } } -/** - * Delete preview files, pour le cas de regeneration de commande - * @param $db data base object - * @param $comfournid id de la commande a effacer - * @param $comfournref reference de la commande si besoin - * @return int - */ -function supplier_order_delete_preview($db, $comfournid, $comfournref='') -{ - global $langs,$conf; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - if (!$comfournref) - { - $comfourn = new CommandeFournisseur($db,"",$comfournid); - $comfourn->fetch($comfournid); - $comfournref = $comfourn->ref; - $soc = new Societe($db); - $soc->fetch($comfourn->socid); - } - - - - if ($conf->fournisseur->dir_output.'/commande') - { - $suppordref = dol_sanitizeFileName($comfournref); - $dir = $conf->fournisseur->dir_output . "/" . $suppordref ; - $file = $dir . "/" . $suppordref . ".pdf.png"; - $multiple = $file . "."; - - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! dol_delete_file($file,1) ) - { - $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 ) ) - { - if ( ! dol_delete_file($preview,1) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); - return 0; - } - } - } - } - } - - return 1; -} ?> diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 98fcb0d37ac..212c7d84694 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -180,7 +180,7 @@ class Fichinter extends CommonObject if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; } $this->db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; $sql.= ", description = '".$this->db->escape($this->description)."'"; $sql.= ", duree = ".$this->duree; @@ -617,7 +617,7 @@ class Fichinter extends CommonObject $file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; if (file_exists($file)) { - fichinter_delete_preview($this->db, $this->id, $this->ref); + dol_delete_preview($this); if (!dol_delete_file($file)) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b511ac8418b..bd3132a322c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -438,7 +438,7 @@ class Project extends CommonObject $file = $conf->projet->dir_output . "/" . $projectref . "/" . $projectref . ".pdf"; if (file_exists($file)) { - //project_delete_preview($this->db, $this->id, $this->ref); + dol_delete_preview($this); if (!dol_delete_file($file)) {