25 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.form.class.php";
26 require_once DOL_DOCUMENT_ROOT.
"/resource/class/dolresource.class.php";
42 public $substit = array();
44 public $param = array();
80 public function select_resource_list($selected =
'', $htmlname =
'fk_resource', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey =
'', $outputmode = 0, $limit = 20, $morecss =
'')
83 global $conf, $user, $langs;
90 $resources_used = $resourcestat->fetch_all(
'ASC',
't.rowid', $limit, 0, $filter);
94 $out =
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
95 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
100 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo)
103 $out .=
ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
109 $out .=
'<select id="'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">'.
"\n";
110 if ($showempty) $out .=
'<option value="-1"> </option>'.
"\n";
113 if (is_array($resourcestat->lines)) $num = count($resourcestat->lines);
121 $resourceclass = ucfirst($resourcestat->lines[$i]->element);
123 $label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref :
''.$resourcestat->lines[$i]->label;
124 if ($resourceclass !=
'Dolresource') $label .=
' ('.$langs->trans($resourceclass).
')';
126 if ($selected > 0 && $selected == $resourcestat->lines[$i]->id)
128 $out .=
'<option value="'.$resourcestat->lines[$i]->id.
'" selected>'.$label.
'</option>';
130 $out .=
'<option value="'.$resourcestat->lines[$i]->id.
'">'.$label.
'</option>';
133 array_push($outarray, array(
'key'=>$resourcestat->lines[$i]->id,
'value'=>$resourcestat->lines[$i]->label,
'label'=>$resourcestat->lines[$i]->label));
136 if (($i % 10) == 0) $out .=
"\n";
139 $out .=
'</select>'.
"\n";
141 if ($outputmode != 2)
143 $out .=
'<input type="submit" class="button" value="'.$langs->trans(
"Search").
'"> ';
151 if ($outputmode && $outputmode != 2)
return $outarray;
168 public function select_types_resource($selected =
'', $htmlname =
'type_resource', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0)
171 global $langs, $user;
175 dol_syslog(get_class($this).
"::select_types_resource ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
177 $filterarray = array();
179 if ($filtertype !=
'' && $filtertype !=
'-1') $filterarray = explode(
',', $filtertype);
181 $resourcestat->load_cache_code_type_resource();
182 print '<select id="select'.$htmlname.
'" class="flat maxwidthonsmartphone select_'.$htmlname.
'" name="'.$htmlname.
'">';
183 if ($empty)
print '<option value=""> </option>';
184 if (is_array($resourcestat->cache_code_type_resource) && count($resourcestat->cache_code_type_resource))
186 foreach ($resourcestat->cache_code_type_resource as $id => $arraytypes)
189 if ($empty && empty($arraytypes[
'code']))
continue;
191 if ($format == 0)
print '<option value="'.$id.
'"';
192 elseif ($format == 1)
print '<option value="'.$arraytypes[
'code'].
'"';
193 elseif ($format == 2)
print '<option value="'.$arraytypes[
'code'].
'"';
194 elseif ($format == 3)
print '<option value="'.$id.
'"';
196 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code'])
print ' selected';
197 elseif ($selected == $id)
print ' selected';
199 if ($format == 0) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
200 elseif ($format == 1) $value = $arraytypes[
'code'];
201 elseif ($format == 2) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
202 elseif ($format == 3) $value = $arraytypes[
'code'];
203 print $value ? $value :
' ';
208 if ($user->admin && !$noadmininfo)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
$conf db
API class for accounts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.