';
- print $langs->trans(ucfirst($object_resource->element));
+ print $object_resource->type_label;
print '
';
diff --git a/htdocs/resource/class/actions_resource.class.php b/htdocs/resource/class/actions_resource.class.php
index 9e1f9b44f80..f41504e829d 100644
--- a/htdocs/resource/class/actions_resource.class.php
+++ b/htdocs/resource/class/actions_resource.class.php
@@ -22,7 +22,7 @@
/**
* Actions class file for resources
- *
+ *
*/
class ActionsResource
{
@@ -43,18 +43,49 @@ class ActionsResource
/**
* doActions for resource module
- *
+ *
* @param array $parameters parameters
* @param Object $object object
* @param string $action action
*/
- function doActions($parameters, &$object, &$action)
+ function doActions($parameters, &$object, &$action)
{
global $langs,$user;
$langs->load('resource');
-
+
if (in_array('element_resource',explode(':',$parameters['context'])))
{
+
+ $element_id = GETPOST('element_id','int');
+ $element = GETPOST('element','alpha');
+ $resource_type = GETPOST('resource_type');
+
+ $fk_resource = GETPOST('fk_resource');
+
+ $busy = GETPOST('busy','int');
+ $mandatory = GETPOST('mandatory','int');
+
+ if($action == 'add_element_resource' && !GETPOST('cancel'))
+ {
+ $objstat = fetchObjectByElement($element_id,$element);
+
+ $res = $objstat->add_element_resource($fk_resource,$resource_type,$busy,$mandatory);
+
+
+ if($res > 0)
+ {
+ setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
+ header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
+ exit;
+ }
+ else
+ {
+ setEventMessage($langs->trans('ErrorWhenLinkingResource'),'errors');
+ header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
+ exit;
+ }
+ }
+
// Delete a resource linked to an element
if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && GETPOST('confirm') == 'yes')
{
diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php
index 11a51340971..cdeb11950eb 100644
--- a/htdocs/resource/class/html.formresource.class.php
+++ b/htdocs/resource/class/html.formresource.class.php
@@ -53,7 +53,7 @@ class FormResource
/**
- * Output html form to select a location (place)
+ * Output html form to select a resource
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
@@ -63,7 +63,7 @@ class FormResource
* @param int $forcecombo Force to use combo box
* @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $filterkey Filter on key value
- * @param int $outputmode 0=HTML select string, 1=Array
+ * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag
* @param int $limit Limit number of answers
* @return string HTML string with
*/
@@ -76,10 +76,13 @@ class FormResource
$resourcestat = new Resource($this->db);
- $resources_used = $resourcestat->fetch_all_used('ASC', 't.rowid', $limit, $offset, $filter='');
+ $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter='');
- $out = '
';
+ $out.= '';
+ }
}
else
{
dol_print_error($this->db);
}
- if ($outputmode) return $outarray;
+ if ($outputmode && $outputmode != 2) return $outarray;
return $out;
}
-
+
/**
* Return html list of tickets type
*
@@ -151,15 +157,15 @@ class FormResource
function select_types_resource($selected='',$htmlname='type_resource',$filtertype='',$format=0, $empty=0, $noadmininfo=0,$maxlength=0)
{
global $langs,$user;
-
+
$resourcestat = new Resource($this->db);
-
+
dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG);
-
+
$filterarray=array();
-
+
if ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',',$filtertype);
-
+
$resourcestat->load_cache_code_type_resource();
print '