38 $this->feedback = array();
39 $this->store_convert = tempnam($_ENV[
'TMP'],
'convert_');
40 $this->store_pdf = tempnam($_ENV[
'TMP'],
'pdf_');
41 unlink($this->store_convert);
42 unlink($this->store_pdf);
45 if ( mkdir($this->store_convert) == FALSE )
46 throw new Exception(sprintf(
"Create %s failed",$this->store_onvert));
47 if ( mkdir($this->store_pdf)== FALSE )
48 throw new Exception(sprintf(
"Create %s failed",$this->store_pdf));
60 $stmt=PDFTK.
" ".$this->store_pdf.
'/*pdf output '.$this->store_pdf.
'/result.pdf';
67 $cnt_feedback=count($this->feedback);
68 $this->feedback[$cnt_feedback][
'file']=
'result.pdf';
69 $this->feedback[$cnt_feedback][
'message']=
' cannot concatenate PDF';
70 $this->feedback[$cnt_feedback][
'error']=
$status;
73 catch (Exception $exc)
75 $cnt_feedback=count($this->feedback);
76 $this->feedback[$cnt_feedback][
'file']=
' ';
77 $this->feedback[$cnt_feedback][
'message']=$exc->getMessage();
78 $this->feedback[$cnt_feedback][
'error']=0;
88 $res=$zip->open(
"{$this->store_pdf}/result.zip",ZipArchive::CREATE);
90 error_log(
"ERR-DE89 cannot create zip file");
91 throw new Exception ( __FILE__.
":".__LINE__.
"cannot recreate zip");
93 chdir($this->store_pdf);
95 $res=$zip->add_file_pattern($this->store_pdf,
"/.*.pdf/");
97 error_log(
"ERR-DE96 aucun fichier trouvé");
98 throw new Exception ( __FILE__.
":".__LINE__.
"cannot recreate zip");
120 copy($p_source, $this->store_pdf .
'/' .
$target);
127 header(
'Content-Type: application/x-download');
128 header(
'Content-Disposition: attachment; filename="result.pdf"');
129 header(
'Cache-Control: private, max-age=0, must-revalidate');
130 header(
'Pragma: public');
131 echo file_get_contents($this->store_pdf .
'/result.pdf');
138 header(
'Content-Type: application/zip');
139 header(
'Content-Disposition: attachment; filename="result.zip"');
140 header(
'Cache-Control: private, max-age=0, must-revalidate');
141 header(
'Pragma: public');
142 echo file_get_contents($this->store_pdf .
'/result.zip');
149 $files= scandir($this->store_convert);
150 $nb_file=count($files);
151 for (
$i=0;
$i < $nb_file;
$i++) {
152 if (is_file($this->store_convert.
"/".$files[
$i])) unlink($this->store_convert.
"/".$files[
$i]);
154 rmdir($this->store_convert);
155 $files= scandir($this->store_pdf);
156 $nb_file=count($files);
157 for (
$i=0;
$i < $nb_file;
$i++) {
158 if (is_file($this->store_pdf.
"/".$files[
$i])) unlink($this->store_pdf.
"/".$files[
$i]);
160 rmdir($this->store_pdf);
195 if ($output_receipt==NULL)
199 $output=$output_receipt[
'output'];
200 $file_pdf=$output_receipt[
'filepdf'];
203 $a_reconcilied_operation=[];
205 $a_reconcilied_operation=
$cn->get_array(
"select jr_id,jra_concerned
206 from jrn_rapt where jra_concerned=$1 or jr_id=$1", [
$value]);
210 foreach ($a_reconcilied_operation as $reconcilied_operation)
212 $op=($reconcilied_operation[
'jr_id']==
$value)?$reconcilied_operation[
'jra_concerned']:$reconcilied_operation[
'jr_id'];
215 if ($output_rec==NULL)
220 $output3=$this->store_convert.
'/tmp_operation_'.$file_pdf;
222 $stmt=PDFTK.
" ".
$output.
" ".$output_rec[
'output'].
228 $cnt_feedback=count($this->feedback);
229 $this->feedback[$cnt_feedback][
'file']=$output3;
230 $this->feedback[$cnt_feedback][
'message']=_(
'Echec ');
231 $this->feedback[$cnt_feedback][
'error']=
$status;
235 unlink($output_rec[
'output']);
242 $detail_operation->export_pdf(array(
"acc",
"anc"));
245 $output2=$this->store_convert.
'/operation_'.$file_pdf;
248 $stmt=PDFTK.
" ".$detail_operation->get_pdf_filename().
" ".
$output.
255 $cnt_feedback=count($this->feedback);
256 $this->feedback[$cnt_feedback][
'file']=$output2;
257 $this->feedback[$cnt_feedback][
'message']=_(
'Echec Ajout detail ');
258 $this->feedback[$cnt_feedback][
'error']=
$status;
263 $detail_operation->unlink();
304 if (CONVERT_GIF_PDF ==
'NOT')
throw new Exception(_(
"CONVERT_GIF_PDF n'est pas installé"));
305 if (PDFTK ==
'NOT')
throw new Exception(_(
"TKPDF n'est pas installé"));
306 if ( FIX_BROKEN_PDF ==
'YES') {
307 if (
PS2PDF ==
'NOT')
throw new Exception(_(
'PS2PDF non installé'));
308 if (
PDF2PS ==
'NOT')
throw new Exception(_(
'PDF2PS non installé'));
310 }
catch (Exception
$ex)
325 $cnt_feedback=count($this->feedback);
328 $file=
$cn->get_array(
'select jr_pj,jr_pj_name,jr_pj_number,jr_pj_type from jrn '
329 .
' where jr_id=$1', array($p_jrn_id));
332 if (
$file[0][
'jr_pj']==
'')
344 $cn->lo_export(
$file[0][
'jr_pj'], $this->store_convert.
'/'.$filename);
347 if ( ! file_exists( $this->store_convert.
'/'.$filename) ){
348 throw new \Exception(
"ERR:DE342 Ne peut pas exporter le fichier $filename");
352 if (
$file[0][
'jr_pj_type']!=
'application/pdf')
355 $arg=
" ".escapeshellarg($this->store_convert.DIRECTORY_SEPARATOR.$filename);
356 echo
"arg = [".$arg.
"]";
357 passthru(OFFICE.
" ".$arg,
$status);
360 $this->feedback[$cnt_feedback][
'file']=$filename;
361 $this->feedback[$cnt_feedback][
'message']=
' cannot convert to PDF';
362 $this->feedback[$cnt_feedback][
'error']=
$status;
367 $img=imagecreatefromgif(NOALYSS_INCLUDE.
'/template/template.gif');
368 $font=imagecolorallocatealpha(
$img, 100, 100, 100, 110);
369 imagettftext(
$img, 40, 25, 500, 1000, $font,
370 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
371 , _(
"Copie certifiée conforme à l'original"));
372 imagettftext(
$img, 40, 25, 550, 1100, $font,
373 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
374 ,
$file[0][
'jr_pj_number']);
375 imagettftext(
$img, 40, 25, 600, 1200, $font,
376 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
377 ,
$file[0][
'jr_pj_name']);
378 imagegif(
$img, $this->store_convert.
'/'.
'stamp.gif');
381 $stmt=CONVERT_GIF_PDF.
" ".escapeshellarg($this->store_convert.
'/'.
'stamp.gif').
" "
382 .escapeshellarg($this->store_convert.
'/stamp.pdf');
386 $this->feedback[$cnt_feedback][
'file']=
'stamp.pdf';
387 $this->feedback[$cnt_feedback][
'message']=
' cannot convert to PDF';
388 $this->feedback[$cnt_feedback][
'error']=
$status;
396 $ext=strrpos($filename,
".");
397 $file_pdf=substr($filename, 0,
$ext);
402 if (FIX_BROKEN_PDF==
'YES'&&
PDF2PS!=
'NOT'&&
PS2PDF!=
'NOT')
405 $stmpt=
PDF2PS.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf).
406 " ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.ps');
412 $this->feedback[$cnt_feedback][
'file']=$this->store_convert.
'/'.$file_pdf;
413 $this->feedback[$cnt_feedback][
'message']=
' cannot force to PDF';
414 $this->feedback[$cnt_feedback][
'error']=
$status;
418 $stmpt=
PS2PDF.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.ps').
419 " ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.2');
425 $this->feedback[$cnt_feedback][
'file']=$this->store_convert.
'/'.$file_pdf;
426 $this->feedback[$cnt_feedback][
'message']=
' cannot force to PDF';
427 $this->feedback[$cnt_feedback][
'error']=
$status;
431 rename($this->store_convert.
'/'.$file_pdf.
'.2', $this->store_convert.
'/'.$file_pdf);
435 $output=$this->store_convert.
'/stamp_'.$file_pdf;
438 $stmt=PDFTK.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf)
439 .
' stamp '.$this->store_convert.
440 '/stamp.pdf output '.$output;
446 $this->feedback[$cnt_feedback][
'file']=$file_pdf;
447 $this->feedback[$cnt_feedback][
'message']=_(
' ne peut pas convertir en PDF');
448 $this->feedback[$cnt_feedback][
'error']=
$status;
451 return array(
"output"=>
$output,
"filepdf"=>$file_pdf);
460 if (empty(
$p_array)) {
return array();}
464 $array=
$cn->get_array(
"select jr_id ,jr_date from jrn where jr_id in ($list_jrn_id) order by jr_date");
noalyss_str_replace($search, $replace, $string)
Export DOCUMENT from Analytic accountancy, can transform into PDF and add a stamp on each pages.
send_pdf()
send the resulting PDF to the browser
concatenate_pdf()
concatenate all PDF into a single one and save it into the store_pdf folder.
move_file($p_source, $p_target)
copy the file
__construct()
create 2 temporary folders, store_pdf and store_convert, initialize an array feedback containing mess...
export_receipt($p_jrn_id, Progress_Bar $progress, $step)
export a file (
make_zip()
Make a zip file.
send_zip()
send the resulting PDF to the browser
reorder_array($p_array)
Order the array with the date.
export_all($p_array, Progress_Bar $progress, $p_separate=1, $reconcilied_document=2)
export all the pieces in PDF and transform them into a PDF with a stamp.
clean_folder()
remove folder and its content
check_file()
check that the files are installed throw a exception if one is missing
Detail Operation ACC + ANC , it will use Acc_Operation and Anc_Operation.
Use one db for tracking progress bar value, the task id must be unique and let you follow the progres...
set_value($p_value)
Store the progress value into the db.
clean_filename($p_filename)
sanitize the filename remove character which could be a problem,