mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 10:52:37 +01:00
feat(api/documents): build contract
This commit is contained in:
@@ -221,6 +221,22 @@ class Documents extends DolibarrApi
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
}
|
||||
} elseif ($modulepart == 'contrat' || $modulepart == 'contract') {
|
||||
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
|
||||
|
||||
$this->contract = new Contrat($this->db);
|
||||
$result = $this->contract->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Contract not found');
|
||||
}
|
||||
|
||||
$templateused = $doctemplate ? $doctemplate : $this->contract->model_pdf;
|
||||
$result = $this->contract->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
if ($result <= 0) {
|
||||
throw new RestException(500, 'Error generating document missing doctemplate parameter');
|
||||
}
|
||||
} else {
|
||||
throw new RestException(403, 'Generation not available for this modulepart');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user