73 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)
79 if (!is_array($filter)) {
85 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
89 if ($selected && empty($showempty)) {
90 if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
91 $tmparray = explode(
'_', $selected);
92 if (!empty($tmparray[1])) {
95 if (empty($selected)) {
96 $selected = $langs->defaultlang;
105 $out .=
'<select '.($multiselect ?
'multiple="multiple" ' :
'').
'class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($disabled ?
' disabled' :
'').
'>';
106 if ($showempty && !$multiselect) {
107 if (is_numeric($showempty)) {
108 $out .=
'<option value="0"';
110 $out .=
'<option value="-1"';
112 if ($selected ===
'') {
116 if ($showempty !=
'1') {
124 $out .=
'<option value="auto"';
125 if ($selected ===
'auto') {
128 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
131 asort($langs_available);
133 foreach ($langs_available as $key => $value) {
134 $valuetoshow = $value;
135 if ($showcode == 1) {
137 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
139 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
142 if ($showcode == 2) {
144 $valuetoshow = $value.
' <span class="opacitymedium">('.preg_replace(
'/[_-].*$/',
'', $key).
')</span>';
146 $valuetoshow = $value.
' <span class="opacitymedium">('.$key.
')</span>';
152 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
155 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
158 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
163 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
164 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
166 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
173 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
190 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
193 global $langs, $conf;
199 if (!is_array($dirmenuarray)) {
203 $menuarray = array();
204 foreach ($conf->file->dol_document_root as $dirroot) {
205 foreach ($dirmenuarray as $dirtoscan) {
206 $dir = $dirroot.$dirtoscan;
209 $handle = opendir($dir);
210 if (is_resource($handle)) {
211 while (($file = readdir($handle)) !==
false) {
212 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS' && substr($file, 0, 5) !=
'index') {
213 if (preg_match(
'/lib\.php$/i', $file)) {
216 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
219 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
222 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
226 $filelib = preg_replace(
'/\.php$/i',
'', $file);
229 if (preg_match(
'/^eldy/i', $file)) {
231 } elseif (preg_match(
'/^smartphone/i', $file)) {
238 if (preg_match(
'/^auguria/i', $file)) {
239 $morelabel .=
' <span class="opacitymedium">('.$langs->trans(
"Unstable").
')</span>';
241 if ($file == $selected) {
242 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected data-html="'.
dol_escape_htmltag($filelib.$morelabel).
'">'.$filelib.$morelabel;
243 $menuarray[$prefix.
'_'.$file] .=
'</option>';
245 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" data-html="'.
dol_escape_htmltag($filelib.$morelabel).
'">'.$filelib.$morelabel;
246 $menuarray[$prefix.
'_'.$file] .=
'</option>';
258 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
260 foreach ($menuarray as $key => $val) {
261 $tab = explode(
'_', $key);
262 $newprefix = $tab[0];
264 if ($newprefix ==
'1' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1)) {
267 if ($newprefix ==
'2' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2)) {
270 if ($newprefix != $oldprefix) {
272 print
'<option value="-2" disabled>';
273 if ($newprefix ==
'0') {
274 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
276 if ($newprefix ==
'1') {
277 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
279 if ($newprefix ==
'2') {
280 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
282 if ($newprefix ==
'3') {
283 print
'-- '.$langs->trans(
"Other").
' --';
286 $oldprefix = $newprefix;
310 global $langs, $conf;
313 $expdevmenu = array();
315 $menuarray = array();
317 foreach ($dirmenuarray as $dirmenu) {
318 foreach ($conf->file->dol_document_root as $dirroot) {
319 $dir = $dirroot.$dirmenu;
321 $handle = opendir($dir);
322 if (is_resource($handle)) {
323 while (($file = readdir($handle)) !==
false) {
324 if (is_file($dir.
"/".$file) && substr($file, 0, 1) !=
'.' && substr($file, 0, 3) !=
'CVS') {
325 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
326 if (preg_match(
'/^index/i', $filelib)) {
329 if (preg_match(
'/^default/i', $filelib)) {
332 if (preg_match(
'/^empty/i', $filelib)) {
335 if (preg_match(
'/\.lib/i', $filelib)) {
338 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
342 $menuarray[$filelib] = 1;
344 $menuarray[
'all'] = 1;
355 print
'<select class="flat maxwidth150" id="'.$htmlname.
'" name="'.$htmlname.
'">';
356 foreach ($menuarray as $key => $val) {
357 $tab = explode(
'_', $key);
358 print
'<option value="'.$key.
'"';
359 if ($key == $selected) {
364 print $langs->trans(
"AllMenus");
368 print
'</option>'.
"\n";
387 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
388 print
'<option value="-1"> </option>';
391 "Pacific/Midway" =>
"GMT-11:00",
392 "Pacific/Fakaofo" =>
"GMT-10:00",
393 "America/Anchorage" =>
"GMT-09:00",
394 "America/Los_Angeles" =>
"GMT-08:00",
395 "America/Dawson_Creek" =>
"GMT-07:00",
396 "America/Chicago" =>
"GMT-06:00",
397 "America/Bogota" =>
"GMT-05:00",
398 "America/Anguilla" =>
"GMT-04:00",
399 "America/Araguaina" =>
"GMT-03:00",
400 "America/Noronha" =>
"GMT-02:00",
401 "Atlantic/Azores" =>
"GMT-01:00",
402 "Africa/Abidjan" =>
"GMT+00:00",
403 "Europe/Paris" =>
"GMT+01:00",
404 "Europe/Helsinki" =>
"GMT+02:00",
405 "Europe/Moscow" =>
"GMT+03:00",
406 "Asia/Dubai" =>
"GMT+04:00",
407 "Asia/Karachi" =>
"GMT+05:00",
408 "Indian/Chagos" =>
"GMT+06:00",
409 "Asia/Jakarta" =>
"GMT+07:00",
410 "Asia/Hong_Kong" =>
"GMT+08:00",
411 "Asia/Tokyo" =>
"GMT+09:00",
412 "Australia/Sydney" =>
"GMT+10:00",
413 "Pacific/Noumea" =>
"GMT+11:00",
414 "Pacific/Auckland" =>
"GMT+12:00",
415 "Pacific/Enderbury" =>
"GMT+13:00"
417 foreach ($arraytz as $lib => $gmt) {
418 print
'<option value="'.$lib.
'"';
419 if ($selected == $lib || $selected == $gmt) {
422 print
'>'.$gmt.
'</option>'.
"\n";
440 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter =
'', $showempty = 0, $forcecombo = 0)
445 $langs->load(
"dict");
447 $sql =
"SELECT code, label, width, height, unit";
448 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
449 $sql .=
" WHERE active=1";
451 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
454 $paperformat = array();
456 $resql = $this->db->query($sql);
458 $num = $this->db->num_rows($resql);
461 $obj = $this->db->fetch_object($resql);
462 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
464 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
474 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
476 $out .=
'<option value=""';
477 if ($selected ==
'') {
480 $out .=
'> </option>';
482 foreach ($paperformat as $key => $value) {
483 if ($selected == $key) {
484 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
486 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
492 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
514 $out .=
'<select class="flat type" id="'.$htmlname.
'" name="'.$htmlname.
'">';
515 foreach ($type2label as $key => $val) {
518 $selected =
' selected="selected"';
524 if (empty($typewecanchangeinto) || in_array($key, $typewecanchangeinto[$type])) {
525 $out .=
'<option value="'.$key.
'"'.$selected.
' data-html="'.
dol_escape_htmltag($valhtml).
'">'.($val ? $val :
' ').
'</option>';
527 $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 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...