73 public function getHTMLScannerForm($jstoexecuteonadd =
'barcodescannerjs', $mode =
'all', $warehouseselect = 0)
79 $out .=
'<!-- Popup for mass barcode scanning -->'.
"\n";
80 $out .=
'<div class="div-for-modal-topright" style="padding: 15px">';
81 $out .=
'<center>'.img_picto(
'',
'barcode',
'class="pictofixedwidth"').
'<strong>Barcode scanner tool...</strong></center><br>';
83 if ($mode ==
'product') {
84 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct">';
85 } elseif ($mode ==
'lot') {
86 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial">';
88 $out .=
'<input type="radio" name="barcodemode" value="barcodeforautodetect" id="barcodeforautodetect" checked="checked"> <label for="barcodeforautodetect">Autodetect if we scan a product barcode or a lot/serial barcode</label><br>';
89 $out .=
'<input type="radio" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct"> <label for="barcodeforproduct">Scan a product barcode</label><br>';
90 $out .=
'<input type="radio" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial"> <label for="barcodeforlotserial">Scan a product lot or serial number</label><br>';
92 $stringaddbarcode = $langs->trans(
"QtyToAddAfterBarcodeScan",
"tmphtml");
93 $htmltoreplaceby =
'<select name="selectaddorreplace"><option selected value="add">'.$langs->trans(
"Add").
'</option><option value="replace">'.$langs->trans(
"ToReplace").
'</option></select>';
94 $stringaddbarcode = str_replace(
"tmphtml", $htmltoreplaceby, $stringaddbarcode);
95 $out .= $stringaddbarcode.
': <input type="text" name="barcodeproductqty" class="width40 right" value="1"><br>';
96 if ($warehouseselect > 0) {
97 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
99 $formproduct->loadWarehouses();
100 $out .=
img_picto(
'',
'stock',
'class="pictofixedwidth"');
101 $out .= $formproduct->selectWarehouses(
'',
"warehousenew",
'', 0, 0, 0,
'', 0, 1);
105 $out .=
'<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ScanOrTypeOrCopyPasteYourBarCodes")).
'"></textarea>';
115 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" id ="exec'.dol_escape_js($jstoexecuteonadd).
'" name="addscan" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
116 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"CloseWindow")).
'">';
119 $out .=
'<div type="text" id="scantoolmessage" class="scantoolmessage ok nopadding"></div>';
121 $out .=
'<script nonce="'.getNonce().
'">';
122 $out .=
'jQuery("#barcodeforautodetect, #barcodeforproduct, #barcodeforlotserial").click(function(){';
123 $out .=
'console.log("select choice");';
124 $out .=
'jQuery("#scantoolmessage").text("");';
126 $out .=
'$("#exec'.dol_escape_js($jstoexecuteonadd).
'").click(function(){
127 console.log("We call js to execute \''.
dol_escape_js($jstoexecuteonadd).
'\'");
128 '.dol_escape_js($jstoexecuteonadd).'();
129 return false; /* We want to stay on the scan tool */
139 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150 public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null)
155 $sql = "SELECT rowid, label, fk_user
";
156 $sql .= " FROM
".$this->db->prefix()."export_model
";
157 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
158 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
159 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
161 $sql .= " ORDER BY label
";
162 $result = $this->db->query($sql);
164 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
166 if (is_numeric($useempty)) {
167 print '<option value="-1
"> </option>';
169 print '<option value="-1
">'.$langs->trans($useempty).'</option>';
173 $tmpuser = new User($this->db);
175 $num = $this->db->num_rows($result);
178 $obj = $this->db->fetch_object($result);
180 $label = $obj->label;
181 if ($obj->fk_user == 0) {
182 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
183 } elseif ($obj->fk_user > 0) {
184 $tmpuser->fetch($obj->fk_user);
185 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
188 if ($selected == $obj->rowid) {
189 print '<option value="'.$obj->rowid.'" selected data-html="'.dolPrintHTMLForAttribute($label).'">';
191 print '<option value="'.$obj->rowid.'" data-html="'.dolPrintHTMLForAttribute($label).'">';
198 print '<option value="-1
" disabled data-html="'.dolPrintHTMLForAttribute('<span
class=
"opacitymedium">
'.$langs->transnoentitiesnoconv("NoPredefinedExportProfileYet").'</span>
').'">'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet
").'</option>';
201 print ajax_combobox($htmlname);
203 dol_print_error($this->db);
208 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
219 public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null)
224 $sql = "SELECT rowid, label, fk_user
";
225 $sql .= " FROM
".$this->db->prefix()."import_model
";
226 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
227 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
228 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
230 $sql .= " ORDER BY label
";
231 $result = $this->db->query($sql);
233 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
234 if (is_numeric($useempty)) {
235 print '<option value="-1
"> </option>';
237 print '<option value="-1
">'.$langs->trans($useempty).'</option>';
240 $tmpuser = new User($this->db);
242 $num = $this->db->num_rows($result);
245 $obj = $this->db->fetch_object($result);
247 $label = $obj->label;
248 if ($obj->fk_user == 0) {
249 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
250 } elseif ($obj->fk_user > 0) {
251 $tmpuser->fetch($obj->fk_user);
252 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
255 if ($selected == $obj->rowid) {
256 print '<option value="'.$obj->rowid.'" selected data-html="'.dol_escape_htmltag($label).'">';
258 print '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($label).'">';
265 print '<option value="-1
" disabled data-html="'.dolPrintHTMLForAttribute('<span
class=
"opacitymedium">
'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet").'</span>
').'">'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet
").'</option>';
268 print ajax_combobox($htmlname);
270 dol_print_error($this->db);
275 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
283 public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id')
288 $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,
";
289 $sql .= " c.label as country
";
290 $sql .= " FROM
".$this->db->prefix()."c_ecotaxe as e,
".$this->db->prefix()."c_country as c
";
291 $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid
";
292 $sql .= " ORDER BY country, e.organization ASC, e.code ASC
";
294 dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG);
295 $resql = $this->db->query($sql);
297 print '<select class="flat
" name="'.$htmlname.'">';
298 $num = $this->db->num_rows($resql);
300 print '<option value="-1
"> </option>'."\n
";
303 $obj = $this->db->fetch_object($resql);
304 if ($selected && $selected == $obj->rowid) {
305 print '<option value="'.$obj->rowid.'" selected>';
307 print '<option value="'.$obj->rowid.'">';
308 //print '<option onmouseover="showtip(\
''.$obj->label.
'\')
" onMouseout="hidetip()
" value="'.$obj->rowid.'">';
310 $selectOptionValue = $obj->code.' - '.$obj->label.' : '.price($obj->price).' '.$langs->trans("HT
").' ('.$obj->organization.')';
311 print $selectOptionValue;
319 dol_print_error($this->db);
325 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
334 public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '')
341 $sql = "SELECT r.taux, r.revenuestamp_type
";
342 $sql .= " FROM
".$this->db->prefix()."c_revenuestamp as r,
".$this->db->prefix()."c_country as c
";
343 $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid
";
344 $sql .= " AND c.code =
'".$this->db->escape($country_code)."'";
346 dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG);
347 $resql = $this->db->query($sql);
349 $out .= '<select class="flat
" name="'.$htmlname.'">';
350 $num = $this->db->num_rows($resql);
352 $out .= '<option value="0
"> </option>'."\n
";
355 $obj = $this->db->fetch_object($resql);
356 if (($selected && $selected == $obj->taux) || $num == 1) {
357 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').' selected>';
359 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').'>';
361 $out .= $obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '');
369 dol_print_error($this->db);
375 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
388 public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
391 $return = '<select class="flat maxwidth75 right
" name="'.$htmlname.'" '.($disabled ? 'disabled' : '').'>';
393 $return .= '<option value="-1
"'.(($selected == -1 || $selected == '') ? ' selected' : '').'> </option>';
396 for ($i = $start; $i <= $end; $i += $increment) {
397 if ($selected != '' && (int) $selected == $i) {
398 $return .= '<option value="'.$i.'" selected>';
400 $return .= '<option value="'.$i.'">';
403 $return .= '</option>';
406 $return .= '</select>';
411 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
424 public function select_categories($type, $selected = 0, $htmlname = 'search_categ', $nocateg = 0, $showempty = 1, $morecss = '')
427 global $conf, $langs;
428 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
430 // For backward compatibility
431 if (is_numeric($type)) {
432 dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
435 // Load list of "categories
"
436 $static_categs = new Categorie($this->db);
437 $tab_categs = $static_categs->get_full_arbo($type);
441 // Print a select with each of them
442 $moreforfilter .= '<select class="flat minwidth100
'.($morecss ? ' '.$morecss : '').'" id="select_categ_
'.$htmlname.'" name="'.$htmlname.'">';
445 if (!empty($conf->use_javascript_ajax)) {
446 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
448 if (!is_numeric($showempty)) {
449 $textforempty = $showempty;
451 $moreforfilter .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '');
452 //$moreforfilter .= ' data-html="'.dol_escape_htmltag($textforempty).'"';
453 $moreforfilter .= '>'.dol_escape_htmltag($textforempty).'</option>'."\n
";
456 if (is_array($tab_categs)) {
457 foreach ($tab_categs as $categ) {
458 $moreforfilter .= '<option value="'.$categ['id'].'"';
459 if ($categ['id'] == $selected) {
460 $moreforfilter .= ' selected';
462 $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category
', 'class=
"pictofixedwidth" style=
"color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel
'], 50, 'middle
')).'"';
463 $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').'</option>';
467 $langs->load("categories
");
468 $moreforfilter .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NotCategorized
").' -</option>';
470 $moreforfilter .= '</select>';
472 // Enhance with select2
473 if ($conf->use_javascript_ajax) {
474 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
475 $comboenhancement = ajax_combobox('select_categ_'.$htmlname);
476 $moreforfilter .= $comboenhancement;
479 return $moreforfilter;
483 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
496 public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
499 global $conf, $langs, $hookmanager;
502 $langs->load('users');
506 $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
508 // Select each sales and print them in a select input
509 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
512 if (!is_numeric($showempty)) {
513 $textforempty = $showempty;
515 if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
516 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
518 $out .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '').'>'.$textforempty.'</option>'."\n
";
521 // Get list of users allowed to be viewed
522 $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as
status, u.login, u.photo, u.gender, u.entity, u.admin
";
523 $sql_usr .= " FROM
".$this->db->prefix()."user as u
";
525 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
526 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
527 $sql_usr .= " WHERE u.entity IS NOT NULL
"; // Show all users
529 $sql_usr .= " WHERE EXISTS (SELECT ug.fk_user FROM
".$this->db->prefix()."usergroup_user as ug WHERE u.rowid = ug.fk_user AND ug.entity IN (
".getEntity('usergroup')."))
";
530 $sql_usr .= " OR u.entity = 0
"; // Show always superadmin
533 $sql_usr .= " WHERE u.entity IN (
".getEntity('user').")
";
536 if (!$user->hasRight('user', 'user', 'lire')) {
537 $sql_usr .= " AND u.rowid =
".((int) $user->id);
539 if (!empty($user->socid)) {
540 $sql_usr .= " AND u.fk_soc =
".((int) $user->socid);
542 if (getDolUserString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX', getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX'))) {
543 $sql_usr .= " AND u.employee <> 0
";
545 if (getDolUserString('USER_HIDE_EXTERNAL_IN_COMBOBOX', getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX'))) {
546 $sql_usr .= " AND u.fk_soc IS NULL
";
548 if (getDolUserString('USER_HIDE_INACTIVE_IN_COMBOBOX', getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX'))) { // Can be set in setup of module User.
549 $sql_usr .= " AND u.statut <> 0
";
552 //Add hook to filter on user (for example on usergroup define in custom modules)
553 if (!empty($reshook)) {
554 $sql_usr .= $hookmanager->resArray[0];
557 // Add existing sales representatives of thirdparty of external user
558 if (!$user->hasRight('user', 'user', 'lire') && $user->socid) {
559 $sql_usr .= " UNION
";
560 $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as
status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin
";
561 $sql_usr .= " FROM
".$this->db->prefix()."user as u2,
".$this->db->prefix()."societe_commerciaux as sc
";
563 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
564 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
565 $sql_usr .= " WHERE u2.entity IS NOT NULL
"; // Show all users
567 $sql_usr .= " WHERE EXISTS (SELECT ug2.fk_user FROM
".$this->db->prefix()."usergroup_user as ug2 WHERE u2.rowid = ug2.fk_user AND ug2.entity IN (
".getEntity('usergroup')."))
";
570 $sql_usr .= " WHERE u2.entity IN (
".getEntity('user').")
";
573 $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc =
".((int) $user->socid);
575 //Add hook to filter on user (for example on usergroup define in custom modules)
576 if (!empty($reshook)) {
577 $sql_usr .= $hookmanager->resArray[1];
581 if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION')) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
582 $sql_usr .= " ORDER BY
status DESC, firstname ASC, lastname ASC
";
584 $sql_usr .= " ORDER BY
status DESC, lastname ASC, firstname ASC
";
586 //print $sql_usr;exit;
588 $resql_usr = $this->db->query($sql_usr);
590 $userstatic = new User($this->db);
592 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
593 $userstatic->id = $obj_usr->rowid;
594 $userstatic->lastname = $obj_usr->lastname;
595 $userstatic->firstname = $obj_usr->firstname;
596 $userstatic->photo = $obj_usr->photo;
597 $userstatic->status = $obj_usr->status;
598 $userstatic->entity = $obj_usr->entity;
599 $userstatic->admin = $obj_usr->admin;
601 $labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
602 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) {
603 $labeltoshow = $obj_usr->login;
606 $out .= '<option value="'.$obj_usr->rowid.'"';
607 if ($obj_usr->rowid == $selected) {
610 $out .= ' data-html="';
611 $outhtml = $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login
', '', 1).' ';
612 if ($showstatus >= 0 && $obj_usr->status == 0) {
613 $outhtml .= '<strike
class=
"opacitymediumxxx">
';
615 $outhtml .= $labeltoshow;
616 if ($showstatus >= 0 && $obj_usr->status == 0) {
617 $outhtml .= '</strike>
';
619 $out .= dol_escape_htmltag($outhtml);
622 $out .= $labeltoshow;
623 // Complete name with more info
625 if (getDolGlobalString('MAIN_SHOW_LOGIN')) {
626 $out .= ($moreinfo ? ' - ' : ' (').$obj_usr->login;
629 if ($showstatus >= 0) {
630 if ($obj_usr->status == 1 && $showstatus == 1) {
631 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
634 if ($obj_usr->status == 0) {
635 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
639 $out .= ($moreinfo ? ')' : '');
642 $this->db->free($resql_usr);
644 dol_print_error($this->db);
647 if ($norepresentative) {
648 $langs->load("companies
");
649 $out .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NoSalesRepresentativeAffected
").' -</option>';
654 // Enhance with select2
655 if ($conf->use_javascript_ajax) {
656 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
658 $comboenhancement = ajax_combobox($htmlname);
659 if ($comboenhancement) {
660 $out .= $comboenhancement;
682 public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '')
684 global $user, $langs;
686 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
688 //print $modeproject.'-'.$modetask;
689 $task = new Task($this->db);
690 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus);
692 print '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
694 print '<option value="0
"> </option>';
698 $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
701 print ajax_combobox($htmlname);
703 print '<div class="warning
">'.$langs->trans("NoProject
").'</div>';
719 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
721 global $langs, $user, $conf;
725 $numlines = count($lines);
726 for ($i = 0; $i < $numlines; $i++) {
727 if ($lines[$i]->fk_task_parent == $parent) {
728 //var_dump($selectedproject."--
".$selectedtask."--
".$lines[$i]->fk_project."_
".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines
730 // Break on a new project
731 if ($parent == 0) { // We are on a task at first level
732 if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project
734 print '<option value="0
" disabled>----------</option>';
736 print '<option value="'.$lines[$i]->fk_project.'_0
"';
737 if ($selectedproject == $lines[$i]->fk_project) {
741 $labeltoshow = $lines[$i]->projectref;
742 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
743 if (empty($lines[$i]->public)) {
744 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
745 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
747 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
748 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
751 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
752 print '>'; // Project -> Task
756 $lastprojectid = $lines[$i]->fk_project;
761 $newdisablechildoftaskid = $disablechildoftaskid;
764 if (isset($lines[$i]->id)) { // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0
765 // Check if we must disable entry
767 if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) {
769 if ($lines[$i]->fk_task_parent == $disablechildoftaskid) {
770 $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
774 print '<option value="'.$lines[$i]->fk_project.'_
'.$lines[$i]->id.'"';
775 if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) {
782 $labeltoshow = $lines[$i]->projectref;
783 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
784 if (empty($lines[$i]->public)) {
785 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
786 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
788 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
789 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
791 if ($lines[$i]->id) {
792 $labeltoshow .= ' > ';
794 for ($k = 0; $k < $level; $k++) {
795 $labeltoshow .= "
";
797 $labeltoshow .= $lines[$i]->ref.' '.$lines[$i]->label;
799 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
807 if ($lines[$i]->id) {
808 $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
824 public static function showColor($color, $textifnotdefined = '')
827 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
828 if (colorIsLight($color)) {
832 $color = colorArrayToHex(colorStringToArray($color, array()), '');
835 return '<input type="text
" class="colorthumb
" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #
'.$textcolor.'; background-color: #
'.$color.'" value="'.$color.'">';
837 return $textifnotdefined;
841 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
854 public function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = [])
857 print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
874 public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = [], $morecss = '', $setpropertyonselect = '', $default = '')
876 // Deprecation warning
878 dol_syslog(__METHOD__.": form_name parameter is deprecated
", LOG_WARNING);
881 global $langs, $conf;
885 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) {
886 // Case of selection of any color
887 $langs->load("other
");
888 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR')) {
889 $out .= '<link rel="stylesheet
" media="screen
" type="text/css
" href="'.DOL_URL_ROOT.'/
public/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css
" />';
890 $out .= '<script nonce="'.getNonce().'" type="text/javascript
" src="'.DOL_URL_ROOT.'/
public/includes/jquery/plugins/jpicker/jpicker-1.1.6.js
"></script>';
891 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
892 jQuery(document).ready(function(){
893 var originalhex = null;
894 $(\'#colorpicker'.$prefix.'\').jPicker( {
896 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\', /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color
" if left null */
899 type: \'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide
", "show
", "fade
" */
902 show: \'fast\', /* duration of "show
" effect. Acceptable values are "fast
", "slow
", or time in ms */
903 hide: \'fast\' /* duration of "hide
" effect. Acceptable values are "fast
", "slow
", or time in ms */
908 x: \'screenCenter\', /* acceptable values "left
", "center
", "right
", "screenCenter
", or relative px value */
909 y: \'center\' /* acceptable values "top
", "bottom
", "center
", or relative px value */
913 clientPath: \''.DOL_URL_ROOT.'/public/includes/jquery/plugins/jpicker/images/\',
914 picker: { file: \'../../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
916 localization: // alter these to change the text presented by the picker (e.g. different language)
920 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\',
921 newColor: \''.dol_escape_js($langs->trans("New
")).'\',
922 currentColor: \''.dol_escape_js($langs->trans("Current
")).'\',
923 ok: \''.dol_escape_js($langs->trans("Validate")).'\',
924 cancel: \''.dol_escape_js($langs->trans("Cancel
")).'\'
928 function(color, context) { console.log("close color selector
"); },
929 function(color, context) { var hex = color.val(\'hex\'); console.log("new color selected in jpicker
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
930 if ($setpropertyonselect) {
931 $out .= 'if (originalhex == null) {';
932 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
933 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
935 $out .= 'if (hex != null) {';
936 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', \'#\'+hex);';
940 function(color, context) {
941 console.log("cancel selection of color
");';
942 if ($setpropertyonselect) {
943 $out .= 'if (originalhex != null) {
944 console.log("Restore old color
"+originalhex);
945 document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', originalhex);
953 $out .= '<input id="colorpicker
'.$prefix.'" name="'.$prefix.'" size="6
" maxlength="7
" class="colorpicker flat valignmiddle
'.($morecss ? ' '.$morecss : '').'" type="text
" value="'.dol_escape_htmltag($set_color).'" />';
955 $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF'));
956 $out .= '<input id="colorpicker
'.$prefix.'" name="'.$prefix.'" size="6
" maxlength="7
" class="colorpicker flat input-nobottom colorselector valignmiddle
'.($morecss ? ' '.$morecss : '').'" type="color
" data-default="'.$default.'" value="'.dol_escape_htmltag(preg_match('/^#/
', $color) ? $color : '#
'.$color).'" />';
957 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
958 jQuery(document).ready(function(){
959 var originalhex = null;
960 jQuery("#colorpicker
'.$prefix.'").on(\'change\', function() {
961 var hex = jQuery("#colorpicker
'.$prefix.'").val();
962 console.log("new color selected in input color
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
963 if ($setpropertyonselect) {
964 $out .= 'if (originalhex == null) {';
965 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
966 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
968 $out .= 'if (hex != null) {';
969 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', hex);';
978 // In most cases, this is not used. We used instead function with no specific list of colors
979 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) {
980 $out .= '<link rel="stylesheet
" href="'.DOL_URL_ROOT.'/
public/includes/jquery/plugins/colorpicker/jquery.colorpicker.css
" type="text/css
" media="screen
" />';
981 $out .= '<script nonce="'.getNonce().'" src="'.DOL_URL_ROOT.'/
public/includes/jquery/plugins/colorpicker/jquery.colorpicker.js
" type="text/javascript
"></script>';
982 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
983 jQuery(document).ready(function(){
984 jQuery(\'#colorpicker'.$prefix.'\').colorpicker({
992 $out .= '<select id="colorpicker
'.$prefix.'" class="colorpicker flat
'.($morecss ? ' '.$morecss : '').'" name="'.$prefix.'">';
993 //print '<option value="-1
"> </option>';
994 foreach ($arrayofcolors as $val) {
995 $out .= '<option value="'.$val.'"';
996 if ($set_color == $val) {
999 $out .= '>'.$val.'</option>';
1001 $out .= '</select>';
1007 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1018 public function CreateColorIcon($color, $module, $name, $x = 12, $y = 12)
1023 $file = $conf->$module->dir_temp.'/'.$name.'.png';
1025 // We create temp directory
1026 if (!file_exists($conf->$module->dir_temp)) {
1027 dol_mkdir($conf->$module->dir_temp);
1030 // On cree l'image en vraies couleurs
1031 $image = imagecreatetruecolor($x, $y);
1033 $color = substr($color, 1, 6);
1035 $red = hexdec(substr($color, 0, 2)); // Red channel conversion
1036 $green = hexdec(substr($color, 2, 2)); // Green channel conversion
1037 $blue = hexdec(substr($color, 4, 2)); // Blue channel conversion
1039 $couleur = imagecolorallocate($image, $red, $green, $blue);
1040 //print $red.$green.$blue;
1041 imagefill($image, 0, 0, $couleur); // Fill the image
1042 // Create the colr and store it in a variable to maintain it
1043 imagepng($image, $file); // Returns an image in PNG format
1044 imagedestroy($image);
1047 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1056 public function select_dayofweek($selected = '', $htmlname = 'weekid', $useempty = 0)
1062 0 => $langs->trans("Day0
"),
1063 1 => $langs->trans("Day1
"),
1064 2 => $langs->trans("Day2
"),
1065 3 => $langs->trans("Day3
"),
1066 4 => $langs->trans("Day4
"),
1067 5 => $langs->trans("Day5
"),
1068 6 => $langs->trans("Day6
")
1071 $select_week = '<select class="flat
" name="'.$htmlname.'" id="'.$htmlname.'">';
1073 $select_week .= '<option value="-1
"> </option>';
1075 foreach ($week as $key => $val) {
1076 if ($selected == $key) {
1077 $select_week .= '<option value="'.$key.'" selected>';
1079 $select_week .= '<option value="'.$key.'">';
1081 $select_week .= $val;
1082 $select_week .= '</option>';
1084 $select_week .= '</select>';
1086 $select_week .= ajax_combobox($htmlname);
1088 return $select_week;
1101 public function selectDay($selected = '', $htmlname = 'dayid', $useempty = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false)
1103 $select_day = '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
1105 $select_day .= '<option value="0
"> </option>';
1107 for ($i = 1; $i <= 31; $i++) {
1108 if ((int) $selected == $i) {
1109 $select_day .= '<option value="'.$i.'" selected>';
1111 $select_day .= '<option value="'.$i.'">';
1113 $select_day .= sprintf("%02d
", $i);
1114 $select_day .= '</option>';
1116 $select_day .= '</select>';
1118 // Add code for jquery to use multiselect
1120 // Enhance with select2
1121 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1122 $select_day .= ajax_combobox($htmlname);
1128 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1140 public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false)
1145 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1148 $montharray = monthArray($langs, 0); // Get array of month with long labels
1150 $montharray = monthArray($langs, 1); // Get array of month with short labels
1153 $select_month = '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
1155 if (is_numeric($useempty)) {
1156 $select_month .= '<option value="0
"> </option>';
1158 $select_month .= '<option value="-1
">'.$useempty.'</option>';
1161 foreach ($montharray as $key => $val) {
1162 if ((int) $selected == $key) {
1163 $select_month .= '<option value="'.$key.'" selected>';
1165 $select_month .= '<option value="'.$key.'">';
1167 $select_month .= $val;
1168 $select_month .= '</option>';
1170 $select_month .= '</select>';
1172 // Add code for jquery to use multiselect
1174 // Enhance with select2
1175 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1176 $select_month .= ajax_combobox($htmlname);
1179 return $select_month;
1182 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1199 public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false)
1202 print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
1220 public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false)
1224 $currentyear = idate("Y
") + $offset;
1225 $max_year = $currentyear + $max_year;
1226 $min_year = $currentyear - $min_year;
1227 if (empty($selected) && empty($useempty)) {
1228 $selected = $currentyear;
1231 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$option.' >';
1233 $selected_html = '';
1234 if ((string) $selected == '') {
1235 $selected_html = ' selected';
1237 $out .= '<option value=""'.$selected_html.'> </option>';
1240 for ($y = $max_year; $y >= $min_year; $y--) {
1241 $selected_html = '';
1242 if ((int) $selected > 0 && $y == (int) $selected) {
1243 $selected_html = ' selected';
1245 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1248 for ($y = $min_year; $y <= $max_year; $y++) {
1249 $selected_html = '';
1250 if ((int) $selected > 0 && $y == (int) $selected) {
1251 $selected_html = ' selected';
1253 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1256 $out .= "</select>\n
";
1258 // Add code for jquery to use multiselect
1260 // Enhance with select2
1261 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1262 $out .= ajax_combobox($htmlname);
1277 public static function getBoxesArea($user, $areacode)
1279 global $conf, $langs, $db;
1281 include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
1284 @phan-var-force ModeleBoxes[] $boxactivated
1285 @phan-var-force int[] $boxidactivatedforuser
1288 $confuserzone = 'MAIN_BOXES_'.$areacode;
1292 // $boxactivated will be array of boxes enabled into global setup
1293 // $boxidactivatedforuser will be array of boxes chose by user
1295 $selectboxlist = '';
1296 $boxactivated = InfoBox::listBoxes($db, 'activated', (int) $areacode, (empty($user->conf->$confuserzone) ? null : $user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup)
1298 $boxidactivatedforuser = array();
1299 foreach ($boxactivated as $box) {
1300 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1301 $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user
1304 if (!empty($box->lang)) {
1305 $langs->loadLangs(array($box->lang));
1306 $box->boxlabel = $langs->transnoentitiesnoconv($box->boxlabel);
1311 // Define selectboxlist
1312 $arrayboxtoactivatelabel = array();
1313 if (getDolUserString($confuserzone)) {
1315 $langs->load("boxes
"); // Load label of boxes
1316 foreach ($boxactivated as $box) {
1317 if (!empty($boxidactivatedforuser[$box->id])) {
1318 continue; // Already visible for user
1321 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1322 //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph
").')';
1323 if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') {
1324 $label .= ' <span class="fas fa-chart-bar
"></span>';
1326 $arrayboxtoactivatelabel[$box->id] = array('label' => $label, 'data-html' => img_picto('', $box->boximg, 'class="pictofixedwidth valignmiddle
"').'<span class="valignmiddle
">'.$langs->trans($label).'</span>'); // We keep only boxes not shown for user, to show into combo list
1328 foreach ($boxidactivatedforuser as $boxid) {
1329 if (empty($boxorder)) {
1332 $boxorder .= $boxid.',';
1335 //var_dump($boxidactivatedforuser);
1337 // Class Form must have been already loaded
1338 $selectboxlist .= '<!-- Form with select box list -->'."\n
";
1339 $selectboxlist .= '<form id="addbox
" name="addbox
" method="POST
" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
1340 $selectboxlist .= '<input type="hidden
" name="token
" value="'.newToken().'">';
1341 $selectboxlist .= '<input type="hidden
" name="addbox
" value="addbox
">';
1342 $selectboxlist .= '<input type="hidden
" name="userid
" value="'.$user->id.'">';
1343 $selectboxlist .= '<input type="hidden
" name="areacode
" value="'.$areacode.'">';
1344 $selectboxlist .= '<input type="hidden
" name="boxorder
" value="'.$boxorder.'">';
1345 $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd
").'...', 0, 0, '', 0, 0, 0, 'ASC', 'noborderfocus selectwidget maxwidth300 hideonprint', 0, 'hidden selected', 0, 0);
1346 if (empty($conf->use_javascript_ajax)) {
1347 $selectboxlist .= ' <input type="submit
" class="button" value="'.$langs->trans("AddBox").'">';
1349 $selectboxlist .= '</form>';
1350 if (!empty($conf->use_javascript_ajax)) {
1351 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1352 $selectboxlist .= ajax_combobox("boxcombo
");
1356 // Javascript code for dynamic actions
1357 if (!empty($conf->use_javascript_ajax)) {
1358 $selectboxlist .= '<script nonce="'.getNonce().'" type="text/javascript
">
1360 // To update list of activated boxes
1361 function updateBoxOrder(closing) {
1362 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1363 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1364 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1365 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
1368 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1371 // We force reload to be sure to get all boxes into list
1372 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'&action=delbox&token='.newToken().'\';
1377 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1383 jQuery(document).ready(function() {
1384 jQuery("#boxcombo
").change(function() {
1385 var boxid=jQuery("#boxcombo
").val();
1387 console.log("A box widget has been selected
for addition, we call ajax page to add it.
")
1388 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1389 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1390 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1392 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\'
1393 }).done(function() {
1394 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'\';
1398 if (!count($arrayboxtoactivatelabel)) {
1399 $selectboxlist .= 'jQuery("#boxcombo
").hide();';
1403 jQuery("#boxhalfleft, #boxhalfright
").sortable({
1404 handle: \'.boxhandle\',
1405 revert: \'invalid\',
1406 items: \'.boxdraggable\',
1407 containment: \'document\',
1408 connectWith: \'#boxhalfleft, #boxhalfright\',
1409 stop: function(event, ui) {
1410 console.log("We moved box so we call updateBoxOrder with ajax actions
");
1411 updateBoxOrder(1); /* 1 to avoid message after a move */
1415 jQuery(".boxclose
").click(function() {
1416 var self = this; // because JQuery can modify this
1417 var boxid = self.id.substring(8);
1419 var label = jQuery(\'#boxlabelentry\'+boxid).val();
1420 console.log("We close box
"+boxid);
1421 jQuery(\'#boxto_\'+boxid).remove();
1422 jQuery(\'#boxcombo\').append(new Option(label, boxid));
1423 updateBoxOrder(1); /* 1 to avoid message after a remove */
1429 $selectboxlist .= '</script>'."\n
";
1432 // Define boxlista and boxlistb
1435 $nbboxactivated = count($boxidactivatedforuser);
1437 if ($nbboxactivated) {
1438 // Load translation files required by the page
1439 $langs->loadLangs(array("boxes
", "projects
"));
1441 $emptybox = new ModeleBoxes($db);
1443 $boxlista .= "\n<!-- Box left container -->\n
";
1445 // Define $box_max_lines
1446 $box_max_lines = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
1449 foreach ($boxactivated as $key => $box) {
1450 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1453 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1454 $box->box_order = 'A'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1456 if (preg_match('/^A/i', $box->box_order)) { // column A
1458 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1459 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1461 $box->loadBox($box_max_lines);
1462 $boxlista .= $box->showBox(null, null, 1);
1466 if ($conf->browser->layout != 'phone') {
1467 $emptybox->box_id = 'A';
1468 $emptybox->info_box_head = array();
1469 $emptybox->info_box_contents = array();
1470 $boxlista .= $emptybox->showBox(array(), array(), 1);
1472 $boxlista .= "<!-- End box left container -->\n
";
1474 $boxlistb .= "\n<!-- Box right container -->\n
";
1477 foreach ($boxactivated as $key => $box) {
1478 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1481 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1482 $box->box_order = 'B'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1484 if (preg_match('/^B/i', $box->box_order)) { // colonne B
1486 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1487 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1489 $box->loadBox($box_max_lines);
1490 $boxlistb .= $box->showBox(null, null, 1);
1494 if ($conf->browser->layout != 'phone') {
1495 $emptybox->box_id = 'B';
1496 $emptybox->info_box_head = array();
1497 $emptybox->info_box_contents = array();
1498 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1501 $boxlistb .= "<!-- End box right container -->\n
";
1504 return array('selectboxlist' => count($boxactivated) ? $selectboxlist : '', 'boxactivated' => $boxactivated, 'boxlista' => $boxlista, 'boxlistb' => $boxlistb);
1508 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1521 public function select_dictionary($htmlname, $dictionarytable, $keyfield = 'code', $labelfield = 'label', $selected = '', $useempty = 0, $moreattrib = '')
1526 $langs->load("admin
");
1528 $sql = "SELECT rowid,
".$this->db->sanitize($keyfield).",
".$this->db->sanitize($labelfield);
1529 $sql .= " FROM
".$this->db->prefix().$dictionarytable;
1530 $sql .= $this->db->order($labelfield);
1533 $result = $this->db->query($sql);
1535 $num = $this->db->num_rows($result);
1538 print '<select id="select
'.$htmlname.'" class="flat selectdictionary
" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
1539 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
1540 print '<option value="-1
"> </option>';
1544 $obj = $this->db->fetch_object($result);
1545 if ($selected == $obj->rowid || $selected == $obj->{$keyfield}) {
1546 print '<option value="'.$obj->{$keyfield}.'" selected>';
1548 print '<option value="'.$obj->{$keyfield}.'">';
1550 $label = ($langs->trans($dictionarytable.$obj->{$keyfield}) != $dictionarytable.$obj->{$labelfield} ? $langs->trans($dictionarytable.$obj->{$keyfield}) : $obj->{$labelfield});
1557 print $langs->trans("DictionaryEmpty
");
1560 dol_print_error($this->db);
1574 public function selectAutoManual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0)
1578 $automatic = "automatic
";
1585 $disabled = ($disabled ? ' disabled' : '');
1587 $resultautomanual = '<select class="flat width100
" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n
";
1589 $resultautomanual .= '<option value="-1
"'.(($value < 0) ? ' selected' : '').'> </option>'."\n
";
1591 if (("$value
" == 'automatic') || ($value == 1)) {
1592 $resultautomanual .= '<option value="'.$automatic.'" selected>'.$langs->trans("Automatic
").'</option>'."\n
";
1593 $resultautomanual .= '<option value="'.$manual.'">'.$langs->trans("Manual
").'</option>'."\n
";
1595 $selected = (($useempty && $value != '0' && $value != 'manual') ? '' : ' selected');
1596 $resultautomanual .= '<option value="'.$automatic.'">'.$langs->trans("Automatic
").'</option>'."\n
";
1597 $resultautomanual .= '<option value="'.$manual.'"'.$selected.'>'.$langs->trans("Manual
").'</option>'."\n
";
1599 $resultautomanual .= '</select>'."\n
";
1600 return $resultautomanual;
1614 public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1')
1618 $arrayofgroupbylabel = array();
1619 foreach ($arrayofgroupby as $key => $val) {
1620 $arrayofgroupbylabel[$key] = $val['label'];
1622 $result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
1637 public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1', $morecss = 'minwidth250 maxwidth500')
1641 $arrayofxaxislabel = array();
1642 foreach ($arrayofxaxis as $key => $val) {
1643 $arrayofxaxislabel[$key] = $val['label'];
1645 $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
Class toolbox to validate values.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
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...
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...