74 public function select_language($selected =
'', $htmlname =
'lang_id', $showauto = 0, $filter = array(), $showempty =
'', $showwarning = 0, $disabled = 0, $morecss =
'', $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') {
129 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
132 asort($langs_available);
134 foreach ($langs_available as $key => $value) {
135 $valuetoshow = $value;
136 if ($showcode == 1) {
138 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
140 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
143 if ($showcode == 2) {
145 $valuetoshow = $value.
' <span class="opacitymedium">('.preg_replace(
'/[_-].*$/',
'', $key).
')</span>';
147 $valuetoshow = $value.
' <span class="opacitymedium">('.$key.
')</span>';
153 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
156 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
159 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
164 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
165 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
167 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
174 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
191 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
194 global $langs, $conf;
200 if (!is_array($dirmenuarray)) {
204 $menuarray = array();
205 foreach ($conf->file->dol_document_root as $dirroot) {
206 foreach ($dirmenuarray as $dirtoscan) {
207 $dir = $dirroot.$dirtoscan;
210 $handle = opendir($dir);
211 if (is_resource($handle)) {
212 while (($file = readdir($handle)) !==
false) {
213 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS' && substr($file, 0, 5) !=
'index') {
214 if (preg_match(
'/lib\.php$/i', $file)) {
217 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
220 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
223 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
227 $filetoshow = preg_replace(
'/\.php$/i',
'', $file);
228 $filetoshow = ucfirst(preg_replace(
'/_menu$/i',
'', $filetoshow));
231 if (preg_match(
'/^eldy/i', $file)) {
233 } elseif (preg_match(
'/^smartphone/i', $file)) {
240 if (preg_match(
'/^auguria/i', $file)) {
241 $morelabel .=
' <span class="opacitymedium">('.$langs->trans(
"Unstable").
')</span>';
243 if ($file == $selected) {
244 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected data-html="'.
dol_escape_htmltag($filetoshow.$morelabel).
'">';
245 $menuarray[$prefix.
'_'.$file] .= $filetoshow.$morelabel;
246 $menuarray[$prefix.
'_'.$file] .=
'</option>';
248 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" data-html="'.
dol_escape_htmltag($filetoshow.$morelabel).
'">';
249 $menuarray[$prefix.
'_'.$file] .= $filetoshow.$morelabel;
250 $menuarray[$prefix.
'_'.$file] .=
'</option>';
262 print
'<select class="flat minwidth150" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
264 foreach ($menuarray as $key => $val) {
265 $tab = explode(
'_', $key);
266 $newprefix = $tab[0];
268 if ($newprefix ==
'1' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1)) {
271 if ($newprefix ==
'2' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2)) {
274 if ($newprefix != $oldprefix) {
276 print
'<option value="-2" disabled>';
277 if ($newprefix ==
'0') {
278 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
280 if ($newprefix ==
'1') {
281 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
283 if ($newprefix ==
'2') {
284 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
286 if ($newprefix ==
'3') {
287 print
'-- '.$langs->trans(
"Other").
' --';
290 $oldprefix = $newprefix;
314 global $langs, $conf;
317 $expdevmenu = array();
319 $menuarray = array();
321 foreach ($dirmenuarray as $dirmenu) {
322 foreach ($conf->file->dol_document_root as $dirroot) {
323 $dir = $dirroot.$dirmenu;
325 $handle = opendir($dir);
326 if (is_resource($handle)) {
327 while (($file = readdir($handle)) !==
false) {
328 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
329 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
330 if (preg_match(
'/^index/i', $filelib)) {
333 if (preg_match(
'/^default/i', $filelib)) {
336 if (preg_match(
'/^empty/i', $filelib)) {
339 if (preg_match(
'/\.lib/i', $filelib)) {
342 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
346 $menuarray[$filelib] = 1;
348 $menuarray[
'all'] = 1;
359 print
'<select class="flat maxwidth150" id="'.$htmlname.
'" name="'.$htmlname.
'">';
360 foreach ($menuarray as $key => $val) {
361 $tab = explode(
'_', $key);
362 print
'<option value="'.$key.
'"';
363 if ($key == $selected) {
368 print $langs->trans(
"AllMenus");
372 print
'</option>'.
"\n";
391 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
392 print
'<option value="-1"> </option>';
395 "Pacific/Midway" =>
"GMT-11:00",
396 "Pacific/Fakaofo" =>
"GMT-10:00",
397 "America/Anchorage" =>
"GMT-09:00",
398 "America/Los_Angeles" =>
"GMT-08:00",
399 "America/Dawson_Creek" =>
"GMT-07:00",
400 "America/Chicago" =>
"GMT-06:00",
401 "America/Bogota" =>
"GMT-05:00",
402 "America/Anguilla" =>
"GMT-04:00",
403 "America/Araguaina" =>
"GMT-03:00",
404 "America/Noronha" =>
"GMT-02:00",
405 "Atlantic/Azores" =>
"GMT-01:00",
406 "Africa/Abidjan" =>
"GMT+00:00",
407 "Europe/Paris" =>
"GMT+01:00",
408 "Europe/Helsinki" =>
"GMT+02:00",
409 "Europe/Moscow" =>
"GMT+03:00",
410 "Asia/Dubai" =>
"GMT+04:00",
411 "Asia/Karachi" =>
"GMT+05:00",
412 "Indian/Chagos" =>
"GMT+06:00",
413 "Asia/Jakarta" =>
"GMT+07:00",
414 "Asia/Hong_Kong" =>
"GMT+08:00",
415 "Asia/Tokyo" =>
"GMT+09:00",
416 "Australia/Sydney" =>
"GMT+10:00",
417 "Pacific/Noumea" =>
"GMT+11:00",
418 "Pacific/Auckland" =>
"GMT+12:00",
419 "Pacific/Enderbury" =>
"GMT+13:00"
421 foreach ($arraytz as $lib => $gmt) {
422 print
'<option value="'.$lib.
'"';
423 if ($selected == $lib || $selected == $gmt) {
426 print
'>'.$gmt.
'</option>'.
"\n";
444 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter =
'', $showempty = 0, $forcecombo = 0)
449 $langs->load(
"dict");
451 $sql =
"SELECT code, label, width, height, unit";
452 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
453 $sql .=
" WHERE active=1";
455 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
458 $paperformat = array();
460 $resql = $this->db->query($sql);
462 $num = $this->db->num_rows($resql);
465 $obj = $this->db->fetch_object($resql);
466 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
468 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
478 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
480 $out .=
'<option value=""';
481 if ($selected ==
'') {
484 $out .=
'> </option>';
486 foreach ($paperformat as $key => $value) {
487 if ($selected == $key) {
488 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
490 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
496 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
518 $out .=
'<select class="flat type" id="'.$htmlname.
'" name="'.$htmlname.
'">';
519 foreach ($type2label as $key => $val) {
522 $selected =
' selected="selected"';
528 if (empty($typewecanchangeinto) || in_array($key, $typewecanchangeinto[$type])) {
529 $out .=
'<option value="'.$key.
'"'.$selected.
' data-html="'.
dol_escape_htmltag($valhtml).
'">'.($val ? $val :
' ').
'</option>';
531 $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...