70 public function getHTMLScannerForm($jstoexecuteonadd =
'barcodescannerjs', $mode =
'all', $warehouseselect = 0)
76 $out .=
'<!-- Popup for mass barcode scanning -->'.
"\n";
77 $out .=
'<div class="div-for-modal-topright" style="padding: 15px">';
78 $out .=
'<center>'.img_picto(
'',
'barcode',
'class="pictofixedwidth"').
'<strong>Barcode scanner tool...</strong></center><br>';
80 if ($mode ==
'product') {
81 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct">';
82 } elseif ($mode ==
'lot') {
83 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial">';
85 $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>';
86 $out .=
'<input type="radio" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct"> <label for="barcodeforproduct">Scan a product barcode</label><br>';
87 $out .=
'<input type="radio" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial"> <label for="barcodeforlotserial">Scan a product lot or serial number</label><br>';
89 $stringaddbarcode = $langs->trans(
"QtyToAddAfterBarcodeScan",
"tmphtml");
90 $htmltoreplaceby =
'<select name="selectaddorreplace"><option selected value="add">'.$langs->trans(
"Add").
'</option><option value="replace">'.$langs->trans(
"ToReplace").
'</option></select>';
91 $stringaddbarcode = str_replace(
"tmphtml", $htmltoreplaceby, $stringaddbarcode);
92 $out .= $stringaddbarcode.
': <input type="text" name="barcodeproductqty" class="width40 right" value="1"><br>';
93 if ($warehouseselect > 0) {
94 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
96 $formproduct->loadWarehouses();
97 $out .=
img_picto(
'',
'stock',
'class="pictofixedwidth"');
98 $out .= $formproduct->selectWarehouses(
'',
"warehousenew",
'', 0, 0, 0,
'', 0, 1);
102 $out .=
'<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ScanOrTypeOrCopyPasteYourBarCodes")).
'"></textarea>';
112 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" id ="exec'.dol_escape_js($jstoexecuteonadd).
'" name="addscan" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
113 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"CloseWindow")).
'">';
116 $out .=
'<div type="text" id="scantoolmessage" class="scantoolmessage ok nopadding"></div>';
118 $out .=
'<script nonce="'.getNonce().
'">';
119 $out .=
'jQuery("#barcodeforautodetect, #barcodeforproduct, #barcodeforlotserial").click(function(){';
120 $out .=
'console.log("select choice");';
121 $out .=
'jQuery("#scantoolmessage").text("");';
123 $out .=
'$("#exec'.dol_escape_js($jstoexecuteonadd).
'").click(function(){
124 console.log("We call js to execute \''.
dol_escape_js($jstoexecuteonadd).
'\'");
125 '.dol_escape_js($jstoexecuteonadd).'();
126 return false; /* We want to stay on the scan tool */
136 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
147 public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null)
150 global $conf, $langs, $user;
152 $sql = "SELECT
rowid, label, fk_user
";
153 $sql .= " FROM
".$this->db->prefix()."export_model
";
154 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
155 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
156 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
158 $sql .= " ORDER BY label
";
159 $result = $this->db->query($sql);
161 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
163 print '<option value="-1
"> </option>';
166 $tmpuser = new User($this->db);
168 $num = $this->db->num_rows($result);
171 $obj = $this->db->fetch_object($result);
173 $label = $obj->label;
174 if ($obj->fk_user == 0) {
175 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
176 } elseif ($obj->fk_user > 0) {
177 $tmpuser->fetch($obj->fk_user);
178 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
181 if ($selected == $obj->rowid) {
182 print '<option value="'.$obj->rowid.'" selected data-html="'.dol_escape_htmltag($label).'">';
184 print '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($label).'">';
191 print ajax_combobox($htmlname);
193 dol_print_error($this->db);
198 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
209 public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null)
212 global $conf, $langs, $user;
214 $sql = "SELECT
rowid, label, fk_user
";
215 $sql .= " FROM
".$this->db->prefix()."import_model
";
216 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
217 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
218 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
220 $sql .= " ORDER BY label
";
221 $result = $this->db->query($sql);
223 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
225 print '<option value="-1
"> </option>';
228 $tmpuser = new User($this->db);
230 $num = $this->db->num_rows($result);
233 $obj = $this->db->fetch_object($result);
235 $label = $obj->label;
236 if ($obj->fk_user == 0) {
237 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
238 } elseif ($obj->fk_user > 0) {
239 $tmpuser->fetch($obj->fk_user);
240 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
243 if ($selected == $obj->rowid) {
244 print '<option value="'.$obj->rowid.'" selected data-html="'.dol_escape_htmltag($label).'">';
246 print '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($label).'">';
253 print ajax_combobox($htmlname);
255 dol_print_error($this->db);
260 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
268 public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id')
273 $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,
";
274 $sql .= " c.label as country
";
275 $sql .= " FROM
".$this->db->prefix()."c_ecotaxe as e,
".$this->db->prefix()."c_country as c
";
276 $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid
";
277 $sql .= " ORDER BY country, e.organization ASC, e.code ASC
";
279 dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG);
280 $resql = $this->db->query($sql);
282 print '<select class="flat
" name="'.$htmlname.'">';
283 $num = $this->db->num_rows($resql);
285 print '<option value="-1
"> </option>'."\n
";
288 $obj = $this->db->fetch_object($resql);
289 if ($selected && $selected == $obj->rowid) {
290 print '<option value="'.$obj->rowid.'" selected>';
292 print '<option value="'.$obj->rowid.'">';
293 //print '<option onmouseover="showtip(\
''.$obj->label.
'\')
" onMouseout="hidetip()
" value="'.$obj->rowid.'">';
295 $selectOptionValue = $obj->code.' - '.$obj->label.' : '.price($obj->price).' '.$langs->trans("HT
").' ('.$obj->organization.')';
296 print $selectOptionValue;
304 dol_print_error($this->db);
310 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
319 public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '')
326 $sql = "SELECT r.taux, r.revenuestamp_type
";
327 $sql .= " FROM
".$this->db->prefix()."c_revenuestamp as r,
".$this->db->prefix()."c_country as c
";
328 $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid
";
329 $sql .= " AND c.code =
'".$this->db->escape($country_code)."'";
331 dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG);
332 $resql = $this->db->query($sql);
334 $out .= '<select class="flat
" name="'.$htmlname.'">';
335 $num = $this->db->num_rows($resql);
337 $out .= '<option value="0
"> </option>'."\n
";
340 $obj = $this->db->fetch_object($resql);
341 if (($selected && $selected == $obj->taux) || $num == 1) {
342 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').' selected>';
344 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').'>';
346 $out .= $obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '');
354 dol_print_error($this->db);
360 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
373 public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
376 $return = '<select class="flat maxwidth75 right
" name="'.$htmlname.'" '.($disabled ? 'disabled' : '').'>';
378 $return .= '<option value="-1
"'.(($selected == -1 || $selected == '') ? ' selected' : '').'> </option>';
381 for ($i = $start; $i <= $end; $i += $increment) {
382 if ($selected != '' && (int) $selected == $i) {
383 $return .= '<option value="'.$i.'" selected>';
385 $return .= '<option value="'.$i.'">';
388 $return .= '</option>';
391 $return .= '</select>';
396 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
409 public function select_categories($type, $selected = 0, $htmlname = 'search_categ', $nocateg = 0, $showempty = 1, $morecss = '')
412 global $conf, $langs;
413 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
415 // For backward compatibility
416 if (is_numeric($type)) {
417 dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
420 // Load list of "categories
"
421 $static_categs = new Categorie($this->db);
422 $tab_categs = $static_categs->get_full_arbo($type);
426 // Print a select with each of them
427 $moreforfilter .= '<select class="flat minwidth100
'.($morecss ? ' '.$morecss : '').'" id="select_categ_
'.$htmlname.'" name="'.$htmlname.'">';
430 if (!empty($conf->use_javascript_ajax)) {
431 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
433 if (!is_numeric($showempty)) {
434 $textforempty = $showempty;
436 $moreforfilter .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '');
437 //$moreforfilter .= ' data-html="'.dol_escape_htmltag($textforempty).'"';
438 $moreforfilter .= '>'.dol_escape_htmltag($textforempty).'</option>'."\n
";
441 if (is_array($tab_categs)) {
442 foreach ($tab_categs as $categ) {
443 $moreforfilter .= '<option value="'.$categ['id'].'"';
444 if ($categ['id'] == $selected) {
445 $moreforfilter .= ' selected';
447 $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category
', 'class=
"pictofixedwidth" style=
"color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel
'], 50, 'middle
')).'"';
448 $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').'</option>';
452 $langs->load("categories
");
453 $moreforfilter .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NotCategorized
").' -</option>';
455 $moreforfilter .= '</select>';
457 // Enhance with select2
458 if ($conf->use_javascript_ajax) {
459 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
460 $comboenhancement = ajax_combobox('select_categ_'.$htmlname);
461 $moreforfilter .= $comboenhancement;
464 return $moreforfilter;
468 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
481 public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
484 global $conf, $langs, $hookmanager;
487 $langs->load('users');
491 $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
493 // Select each sales and print them in a select input
494 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
497 if (!is_numeric($showempty)) {
498 $textforempty = $showempty;
500 if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
501 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
503 $out .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '').'>'.$textforempty.'</option>'."\n
";
506 // Get list of users allowed to be viewed
507 $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as
status, u.login, u.photo, u.gender, u.entity, u.admin
";
508 $sql_usr .= " FROM
".$this->db->prefix()."user as u
";
510 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
511 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
512 $sql_usr .= " WHERE u.entity IS NOT NULL
"; // Show all users
514 $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')."))
";
515 $sql_usr .= " OR u.entity = 0
"; // Show always superadmin
518 $sql_usr .= " WHERE u.entity IN (
".getEntity('user').")
";
521 if (!$user->hasRight('user', 'user', 'lire')) {
522 $sql_usr .= " AND u.rowid =
".((int) $user->id);
524 if (!empty($user->socid)) {
525 $sql_usr .= " AND u.fk_soc =
".((int) $user->socid);
527 if (getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX')) {
528 $sql_usr .= " AND u.employee <> 0
";
530 if (getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX')) {
531 $sql_usr .= " AND u.fk_soc IS NULL
";
533 if (getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX')) {
534 $sql_usr .= " AND u.statut <> 0
";
537 //Add hook to filter on user (for example on usergroup define in custom modules)
538 if (!empty($reshook)) {
539 $sql_usr .= $hookmanager->resArray[0];
542 // Add existing sales representatives of thirdparty of external user
543 if (!$user->hasRight('user', 'user', 'lire') && $user->socid) {
544 $sql_usr .= " UNION
";
545 $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as
status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin
";
546 $sql_usr .= " FROM
".$this->db->prefix()."user as u2,
".$this->db->prefix()."societe_commerciaux as sc
";
548 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
549 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
550 $sql_usr .= " WHERE u2.entity IS NOT NULL
"; // Show all users
552 $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')."))
";
555 $sql_usr .= " WHERE u2.entity IN (
".getEntity('user').")
";
558 $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc =
".((int) $user->socid);
560 //Add hook to filter on user (for example on usergroup define in custom modules)
561 if (!empty($reshook)) {
562 $sql_usr .= $hookmanager->resArray[1];
566 if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION')) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
567 $sql_usr .= " ORDER BY
status DESC, firstname ASC, lastname ASC
";
569 $sql_usr .= " ORDER BY
status DESC, lastname ASC, firstname ASC
";
571 //print $sql_usr;exit;
573 $resql_usr = $this->db->query($sql_usr);
575 $userstatic = new User($this->db);
577 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
578 $userstatic->id = $obj_usr->rowid;
579 $userstatic->lastname = $obj_usr->lastname;
580 $userstatic->firstname = $obj_usr->firstname;
581 $userstatic->photo = $obj_usr->photo;
582 $userstatic->status = $obj_usr->status;
583 $userstatic->entity = $obj_usr->entity;
584 $userstatic->admin = $obj_usr->admin;
586 $labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
587 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) {
588 $labeltoshow = $obj_usr->login;
591 $out .= '<option value="'.$obj_usr->rowid.'"';
592 if ($obj_usr->rowid == $selected) {
595 $out .= ' data-html="';
596 $outhtml = $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login
', '', 1).' ';
597 if ($showstatus >= 0 && $obj_usr->status == 0) {
598 $outhtml .= '<strike
class=
"opacitymediumxxx">
';
600 $outhtml .= $labeltoshow;
601 if ($showstatus >= 0 && $obj_usr->status == 0) {
602 $outhtml .= '</strike>
';
604 $out .= dol_escape_htmltag($outhtml);
607 $out .= $labeltoshow;
608 // Complete name with more info
610 if (getDolGlobalString('MAIN_SHOW_LOGIN')) {
611 $out .= ($moreinfo ? ' - ' : ' (').$obj_usr->login;
614 if ($showstatus >= 0) {
615 if ($obj_usr->status == 1 && $showstatus == 1) {
616 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
619 if ($obj_usr->status == 0) {
620 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
624 $out .= ($moreinfo ? ')' : '');
627 $this->db->free($resql_usr);
629 dol_print_error($this->db);
632 if ($norepresentative) {
633 $langs->load("companies
");
634 $out .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NoSalesRepresentativeAffected
").' -</option>';
639 // Enhance with select2
640 if ($conf->use_javascript_ajax) {
641 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
643 $comboenhancement = ajax_combobox($htmlname);
644 if ($comboenhancement) {
645 $out .= $comboenhancement;
667 public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '')
669 global $user, $langs;
671 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
673 //print $modeproject.'-'.$modetask;
674 $task = new Task($this->db);
675 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus);
677 print '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
679 print '<option value="0
"> </option>';
683 $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
686 print ajax_combobox($htmlname);
688 print '<div class="warning
">'.$langs->trans("NoProject
").'</div>';
704 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
706 global $langs, $user, $conf;
710 $numlines = count($lines);
711 for ($i = 0; $i < $numlines; $i++) {
712 if ($lines[$i]->fk_task_parent == $parent) {
713 //var_dump($selectedproject."--
".$selectedtask."--
".$lines[$i]->fk_project."_
".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines
715 // Break on a new project
716 if ($parent == 0) { // We are on a task at first level
717 if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project
719 print '<option value="0
" disabled>----------</option>';
721 print '<option value="'.$lines[$i]->fk_project.'_0
"';
722 if ($selectedproject == $lines[$i]->fk_project) {
726 $labeltoshow = $lines[$i]->projectref;
727 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
728 if (empty($lines[$i]->public)) {
729 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
730 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
732 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
733 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
736 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
737 print '>'; // Project -> Task
741 $lastprojectid = $lines[$i]->fk_project;
746 $newdisablechildoftaskid = $disablechildoftaskid;
749 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
750 // Check if we must disable entry
752 if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) {
754 if ($lines[$i]->fk_task_parent == $disablechildoftaskid) {
755 $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
759 print '<option value="'.$lines[$i]->fk_project.'_
'.$lines[$i]->id.'"';
760 if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) {
767 $labeltoshow = $lines[$i]->projectref;
768 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
769 if (empty($lines[$i]->public)) {
770 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
771 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
773 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
774 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
776 if ($lines[$i]->id) {
777 $labeltoshow .= ' > ';
779 for ($k = 0; $k < $level; $k++) {
780 $labeltoshow .= "
";
782 $labeltoshow .= $lines[$i]->ref.' '.$lines[$i]->label;
784 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
792 if ($lines[$i]->id) {
793 $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
809 public static function showColor($color, $textifnotdefined = '')
812 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
813 if (colorIsLight($color)) {
817 $color = colorArrayToHex(colorStringToArray($color, array()), '');
820 return '<input type="text
" class="colorthumb
" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #
'.$textcolor.'; background-color: #
'.$color.'" value="'.$color.'">';
822 return $textifnotdefined;
826 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
839 public function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = [])
842 print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
859 public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = [], $morecss = '', $setpropertyonselect = '', $default = '')
861 // Deprecation warning
863 dol_syslog(__METHOD__.": form_name parameter is deprecated
", LOG_WARNING);
866 global $langs, $conf;
870 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) {
871 // Case of selection of any color
872 $langs->load("other
");
873 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR')) {
874 $out .= '<link rel="stylesheet
" media="screen
" type="text/css
" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css
" />';
875 $out .= '<script nonce="'.getNonce().'" type="text/javascript
" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/jpicker-1.1.6.js
"></script>';
876 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
877 jQuery(document).ready(function(){
878 var originalhex = null;
879 $(\'#colorpicker'.$prefix.'\').jPicker( {
881 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\', /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color
" if left null */
884 type: \'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide
", "show
", "fade
" */
887 show: \'fast\', /* duration of "show
" effect. Acceptable values are "fast
", "slow
", or time in ms */
888 hide: \'fast\' /* duration of "hide
" effect. Acceptable values are "fast
", "slow
", or time in ms */
893 x: \'screenCenter\', /* acceptable values "left
", "center
", "right
", "screenCenter
", or relative px value */
894 y: \'center\' /* acceptable values "top
", "bottom
", "center
", or relative px value */
898 clientPath: \''.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/images/\',
899 picker: { file: \'../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
901 localization: // alter these to change the text presented by the picker (e.g. different language)
905 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\',
906 newColor: \''.dol_escape_js($langs->trans("New
")).'\',
907 currentColor: \''.dol_escape_js($langs->trans("Current
")).'\',
908 ok: \''.dol_escape_js($langs->trans("Validate")).'\',
909 cancel: \''.dol_escape_js($langs->trans("Cancel
")).'\'
913 function(color, context) { console.log("close color selector
"); },
914 function(color, context) { var hex = color.val(\'hex\'); console.log("new color selected in jpicker
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
915 if ($setpropertyonselect) {
916 $out .= 'if (originalhex == null) {';
917 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
918 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
920 $out .= 'if (hex != null) {';
921 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', \'#\'+hex);';
925 function(color, context) {
926 console.log("cancel selection of color
");';
927 if ($setpropertyonselect) {
928 $out .= 'if (originalhex != null) {
929 console.log("Restore old color
"+originalhex);
930 document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', originalhex);
938 $out .= '<input id="colorpicker
'.$prefix.'" name="'.$prefix.'" size="6
" maxlength="7
" class="flat valignmiddle
'.($morecss ? ' '.$morecss : '').'" type="text
" value="'.dol_escape_htmltag($set_color).'" />';
940 $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF'));
941 $out .= '<input id="colorpicker
'.$prefix.'" name="'.$prefix.'" size="6
" maxlength="7
" class="flat input-nobottom colorselector valignmiddle
'.($morecss ? ' '.$morecss : '').'" type="color
" data-default="'.$default.'" value="'.dol_escape_htmltag(preg_match('/^#/
', $color) ? $color : '#
'.$color).'" />';
942 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
943 jQuery(document).ready(function(){
944 var originalhex = null;
945 jQuery("#colorpicker
'.$prefix.'").on(\'change\', function() {
946 var hex = jQuery("#colorpicker
'.$prefix.'").val();
947 console.log("new color selected in input color
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
948 if ($setpropertyonselect) {
949 $out .= 'if (originalhex == null) {';
950 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
951 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
953 $out .= 'if (hex != null) {';
954 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', hex);';
963 // In most cases, this is not used. We used instead function with no specific list of colors
964 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) {
965 $out .= '<link rel="stylesheet
" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css
" type="text/css
" media="screen
" />';
966 $out .= '<script nonce="'.getNonce().'" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.js
" type="text/javascript
"></script>';
967 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
968 jQuery(document).ready(function(){
969 jQuery(\'#colorpicker'.$prefix.'\').colorpicker({
977 $out .= '<select id="colorpicker
'.$prefix.'" class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$prefix.'">';
978 //print '<option value="-1
"> </option>';
979 foreach ($arrayofcolors as $val) {
980 $out .= '<option value="'.$val.'"';
981 if ($set_color == $val) {
984 $out .= '>'.$val.'</option>';
992 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1003 public function CreateColorIcon($color, $module, $name, $x = 12, $y = 12)
1008 $file = $conf->$module->dir_temp.'/'.$name.'.png';
1010 // We create temp directory
1011 if (!file_exists($conf->$module->dir_temp)) {
1012 dol_mkdir($conf->$module->dir_temp);
1015 // On cree l'image en vraies couleurs
1016 $image = imagecreatetruecolor($x, $y);
1018 $color = substr($color, 1, 6);
1020 $red = hexdec(substr($color, 0, 2)); // Red channel conversion
1021 $green = hexdec(substr($color, 2, 2)); // Green channel conversion
1022 $blue = hexdec(substr($color, 4, 2)); // Blue channel conversion
1024 $couleur = imagecolorallocate($image, $red, $green, $blue);
1025 //print $red.$green.$blue;
1026 imagefill($image, 0, 0, $couleur); // Fill the image
1027 // Create the colr and store it in a variable to maintain it
1028 imagepng($image, $file); // Returns an image in PNG format
1029 imagedestroy($image);
1032 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1041 public function select_dayofweek($selected = '', $htmlname = 'weekid', $useempty = 0)
1047 0 => $langs->trans("Day0
"),
1048 1 => $langs->trans("Day1
"),
1049 2 => $langs->trans("Day2
"),
1050 3 => $langs->trans("Day3
"),
1051 4 => $langs->trans("Day4
"),
1052 5 => $langs->trans("Day5
"),
1053 6 => $langs->trans("Day6
")
1056 $select_week = '<select class="flat
" name="'.$htmlname.'" id="'.$htmlname.'">';
1058 $select_week .= '<option value="-1
"> </option>';
1060 foreach ($week as $key => $val) {
1061 if ($selected == $key) {
1062 $select_week .= '<option value="'.$key.'" selected>';
1064 $select_week .= '<option value="'.$key.'">';
1066 $select_week .= $val;
1067 $select_week .= '</option>';
1069 $select_week .= '</select>';
1071 $select_week .= ajax_combobox($htmlname);
1073 return $select_week;
1076 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1088 public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false)
1093 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1096 $montharray = monthArray($langs, 0); // Get array
1098 $montharray = monthArray($langs, 1);
1101 $select_month = '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
1103 $select_month .= '<option value="0
"> </option>';
1105 foreach ($montharray as $key => $val) {
1106 if ($selected == $key) {
1107 $select_month .= '<option value="'.$key.'" selected>';
1109 $select_month .= '<option value="'.$key.'">';
1111 $select_month .= $val;
1112 $select_month .= '</option>';
1114 $select_month .= '</select>';
1116 // Add code for jquery to use multiselect
1118 // Enhance with select2
1119 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1120 $select_month .= ajax_combobox($htmlname);
1123 return $select_month;
1126 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1143 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)
1146 print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
1164 public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false)
1168 $currentyear = idate("Y
") + $offset;
1169 $max_year = $currentyear + $max_year;
1170 $min_year = $currentyear - $min_year;
1171 if (empty($selected) && empty($useempty)) {
1172 $selected = $currentyear;
1175 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$option.' >';
1177 $selected_html = '';
1178 if ($selected == '') {
1179 $selected_html = ' selected';
1181 $out .= '<option value=""'.$selected_html.'> </option>';
1184 for ($y = $max_year; $y >= $min_year; $y--) {
1185 $selected_html = '';
1186 if ($selected > 0 && $y == $selected) {
1187 $selected_html = ' selected';
1189 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1192 for ($y = $min_year; $y <= $max_year; $y++) {
1193 $selected_html = '';
1194 if ($selected > 0 && $y == $selected) {
1195 $selected_html = ' selected';
1197 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1200 $out .= "</select>\n
";
1202 // Add code for jquery to use multiselect
1204 // Enhance with select2
1205 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1206 $out .= ajax_combobox($htmlname);
1221 public static function getBoxesArea($user, $areacode)
1223 global $conf, $langs, $db;
1225 include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
1227 $confuserzone = 'MAIN_BOXES_'.$areacode;
1229 // $boxactivated will be array of boxes enabled into global setup
1230 // $boxidactivatedforuser will be array of boxes chose by user
1232 $selectboxlist = '';
1233 $boxactivated = InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone) ? null : $user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup)
1235 $boxidactivatedforuser = array();
1236 foreach ($boxactivated as $box) {
1237 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1238 $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user
1242 // Define selectboxlist
1243 $arrayboxtoactivatelabel = array();
1244 if (!empty($user->conf->$confuserzone)) {
1246 $langs->load("boxes
"); // Load label of boxes
1247 foreach ($boxactivated as $box) {
1248 if (!empty($boxidactivatedforuser[$box->id])) {
1249 continue; // Already visible for user
1251 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1252 //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph
").')';
1253 if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') {
1254 $label = $label.' <span class="fas fa-chart-bar
"></span>';
1256 $arrayboxtoactivatelabel[$box->id] = array('label' => $label, 'data-html' => img_picto('', $box->boximg, 'class="pictofixedwidth
"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list
1258 foreach ($boxidactivatedforuser as $boxid) {
1259 if (empty($boxorder)) {
1262 $boxorder .= $boxid.',';
1265 //var_dump($boxidactivatedforuser);
1267 // Class Form must have been already loaded
1268 $selectboxlist .= '<!-- Form with select box list -->'."\n
";
1269 $selectboxlist .= '<form id="addbox
" name="addbox
" method="POST
" action="'.$_SERVER["PHP_SELF"].'">';
1270 $selectboxlist .= '<input type="hidden
" name="token
" value="'.newToken().'">';
1271 $selectboxlist .= '<input type="hidden
" name="addbox
" value="addbox
">';
1272 $selectboxlist .= '<input type="hidden
" name="userid
" value="'.$user->id.'">';
1273 $selectboxlist .= '<input type="hidden
" name="areacode
" value="'.$areacode.'">';
1274 $selectboxlist .= '<input type="hidden
" name="boxorder
" value="'.$boxorder.'">';
1275 $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd
").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth300 hideonprint', 0, 'hidden selected', 0, 0);
1276 if (empty($conf->use_javascript_ajax)) {
1277 $selectboxlist .= ' <input type="submit
" class="button" value="'.$langs->trans("AddBox").'">';
1279 $selectboxlist .= '</form>';
1280 if (!empty($conf->use_javascript_ajax)) {
1281 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1282 $selectboxlist .= ajax_combobox("boxcombo
");
1286 // Javascript code for dynamic actions
1287 if (!empty($conf->use_javascript_ajax)) {
1288 $selectboxlist .= '<script nonce="'.getNonce().'" type="text/javascript
">
1290 // To update list of activated boxes
1291 function updateBoxOrder(closing) {
1292 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1293 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1294 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1295 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
1298 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1301 // We force reload to be sure to get all boxes into list
1302 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'&action=delbox&token='.newToken().'\';
1307 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1313 jQuery(document).ready(function() {
1314 jQuery("#boxcombo
").change(function() {
1315 var boxid=jQuery("#boxcombo
").val();
1317 console.log("A box widget has been selected
for addition, we call ajax page to add it.
")
1318 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1319 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1320 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1322 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\'
1323 }).done(function() {
1324 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'\';
1328 if (!count($arrayboxtoactivatelabel)) {
1329 $selectboxlist .= 'jQuery("#boxcombo
").hide();';
1333 jQuery("#boxhalfleft, #boxhalfright
").sortable({
1334 handle: \'.boxhandle\',
1335 revert: \'invalid\',
1336 items: \'.boxdraggable\',
1337 containment: \'document\',
1338 connectWith: \'#boxhalfleft, #boxhalfright\',
1339 stop: function(event, ui) {
1340 console.log("We moved box so we call updateBoxOrder with ajax actions
");
1341 updateBoxOrder(1); /* 1 to avoid message after a move */
1345 jQuery(".boxclose
").click(function() {
1346 var self = this; // because JQuery can modify this
1347 var boxid = self.id.substring(8);
1349 var label = jQuery(\'#boxlabelentry\'+boxid).val();
1350 console.log("We close box
"+boxid);
1351 jQuery(\'#boxto_\'+boxid).remove();
1352 jQuery(\'#boxcombo\').append(new Option(label, boxid));
1353 updateBoxOrder(1); /* 1 to avoid message after a remove */
1359 $selectboxlist .= '</script>'."\n
";
1362 // Define boxlista and boxlistb
1365 $nbboxactivated = count($boxidactivatedforuser);
1367 if ($nbboxactivated) {
1368 // Load translation files required by the page
1369 $langs->loadLangs(array("boxes
", "projects
"));
1371 $emptybox = new ModeleBoxes($db);
1373 $boxlista .= "\n<!-- Box left container -->\n
";
1375 // Define $box_max_lines
1376 $box_max_lines = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
1379 foreach ($boxactivated as $key => $box) {
1380 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1383 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1384 $box->box_order = 'A'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1386 if (preg_match('/^A/i', $box->box_order)) { // column A
1388 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1389 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1391 $box->loadBox($box_max_lines);
1392 $boxlista .= $box->showBox(null, null, 1);
1396 if ($conf->browser->layout != 'phone') {
1397 $emptybox->box_id = 'A';
1398 $emptybox->info_box_head = array();
1399 $emptybox->info_box_contents = array();
1400 $boxlista .= $emptybox->showBox(array(), array(), 1);
1402 $boxlista .= "<!-- End box left container -->\n
";
1404 $boxlistb .= "\n<!-- Box right container -->\n
";
1407 foreach ($boxactivated as $key => $box) {
1408 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1411 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1412 $box->box_order = 'B'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1414 if (preg_match('/^B/i', $box->box_order)) { // colonne B
1416 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1417 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1419 $box->loadBox($box_max_lines);
1420 $boxlistb .= $box->showBox(null, null, 1);
1424 if ($conf->browser->layout != 'phone') {
1425 $emptybox->box_id = 'B';
1426 $emptybox->info_box_head = array();
1427 $emptybox->info_box_contents = array();
1428 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1431 $boxlistb .= "<!-- End box right container -->\n
";
1434 return array('selectboxlist' => count($boxactivated) ? $selectboxlist : '', 'boxactivated' => $boxactivated, 'boxlista' => $boxlista, 'boxlistb' => $boxlistb);
1438 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1451 public function select_dictionary($htmlname, $dictionarytable, $keyfield = 'code', $labelfield = 'label', $selected = '', $useempty = 0, $moreattrib = '')
1454 global $langs, $conf;
1456 $langs->load("admin
");
1458 $sql = "SELECT
rowid,
".$keyfield.",
".$labelfield;
1459 $sql .= " FROM
".$this->db->prefix().$dictionarytable;
1460 $sql .= " ORDER BY
".$labelfield;
1463 $result = $this->db->query($sql);
1465 $num = $this->db->num_rows($result);
1468 print '<select id="select
'.$htmlname.'" class="flat selectdictionary
" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
1469 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
1470 print '<option value="-1
"> </option>';
1474 $obj = $this->db->fetch_object($result);
1475 if ($selected == $obj->rowid || $selected == $obj->{$keyfield}) {
1476 print '<option value="'.$obj->{$keyfield}.'" selected>';
1478 print '<option value="'.$obj->{$keyfield}.'">';
1480 $label = ($langs->trans($dictionarytable.$obj->{$keyfield}) != $dictionarytable.$obj->{$labelfield} ? $langs->trans($dictionarytable.$obj->{$keyfield}) : $obj->{$labelfield});
1487 print $langs->trans("DictionaryEmpty
");
1490 dol_print_error($this->db);
1504 public function selectAutoManual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0)
1508 $automatic = "automatic
";
1515 $disabled = ($disabled ? ' disabled' : '');
1517 $resultautomanual = '<select class="flat width100
" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n
";
1519 $resultautomanual .= '<option value="-1
"'.(($value < 0) ? ' selected' : '').'> </option>'."\n
";
1521 if (("$value
" == 'automatic') || ($value == 1)) {
1522 $resultautomanual .= '<option value="'.$automatic.'" selected>'.$langs->trans("Automatic
").'</option>'."\n
";
1523 $resultautomanual .= '<option value="'.$manual.'">'.$langs->trans("Manual
").'</option>'."\n
";
1525 $selected = (($useempty && $value != '0' && $value != 'manual') ? '' : ' selected');
1526 $resultautomanual .= '<option value="'.$automatic.'">'.$langs->trans("Automatic
").'</option>'."\n
";
1527 $resultautomanual .= '<option value="'.$manual.'"'.$selected.'>'.$langs->trans("Manual
").'</option>'."\n
";
1529 $resultautomanual .= '</select>'."\n
";
1530 return $resultautomanual;
1544 public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1')
1546 global $langs, $extrafields, $form;
1548 $arrayofgroupbylabel = array();
1549 foreach ($arrayofgroupby as $key => $val) {
1550 $arrayofgroupbylabel[$key] = $val['label'];
1552 $result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
1567 public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1', $morecss = 'minwidth250 maxwidth500')
1571 $arrayofxaxislabel = array();
1572 foreach ($arrayofxaxis as $key => $val) {
1573 $arrayofxaxislabel[$key] = $val['label'];
1575 $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Class toolbox to validate values.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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...
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db user
Active Directory does not allow anonymous connections.