From 89c2d6731bdbf8f0c3f193b5ea45eccc35328cf3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 27 Feb 2019 00:48:13 +0100 Subject: [PATCH] ADD product document support in API --- htdocs/api/class/api_documents.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8db471855d6..f4ae79d888e 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -355,6 +355,22 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } + else if ($modulepart == 'produit' || $modulepart == 'product') + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + + $object = new Product($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Product not found'); + } + + $upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); + } else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';