74 public function select_language($selected =
'', $htmlname =
'lang_id', $showauto = 0, $filter = array(), $showempty =
'', $showwarning = 0, $disabled = 0, $morecss =
'minwidth100', $showcode = 0, $forcecombo = 0, $multiselect = 0, $onlykeys = array(), $mainlangonly = 0)
80 if (!is_array($filter)) {
86 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
90 if ($selected && empty($showempty)) {
91 if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
92 $tmparray = explode(
'_', $selected);
93 if (!empty($tmparray[1])) {
96 if (empty($selected)) {
97 $selected = $langs->defaultlang;
106 $out .=
'<select '.($multiselect ?
'multiple="multiple" ' :
'').
'class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($disabled ?
' disabled' :
'').
'>';
107 if ($showempty && !$multiselect) {
108 if (is_numeric($showempty)) {
109 $out .=
'<option value="0"';
111 $out .=
'<option value="-1"';
113 if ($selected ===
'') {
117 if ($showempty !=
'1') {
125 $out .=
'<option value="auto"';
126 if ($selected ===
'auto') {
130 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
132 $out .=
'>'.$langs->trans(
"AutoDetectLangShort").
'</option>';
136 asort($langs_available);
138 foreach ($langs_available as $key => $value) {
139 $valuetoshow = $value;
140 if ($showcode == 1) {
142 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
144 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
147 if ($showcode == 2 || $showcode == 3) {
149 $valuetoshow = $value.
' <span class="opacitymedium">'.($showcode == 3 ?
'' :
'(').preg_replace(
'/[_-].*$/',
'', $key).($showcode == 3 ?
'' :
')').
'</span>';
151 $valuetoshow = $value.
' <span class="opacitymedium">'.($showcode == 3 ?
'' :
'(').$key.($showcode == 3 ?
'' :
')').
'</span>';
157 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
160 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
163 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
169 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
170 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
172 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
179 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
196 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
199 global $langs,
$conf;
205 if (!is_array($dirmenuarray)) {
209 $menuarray = array();
210 foreach (
$conf->file->dol_document_root as $dirroot) {
211 foreach ($dirmenuarray as $dirtoscan) {
212 $dir = $dirroot.$dirtoscan;
215 $handle = opendir($dir);
216 if (is_resource($handle)) {
217 while (($file = readdir($handle)) !==
false) {
218 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS' && substr($file, 0, 5) !=
'index') {
219 if (preg_match(
'/lib\.php$/i', $file)) {
222 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
225 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
228 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
232 $filetoshow = preg_replace(
'/\.php$/i',
'', $file);
233 $filetoshow = ucfirst(preg_replace(
'/_menu$/i',
'', $filetoshow));
236 if (preg_match(
'/^eldy/i', $file)) {
238 } elseif (preg_match(
'/^smartphone/i', $file)) {
245 if (preg_match(
'/^auguria/i', $file)) {
246 $morelabel .=
' <span class="opacitymedium">('.$langs->trans(
"Unstable").
')</span>';
248 if ($file == $selected) {
249 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected data-html="'.
dol_escape_htmltag($filetoshow.$morelabel).
'">';
250 $menuarray[$prefix.
'_'.$file] .= $filetoshow.$morelabel;
251 $menuarray[$prefix.
'_'.$file] .=
'</option>';
253 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" data-html="'.
dol_escape_htmltag($filetoshow.$morelabel).
'">';
254 $menuarray[$prefix.
'_'.$file] .= $filetoshow.$morelabel;
255 $menuarray[$prefix.
'_'.$file] .=
'</option>';
267 print
'<select class="flat minwidth150" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
269 foreach ($menuarray as $key => $val) {
270 $tab = explode(
'_', $key);
271 $newprefix = $tab[0];
273 if ($newprefix ==
'1' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1)) {
276 if ($newprefix ==
'2' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2)) {
279 if ($newprefix != $oldprefix) {
281 print
'<option value="-2" disabled>';
282 if ($newprefix ==
'0') {
283 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
285 if ($newprefix ==
'1') {
286 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
288 if ($newprefix ==
'2') {
289 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
291 if ($newprefix ==
'3') {
292 print
'-- '.$langs->trans(
"Other").
' --';
295 $oldprefix = $newprefix;
319 global $langs,
$conf;
322 $expdevmenu = array();
324 $menuarray = array();
326 foreach ($dirmenuarray as $dirmenu) {
327 foreach (
$conf->file->dol_document_root as $dirroot) {
328 $dir = $dirroot.$dirmenu;
330 $handle = opendir($dir);
331 if (is_resource($handle)) {
332 while (($file = readdir($handle)) !==
false) {
333 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
334 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
335 if (preg_match(
'/^index/i', $filelib)) {
338 if (preg_match(
'/^default/i', $filelib)) {
341 if (preg_match(
'/^empty/i', $filelib)) {
344 if (preg_match(
'/\.lib/i', $filelib)) {
347 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
351 $menuarray[$filelib] = 1;
353 $menuarray[
'all'] = 1;
364 print
'<select class="flat width150" id="'.$htmlname.
'" name="'.$htmlname.
'">';
365 foreach ($menuarray as $key => $val) {
366 $tab = explode(
'_', $key);
367 print
'<option value="'.$key.
'"';
368 if ($key == $selected) {
373 print $langs->trans(
"AllMenus");
377 print
'</option>'.
"\n";
396 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
397 print
'<option value="-1"> </option>';
400 "Pacific/Midway" =>
"GMT-11:00",
401 "Pacific/Fakaofo" =>
"GMT-10:00",
402 "America/Anchorage" =>
"GMT-09:00",
403 "America/Los_Angeles" =>
"GMT-08:00",
404 "America/Dawson_Creek" =>
"GMT-07:00",
405 "America/Chicago" =>
"GMT-06:00",
406 "America/Bogota" =>
"GMT-05:00",
407 "America/Anguilla" =>
"GMT-04:00",
408 "America/Araguaina" =>
"GMT-03:00",
409 "America/Noronha" =>
"GMT-02:00",
410 "Atlantic/Azores" =>
"GMT-01:00",
411 "Africa/Abidjan" =>
"GMT+00:00",
412 "Europe/Paris" =>
"GMT+01:00",
413 "Europe/Helsinki" =>
"GMT+02:00",
414 "Europe/Moscow" =>
"GMT+03:00",
415 "Asia/Dubai" =>
"GMT+04:00",
416 "Asia/Karachi" =>
"GMT+05:00",
417 "Indian/Chagos" =>
"GMT+06:00",
418 "Asia/Jakarta" =>
"GMT+07:00",
419 "Asia/Hong_Kong" =>
"GMT+08:00",
420 "Asia/Tokyo" =>
"GMT+09:00",
421 "Australia/Sydney" =>
"GMT+10:00",
422 "Pacific/Noumea" =>
"GMT+11:00",
423 "Pacific/Auckland" =>
"GMT+12:00",
424 "Pacific/Enderbury" =>
"GMT+13:00"
426 foreach ($arraytz as $lib => $gmt) {
427 print
'<option value="'.$lib.
'"';
428 if ($selected == $lib || $selected == $gmt) {
431 print
'>'.$gmt.
'</option>'.
"\n";
449 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter =
'', $showempty = 0, $forcecombo = 0)
454 $langs->load(
"dict");
456 $sql =
"SELECT code, label, width, height, unit";
457 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
458 $sql .=
" WHERE active=1";
460 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
463 $paperformat = array();
465 $resql = $this->db->query($sql);
467 $num = $this->db->num_rows($resql);
470 $obj = $this->db->fetch_object($resql);
471 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
473 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
483 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
485 $out .=
'<option value=""';
486 if ($selected ==
'') {
489 $out .=
'> </option>';
491 foreach ($paperformat as $key => $value) {
492 if ($selected == $key) {
493 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
495 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
501 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
523 $out .=
'<!-- combo with type of extrafields -->'.
"\n";
524 $out .=
'<select class="flat type" id="'.$htmlname.
'" name="'.$htmlname.
'">';
525 foreach ($type2label as $key => $val) {
528 $selected =
' selected="selected"';
534 if (empty($typewecanchangeinto) || in_array($key, $typewecanchangeinto[$type])) {
535 $out .=
'<option value="'.$key.
'"'.$selected.
' data-html="'.
dol_escape_htmltag($valhtml).
'">'.($val ? $val :
' ').
'</option>';
537 $out .=
'<option value="'.$key.
'" disabled="disabled"'.$selected.
' data-html="'.
dol_escape_htmltag($valhtml).
'">'.($val ? $val :
' ').
'</option>';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
getPictoForType($key, $morecss='')
Return the picto for a data type.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...