From 4dfb0a8f1bf04248536acf77b2a92f8cee98535a Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Fri, 10 Nov 2017 16:42:06 +0100 Subject: [PATCH] NEW add the ability to regenerate an pdf for the order module add the ability to regenerate an pdf for the order module --- htdocs/api/class/api_documents.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index da97215dc0c..669fc09911e 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -119,6 +119,20 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } + if ($module_part == 'commande' || $module_part == 'order') + { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $this->order = new Commande($this->db); + $result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } + $result = $this->order->generateDocument($this->order->modelpdf, $langs, $hidedetails, $hidedesc, $hideref); + if( $result <= 0 ) { + throw new RestException(500, 'Error generating document'); + } + } + } $filename = basename($original_file);