diff --git a/include/class_anc_grandlivre.php b/include/class_anc_grandlivre.php index 2a3d920b4..d7a59e113 100644 --- a/include/class_anc_grandlivre.php +++ b/include/class_anc_grandlivre.php @@ -124,17 +124,27 @@ class Anc_GrandLivre extends Anc_Print function button_export_pdf($p_string = "") { - $r = ""; - $r.= HtmlInput::hidden("to", $this->to); - $r.= HtmlInput::hidden("from", $this->from); - $r.= HtmlInput::hidden("pa_id", $this->pa_id); - $r.= HtmlInput::hidden("from_poste", $this->from_poste); - $r.= HtmlInput::hidden("to_poste", $this->to_poste); - $r.= HtmlInput::hidden("act","PDF:AncReceipt"); + if (CONVERT_GIF_PDF <> 'NOT' && PDFTK <> 'NOT') + { + $r = ""; + $r.= HtmlInput::hidden("to", $this->to); + $r.= HtmlInput::hidden("from", $this->from); + $r.= HtmlInput::hidden("pa_id", $this->pa_id); + $r.= HtmlInput::hidden("from_poste", $this->from_poste); + $r.= HtmlInput::hidden("to_poste", $this->to_poste); + $r.= HtmlInput::hidden("act","PDF:AncReceipt"); - $r.= $p_string; - $r.= dossier::hidden(); - $r.=HtmlInput::submit('bt_receipt_anal_pdf', _("Export des pièces en PDF")); + $r.= $p_string; + $r.= dossier::hidden(); + $r.=HtmlInput::submit('bt_receipt_anal_pdf', _("Export des pièces en PDF")); + } + else + { + + $r = ""; + $msg = _("Les extensions pour convertir en pdf ne sont pas installées"); + $r = HtmlInput::button("bt_receipt_anal", _('Export des pièces en PDF'), sprintf('onclick="alert(\'%s\')"',$msg)); + } return $r; } /*! diff --git a/include/class_document_export.php b/include/class_document_export.php index b3bc1ee85..b7e4efe08 100644 --- a/include/class_document_export.php +++ b/include/class_document_export.php @@ -1,19 +1,37 @@ store_convert); mkdir($this->store_pdf); } - + /** + * @brief concatenate all PDF into a single one and save it into the + * store_pdf folder + */ function concatenate_pdf() { + $this->check_file(); $stmt = PDFTK . " " . $this->store_pdf . '/stamp_*pdf output ' . $this->store_pdf . '/result.pdf'; $status = 0; echo $stmt; @@ -43,12 +65,15 @@ class Document_Export $this->feedback[$cnt_feedback]['error'] = $status; } } - + function move_file($p_source, $target) { + $this->check_file(); copy($p_source, $this->store_pdf . '/' . $target); } - + /** + * @brief send the resulting PDF to the browser + */ function send_pdf() { header('Content-Type: application/x-download'); @@ -64,11 +89,13 @@ class Document_Export } /** - * @brief export all the pieces in PDF + * @brief export all the pieces in PDF and transform them into a PDF with + * a stamp * @param $p_array contents all the jr_id */ function export_all($p_array) { + $this->check_file(); ob_start(); var_dump($p_array); global $cn; @@ -139,7 +166,7 @@ class Document_Export { $this->feedback[$cnt_feedback]['file'] = $file_pdf; - $this->feedback[$cnt_feedback]['message'] = ' cannot convert to stamped PDF'; + $this->feedback[$cnt_feedback]['message'] = _(' ne peut pas convertir en PDF'); $this->feedback[$cnt_feedback]['error'] = $status; $cnt_feedback++; continue; @@ -156,5 +183,19 @@ class Document_Export var_dump($this->feedback); // concatenate all pdf into one } - + /** + * @brief check that the files are installed + * throw a exception if one is missing + */ + function check_file() + { + try + { + if (CONVERT_GIF_PDF == 'NO') throw new Exception(_("CONVERT_GIF_PDF n'est pas installé")); + if (PDFTK == 'NO') throw new Exception(_("TKPDF n'est pas installé")); + } catch (Exception $ex) + { + throw ($ex); + } + } }