71 public function select_export_model($selected =
'', $htmlname =
'exportmodelid', $type =
'', $useempty = 0, $fk_user = null)
74 global $conf, $langs, $user;
76 $sql =
"SELECT rowid, label, fk_user";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"export_model";
78 $sql .=
" WHERE type = '".$this->db->escape($type).
"'";
79 if (!empty($fk_user)) $sql .=
" AND fk_user IN (0, ".$fk_user.
")";
80 $sql .=
" ORDER BY label";
81 $result = $this->
db->query($sql);
84 print '<select class="flat minwidth200" name="'.$htmlname.
'" id="'.$htmlname.
'">';
87 print '<option value="-1"> </option>';
90 $num = $this->
db->num_rows($result);
94 $obj = $this->
db->fetch_object($result);
97 if ($obj->fk_user == 0) {
98 $label .=
' <span class="opacitymedium">('.$langs->trans(
"Everybody").
')</span>';
99 } elseif (!empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) {
100 $tmpuser =
new User($this->
db);
101 $tmpuser->fetch($obj->fk_user);
102 $label .=
' <span class="opacitymedium">('.$tmpuser->getFullName($langs).
')</span>';
105 if ($selected == $obj->rowid)
134 public function select_import_model($selected =
'', $htmlname =
'importmodelid', $type =
'', $useempty = 0, $fk_user = null)
137 global $conf, $langs, $user;
139 $sql =
"SELECT rowid, label, fk_user";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"import_model";
141 $sql .=
" WHERE type = '".$this->db->escape($type).
"'";
142 if (!empty($fk_user)) $sql .=
" AND fk_user IN (0, ".$fk_user.
")";
143 $sql .=
" ORDER BY rowid";
144 $result = $this->
db->query($sql);
147 print '<select class="flat minwidth200" name="'.$htmlname.
'" id="'.$htmlname.
'">';
150 print '<option value="-1"> </option>';
153 $num = $this->
db->num_rows($result);
157 $obj = $this->
db->fetch_object($result);
159 $label = $obj->label;
160 if ($obj->fk_user == 0) {
161 $label .=
' <span class="opacitymedium">('.$langs->trans(
"Everybody").
')</span>';
162 } elseif (!empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) {
163 $tmpuser =
new User($this->
db);
164 $tmpuser->fetch($obj->fk_user);
165 $label .=
' <span class="opacitymedium">('.$tmpuser->getFullName($langs).
')</span>';
168 if ($selected == $obj->rowid)
199 $sql =
"SELECT e.rowid, e.code, e.label, e.price, e.organization,";
200 $sql .=
" c.label as country";
201 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ecotaxe as e,".MAIN_DB_PREFIX.
"c_country as c";
202 $sql .=
" WHERE e.active = 1 AND e.fk_pays = c.rowid";
203 $sql .=
" ORDER BY country, e.organization ASC, e.code ASC";
205 dol_syslog(get_class($this).
'::select_ecotaxes', LOG_DEBUG);
209 print '<select class="flat" name="'.$htmlname.
'">';
212 print '<option value="-1"> </option>'.
"\n";
217 $obj = $this->
db->fetch_object(
$resql);
218 if ($selected && $selected == $obj->rowid)
220 print '<option value="'.$obj->rowid.
'" selected>';
222 print '<option value="'.$obj->rowid.
'">';
225 $selectOptionValue = $obj->code.
' - '.$obj->label.
' : '.
price($obj->price).
' '.$langs->trans(
"HT").
' ('.$obj->organization.
')';
226 print $selectOptionValue;
256 $sql =
"SELECT r.taux, r.revenuestamp_type";
257 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_revenuestamp as r,".MAIN_DB_PREFIX.
"c_country as c";
258 $sql .=
" WHERE r.active = 1 AND r.fk_pays = c.rowid";
259 $sql .=
" AND c.code = '".$this->db->escape($country_code).
"'";
261 dol_syslog(get_class($this).
'::select_revenue_stamp', LOG_DEBUG);
265 $out .=
'<select class="flat" name="'.$htmlname.
'">';
268 $out .=
'<option value="0"> </option>'.
"\n";
273 $obj = $this->
db->fetch_object(
$resql);
274 if (($selected && $selected == $obj->taux) || $num == 1)
276 $out .=
'<option value="'.$obj->taux.($obj->revenuestamp_type ==
'percent' ?
'%' :
'').
'"'.($obj->revenuestamp_type ==
'percent' ?
' data-type="percent"' :
'').
' selected>';
278 $out .=
'<option value="'.$obj->taux.($obj->revenuestamp_type ==
'percent' ?
'%' :
'').
'"'.($obj->revenuestamp_type ==
'percent' ?
' data-type="percent"' :
'').
'>';
281 $out .= $obj->taux.($obj->revenuestamp_type ==
'percent' ?
'%' :
'');
308 public function select_percent($selected = 0, $htmlname =
'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
311 $return =
'<select class="flat" name="'.$htmlname.
'" '.($disabled ?
'disabled' :
'').
'>';
312 if ($showempty) $return .=
'<option value="-1"'.(($selected == -1 || $selected ==
'') ?
' selected' :
'').
'> </option>';
314 for ($i = $start; $i <= $end; $i += $increment)
316 if ($selected !=
'' && (
int) $selected == $i)
318 $return .=
'<option value="'.$i.
'" selected>';
320 $return .=
'<option value="'.$i.
'">';
323 $return .=
'</option>';
326 $return .=
'</select>';
344 public function select_categories($type, $selected = 0, $htmlname =
'search_categ', $nocateg = 0, $showempty = 1, $morecss =
'')
347 global $conf, $langs;
348 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
351 if (is_numeric($type))
353 dol_syslog(__METHOD__.
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
358 $tab_categs = $static_categs->get_full_arbo($type);
362 if ($conf->use_javascript_ajax)
364 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
365 $comboenhancement =
ajax_combobox(
'select_categ_'.$htmlname);
366 $moreforfilter .= $comboenhancement;
370 $moreforfilter .=
'<select class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" id="select_categ_'.$htmlname.
'" name="'.$htmlname.
'">';
371 if ($showempty) $moreforfilter .=
'<option value="0"> </option>';
373 if (is_array($tab_categs))
375 foreach ($tab_categs as $categ)
377 $moreforfilter .=
'<option value="'.$categ[
'id'].
'"';
378 if ($categ[
'id'] == $selected) $moreforfilter .=
' selected';
379 $moreforfilter .=
'>'.dol_trunc($categ[
'fulllabel'], 50,
'middle').
'</option>';
384 $langs->load(
"categories");
385 $moreforfilter .=
'<option value="-2"'.($selected == -2 ?
' selected' :
'').
'>- '.$langs->trans(
"NotCategorized").
' -</option>';
387 $moreforfilter .=
'</select>';
389 return $moreforfilter;
409 global $conf, $langs, $hookmanager;
411 $langs->load(
'users');
415 if ($conf->use_javascript_ajax)
417 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
420 if ($comboenhancement)
422 $out .= $comboenhancement;
426 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
429 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'">';
430 if ($showempty) $out .=
'<option value="0"> </option>';
433 $sql_usr =
"SELECT u.rowid, u.lastname, u.firstname, u.statut as status, u.login, u.photo, u.gender, u.entity, u.admin";
434 $sql_usr .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
436 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
438 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
439 $sql_usr .=
" WHERE u.entity IS NOT NULL";
441 $sql_usr .=
" WHERE EXISTS (SELECT ug.fk_user FROM ".MAIN_DB_PREFIX.
"usergroup_user as ug WHERE u.rowid = ug.fk_user AND ug.entity IN (".
getEntity(
'usergroup').
"))";
442 $sql_usr .=
" OR u.entity = 0";
445 $sql_usr .=
" WHERE u.entity IN (".getEntity(
'user').
")";
448 if (empty($user->rights->user->user->lire)) $sql_usr .=
" AND u.rowid = ".$user->id;
449 if (!empty($user->socid)) $sql_usr .=
" AND u.fk_soc = ".$user->socid;
452 if (!empty($reshook)) $sql_usr .= $hookmanager->resArray[0];
455 if (empty($user->rights->user->user->lire) && $user->socid)
457 $sql_usr .=
" UNION ";
458 $sql_usr .=
"SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin";
459 $sql_usr .=
" FROM ".MAIN_DB_PREFIX.
"user as u2, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
461 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
463 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
464 $sql_usr .=
" WHERE u2.entity IS NOT NULL";
466 $sql_usr .=
" WHERE EXISTS (SELECT ug2.fk_user FROM ".MAIN_DB_PREFIX.
"usergroup_user as ug2 WHERE u2.rowid = ug2.fk_user AND ug2.entity IN (".
getEntity(
'usergroup').
"))";
469 $sql_usr .=
" WHERE u2.entity IN (".getEntity(
'user').
")";
472 $sql_usr .=
" AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->socid;
475 if (!empty($reshook)) $sql_usr .= $hookmanager->resArray[1];
477 $sql_usr .=
" ORDER BY statut DESC, lastname ASC";
480 $resql_usr = $this->
db->query($sql_usr);
483 $userstatic =
new User($this->
db);
486 while ($obj_usr = $this->
db->fetch_object($resql_usr))
488 $userstatic->id = $obj_usr->rowid;
489 $userstatic->lastname = $obj_usr->lastname;
490 $userstatic->firstname = $obj_usr->firstname;
491 $userstatic->photo = $obj_usr->photo;
492 $userstatic->statut = $obj_usr->status;
493 $userstatic->entity = $obj_usr->entity;
494 $userstatic->admin = $obj_usr->admin;
497 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) $labeltoshow = $obj_usr->login;
499 $out .=
'<option value="'.$obj_usr->rowid.
'"';
500 if ($obj_usr->rowid == $selected) $out .=
' selected';
501 $out .=
' data-html="';
503 if (!empty($obj_usr->photo))
505 $outhtml .= $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1).
' ';
507 if ($showstatus >= 0 && $obj_usr->status == 0) $outhtml .=
'<strike class="opacitymediumxxx">';
508 $outhtml .= $labeltoshow;
509 if ($showstatus >= 0 && $obj_usr->status == 0) $outhtml .=
'</strike>';
513 $out .= $labeltoshow;
516 if (!empty($conf->global->MAIN_SHOW_LOGIN))
518 $out .= ($moreinfo ?
' - ' :
' (').$obj_usr->login;
521 if ($showstatus >= 0)
523 if ($obj_usr->status == 1 && $showstatus == 1)
525 $out .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Enabled');
528 if ($obj_usr->status == 0)
530 $out .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Disabled');
534 $out .= ($moreinfo ?
')' :
'');
537 $this->
db->free($resql_usr);
542 if ($norepresentative)
544 $langs->load(
"companies");
545 $out .=
'<option value="-2"'.($selected == -2 ?
' selected' :
'').
'>- '.$langs->trans(
"NoSalesRepresentativeAffected").
' -</option>';
568 public function selectProjectTasks($selectedtask =
'', $projectid = 0, $htmlname =
'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus =
'', $morecss =
'')
570 global $user, $langs;
572 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
575 $task =
new Task($this->
db);
576 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode,
'', $filteronprojstatus);
579 print '<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
580 if ($useempty)
print '<option value="0"> </option>';
583 $this->
_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
588 print '<div class="warning">'.$langs->trans(
"NoProject").
'</div>';
604 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
606 global $langs, $user, $conf;
610 $numlines = count($lines);
611 for ($i = 0; $i < $numlines; $i++) {
612 if ($lines[$i]->fk_parent == $parent) {
618 if ($lines[$i]->fk_project != $lastprojectid)
620 if ($i > 0)
print '<option value="0" disabled>----------</option>';
621 print '<option value="'.$lines[$i]->fk_project.
'_0"';
622 if ($selectedproject == $lines[$i]->fk_project)
print ' selected';
624 $labeltoshow = $langs->trans(
"Project").
' '.$lines[$i]->projectref;
625 if (empty($lines[$i]->
public)) {
626 $labeltoshow .=
' <span class="opacitymedium">('.$langs->trans(
"Visibility").
': '.$langs->trans(
"PrivateProject").
')</span>';
628 $labeltoshow .=
' <span class="opacitymedium">('.$langs->trans(
"Visibility").
': '.$langs->trans(
"SharedProject").
')</span>';
631 print ' data-html="'.dol_escape_htmltag($labeltoshow).
'"';
636 $lastprojectid = $lines[$i]->fk_project;
641 $newdisablechildoftaskid = $disablechildoftaskid;
644 if (isset($lines[$i]->
id))
648 if ($disablechildoftaskid && (($lines[$i]->
id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid)))
651 if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid = $lines[$i]->id;
654 print '<option value="'.$lines[$i]->fk_project.
'_'.$lines[$i]->id.
'"';
655 if (($lines[$i]->
id == $selectedtask) || ($lines[$i]->fk_project.
'_'.$lines[$i]->id == $selectedtask))
print ' selected';
656 if ($disabled)
print ' disabled';
658 $labeltoshow = $langs->trans(
"Project").
' '.$lines[$i]->projectref;
659 $labeltoshow .=
' '.$lines[$i]->projectlabel;
660 if (empty($lines[$i]->
public))
662 $labeltoshow .=
' <span class="opacitymedium">('.$langs->trans(
"Visibility").
': '.$langs->trans(
"PrivateProject").
')</span>';
664 $labeltoshow .=
' <span class="opacitymedium">('.$langs->trans(
"Visibility").
': '.$langs->trans(
"SharedProject").
')</span>';
666 if ($lines[$i]->
id) $labeltoshow .=
' > ';
667 for ($k = 0; $k < $level; $k++)
669 $labeltoshow .=
" ";
671 $labeltoshow .= $lines[$i]->ref.
' '.$lines[$i]->label;
673 print ' data-html="'.dol_escape_htmltag($labeltoshow).
'"';
681 if ($lines[$i]->
id) $this->
_pLineSelect($inc, $lines[$i]->
id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
696 public static function showColor($color, $textifnotdefined =
'')
699 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
704 if ($color)
print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.
'; background-color: #'.$color.
'" value="'.$color.
'">';
705 else print $textifnotdefined;
721 public function select_color($set_color =
'', $prefix =
'f_color', $form_name =
'', $showcolorbox = 1, $arrayofcolors =
'')
724 print $this->
selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
740 public static function selectColor($set_color =
'', $prefix =
'f_color', $form_name =
'', $showcolorbox = 1, $arrayofcolors =
'', $morecss =
'', $setpropertyonselect =
'')
744 dol_syslog(__METHOD__.
": form_name parameter is deprecated", LOG_WARNING);
747 global $langs, $conf;
751 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1)
753 $langs->load(
"other");
754 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax))
756 $out .=
'<link rel="stylesheet" media="screen" type="text/css" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css" />';
757 $out .=
'<script type="text/javascript" src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/jpicker/jpicker-1.1.6.js"></script>';
758 $out .=
'<script type="text/javascript">
759 jQuery(document).ready(function(){
760 $(\'#colorpicker'.$prefix.
'\').jPicker( {
762 title: \
''.dol_escape_js($langs->trans(
"SelectAColor")).
'\',
765 type: \
'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide", "show", "fade" */
768 show: \'fast\', /* duration of "show" effect. Acceptable values are "fast", "slow", or time in ms */
769 hide: \'fast\' /* duration of "hide" effect. Acceptable values are "fast", "slow", or time in ms */
774 x: \'screenCenter\', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */
775 y: \'center\' /* acceptable values "top", "bottom", "center", or relative px value */
779 clientPath: \''.DOL_URL_ROOT.
'/includes/jquery/plugins/jpicker/images/\',
780 picker: { file: \'../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
782 localization: // alter these to change the text presented by the picker (e.g. different language)
788 currentColor: \
''.
dol_escape_js($langs->trans(
"Current")).
'\',
794 function(color, context) { console.log(
"close"); },
795 function(color, context) { var hex = color.val(\
'hex\'); console.log("new color selected in jpicker "+hex);';
796 if ($setpropertyonselect) { $out .=
' if (hex != null) document.documentElement.style.setProperty(\'--'.$setpropertyonselect.
'\', \
'#\'+hex);'; }
798 function(color, context) { console.log("cancel"); }
803 $out .=
'<input id="colorpicker'.$prefix.
'" name="'.$prefix.
'" size="6" maxlength="7" class="flat'.($morecss ?
' '.$morecss :
'').
'" type="text" value="'.
dol_escape_htmltag($set_color).
'" />';
806 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax))
808 $out .=
'<link rel="stylesheet" href="'.DOL_URL_ROOT.
'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type="text/css" media="screen" />';
809 $out .=
'<script src="'.DOL_URL_ROOT.
'/includes/jquery/plugins/colorpicker/jquery.colorpicker.js" type="text/javascript"></script>';
810 $out .=
'<script type="text/javascript">
811 jQuery(document).ready(function(){
812 jQuery(\'#colorpicker'.$prefix.
'\').colorpicker({
820 $out .= '<select
id=
"colorpicker'.$prefix.'" class=
"flat'.($morecss ? ' '.$morecss : '').'" name=
"'.$prefix.'">
';
821 //print '<option value=
"-1"> </option>
';
822 foreach ($arrayofcolors as $val)
824 $out .= '<option value=
"'.$val.'"';
825 if ($set_color == $val) $out .= ' selected
';
826 $out .= '>
'.$val.'</option>
';
834 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
845 public function CreateColorIcon($color, $module, $name, $x = '12
', $y = '12
')
850 $file = $conf->$module->dir_temp.'/
'.$name.'.png
';
852 // On cree le repertoire contenant les icones
853 if (!file_exists($conf->$module->dir_temp))
855 dol_mkdir($conf->$module->dir_temp);
858 // On cree l'image en vraies couleurs
859 $image = imagecreatetruecolor($x, $y);
861 $color = substr($color, 1, 6);
863 $rouge = hexdec(substr($color, 0, 2));
864 $vert = hexdec(substr($color, 2, 2));
865 $bleu = hexdec(substr($color, 4, 2));
867 $couleur = imagecolorallocate($image, $rouge, $vert, $bleu);
869 imagefill($image, 0, 0, $couleur);
871 ImagePng($image, $file);
872 ImageDestroy($image);
890 0=>$langs->trans(
"Day0"),
891 1=>$langs->trans(
"Day1"),
892 2=>$langs->trans(
"Day2"),
893 3=>$langs->trans(
"Day3"),
894 4=>$langs->trans(
"Day4"),
895 5=>$langs->trans(
"Day5"),
896 6=>$langs->trans(
"Day6")
899 $select_week =
'<select class="flat" name="'.$htmlname.
'">';
902 $select_week .=
'<option value="-1"> </option>';
904 foreach ($week as $key => $val)
906 if ($selected == $key)
908 $select_week .=
'<option value="'.$key.
'" selected>';
910 $select_week .=
'<option value="'.$key.
'">';
912 $select_week .= $val;
913 $select_week .=
'</option>';
915 $select_week .=
'</select>';
931 public function select_month($selected =
'', $htmlname =
'monthid', $useempty = 0, $longlabel = 0, $morecss =
'minwidth50 maxwidth75imp valignmiddle', $addjscombo =
false)
936 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
938 if ($longlabel) $montharray =
monthArray($langs, 0);
941 $select_month =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
944 $select_month .=
'<option value="0"> </option>';
946 foreach ($montharray as $key => $val)
948 if ($selected == $key)
950 $select_month .=
'<option value="'.$key.
'" selected>';
952 $select_month .=
'<option value="'.$key.
'">';
954 $select_month .= $val;
955 $select_month .=
'</option>';
957 $select_month .=
'</select>';
963 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
967 return $select_month;
985 public function select_year($selected =
'', $htmlname =
'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option =
'', $morecss =
'valignmiddle maxwidth75imp')
988 print $this->
selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss);
1006 public function selectyear($selected =
'', $htmlname =
'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option =
'', $morecss =
'valignmiddle width75', $addjscombo =
false)
1010 $currentyear = date(
"Y") + $offset;
1011 $max_year = $currentyear + $max_year;
1012 $min_year = $currentyear - $min_year;
1013 if (empty($selected) && empty($useempty)) $selected = $currentyear;
1015 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$option.
' >';
1018 $selected_html =
'';
1019 if ($selected ==
'') $selected_html =
' selected';
1020 $out .=
'<option value=""'.$selected_html.
'> </option>';
1024 for ($y = $max_year; $y >= $min_year; $y--)
1026 $selected_html =
'';
1027 if ($selected > 0 && $y == $selected) $selected_html =
' selected';
1028 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1031 for ($y = $min_year; $y <= $max_year; $y++)
1033 $selected_html =
'';
1034 if ($selected > 0 && $y == $selected) $selected_html =
' selected';
1035 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1038 $out .=
"</select>\n";
1044 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1062 global $conf, $langs, $db;
1064 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1066 $confuserzone =
'MAIN_BOXES_'.$areacode;
1071 $selectboxlist =
'';
1072 $boxactivated =
InfoBox::listBoxes($db,
'activated', $areacode, (empty($user->conf->$confuserzone) ?null:$user), array(), 0);
1074 $boxidactivatedforuser = array();
1075 foreach ($boxactivated as $box)
1077 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id] = $box->id;
1081 $arrayboxtoactivatelabel = array();
1082 if (!empty($user->conf->$confuserzone))
1085 $langs->load(
"boxes");
1086 foreach ($boxactivated as $box)
1088 if (!empty($boxidactivatedforuser[$box->id]))
continue;
1089 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1091 if (preg_match(
'/graph/', $box->class) && $conf->browser->layout !=
'phone')
1093 $label = $label.
' <span class="fa fa-bar-chart"></span>';
1095 $arrayboxtoactivatelabel[$box->id] = $label;
1097 foreach ($boxidactivatedforuser as $boxid)
1099 if (empty($boxorder)) $boxorder .=
'A:';
1100 $boxorder .= $boxid.
',';
1106 $selectboxlist .=
'<!-- Form with select box list -->'.
"\n";
1107 $selectboxlist .=
'<form id="addbox" name="addbox" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1108 $selectboxlist .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1109 $selectboxlist .=
'<input type="hidden" name="addbox" value="addbox">';
1110 $selectboxlist .=
'<input type="hidden" name="userid" value="'.$user->id.
'">';
1111 $selectboxlist .=
'<input type="hidden" name="areacode" value="'.$areacode.
'">';
1112 $selectboxlist .=
'<input type="hidden" name="boxorder" value="'.$boxorder.
'">';
1113 $selectboxlist .=
Form::selectarray(
'boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans(
"ChooseBoxToAdd").
'...', 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth150onsmartphone', 0,
'hidden selected', 0, 1);
1114 if (empty($conf->use_javascript_ajax)) $selectboxlist .=
' <input type="submit" class="button" value="'.$langs->trans(
"AddBox").
'">';
1115 $selectboxlist .=
'</form>';
1116 if (!empty($conf->use_javascript_ajax))
1118 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1124 if (!empty($conf->use_javascript_ajax))
1126 $selectboxlist .=
'<script type="text/javascript" language="javascript">
1128 // To update list of activated boxes
1129 function updateBoxOrder(closing) {
1130 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1131 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1132 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1133 if (boxorder==\'A:A-B:B\' && closing == 1) // There is no more boxes on screen, and we are after a delete of a box so we must hide title
1136 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=0&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1139 // We force reload to be sure to get all boxes into list
1140 window.location.search=\'mainmenu='.
GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'&action=delbox\';
1145 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1151 jQuery(document).ready(function() {
1152 jQuery("#boxcombo").change(function() {
1153 var boxid=jQuery("#boxcombo").val();
1155 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1156 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1157 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1159 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.
'&userid='.$user->id.
'\',
1162 window.location.search=\
'mainmenu='.GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'&action=addbox&boxid=\'+boxid;
1165 if (!count($arrayboxtoactivatelabel)) $selectboxlist .=
'jQuery("#boxcombo").hide();';
1168 jQuery("#boxhalfleft, #boxhalfright").sortable({
1169 handle: \'.boxhandle\',
1170 revert: \'invalid\',
1171 items: \'.boxdraggable\',
1172 containment: \'document\',
1173 connectWith: \'#boxhalfleft, #boxhalfright\',
1174 stop: function(event, ui) {
1175 updateBoxOrder(1); /* 1 to avoid message after a move */
1179 jQuery(".boxclose").click(function() {
1180 var self = this; // because JQuery can modify this
1181 var boxid=self.id.substring(8);
1182 var label=jQuery(\'#boxlabelentry\'+boxid).val();
1183 console.log("We close box "+boxid);
1184 jQuery(\'#boxto_\'+boxid).remove();
1185 if (boxid > 0) jQuery(\'#boxcombo\').append(new Option(label, boxid));
1186 updateBoxOrder(1); /* 1 to avoid message after a remove */
1191 $selectboxlist .=
'</script>'.
"\n";
1195 $boxlista =
''; $boxlistb =
'';
1196 $nbboxactivated = count($boxidactivatedforuser);
1198 if ($nbboxactivated)
1201 $langs->loadLangs(array(
"boxes",
"projects"));
1205 $boxlista .=
"\n<!-- Box left container -->\n";
1209 if (!empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines = $conf->global->MAIN_BOXES_MAXLINES;
1212 foreach ($boxactivated as $key => $box)
1214 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0))
continue;
1215 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order =
'A'.sprintf(
"%02d", ($ii + 1));
1216 if (preg_match(
'/^A/i', $box->box_order))
1222 $box->loadBox($box_max_lines);
1223 $boxlista .= $box->showBox(null, null, 1);
1227 if ($conf->browser->layout !=
'phone')
1229 $emptybox->box_id =
'A';
1230 $emptybox->info_box_head = array();
1231 $emptybox->info_box_contents = array();
1232 $boxlista .= $emptybox->showBox(array(), array(), 1);
1234 $boxlista .=
"<!-- End box left container -->\n";
1236 $boxlistb .=
"\n<!-- Box right container -->\n";
1239 foreach ($boxactivated as $key => $box)
1241 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0))
continue;
1242 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order =
'B'.sprintf(
"%02d", ($ii + 1));
1243 if (preg_match(
'/^B/i', $box->box_order))
1249 $box->loadBox($box_max_lines);
1250 $boxlistb .= $box->showBox(null, null, 1);
1254 if ($conf->browser->layout !=
'phone')
1256 $emptybox->box_id =
'B';
1257 $emptybox->info_box_head = array();
1258 $emptybox->info_box_contents = array();
1259 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1262 $boxlistb .=
"<!-- End box right container -->\n";
1265 return array(
'selectboxlist'=>count($boxactivated) ? $selectboxlist :
'',
'boxactivated'=>$boxactivated,
'boxlista'=>$boxlista,
'boxlistb'=>$boxlistb);
1282 public function select_dictionary($htmlname, $dictionarytable, $keyfield =
'code', $labelfield =
'label', $selected =
'', $useempty = 0, $moreattrib =
'')
1285 global $langs, $conf;
1287 $langs->load(
"admin");
1289 $sql =
"SELECT rowid, ".$keyfield.
", ".$labelfield;
1290 $sql .=
" FROM ".MAIN_DB_PREFIX.$dictionarytable;
1291 $sql .=
" ORDER BY ".$labelfield;
1293 dol_syslog(get_class($this).
"::select_dictionary", LOG_DEBUG);
1294 $result = $this->
db->query($sql);
1297 $num = $this->
db->num_rows($result);
1301 print '<select id="select'.$htmlname.
'" class="flat selectdictionary" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
1302 if ($useempty == 1 || ($useempty == 2 && $num > 1))
1304 print '<option value="-1"> </option>';
1309 $obj = $this->
db->fetch_object($result);
1310 if ($selected == $obj->rowid || $selected == $obj->$keyfield)
1312 print '<option value="'.$obj->$keyfield.
'" selected>';
1314 print '<option value="'.$obj->$keyfield.
'">';
1316 print $obj->$labelfield;
1322 print $langs->trans(
"DictionaryEmpty");
1339 public function selectAutoManual($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0)
1343 $automatic =
"automatic"; $manual =
"manual";
1350 $disabled = ($disabled ?
' disabled' :
'');
1352 $resultautomanual =
'<select class="flat width100" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
1353 if ($useempty) $resultautomanual .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
1354 if ((
"$value" ==
'automatic') || ($value == 1))
1356 $resultautomanual .=
'<option value="'.$automatic.
'" selected>'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1357 $resultautomanual .=
'<option value="'.$manual.
'">'.$langs->trans(
"Manual").
'</option>'.
"\n";
1359 $selected = (($useempty && $value !=
'0' && $value !=
'manual') ?
'' :
' selected');
1360 $resultautomanual .=
'<option value="'.$automatic.
'">'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1361 $resultautomanual .=
'<option value="'.$manual.
'"'.$selected.
'>'.$langs->trans(
"Manual").
'</option>'.
"\n";
1363 $resultautomanual .=
'</select>'.
"\n";
1364 return $resultautomanual;
1377 public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss =
'minwidth200 maxwidth250')
1379 global $langs, $extrafields, $form;
1381 $YYYY = substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1);
1382 $MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
1383 $DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
1384 $HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
1385 $MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
1386 $SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
1388 foreach ($object->fields as $key => $val) {
1389 if (!$val[
'measure']) {
1390 if (in_array($key, array(
1391 'id',
'ref_int',
'ref_ext',
'rowid',
'entity',
'last_main_doc',
'logo',
'logo_squarred',
'extraparams',
1392 'parent',
'photo',
'socialnetworks',
'webservices_url',
'webservices_key')))
continue;
1393 if (isset($val[
'enabled']) && !
dol_eval($val[
'enabled'], 1))
continue;
1394 if (isset($val[
'visible']) && !
dol_eval($val[
'visible'], 1))
continue;
1395 if (preg_match(
'/^fk_/', $key) && !preg_match(
'/^fk_statu/', $key))
continue;
1396 if (preg_match(
'/^pass/', $key))
continue;
1397 if (in_array($val[
'type'], array(
'html',
'text')))
continue;
1398 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
1399 $arrayofgroupby[
't.'.$key.
'-year'] = array(
'label' => $langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
')</span>',
'position' => $val[
'position'].
'-y');
1400 $arrayofgroupby[
't.'.$key.
'-month'] = array(
'label' => $langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
')</span>',
'position' => $val[
'position'].
'-m');
1401 $arrayofgroupby[
't.'.$key.
'-day'] = array(
'label' => $langs->trans($val[
'label']).
' <span class="opacitymedium">('.$YYYY.
'-'.$MM.
'-'.$DD.
')</span>',
'position' => $val[
'position'].
'-d');
1403 $arrayofgroupby[
't.'.$key] = array(
'label' => $langs->trans($val[
'label']),
'position' => (int) $val[
'position']);
1408 if ($object->isextrafieldmanaged) {
1409 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
1410 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'separate')
continue;
1411 if (!empty($extrafields->attributes[$object->table_element][
'totalizable'][$key]))
continue;
1412 $arrayofgroupby[
'te.'.$key] = array(
'label' => $langs->trans($extrafields->attributes[$object->table_element][
'label'][$key]),
'position' => 1000 + (int) $extrafields->attributes[$object->table_element][
'pos'][$key]);
1416 $arrayofgroupby =
dol_sort_array($arrayofgroupby,
'position',
'asc', 0, 0, 1);
1417 $arrayofgroupbylabel = array();
1418 foreach ($arrayofgroupby as $key => $val) {
1419 $arrayofgroupbylabel[$key] = $val[
'label'];
1421 $result = $form->selectarray(
'search_groupby', $arrayofgroupbylabel, $search_groupby, 1, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
1436 global $langs, $extrafields, $form;
1438 $YYYY = substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1);
1439 $MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
1440 $DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
1441 $HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
1442 $MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
1443 $SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
1446 foreach ($object->fields as $key => $val) {
1447 if (!$val[
'measure']) {
1448 if (in_array($key, array(
1449 'id',
'ref_int',
'ref_ext',
'rowid',
'entity',
'last_main_doc',
'logo',
'logo_squarred',
'extraparams',
1450 'parent',
'photo',
'socialnetworks',
'webservices_url',
'webservices_key')))
continue;
1451 if (isset($val[
'enabled']) && !
dol_eval($val[
'enabled'], 1))
continue;
1452 if (isset($val[
'visible']) && !
dol_eval($val[
'visible'], 1))
continue;
1453 if (preg_match(
'/^fk_/', $key) && !preg_match(
'/^fk_statu/', $key))
continue;
1454 if (preg_match(
'/^pass/', $key))
continue;
1455 if (in_array($val[
'type'], array(
'html',
'text')))
continue;
1456 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
1457 $arrayofxaxis[
't.'.$key.
'-year'] = array(
'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
')',
'position' => $val[
'position'].
'-y');
1458 $arrayofxaxis[
't.'.$key.
'-month'] = array(
'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
')',
'position' => $val[
'position'].
'-m');
1459 $arrayofxaxis[
't.'.$key.
'-day'] = array(
'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
'-'.$DD.
')',
'position' => $val[
'position'].
'-d');
1461 $arrayofxaxis[
't.'.$key] = array(
'label' => $langs->trans($val[
'label']),
'position' => (int) $val[
'position']);
1467 if ($object->isextrafieldmanaged) {
1468 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
1469 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'separate')
continue;
1470 if (!empty($extrafields->attributes[$object->table_element][
'totalizable'][$key]))
continue;
1471 $arrayofxaxis[
'te.'.$key] = array(
'label' => $langs->trans($extrafields->attributes[$object->table_element][
'label'][$key]),
'position' => 1000 + (int) $extrafields->attributes[$object->table_element][
'pos'][$key]);
1475 $arrayofxaxis =
dol_sort_array($arrayofxaxis,
'position',
'asc', 0, 0, 1);
1477 $arrayofxaxislabel = array();
1478 foreach ($arrayofxaxis as $key => $val) {
1479 $arrayofxaxislabel[$key] = $val[
'label'];
1481 $result = $form->selectarray(
'search_xaxis', $arrayofxaxislabel, $search_xaxis, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth250', 1);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Class to manage Dolibarr users.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255).
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
static listBoxes($db, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
Return array of boxes qualified for area and user.
monthArray($outputlangs, $short=0)
Return array of translated months or selected month.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
colorIsLight($stringcolor)
Return true if the color is light.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
colorArrayToHex($arraycolor, $colorifnotfound= '888888')
Convert an array with RGB value into hex RGB value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...