65 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)
70 if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) {
71 if (!is_array($filter)) {
74 $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1;
77 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
81 if ($selected && empty($showempty)) {
82 if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
83 $tmparray = explode(
'_', $selected);
84 if (!empty($tmparray[1])) {
87 if (empty($selected)) {
88 $selected = $langs->defaultlang;
97 $out .=
'<select '.($multiselect ?
'multiple="multiple" ' :
'').
'class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($disabled ?
' disabled' :
'').
'>';
98 if ($showempty && !$multiselect) {
99 $out .=
'<option value="0"';
100 if ($selected ===
'') {
104 if ($showempty !=
'1') {
112 $out .=
'<option value="auto"';
113 if ($selected ===
'auto') {
116 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
119 asort($langs_available);
121 foreach ($langs_available as $key => $value) {
122 $valuetoshow = $value;
123 if ($showcode == 1) {
125 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
127 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
130 if ($showcode == 2) {
132 $valuetoshow = $value.
' <span class="opacitymedium">('.preg_replace(
'/[_-].*$/',
'', $key).
')</span>';
134 $valuetoshow = $value.
' <span class="opacitymedium">('.$key.
')</span>';
140 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
143 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
146 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
151 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
152 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
154 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
161 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
178 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
181 global $langs, $conf;
187 if (!is_array($dirmenuarray)) {
191 $menuarray = array();
192 foreach ($conf->file->dol_document_root as $dirroot) {
193 foreach ($dirmenuarray as $dirtoscan) {
194 $dir = $dirroot.$dirtoscan;
197 $handle = opendir($dir);
198 if (is_resource($handle)) {
199 while (($file = readdir($handle)) !==
false) {
200 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS' && substr($file, 0, 5) !=
'index') {
201 if (preg_match(
'/lib\.php$/i', $file)) {
204 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
207 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
210 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
214 $filelib = preg_replace(
'/\.php$/i',
'', $file);
217 if (preg_match(
'/^eldy/i', $file)) {
219 } elseif (preg_match(
'/^smartphone/i', $file)) {
225 if ($file == $selected) {
226 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected>'.$filelib.
'</option>';
228 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'">'.$filelib.
'</option>';
240 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
242 foreach ($menuarray as $key => $val) {
243 $tab = explode(
'_', $key);
244 $newprefix = $tab[0];
245 if ($newprefix ==
'1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) {
248 if ($newprefix ==
'2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) {
251 if ($newprefix != $oldprefix) {
253 print
'<option value="-1" disabled>';
254 if ($newprefix ==
'0') {
255 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
257 if ($newprefix ==
'1') {
258 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
260 if ($newprefix ==
'2') {
261 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
263 if ($newprefix ==
'3') {
264 print
'-- '.$langs->trans(
"Other").
' --';
267 $oldprefix = $newprefix;
286 global $langs, $conf;
289 $expdevmenu = array();
291 $menuarray = array();
293 foreach ($dirmenuarray as $dirmenu) {
294 foreach ($conf->file->dol_document_root as $dirroot) {
295 $dir = $dirroot.$dirmenu;
297 $handle = opendir($dir);
298 if (is_resource($handle)) {
299 while (($file = readdir($handle)) !==
false) {
300 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS') {
301 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
302 if (preg_match(
'/^index/i', $filelib)) {
305 if (preg_match(
'/^default/i', $filelib)) {
308 if (preg_match(
'/^empty/i', $filelib)) {
311 if (preg_match(
'/\.lib/i', $filelib)) {
314 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
318 $menuarray[$filelib] = 1;
320 $menuarray[
'all'] = 1;
331 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
333 foreach ($menuarray as $key => $val) {
334 $tab = explode(
'_', $key);
335 $newprefix = $tab[0];
336 print
'<option value="'.$key.
'"';
337 if ($key == $selected) {
342 print $langs->trans(
"AllMenus");
346 print
'</option>'.
"\n";
365 global $langs, $conf;
367 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
368 print
'<option value="-1"> </option>';
371 "Pacific/Midway"=>
"GMT-11:00",
372 "Pacific/Fakaofo"=>
"GMT-10:00",
373 "America/Anchorage"=>
"GMT-09:00",
374 "America/Los_Angeles"=>
"GMT-08:00",
375 "America/Dawson_Creek"=>
"GMT-07:00",
376 "America/Chicago"=>
"GMT-06:00",
377 "America/Bogota"=>
"GMT-05:00",
378 "America/Anguilla"=>
"GMT-04:00",
379 "America/Araguaina"=>
"GMT-03:00",
380 "America/Noronha"=>
"GMT-02:00",
381 "Atlantic/Azores"=>
"GMT-01:00",
382 "Africa/Abidjan"=>
"GMT+00:00",
383 "Europe/Paris"=>
"GMT+01:00",
384 "Europe/Helsinki"=>
"GMT+02:00",
385 "Europe/Moscow"=>
"GMT+03:00",
386 "Asia/Dubai"=>
"GMT+04:00",
387 "Asia/Karachi"=>
"GMT+05:00",
388 "Indian/Chagos"=>
"GMT+06:00",
389 "Asia/Jakarta"=>
"GMT+07:00",
390 "Asia/Hong_Kong"=>
"GMT+08:00",
391 "Asia/Tokyo"=>
"GMT+09:00",
392 "Australia/Sydney"=>
"GMT+10:00",
393 "Pacific/Noumea"=>
"GMT+11:00",
394 "Pacific/Auckland"=>
"GMT+12:00",
395 "Pacific/Enderbury"=>
"GMT+13:00"
397 foreach ($arraytz as $lib => $gmt) {
398 print
'<option value="'.$lib.
'"';
399 if ($selected == $lib || $selected == $gmt) {
402 print
'>'.$gmt.
'</option>'.
"\n";
420 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter = 0, $showempty = 0, $forcecombo = 0)
425 $langs->load(
"dict");
427 $sql =
"SELECT code, label, width, height, unit";
428 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
429 $sql .=
" WHERE active=1";
431 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
439 $obj = $this->
db->fetch_object(
$resql);
440 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
442 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
452 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
454 $out .=
'<option value=""';
455 if ($selected ==
'') {
458 $out .=
'> </option>';
460 foreach ($paperformat as $key => $value) {
461 if ($selected == $key) {
462 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
464 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
470 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
$conf db
API class for accounts.