mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-07 17:42:53 +01:00
Added product document generation
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user