diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 45595712b68..c7e7cd572ef 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -346,6 +346,83 @@ class Contracts extends DolibarrApi return false; } + /** + * Activate a service line of a given contract + * + * @param int $id Id of contract to activate + * @param int $lineid Id of line to activate + * @param string $datestart {@from body} Date start {@type timestamp} + * @param string $datend {@from body} Date end {@type timestamp} + * @param string $comment {@from body} Comment + * + * @url PUT {id}/lines/{lineid}/activate + * + * @return object + */ + function activateLine($id, $lineid, $datestart, $dateend = NULL, $comment = NULL) { + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + + $result = $this->contract->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Contrat not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + + return false; + } + + /** + * Unactivate a service line of a given contract + * + * @param int $id Id of contract to activate + * @param int $lineid Id of line to activate + * @param string $datestart {@from body} Date start {@type timestamp} + * @param string $comment {@from body} Comment + * + * @url PUT {id}/lines/{lineid}/unactivate + * + * @return object + */ + function unactivateLine($id, $lineid, $datestart, $comment = NULL) { + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + + $result = $this->contract->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Contrat not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $request_data = (object) $request_data; + + $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + + return false; + } + /** * Delete a line to given contract * diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 049f768b549..ee49d15cfac 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -615,7 +615,10 @@ class FormFile $modelselected=$arraykeys[0]; } $out.= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('model'); + if ($conf->use_javascript_ajax) + { + $out.= ajax_combobox('model'); + } } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bc3027f5aa4..6b759c8d2cc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5850,7 +5850,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb // If inline message with no format, we add it. if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
/i',$out)) { - $divstart='
'; + $divstart='
'; $divend='
'; }