diff --git a/include/class/class_document_export.php b/include/class/class_document_export.php index 05a95fa30..fc20d52c6 100644 --- a/include/class/class_document_export.php +++ b/include/class/class_document_export.php @@ -98,13 +98,19 @@ class Document_Export */ function clean_folder() { - return; $files= scandir($this->store_convert); - $nb_file=count($file); + $nb_file=count($files); for ($i=0;$i < $nb_file;$i++) { - if (is_file($files[$i])) unlink($file[$i]); + if (is_file($this->store_convert."/".$files[$i])) unlink($this->store_convert."/".$files[$i]); } rmdir($this->store_convert); + $files= scandir($this->store_pdf); + $nb_file=count($files); + for ($i=0;$i < $nb_file;$i++) { + if (is_file($this->store_pdf."/".$files[$i])) unlink($this->store_pdf."/".$files[$i]); + } + rmdir($this->store_pdf); + } /** @@ -243,6 +249,9 @@ class Document_Export $cnt_feedback++; continue; } + // remove doc with detail + $detail_operation->unlink(); + // overwrite old with new PDF rename ($output2,$output); diff --git a/include/class/class_pdf_operation.php b/include/class/class_pdf_operation.php index 7a5742750..d0975c157 100644 --- a/include/class/class_pdf_operation.php +++ b/include/class/class_pdf_operation.php @@ -459,4 +459,11 @@ class PDF_Operation extends PDF { function download_pdf() { $this->pdf->Output("acc_op".$this->acc_detail->det->jr_internal.".pdf"); } + /** + * @brief unlink the file if exists + */ + function unlink() { + $file=$this->get_pdf_filename(); + if ( is_file($file)) unlink ($file); + } }