Merge pull request #36646 from W1W1-M/new-document-api-builddoc-product
NEW document API builddoc product
This commit is contained in:
commit
1bb057e046
1 changed files with 17 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ class Documents extends DolibarrApi
|
|||
* @since 18.0.0 Added support for contract and suppliers invoice documents
|
||||
* @since 19.0.0 Added support for shipment documents
|
||||
* @since 20.0.0 Added support for mrp documents
|
||||
* @since 23.0.0 Added support for product documents
|
||||
*
|
||||
* @param string $modulepart Name of module or area concerned by file download ('thirdparty', 'member', 'proposal', 'supplier_proposal', 'order', 'supplier_order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...)
|
||||
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf).
|
||||
|
|
@ -297,6 +298,22 @@ class Documents extends DolibarrApi
|
|||
$templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf;
|
||||
$result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document missing doctemplate parameter');
|
||||
}
|
||||
} elseif ($modulepart == 'product') {
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
$tmpobject = new Product($this->db);
|
||||
$result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Product not found');
|
||||
}
|
||||
|
||||
$templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf;
|
||||
$result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document missing doctemplate parameter');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue