diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 6616b127d38..0f8b1ac09d5 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -258,6 +258,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 == 'mrp') { + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + + $tmpobject = new Mo($this->db); + $result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + + if (!$result) { + throw new RestException(404, 'MO 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'); } @@ -567,6 +583,17 @@ class Documents extends DolibarrApi } $upload_dir = $conf->projet->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'project'); + } elseif ($modulepart == 'mrp') { + $modulepart = 'mrp'; + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + + $object = new Mo($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'MO not found'); + } + + $upload_dir = $conf->mrp->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'mrp'); } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } @@ -749,6 +776,10 @@ class Documents extends DolibarrApi $modulepart = 'contrat'; require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $object = new Contrat($this->db); + } elseif ($modulepart == 'mrp') { + $modulepart = 'mrp'; + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + $object = new Mo($this->db); } else { // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9497526b4aa..49127c3f0dd 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -600,16 +600,17 @@ class Proposals extends DolibarrApi * Add a contact type of given commercial proposal * * @param int $id Id of commercial proposal to update - * @param int $contactid Id of contact to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $contactid Id of external or internal contact to add + * @param string $type Type of the external contact (BILLING, SHIPPING, CUSTOMER), internal contact (SALESREPFOLL) + * @param string $source Source of the contact (internal, external) * @return array * - * @url POST {id}/contact/{contactid}/{type} + * @url POST {id}/contact/{contactid}/{type}/{source} * * @throws RestException 401 * @throws RestException 404 */ - public function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type, $source = 'external') { if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); @@ -621,15 +622,23 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Proposal not found'); } - if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { - throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); + if (!in_array($source, array('internal', 'external'), true)) { + throw new RestException(500, 'Availables sources: internal OR external'); + } + + if ($source == 'external' && !in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { + throw new RestException(500, 'Availables external types: BILLING, SHIPPING OR CUSTOMER'); + } + + if ($source == 'internal' && !in_array($type, array('SALESREPFOLL'), true)) { + throw new RestException(500, 'Availables internal types: SALESREPFOLL'); } if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->propal->add_contact($contactid, $type, 'external'); + $result = $this->propal->add_contact($contactid, $type, $source); if (!$result) { throw new RestException(500, 'Error when added the contact'); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 37e45ec6888..00d05a7d8a3 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -731,7 +731,7 @@ if ($num > 0) { } if ($user->hasRight('cron', 'execute')) { if (!empty($obj->status)) { - print ' 1 if OK, -1 if KO + * @return int Return 1 if OK, -1 if KO */ public function create($user) { @@ -141,7 +141,7 @@ class ProductCombination2ValuePair * Retrieve all ProductCombination2ValuePair linked to a given ProductCombination ID. * * @param int $fk_combination ID of the ProductCombination - * @return -1|ProductCombination2ValuePair[] -1 if KO, array of ProductCombination2ValuePair if OK + * @return -1|ProductCombination2ValuePair[] Return <0 if KO, array of ProductCombination2ValuePair if OK */ public function fetchByFkCombination($fk_combination) { @@ -180,7 +180,7 @@ class ProductCombination2ValuePair * Delete all ProductCombination2ValuePair linked to a given ProductCombination ID. * * @param int $fk_combination ID of the ProductCombination - * @return int<-1|1> -1 if KO, 1 if OK + * @return int Return <0 if KO, 1 if OK */ public function deleteByFkCombination($fk_combination) {