Merge pull request #24223 from kubajznik/add-modulepart-contact-documents-api

NEW Support contact in post() document API
This commit is contained in:
Laurent Destailleur 2023-03-17 21:08:02 +01:00 committed by GitHub
commit f51b209d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -607,7 +607,8 @@ class Documents extends DolibarrApi
if ($ref) {
$tmpreldir = '';
$fetchbyid = false;
if ($modulepart == 'facture' || $modulepart == 'invoice') {
$modulepart = 'facture';
@ -666,13 +667,22 @@ class Documents extends DolibarrApi
$modulepart = 'propale';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($this->db);
} elseif ($modulepart == 'contact' || $modulepart == 'socpeople') {
$modulepart = 'contact';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$object = new Contact($this->db);
$fetchbyid = true;
} else {
// TODO Implement additional moduleparts
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
}
if (is_object($object)) {
$result = $object->fetch('', $ref);
if ($fetchbyid) {
$result = $object->fetch($ref);
} else {
$result = $object->fetch('', $ref);
}
if ($result == 0) {
throw new RestException(404, "Object with ref '".$ref."' was not found.");