42 $this->feedback = array();
43 $this->store_convert = tempnam($_ENV[
'TMP'],
'convert_');
44 $this->store_pdf = tempnam($_ENV[
'TMP'],
'pdf_');
45 unlink($this->store_convert);
46 unlink($this->store_pdf);
49 if ( mkdir($this->store_convert) == FALSE )
50 throw new Exception(sprintf(
"ERR DE50-Create %s failed",$this->store_onvert));
51 if ( mkdir($this->store_pdf)== FALSE )
52 throw new Exception(sprintf(
"ERR DE52 Create %s failed",$this->store_pdf));
64 $stmt=PDFTK.
" ".$this->store_pdf.
'/*pdf output '.$this->store_pdf.
'/result.pdf';
71 $cnt_feedback=count($this->feedback);
72 $this->feedback[$cnt_feedback][
'file']=
'result.pdf';
73 $this->feedback[$cnt_feedback][
'message']=
'DE73 cannot concatenate PDF';
74 $this->feedback[$cnt_feedback][
'error']=
$status;
77 catch (Exception $exc)
79 $cnt_feedback=count($this->feedback);
80 $this->feedback[$cnt_feedback][
'file']=
' ';
81 $this->feedback[$cnt_feedback][
'message']=$exc->getMessage();
82 $this->feedback[$cnt_feedback][
'error']=0;
155 $files= scandir($this->store_convert);
156 $nb_file=count($files);
157 for (
$i=0;
$i < $nb_file;
$i++) {
158 if (is_file($this->store_convert.
"/".$files[
$i])) unlink($this->store_convert.
"/".$files[
$i]);
160 rmdir($this->store_convert);
161 $files= scandir($this->store_pdf);
162 $nb_file=count($files);
163 for (
$i=0;
$i < $nb_file;
$i++) {
164 if (is_file($this->store_pdf.
"/".$files[
$i])) unlink($this->store_pdf.
"/".$files[
$i]);
166 rmdir($this->store_pdf);
201 if ($output_receipt==NULL)
205 $output=$output_receipt[
'output'];
206 $file_pdf=$output_receipt[
'filepdf'];
209 $a_reconcilied_operation=[];
211 $a_reconcilied_operation=
$cn->get_array(
"select jr_id,jra_concerned
212 from jrn_rapt where jra_concerned=$1 or jr_id=$1", [
$value]);
216 foreach ($a_reconcilied_operation as $reconcilied_operation)
218 $op=($reconcilied_operation[
'jr_id']==
$value)?$reconcilied_operation[
'jra_concerned']:$reconcilied_operation[
'jr_id'];
221 if ($output_rec==NULL)
226 $output3=$this->store_convert.
'/tmp_operation_'.$file_pdf;
228 $stmt=PDFTK.
" ".
$output.
" ".$output_rec[
'output'].
234 $cnt_feedback=count($this->feedback);
235 $this->feedback[$cnt_feedback][
'file']=$output3;
236 $this->feedback[$cnt_feedback][
'message']=
_(
'Echec ');
237 $this->feedback[$cnt_feedback][
'error']=
$status;
241 unlink($output_rec[
'output']);
248 $detail_operation->export_pdf(array(
"acc",
"anc"));
251 $output2=$this->store_convert.
'/operation_'.$file_pdf;
254 $stmt=PDFTK.
" ".$detail_operation->get_pdf_filename().
" ".
$output.
261 $cnt_feedback=count($this->feedback);
262 $this->feedback[$cnt_feedback][
'file']=$output2;
263 $this->feedback[$cnt_feedback][
'message']=
_(
'Echec Ajout detail ');
264 $this->feedback[$cnt_feedback][
'error']=
$status;
269 $detail_operation->unlink();
280 if (DEBUGNOALYSS>1) {
281 tracedebug(date(
'y-m-d').
"-debug.log",$this->feedback,
'feedback');
333 $cnt_feedback=count($this->feedback);
336 $file=
$cn->get_array(
'select jr_pj,jr_pj_name,jr_pj_number,jr_pj_type from jrn '
337 .
' where jr_id=$1', array($p_jrn_id));
340 if (
$file[0][
'jr_pj']==
'')
352 $cn->lo_export(
$file[0][
'jr_pj'], $this->store_convert.
'/'.$filename);
355 if ( ! file_exists( $this->store_convert.
'/'.$filename) ){
356 throw new \Exception(
"ERR:DE342 Ne peut pas exporter le fichier $filename");
360 if (
$file[0][
'jr_pj_type']!=
'application/pdf')
363 $arg=
" ".escapeshellarg($this->store_convert.DIRECTORY_SEPARATOR.$filename);
364 echo
"arg = [".$arg.
"]";
365 passthru(OFFICE.
" ".$arg,
$status);
368 $this->feedback[$cnt_feedback][
'file']=$filename;
369 $this->feedback[$cnt_feedback][
'message']=
' OFFICE cannot convert to PDF';
370 $this->feedback[$cnt_feedback][
'error']=
$status;
375 $img=imagecreatefromgif(NOALYSS_INCLUDE.
'/template/template.gif');
376 $font=imagecolorallocatealpha(
$img, 100, 100, 100, 110);
377 imagettftext(
$img, 40, 25, 500, 1000, $font,
378 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
379 ,
_(
"Copie certifiee conforme a l'original"));
380 imagettftext(
$img, 40, 25, 550, 1100, $font,
381 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
382 ,
$file[0][
'jr_pj_number']);
383 imagettftext(
$img, 40, 25, 600, 1200, $font,
384 NOALYSS_INCLUDE.
'/tfpdf/font/unifont/DejaVuSans.ttf'
386 imagegif(
$img, $this->store_convert.
'/'.
'stamp.gif');
389 $stmt=CONVERT_GIF_PDF.
" ".escapeshellarg($this->store_convert.
'/'.
'stamp.gif').
" "
390 .escapeshellarg($this->store_convert.
'/stamp.pdf');
394 $this->feedback[$cnt_feedback][
'file']=
'stamp.pdf';
395 $this->feedback[$cnt_feedback][
'message']=
' CONVERT_GIF_PDF cannot convert to PDF';
396 $this->feedback[$cnt_feedback][
'error']=
$status;
404 $ext=strrpos($filename,
".");
405 $file_pdf=substr($filename, 0,
$ext);
410 if (FIX_BROKEN_PDF==
'YES'&&
PDF2PS!=
'NOT'&&
PS2PDF!=
'NOT')
413 $stmpt=
PDF2PS.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf).
414 " ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.ps');
420 $this->feedback[$cnt_feedback][
'file']=$this->store_convert.
'/'.$file_pdf;
421 $this->feedback[$cnt_feedback][
'message']=
' cannot force to PDF';
422 $this->feedback[$cnt_feedback][
'error']=
$status;
426 $stmpt=
PS2PDF.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.ps').
427 " ".escapeshellarg($this->store_convert.
'/'.$file_pdf.
'.2');
433 $this->feedback[$cnt_feedback][
'file']=$this->store_convert.
'/'.$file_pdf;
434 $this->feedback[$cnt_feedback][
'message']=
' cannot force to PDF';
435 $this->feedback[$cnt_feedback][
'error']=
$status;
439 rename($this->store_convert.
'/'.$file_pdf.
'.2', $this->store_convert.
'/'.$file_pdf);
443 $output=$this->store_convert.
'/stamp_'.$file_pdf;
446 $stmt=PDFTK.
" ".escapeshellarg($this->store_convert.
'/'.$file_pdf)
447 .
' stamp '.$this->store_convert.
448 '/stamp.pdf output '.$output;
454 $this->feedback[$cnt_feedback][
'file']=$file_pdf;
455 $this->feedback[$cnt_feedback][
'message']=
_(
'PDFTK ne peut pas convertir en PDF').
" cmd =[$stmt] status [$status]";
456 $this->feedback[$cnt_feedback][
'error']=
$status;
459 return array(
"output"=>
$output,
"filepdf"=>$file_pdf);