73 public function getHTMLScannerForm($jstoexecuteonadd =
'barcodescannerjs', $mode =
'all', $warehouseselect = 0)
78 $jstoexecuteonadd =
sanitizeVal($jstoexecuteonadd,
'aZ09');
82 $out .=
'<!-- Popup for mass barcode scanning -->'.
"\n";
83 $out .=
'<div class="div-for-modal-topright" style="padding: 15px">';
84 $out .=
'<center>'.img_picto(
'',
'barcode',
'class="pictofixedwidth"').
'<strong>Barcode scanner tool...</strong></center><br>';
86 if ($mode ==
'product') {
87 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct">';
88 } elseif ($mode ==
'lot') {
89 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial">';
91 $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>';
92 $out .=
'<input type="radio" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct"> <label for="barcodeforproduct">Scan a product barcode</label><br>';
93 $out .=
'<input type="radio" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial"> <label for="barcodeforlotserial">Scan a product lot or serial number</label><br>';
95 $stringaddbarcode = $langs->trans(
"QtyToAddAfterBarcodeScan",
"tmphtml");
96 $htmltoreplaceby =
'<select name="selectaddorreplace"><option selected value="add">'.$langs->trans(
"Add").
'</option><option value="replace">'.$langs->trans(
"ToReplace").
'</option></select>';
97 $stringaddbarcode = str_replace(
"tmphtml", $htmltoreplaceby, $stringaddbarcode);
98 $out .= $stringaddbarcode.
': <input type="text" name="barcodeproductqty" class="width40 right" value="1"><br>';
99 if ($warehouseselect > 0) {
100 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
102 $formproduct->loadWarehouses();
103 $out .= img_picto(
'',
'stock',
'class="pictofixedwidth"');
104 $out .= $formproduct->selectWarehouses(
'',
"warehousenew",
'', 0, 0, 0,
'', 0, 1);
108 $out .=
'<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ScanOrTypeOrCopyPasteYourBarCodes")).
'"></textarea>';
118 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" id="exec'.$jstoexecuteonadd.
'" name="addscan" value="'.dolPrintHTMLForAttribute($langs->trans(
"Add")).
'">';
119 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"CloseWindow")).
'">';
122 $out .=
'<div type="text" id="scantoolmessage" class="scantoolmessage ok nopadding"></div>';
124 $out .=
'<script nonce="'.getNonce().
'">';
125 $out .=
'jQuery("#barcodeforautodetect, #barcodeforproduct, #barcodeforlotserial").click(function(){';
126 $out .=
'console.log("select choice");';
127 $out .=
'jQuery("#scantoolmessage").text("");';
129 $out .=
'$(\'#exec'.$jstoexecuteonadd.
'\').click(
function(){
130 console.log(\
'We call js to execute '.$jstoexecuteonadd.
'\');
131 '.$jstoexecuteonadd.'();
142 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
153 public function select_export_model($selected = '
', $htmlname = 'exportmodelid
', $type = '', $useempty = 0, $fk_user = null)
158 $sql = "SELECT rowid, label, fk_user";
159 $sql .= " FROM ".$this->db->prefix()."export_model";
160 $sql .= " WHERE type = '".$this->db->escape($type)."'";
161 if (!getDolGlobalString('EXPORTS_SHARE_MODELS
')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
162 $sql .= " AND fk_user IN (0, ".((int) $fk_user).")";
164 $sql .= " ORDER BY label";
165 $result = $this->db->query($sql);
167 print '<select
class=
"flat minwidth200" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
169 if (is_numeric($useempty)) {
170 print '<option value=
"-1"> </option>
';
172 print '<option value=
"-1">
'.$langs->trans($useempty).'</option>
';
176 $tmpuser = new User($this->db);
178 $num = $this->db->num_rows($result);
181 $obj = $this->db->fetch_object($result);
183 $label = $obj->label;
184 if ($obj->fk_user == 0) {
185 $label .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Everybody").')</span>
';
186 } elseif ($obj->fk_user > 0) {
187 $tmpuser->fetch($obj->fk_user);
188 $label .= ' <span
class=
"opacitymedium">(
'.$tmpuser->getFullName($langs).')</span>
';
191 if ($selected == $obj->rowid) {
192 print '<option value=
"'.$obj->rowid.'" selected data-html=
"'.dolPrintHTMLForAttribute($label).'">
';
194 print '<option value=
"'.$obj->rowid.'" data-html=
"'.dolPrintHTMLForAttribute($label).'">
';
201 print '<option value=
"-1" disabled data-html=
"'.dolPrintHTMLForAttribute('<span class="opacitymedium
">'.$langs->transnoentitiesnoconv("NoPredefinedExportProfileYet
").'</span>').'">
'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet").'</option>
';
204 print ajax_combobox($htmlname);
206 dol_print_error($this->db);
211 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
222 public function select_import_model($selected = '
', $htmlname = 'importmodelid
', $type = '', $useempty = 0, $fk_user = null)
227 $sql = "SELECT rowid, label, fk_user";
228 $sql .= " FROM ".$this->db->prefix()."import_model";
229 $sql .= " WHERE type = '".$this->db->escape($type)."'";
230 if (!getDolGlobalString('EXPORTS_SHARE_MODELS
')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
231 $sql .= " AND fk_user IN (0, ".((int) $fk_user).")";
233 $sql .= " ORDER BY label";
234 $result = $this->db->query($sql);
236 print '<select
class=
"flat minwidth200" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
237 if (is_numeric($useempty)) {
238 print '<option value=
"-1"> </option>
';
240 print '<option value=
"-1">
'.$langs->trans($useempty).'</option>
';
243 $tmpuser = new User($this->db);
245 $num = $this->db->num_rows($result);
248 $obj = $this->db->fetch_object($result);
250 $label = $obj->label;
251 if ($obj->fk_user == 0) {
252 $label .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Everybody").')</span>
';
253 } elseif ($obj->fk_user > 0) {
254 $tmpuser->fetch($obj->fk_user);
255 $label .= ' <span
class=
"opacitymedium">(
'.$tmpuser->getFullName($langs).')</span>
';
258 if ($selected == $obj->rowid) {
259 print '<option value=
"'.$obj->rowid.'" selected data-html=
"'.dol_escape_htmltag($label).'">
';
261 print '<option value=
"'.$obj->rowid.'" data-html=
"'.dol_escape_htmltag($label).'">
';
268 print '<option value=
"-1" disabled data-html=
"'.dolPrintHTMLForAttribute('<span class="opacitymedium
">'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet
").'</span>').'">
'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet").'</option>
';
271 print ajax_combobox($htmlname);
273 dol_print_error($this->db);
278 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
286 public function select_ecotaxes($selected = '
', $htmlname = 'ecotaxe_id
')
291 $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,";
292 $sql .= " c.label as country";
293 $sql .= " FROM ".$this->db->prefix()."c_ecotaxe as e,".$this->db->prefix()."c_country as c";
294 $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid";
295 $sql .= " ORDER BY country, e.organization ASC, e.code ASC";
298 $resql = $this->db->query($sql);
300 print '<select
class=
"flat" name=
"'.$htmlname.'">
';
301 $num = $this->db->num_rows($resql);
303 print '<option value=
"-1"> </option>
'."\n";
306 $obj = $this->db->fetch_object($resql);
307 if ($selected && $selected == $obj->rowid) {
308 print '<option value=
"'.$obj->rowid.'" selected>
';
310 print '<option value=
"'.$obj->rowid.'">
';
311 //print '<option onmouseover=
"showtip(\''.$obj->label.'\')" onMouseout=
"hidetip()" value=
"'.$obj->rowid.'">
';
313 $selectOptionValue = $obj->code.' -
'.$obj->label.' :
'.price($obj->price).' '.$langs->trans("HT").' (
'.$obj->organization.')
';
314 print $selectOptionValue;
322 dol_print_error($this->db);
328 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
337 public function select_revenue_stamp($selected = '
', $htmlname = 'revenuestamp
', $country_code = '')
344 $sql = "SELECT r.taux, r.revenuestamp_type";
345 $sql .= " FROM ".$this->db->prefix()."c_revenuestamp as r,".$this->db->prefix()."c_country as c";
346 $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid";
347 $sql .= " AND c.code = '".$this->db->escape($country_code)."'";
350 $resql = $this->db->query($sql);
352 $out .= '<select
class=
"flat" name=
"'.$htmlname.'">
';
353 $num = $this->db->num_rows($resql);
355 $out .= '<option value=
"0"> </option>
'."\n";
358 $obj = $this->db->fetch_object($resql);
359 if (($selected && $selected == $obj->taux) || $num == 1) {
360 $out .= '<option value=
"'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent
' ? ' data-
type=
"percent"' : '').' selected>
';
362 $out .= '<option value=
"'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent
' ? ' data-
type=
"percent"' : '').'>
';
364 $out .= $obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '');
372 dol_print_error($this->db);
378 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
391 public function select_percent($selected = 0, $htmlname = 'percent
', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
394 $return = '<select
class=
"flat maxwidth75 right" name=
"'.$htmlname.'" '.($disabled ? 'disabled' : '').'>
';
396 $return .= '<option value=
"-1"'.(($selected == -1 || $selected == '') ? ' selected
' : '').'> </option>
';
399 for ($i = $start; $i <= $end; $i += $increment) {
400 if ($selected != '' && (int) $selected == $i) {
401 $return .= '<option value=
"'.$i.'" selected>
';
403 $return .= '<option value=
"'.$i.'">
';
406 $return .= '</option>
';
409 $return .= '</select>
';
414 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
427 public function select_categories($type, $selected = 0, $htmlname = 'search_categ
', $nocateg = 0, $showempty = 1, $morecss = '')
430 global $conf, $langs;
431 require_once DOL_DOCUMENT_ROOT.'/categories/
class/categorie.class.php
';
433 // For backward compatibility
434 if (is_numeric($type)) {
435 dol_syslog(__METHOD__.':
using numeric value
for parameter
type is deprecated. Use
string code instead.
', LOG_WARNING);
438 // Load list of "categories"
439 $static_categs = new Categorie($this->db);
440 $tab_categs = $static_categs->get_full_arbo($type);
444 // Print a select with each of them
445 $moreforfilter .= '<select
class=
"flat minwidth100'.($morecss ? ' '.$morecss : '').'" id=
"select_categ_'.$htmlname.'" name=
"'.$htmlname.'">
';
448 if (!empty($conf->use_javascript_ajax)) {
449 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
451 if (!is_numeric($showempty)) {
452 $textforempty = $showempty;
454 $moreforfilter .= '<option
class=
"optiongrey" value=
"'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected
' : '');
455 //$moreforfilter .= ' data-html=
"'.dol_escape_htmltag($textforempty).'"';
456 $moreforfilter .= '>
'.dol_escape_htmltag($textforempty).'</option>
'."\n";
459 if (is_array($tab_categs)) {
460 foreach ($tab_categs as $categ) {
461 $moreforfilter .= '<option value=
"'.$categ['id'].'"';
462 if ($categ['id'] == $selected) {
463 $moreforfilter .= ' selected
';
465 $moreforfilter .= ' data-html=
"'.dol_escape_htmltag(img_picto('', 'category', 'class="pictofixedwidth
" style="color: #
'.$categ['color
'].'"').dol_trunc($categ['fulllabel'], 50, 'middle')).'"';
466 $moreforfilter .= '>
'.dol_trunc($categ['fulllabel
'], 50, 'middle
').'</option>
';
470 $langs->load("categories");
471 $moreforfilter .= '<option value=
"-2"'.($selected == -2 ? ' selected
' : '').'>-
'.$langs->trans("NotCategorized").' -</option>
';
473 $moreforfilter .= '</select>
';
475 // Enhance with select2
476 if ($conf->use_javascript_ajax) {
477 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
478 $comboenhancement = ajax_combobox('select_categ_
'.$htmlname);
479 $moreforfilter .= $comboenhancement;
482 return $moreforfilter;
486 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
499 public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '
', $norepresentative = 0)
502 global $conf, $langs, $hookmanager;
505 $langs->load('users
');
509 $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep
', array(), $this, $action);
511 // Select each sales and print them in a select input
512 $out .= '<select
class=
"flat'.($morecss ? ' '.$morecss : '').'" id=
"'.$htmlname.'" name=
"'.$htmlname.'">
';
515 if (!is_numeric($showempty)) {
516 $textforempty = $showempty;
518 if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
519 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
521 $out .= '<option
class=
"optiongrey" value=
"'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected
' : '').'>
'.$textforempty.'</option>
'."\n";
524 // Get list of users allowed to be viewed
525 $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as status, u.login, u.photo, u.gender, u.entity, u.admin";
526 $sql_usr .= " FROM ".$this->db->prefix()."user as u";
528 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE
')) {
529 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
530 $sql_usr .= " WHERE u.entity IS NOT NULL"; // Show all users
532 $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
')."))";
533 $sql_usr .= " OR u.entity = 0"; // Show always superadmin
536 $sql_usr .= " WHERE u.entity IN (".getEntity('user').")";
539 if (!$user->hasRight('user', 'user', 'lire
')) {
540 $sql_usr .= " AND u.rowid = ".((int) $user->id);
542 if (!empty($user->socid)) {
543 $sql_usr .= " AND u.fk_soc = ".((int) $user->socid);
545 if (getDolUserString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX
'))) {
546 $sql_usr .= " AND u.employee <> 0";
548 if (getDolUserString('USER_HIDE_EXTERNAL_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX
'))) {
549 $sql_usr .= " AND u.fk_soc IS NULL";
551 if (getDolUserString('USER_HIDE_INACTIVE_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX
'))) { // Can be set in setup of module User.
552 $sql_usr .= " AND u.statut <> 0";
555 //Add hook to filter on user (for example on usergroup define in custom modules)
556 if (!empty($reshook)) {
557 $sql_usr .= $hookmanager->resArray[0]; // Trust the hook: @phan-suppress-current-line SqlInjection
560 // Add existing sales representatives of thirdparty of external user
561 if (!$user->hasRight('user', 'user', 'lire
') && $user->socid) {
562 $sql_usr .= " UNION ";
563 $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin";
564 $sql_usr .= " FROM ".$this->db->prefix()."user as u2, ".$this->db->prefix()."societe_commerciaux as sc";
566 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE
')) {
567 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
568 $sql_usr .= " WHERE u2.entity IS NOT NULL"; // Show all users
570 $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
')."))";
573 $sql_usr .= " WHERE u2.entity IN (".getEntity('user').")";
576 $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc = ".((int) $user->socid);
578 //Add hook to filter on user (for example on usergroup define in custom modules)
579 if (!empty($reshook)) {
580 $sql_usr .= $hookmanager->resArray[1]; // Trust the hook: @phan-suppress-current-line SqlInjection
584 if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION
')) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
585 $sql_usr .= " ORDER BY status DESC, firstname ASC, lastname ASC";
587 $sql_usr .= " ORDER BY status DESC, lastname ASC, firstname ASC";
589 //print $sql_usr;exit;
591 $resql_usr = $this->db->query($sql_usr);
593 $userstatic = new User($this->db);
595 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
596 $userstatic->id = $obj_usr->rowid;
597 $userstatic->lastname = $obj_usr->lastname;
598 $userstatic->firstname = $obj_usr->firstname;
599 $userstatic->photo = $obj_usr->photo;
600 $userstatic->status = $obj_usr->status;
601 $userstatic->entity = $obj_usr->entity;
602 $userstatic->admin = $obj_usr->admin;
604 $labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
605 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) {
606 $labeltoshow = $obj_usr->login;
609 $out .= '<option value=
"'.$obj_usr->rowid.'"';
610 if ($obj_usr->rowid == $selected) {
613 $out .= ' data-html=
"';
614 $outhtml = $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' ';
615 if ($showstatus >= 0 && $obj_usr->status == 0) {
616 $outhtml .= '<strike class="opacitymediumxxx
">';
618 $outhtml .= $labeltoshow;
619 if ($showstatus >= 0 && $obj_usr->status == 0) {
620 $outhtml .= '</strike>';
622 $out .= dol_escape_htmltag($outhtml);
625 $out .= $labeltoshow;
626 // Complete name with more info
628 if (getDolGlobalString('MAIN_SHOW_LOGIN
')) {
629 $out .= ($moreinfo ? ' -
' : ' (
').$obj_usr->login;
632 if ($showstatus >= 0) {
633 if ($obj_usr->status == 1 && $showstatus == 1) {
634 $out .= ($moreinfo ? ' -
' : ' (
').$langs->trans('Enabled
');
637 if ($obj_usr->status == 0) {
638 $out .= ($moreinfo ? ' -
' : ' (
').$langs->trans('Disabled
');
642 $out .= ($moreinfo ? ')
' : '');
645 $this->db->free($resql_usr);
647 dol_print_error($this->db);
650 if ($norepresentative) {
651 $langs->load("companies");
652 $out .= '<option value=
"-2"'.($selected == -2 ? ' selected
' : '').'>-
'.$langs->trans("NoSalesRepresentativeAffected").' -</option>
';
657 // Enhance with select2
658 if ($conf->use_javascript_ajax) {
659 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
661 $comboenhancement = ajax_combobox($htmlname);
662 if ($comboenhancement) {
663 $out .= $comboenhancement;
685 public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname = 'task_parent
', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '')
687 global $user, $langs;
689 require_once DOL_DOCUMENT_ROOT.'/projet/
class/task.class.php
';
691 //print $modeproject.'-
'.$modetask;
692 $task = new Task($this->db);
693 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus);
695 print '<select
class=
"flat'.($morecss ? ' '.$morecss : '').'" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
697 print '<option value=
"0"> </option>
';
701 $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
704 print ajax_combobox($htmlname);
706 print '<div
class=
"warning">
'.$langs->trans("NoProject").'</div>
';
722 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
724 global $langs, $user, $conf;
728 $numlines = count($lines);
729 for ($i = 0; $i < $numlines; $i++) {
730 if ($lines[$i]->fk_task_parent == $parent) {
731 //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines
733 // Break on a new project
734 if ($parent == 0) { // We are on a task at first level
735 if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project
737 print '<option value=
"0" disabled>----------</option>
';
739 print '<option value=
"'.$lines[$i]->fk_project.'_0"';
740 if ($selectedproject == $lines[$i]->fk_project) {
744 $labeltoshow = $lines[$i]->projectref;
745 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
746 if (empty($lines[$i]->public)) {
747 //$labeltoshow .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("PrivateProject").')</span>
';
748 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project
', 'class=
"pictofixedwidth"').$labeltoshow;
750 //$labeltoshow .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("SharedProject").')</span>
';
751 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub
', 'class=
"pictofixedwidth"').$labeltoshow;
754 print ' data-html=
"'.dol_escape_htmltag($labeltoshow).'"';
755 print '>
'; // Project -> Task
759 $lastprojectid = $lines[$i]->fk_project;
764 $newdisablechildoftaskid = $disablechildoftaskid;
767 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
768 // Check if we must disable entry
770 if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) {
772 if ($lines[$i]->fk_task_parent == $disablechildoftaskid) {
773 $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
777 print '<option value=
"'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
778 if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_
'.$lines[$i]->id == $selectedtask)) {
785 $labeltoshow = $lines[$i]->projectref;
786 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
787 if (empty($lines[$i]->public)) {
788 //$labeltoshow .= ' <span class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("PrivateProject").')</span>
';
789 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project
', 'class=
"pictofixedwidth"').$labeltoshow;
791 //$labeltoshow .= ' <span class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("SharedProject").')</span>
';
792 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub
', 'class=
"pictofixedwidth"').$labeltoshow;
794 if ($lines[$i]->id) {
795 $labeltoshow .= ' >
';
797 for ($k = 0; $k < $level; $k++) {
798 $labeltoshow .= " ";
800 $labeltoshow .= $lines[$i]->ref.' '.$lines[$i]->label;
802 print ' data-html=
"'.dol_escape_htmltag($labeltoshow).'"';
810 if ($lines[$i]->id) {
811 $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
827 public static function showColor($color, $textifnotdefined = '
')
830 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
831 if (colorIsLight($color)) {
835 $color = colorArrayToHex(colorStringToArray($color, array()), '');
838 return '<input
type=
"text" class=
"colorthumb" disabled style=
"padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value=
"'.$color.'">
';
840 return $textifnotdefined;
844 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
857 public function select_color($set_color = '
', $prefix = 'f_color
', $form_name = '', $showcolorbox = 1, $arrayofcolors = [])
860 print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
877 public static function selectColor($set_color = '
', $prefix = 'f_color
', $form_name = '', $showcolorbox = 1, $arrayofcolors = [], $morecss = '', $setpropertyonselect = '', $default = '')
879 // Deprecation warning
881 dol_syslog(__METHOD__.": form_name parameter is deprecated", LOG_WARNING);
884 global $langs, $conf;
888 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) {
889 // Case of selection of any color
890 $langs->load("other");
891 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR
')) {
892 $out .= '<link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css" />
';
893 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript" src=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jpicker/jpicker-1.1.6.js"></script>
';
894 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
895 jQuery(document).ready(function(){
896 var originalhex =
null;
897 $(\
'#colorpicker'.$prefix.
'\').jPicker( {
899 title: \
''.dol_escape_js($langs->trans(
"SelectAColor")).
'\',
902 type: \
'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide", "show", "fade" */
905 show: \'fast\', /* duration of "show" effect. Acceptable values are "fast", "slow", or time in ms */
906 hide: \'fast\' /* duration of "hide" effect. Acceptable values are "fast", "slow", or time in ms */
911 x: \'screenCenter\', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */
912 y: \'center\' /* acceptable values "top", "bottom", "center", or relative px value */
916 clientPath: \''.DOL_URL_ROOT.
'/public/includes/jquery/plugins/jpicker/images/\',
917 picker: { file: \'../../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
919 localization: // alter these to change the text presented by the picker (e.g. different language)
924 newColor: \
''.dol_escape_js($langs->trans(
"New")).
'\',
925 currentColor: \
''.dol_escape_js($langs->trans(
"Current")).
'\',
926 ok: \
''.dol_escape_js($langs->trans(
"Validate")).
'\',
927 cancel: \
''.dol_escape_js($langs->trans(
"Cancel")).
'\'
931 function(color, context) { console.log(
"close color selector"); },
932 function(color, context) { var hex = color.val(\
'hex\'); console.log("new color selected in jpicker "+hex+\' setpropertyonselect='.
dol_escape_js($setpropertyonselect).
'\');
';
933 if ($setpropertyonselect) {
934 $out .= 'if (originalhex ==
null) {
';
935 $out .= ' originalhex = getComputedStyle(document.querySelector(
":root")).getPropertyValue(\
'--'.
dol_escape_js($setpropertyonselect).
'\');
';
936 $out .= ' console.log(
"original color is saved into originalhex = "+originalhex);
';
938 $out .= 'if (hex !=
null) {
';
939 $out .= ' document.documentElement.style.setProperty(\
'--'.
dol_escape_js($setpropertyonselect).
'\', \
'#\'+hex);';
943 function(color, context) {
944 console.log("cancel selection of color");';
945 if ($setpropertyonselect) {
946 $out .=
'if (originalhex != null) {
947 console.log("Restore old color "+originalhex);
948 document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).
'\', originalhex);
956 $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).'" />
';
958 $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF
'));
959 $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).'" />
';
960 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
961 jQuery(document).ready(
function(){
962 var originalhex =
null;
963 jQuery(
"#colorpicker'.$prefix.'").on(\
'change\', function() {
964 var hex = jQuery("#colorpicker'.$prefix.
'").val();
965 console.log("new color selected in input color "+hex+\' setpropertyonselect='.
dol_escape_js($setpropertyonselect).
'\');
';
966 if ($setpropertyonselect) {
967 $out .= 'if (originalhex ==
null) {
';
968 $out .= ' originalhex = getComputedStyle(document.querySelector(
":root")).getPropertyValue(\
'--'.
dol_escape_js($setpropertyonselect).
'\');
';
969 $out .= ' console.log(
"original color is saved into originalhex = "+originalhex);
';
971 $out .= 'if (hex !=
null) {
';
972 $out .= ' document.documentElement.style.setProperty(\
'--'.
dol_escape_js($setpropertyonselect).
'\', hex);
';
981 // In most cases, this is not used. We used instead function with no specific list of colors
982 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) {
983 $out .= '<link rel=
"stylesheet" href=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type=
"text/css" media=
"screen" />
';
984 $out .= '<script nonce=
"'.getNonce().'" src=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/colorpicker/jquery.colorpicker.js" type=
"text/javascript"></script>
';
985 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
986 jQuery(document).ready(
function(){
987 jQuery(\
'#colorpicker'.$prefix.
'\').colorpicker({
995 $out .= '<select
id=
"colorpicker'.$prefix.'" class=
"colorpicker flat'.($morecss ? ' '.$morecss : '').'" name=
"'.$prefix.'">
';
996 //print '<option value=
"-1"> </option>
';
997 foreach ($arrayofcolors as $val) {
998 $out .= '<option value=
"'.$val.'"';
999 if ($set_color == $val) {
1000 $out .= ' selected
';
1002 $out .= '>
'.$val.'</option>
';
1004 $out .= '</select>
';
1010 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1021 public function CreateColorIcon($color, $module, $name, $x = 12, $y = 12)
1026 $file = $conf->$module->dir_temp.'/
'.$name.'.png
';
1028 // We create temp directory
1029 if (!file_exists($conf->$module->dir_temp)) {
1030 dol_mkdir($conf->$module->dir_temp);
1033 // On cree l'image en vraies couleurs
1034 $image = imagecreatetruecolor($x, $y);
1036 $color = substr($color, 1, 6);
1038 $red = hexdec(substr($color, 0, 2));
1039 $green = hexdec(substr($color, 2, 2));
1040 $blue = hexdec(substr($color, 4, 2));
1042 $couleur = imagecolorallocate($image, $red, $green, $blue);
1044 imagefill($image, 0, 0, $couleur);
1046 imagepng($image, $file);
1047 imagedestroy($image);
1065 0 => $langs->trans(
"Day0"),
1066 1 => $langs->trans(
"Day1"),
1067 2 => $langs->trans(
"Day2"),
1068 3 => $langs->trans(
"Day3"),
1069 4 => $langs->trans(
"Day4"),
1070 5 => $langs->trans(
"Day5"),
1071 6 => $langs->trans(
"Day6")
1074 $select_week =
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1076 $select_week .=
'<option value="-1"> </option>';
1078 foreach ($week as $key => $val) {
1079 if ($selected == $key) {
1080 $select_week .=
'<option value="'.$key.
'" selected>';
1082 $select_week .=
'<option value="'.$key.
'">';
1084 $select_week .= $val;
1085 $select_week .=
'</option>';
1087 $select_week .=
'</select>';
1091 return $select_week;
1104 public function selectDay($selected =
'', $htmlname =
'dayid', $useempty = 0, $morecss =
'minwidth50 maxwidth75imp valignmiddle', $addjscombo =
false)
1106 $select_day =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1108 $select_day .=
'<option value="0"> </option>';
1110 for ($i = 1; $i <= 31; $i++) {
1111 if ((
int) $selected == $i) {
1112 $select_day .=
'<option value="'.$i.
'" selected>';
1114 $select_day .=
'<option value="'.$i.
'">';
1116 $select_day .= sprintf(
"%02d", $i);
1117 $select_day .=
'</option>';
1119 $select_day .=
'</select>';
1124 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1143 public function select_month($selected =
'', $htmlname =
'monthid', $useempty = 0, $longlabel = 0, $morecss =
'minwidth50 maxwidth75imp valignmiddle', $addjscombo =
false)
1148 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1156 $select_month =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1158 if (is_numeric($useempty)) {
1159 $select_month .=
'<option value="0"> </option>';
1161 $select_month .=
'<option value="-1">'.$useempty.
'</option>';
1164 foreach ($montharray as $key => $val) {
1165 if ((
int) $selected == $key) {
1166 $select_month .=
'<option value="'.$key.
'" selected>';
1168 $select_month .=
'<option value="'.$key.
'">';
1170 $select_month .= $val;
1171 $select_month .=
'</option>';
1173 $select_month .=
'</select>';
1178 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1182 return $select_month;
1202 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)
1205 print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
1223 public function selectyear($selected =
'', $htmlname =
'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option =
'', $morecss =
'valignmiddle width75', $addjscombo =
false)
1227 $currentyear = idate(
"Y") + $offset;
1228 $max_year = $currentyear + $max_year;
1229 $min_year = $currentyear - $min_year;
1230 if (empty($selected) && empty($useempty)) {
1231 $selected = $currentyear;
1234 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$option.
' >';
1236 $selected_html =
'';
1237 if ((
string) $selected ==
'') {
1238 $selected_html =
' selected';
1240 $out .=
'<option value=""'.$selected_html.
'> </option>';
1243 for ($y = $max_year; $y >= $min_year; $y--) {
1244 $selected_html =
'';
1245 if ((
int) $selected > 0 && $y == (
int) $selected) {
1246 $selected_html =
' selected';
1248 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1251 for ($y = $min_year; $y <= $max_year; $y++) {
1252 $selected_html =
'';
1253 if ((
int) $selected > 0 && $y == (
int) $selected) {
1254 $selected_html =
' selected';
1256 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1259 $out .=
"</select>\n";
1264 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1282 global
$conf, $langs, $db;
1284 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1287 @phan-var-force ModeleBoxes[] $boxactivated
1288 @phan-var-force int[] $boxidactivatedforuser
1291 $confuserzone =
'MAIN_BOXES_'.$areacode;
1298 $selectboxlist =
'';
1299 $boxactivated =
InfoBox::listBoxes($db,
'activated', (
int) $areacode, (empty($user->conf->$confuserzone) ?
null : $user), array(), 0);
1301 $boxidactivatedforuser = array();
1302 foreach ($boxactivated as $box) {
1303 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1304 $boxidactivatedforuser[$box->id] = $box->id;
1307 if (!empty($box->lang)) {
1308 $langs->loadLangs(array($box->lang));
1309 $box->boxlabel = $langs->transnoentitiesnoconv($box->boxlabel);
1315 $arrayboxtoactivatelabel = array();
1318 $langs->load(
"boxes");
1319 foreach ($boxactivated as $box) {
1320 if (!empty($boxidactivatedforuser[$box->id])) {
1324 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1326 if (preg_match(
'/graph/', $box->class) &&
$conf->browser->layout !=
'phone') {
1327 $label .=
' <span class="fas fa-chart-bar"></span>';
1329 $arrayboxtoactivatelabel[$box->id] = array(
'label' => $label,
'data-html' => img_picto(
'', $box->boximg,
'class="pictofixedwidth valignmiddle"').
'<span class="valignmiddle">'.$langs->trans($label).
'</span>');
1331 foreach ($boxidactivatedforuser as $boxid) {
1332 if (empty($boxorder)) {
1335 $boxorder .= $boxid.
',';
1341 $widthforwidget =
'width200';
1342 $selectboxlist .=
'<!-- Form with select box list -->'.
"\n";
1343 $selectboxlist .=
'<form id="addbox" class="parentonrightofpage" name="addbox" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
1344 $selectboxlist .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1345 $selectboxlist .=
'<input type="hidden" name="addbox" value="addbox">';
1346 $selectboxlist .=
'<input type="hidden" name="userid" value="'.$user->id.
'">';
1347 $selectboxlist .=
'<input type="hidden" name="areacode" value="'.$areacode.
'">';
1348 $selectboxlist .=
'<input type="hidden" name="boxorder" value="'.$boxorder.
'">';
1349 $selectboxlist .=
Form::selectarray(
'boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans(
"ChooseBoxToAdd").
'...', 0, 0,
'', 0, 0, 0,
'ASC',
'noborderfocus selectwidget max'.$widthforwidget.
' hideonprint onrightofpage', 0,
'hidden selected', 0, 0);
1350 if (!empty(
$conf->use_javascript_ajax)) {
1351 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1352 $selectboxlist .=
ajax_combobox(
"boxcombo", array(), 0, 0,
'resolve',
'-1',
'onrightofpage '.$widthforwidget);
1354 if (empty(
$conf->use_javascript_ajax)) {
1355 $selectboxlist .=
' <input type="submit" class="button" value="'.$langs->trans(
"AddBox").
'">';
1357 $selectboxlist .=
'</form>';
1361 if (!empty(
$conf->use_javascript_ajax)) {
1362 $selectboxlist .=
'<script nonce="'.getNonce().
'" type="text/javascript">
1364 // To update list of activated boxes
1365 function updateBoxOrder(closing) {
1366 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1367 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1368 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1369 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
1372 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1375 // We force reload to be sure to get all boxes into list
1376 window.location.search=\'mainmenu='.
GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'&action=delbox&token='.
newToken().
'\';
1381 url: \
''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1387 jQuery(document).ready(function() {
1388 jQuery("#boxcombo").change(function() {
1389 var boxid=jQuery("#boxcombo").val();
1391 console.log("A box widget has been selected for addition, we call ajax page to add it.")
1392 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1393 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1394 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1396 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.
'&userid='.$user->id.
'\'
1397 }).done(
function() {
1398 window.location.search=\
'mainmenu='.GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'\';
1402 if (!count($arrayboxtoactivatelabel)) {
1403 $selectboxlist .= 'jQuery(
"#boxcombo").hide();
';
1407 jQuery(
"#boxhalfleft, #boxhalfright").sortable({
1408 handle: \
'.boxhandle\',
1409 revert: \'invalid\',
1410 items: \'.boxdraggable\',
1411 containment: \'document\',
1412 connectWith: \'#boxhalfleft, #boxhalfright\',
1413 stop: function(event, ui) {
1414 console.log("We moved box so we call updateBoxOrder with ajax actions");
1415 updateBoxOrder(1); /* 1 to avoid message after a move */
1419 jQuery(".boxclose").click(function() {
1420 var self = this; // because JQuery can modify this
1421 var boxid = self.id.substring(8);
1423 var label = jQuery(\'#boxlabelentry\'+boxid).val();
1424 console.log("We close box "+boxid);
1425 jQuery(\'#boxto_\'+boxid).remove();
1426 jQuery(\'#boxcombo\').append(new Option(label, boxid));
1427 updateBoxOrder(1); /* 1 to avoid message after a remove */
1433 $selectboxlist .=
'</script>'.
"\n";
1439 $nbboxactivated = count($boxidactivatedforuser);
1441 if ($nbboxactivated) {
1443 $langs->loadLangs(array(
"boxes",
"projects"));
1447 $boxlista .=
"\n<!-- Box left container -->\n";
1453 foreach ($boxactivated as $key => $box) {
1454 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1457 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1458 $box->box_order =
'A'.sprintf(
"%02d", ($ii + 1));
1460 if (preg_match(
'/^A/i', $box->box_order)) {
1465 $box->loadBox($box_max_lines);
1466 $boxlista .= $box->showBox(
null,
null, 1);
1470 if (
$conf->browser->layout !=
'phone') {
1471 $emptybox->box_id =
'A';
1472 $emptybox->info_box_head = array();
1473 $emptybox->info_box_contents = array();
1474 $boxlista .= $emptybox->showBox(array(), array(), 1);
1476 $boxlista .=
"<!-- End box left container -->\n";
1478 $boxlistb .=
"\n<!-- Box right container -->\n";
1481 foreach ($boxactivated as $key => $box) {
1482 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1485 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1486 $box->box_order =
'B'.sprintf(
"%02d", ($ii + 1));
1488 if (preg_match(
'/^B/i', $box->box_order)) {
1493 $box->loadBox($box_max_lines);
1494 $boxlistb .= $box->showBox(
null,
null, 1);
1498 if (
$conf->browser->layout !=
'phone') {
1499 $emptybox->box_id =
'B';
1500 $emptybox->info_box_head = array();
1501 $emptybox->info_box_contents = array();
1502 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1505 $boxlistb .=
"<!-- End box right container -->\n";
1508 return array(
'selectboxlist' => count($boxactivated) ? $selectboxlist :
'',
'boxactivated' => $boxactivated,
'boxlista' => $boxlista,
'boxlistb' => $boxlistb);
1525 public function select_dictionary($htmlname, $dictionarytable, $keyfield =
'code', $labelfield =
'label', $selected =
'', $useempty = 0, $moreattrib =
'')
1530 $langs->load(
"admin");
1532 $sql =
"SELECT rowid, ".$this->db->sanitize($keyfield).
", ".$this->db->sanitize($labelfield);
1533 $sql .=
" FROM ".$this->db->prefix().$dictionarytable;
1534 $sql .= $this->db->order($labelfield);
1536 dol_syslog(get_class($this).
"::select_dictionary", LOG_DEBUG);
1537 $result = $this->db->query($sql);
1539 $num = $this->db->num_rows($result);
1542 print
'<select id="select'.$htmlname.
'" class="flat selectdictionary" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
1543 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
1544 print
'<option value="-1"> </option>';
1548 $obj = $this->db->fetch_object($result);
1549 if ($selected == $obj->rowid || $selected == $obj->{$keyfield}) {
1550 print
'<option value="'.$obj->{$keyfield}.
'" selected>';
1552 print
'<option value="'.$obj->{$keyfield}.
'">';
1554 $label = ($langs->trans($dictionarytable.$obj->{$keyfield}) != $dictionarytable.$obj->{$labelfield} ? $langs->trans($dictionarytable.$obj->{$keyfield}) : $obj->{$labelfield});
1561 print $langs->trans(
"DictionaryEmpty");
1564 dol_print_error($this->db);
1578 public function selectAutoManual($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0)
1582 $automatic =
"automatic";
1589 $disabled = ($disabled ?
' disabled' :
'');
1591 $resultautomanual =
'<select class="flat width100" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
1593 $resultautomanual .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
1595 if ((
"$value" ==
'automatic') || ($value == 1)) {
1596 $resultautomanual .=
'<option value="'.$automatic.
'" selected>'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1597 $resultautomanual .=
'<option value="'.$manual.
'">'.$langs->trans(
"Manual").
'</option>'.
"\n";
1599 $selected = (($useempty && $value !=
'0' && $value !=
'manual') ?
'' :
' selected');
1600 $resultautomanual .=
'<option value="'.$automatic.
'">'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1601 $resultautomanual .=
'<option value="'.$manual.
'"'.$selected.
'>'.$langs->trans(
"Manual").
'</option>'.
"\n";
1603 $resultautomanual .=
'</select>'.
"\n";
1604 return $resultautomanual;
1622 $arrayofgroupbylabel = array();
1623 foreach ($arrayofgroupby as $key => $val) {
1624 $arrayofgroupbylabel[$key] = $val[
'label'];
1626 $result = $form->selectarray(
'search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
1645 $arrayofxaxislabel = array();
1646 foreach ($arrayofxaxis as $key => $val) {
1647 $arrayofxaxislabel[$key] = $val[
'label'];
1649 $result = $form->selectarray(
'search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
static listBoxes($dbs, $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.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$conf db user
Active Directory does not allow anonymous connections.
$conf db name
Only used if Module[ID]Name translation string is not found.