73 public function getHTMLScannerForm($jstoexecuteonadd =
'barcodescannerjs', $mode =
'all', $warehouseselect = 0)
79 $out .=
'<!-- Popup for mass barcode scanning -->'.
"\n";
80 $out .=
'<div class="div-for-modal-topright" style="padding: 15px">';
81 $out .=
'<center>'.img_picto(
'',
'barcode',
'class="pictofixedwidth"').
'<strong>Barcode scanner tool...</strong></center><br>';
83 if ($mode ==
'product') {
84 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct">';
85 } elseif ($mode ==
'lot') {
86 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial">';
88 $out .=
'<input type="radio" name="barcodemode" value="barcodeforautodetect" id="barcodeforautodetect" checked="checked"> <label for="barcodeforautodetect">Autodetect if we scan a product barcode or a lot/serial barcode</label><br>';
89 $out .=
'<input type="radio" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct"> <label for="barcodeforproduct">Scan a product barcode</label><br>';
90 $out .=
'<input type="radio" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial"> <label for="barcodeforlotserial">Scan a product lot or serial number</label><br>';
92 $stringaddbarcode = $langs->trans(
"QtyToAddAfterBarcodeScan",
"tmphtml");
93 $htmltoreplaceby =
'<select name="selectaddorreplace"><option selected value="add">'.$langs->trans(
"Add").
'</option><option value="replace">'.$langs->trans(
"ToReplace").
'</option></select>';
94 $stringaddbarcode = str_replace(
"tmphtml", $htmltoreplaceby, $stringaddbarcode);
95 $out .= $stringaddbarcode.
': <input type="text" name="barcodeproductqty" class="width40 right" value="1"><br>';
96 if ($warehouseselect > 0) {
97 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
99 $formproduct->loadWarehouses();
100 $out .= img_picto(
'',
'stock',
'class="pictofixedwidth"');
101 $out .= $formproduct->selectWarehouses(
'',
"warehousenew",
'', 0, 0, 0,
'', 0, 1);
105 $out .=
'<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ScanOrTypeOrCopyPasteYourBarCodes")).
'"></textarea>';
115 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" id="exec'.dol_escape_js($jstoexecuteonadd).
'" name="addscan" value="'.dolPrintHTMLForAttribute($langs->trans(
"Add")).
'">';
116 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"CloseWindow")).
'">';
119 $out .=
'<div type="text" id="scantoolmessage" class="scantoolmessage ok nopadding"></div>';
121 $out .=
'<script nonce="'.getNonce().
'">';
122 $out .=
'jQuery("#barcodeforautodetect, #barcodeforproduct, #barcodeforlotserial").click(function(){';
123 $out .=
'console.log("select choice");';
124 $out .=
'jQuery("#scantoolmessage").text("");';
128 $out .=
'$(\'#exec'.dol_escape_js($jstoexecuteonadd).
'\').click(
function(){
129 console.log(\
'We call js to execute '.
dol_escape_js($jstoexecuteonadd).
'\');
130 '.dol_escape_js($jstoexecuteonadd).'();
141 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
152 public function select_export_model($selected = '
', $htmlname = 'exportmodelid
', $type = '', $useempty = 0, $fk_user = null)
157 $sql = "SELECT rowid, label, fk_user";
158 $sql .= " FROM ".$this->db->prefix()."export_model";
159 $sql .= " WHERE type = '".$this->db->escape($type)."'";
160 if (!getDolGlobalString('EXPORTS_SHARE_MODELS
')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
161 $sql .= " AND fk_user IN (0, ".((int) $fk_user).")";
163 $sql .= " ORDER BY label";
164 $result = $this->db->query($sql);
166 print '<select
class=
"flat minwidth200" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
168 if (is_numeric($useempty)) {
169 print '<option value=
"-1"> </option>
';
171 print '<option value=
"-1">
'.$langs->trans($useempty).'</option>
';
175 $tmpuser = new User($this->db);
177 $num = $this->db->num_rows($result);
180 $obj = $this->db->fetch_object($result);
182 $label = $obj->label;
183 if ($obj->fk_user == 0) {
184 $label .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Everybody").')</span>
';
185 } elseif ($obj->fk_user > 0) {
186 $tmpuser->fetch($obj->fk_user);
187 $label .= ' <span
class=
"opacitymedium">(
'.$tmpuser->getFullName($langs).')</span>
';
190 if ($selected == $obj->rowid) {
191 print '<option value=
"'.$obj->rowid.'" selected data-html=
"'.dolPrintHTMLForAttribute($label).'">
';
193 print '<option value=
"'.$obj->rowid.'" data-html=
"'.dolPrintHTMLForAttribute($label).'">
';
200 print '<option value=
"-1" disabled data-html=
"'.dolPrintHTMLForAttribute('<span class="opacitymedium
">'.$langs->transnoentitiesnoconv("NoPredefinedExportProfileYet
").'</span>').'">
'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet").'</option>
';
203 print ajax_combobox($htmlname);
205 dol_print_error($this->db);
210 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
221 public function select_import_model($selected = '
', $htmlname = 'importmodelid
', $type = '', $useempty = 0, $fk_user = null)
226 $sql = "SELECT rowid, label, fk_user";
227 $sql .= " FROM ".$this->db->prefix()."import_model";
228 $sql .= " WHERE type = '".$this->db->escape($type)."'";
229 if (!getDolGlobalString('EXPORTS_SHARE_MODELS
')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
230 $sql .= " AND fk_user IN (0, ".((int) $fk_user).")";
232 $sql .= " ORDER BY label";
233 $result = $this->db->query($sql);
235 print '<select
class=
"flat minwidth200" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
236 if (is_numeric($useempty)) {
237 print '<option value=
"-1"> </option>
';
239 print '<option value=
"-1">
'.$langs->trans($useempty).'</option>
';
242 $tmpuser = new User($this->db);
244 $num = $this->db->num_rows($result);
247 $obj = $this->db->fetch_object($result);
249 $label = $obj->label;
250 if ($obj->fk_user == 0) {
251 $label .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Everybody").')</span>
';
252 } elseif ($obj->fk_user > 0) {
253 $tmpuser->fetch($obj->fk_user);
254 $label .= ' <span
class=
"opacitymedium">(
'.$tmpuser->getFullName($langs).')</span>
';
257 if ($selected == $obj->rowid) {
258 print '<option value=
"'.$obj->rowid.'" selected data-html=
"'.dol_escape_htmltag($label).'">
';
260 print '<option value=
"'.$obj->rowid.'" data-html=
"'.dol_escape_htmltag($label).'">
';
267 print '<option value=
"-1" disabled data-html=
"'.dolPrintHTMLForAttribute('<span class="opacitymedium
">'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet
").'</span>').'">
'.$langs->transnoentitiesnoconv("NoPredefinedProfileYet").'</option>
';
270 print ajax_combobox($htmlname);
272 dol_print_error($this->db);
277 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
285 public function select_ecotaxes($selected = '
', $htmlname = 'ecotaxe_id
')
290 $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,";
291 $sql .= " c.label as country";
292 $sql .= " FROM ".$this->db->prefix()."c_ecotaxe as e,".$this->db->prefix()."c_country as c";
293 $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid";
294 $sql .= " ORDER BY country, e.organization ASC, e.code ASC";
297 $resql = $this->db->query($sql);
299 print '<select
class=
"flat" name=
"'.$htmlname.'">
';
300 $num = $this->db->num_rows($resql);
302 print '<option value=
"-1"> </option>
'."\n";
305 $obj = $this->db->fetch_object($resql);
306 if ($selected && $selected == $obj->rowid) {
307 print '<option value=
"'.$obj->rowid.'" selected>
';
309 print '<option value=
"'.$obj->rowid.'">
';
310 //print '<option onmouseover=
"showtip(\''.$obj->label.'\')" onMouseout=
"hidetip()" value=
"'.$obj->rowid.'">
';
312 $selectOptionValue = $obj->code.' -
'.$obj->label.' :
'.price($obj->price).' '.$langs->trans("HT").' (
'.$obj->organization.')
';
313 print $selectOptionValue;
321 dol_print_error($this->db);
327 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
336 public function select_revenue_stamp($selected = '
', $htmlname = 'revenuestamp
', $country_code = '')
343 $sql = "SELECT r.taux, r.revenuestamp_type";
344 $sql .= " FROM ".$this->db->prefix()."c_revenuestamp as r,".$this->db->prefix()."c_country as c";
345 $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid";
346 $sql .= " AND c.code = '".$this->db->escape($country_code)."'";
349 $resql = $this->db->query($sql);
351 $out .= '<select
class=
"flat" name=
"'.$htmlname.'">
';
352 $num = $this->db->num_rows($resql);
354 $out .= '<option value=
"0"> </option>
'."\n";
357 $obj = $this->db->fetch_object($resql);
358 if (($selected && $selected == $obj->taux) || $num == 1) {
359 $out .= '<option value=
"'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent
' ? ' data-
type=
"percent"' : '').' selected>
';
361 $out .= '<option value=
"'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent
' ? ' data-
type=
"percent"' : '').'>
';
363 $out .= $obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '');
371 dol_print_error($this->db);
377 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
390 public function select_percent($selected = 0, $htmlname = 'percent
', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
393 $return = '<select
class=
"flat maxwidth75 right" name=
"'.$htmlname.'" '.($disabled ? 'disabled' : '').'>
';
395 $return .= '<option value=
"-1"'.(($selected == -1 || $selected == '') ? ' selected
' : '').'> </option>
';
398 for ($i = $start; $i <= $end; $i += $increment) {
399 if ($selected != '' && (int) $selected == $i) {
400 $return .= '<option value=
"'.$i.'" selected>
';
402 $return .= '<option value=
"'.$i.'">
';
405 $return .= '</option>
';
408 $return .= '</select>
';
413 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
426 public function select_categories($type, $selected = 0, $htmlname = 'search_categ
', $nocateg = 0, $showempty = 1, $morecss = '')
429 global $conf, $langs;
430 require_once DOL_DOCUMENT_ROOT.'/categories/
class/categorie.class.php
';
432 // For backward compatibility
433 if (is_numeric($type)) {
434 dol_syslog(__METHOD__.':
using numeric value
for parameter
type is deprecated. Use
string code instead.
', LOG_WARNING);
437 // Load list of "categories"
438 $static_categs = new Categorie($this->db);
439 $tab_categs = $static_categs->get_full_arbo($type);
443 // Print a select with each of them
444 $moreforfilter .= '<select
class=
"flat minwidth100'.($morecss ? ' '.$morecss : '').'" id=
"select_categ_'.$htmlname.'" name=
"'.$htmlname.'">
';
447 if (!empty($conf->use_javascript_ajax)) {
448 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
450 if (!is_numeric($showempty)) {
451 $textforempty = $showempty;
453 $moreforfilter .= '<option
class=
"optiongrey" value=
"'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected
' : '');
454 //$moreforfilter .= ' data-html=
"'.dol_escape_htmltag($textforempty).'"';
455 $moreforfilter .= '>
'.dol_escape_htmltag($textforempty).'</option>
'."\n";
458 if (is_array($tab_categs)) {
459 foreach ($tab_categs as $categ) {
460 $moreforfilter .= '<option value=
"'.$categ['id'].'"';
461 if ($categ['id'] == $selected) {
462 $moreforfilter .= ' selected
';
464 $moreforfilter .= ' data-html=
"'.dol_escape_htmltag(img_picto('', 'category', 'class="pictofixedwidth
" style="color: #
'.$categ['color
'].'"').dol_trunc($categ['fulllabel'], 50, 'middle')).'"';
465 $moreforfilter .= '>
'.dol_trunc($categ['fulllabel
'], 50, 'middle
').'</option>
';
469 $langs->load("categories");
470 $moreforfilter .= '<option value=
"-2"'.($selected == -2 ? ' selected
' : '').'>-
'.$langs->trans("NotCategorized").' -</option>
';
472 $moreforfilter .= '</select>
';
474 // Enhance with select2
475 if ($conf->use_javascript_ajax) {
476 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
477 $comboenhancement = ajax_combobox('select_categ_
'.$htmlname);
478 $moreforfilter .= $comboenhancement;
481 return $moreforfilter;
485 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
498 public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '
', $norepresentative = 0)
501 global $conf, $langs, $hookmanager;
504 $langs->load('users
');
508 $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep
', array(), $this, $action);
510 // Select each sales and print them in a select input
511 $out .= '<select
class=
"flat'.($morecss ? ' '.$morecss : '').'" id=
"'.$htmlname.'" name=
"'.$htmlname.'">
';
514 if (!is_numeric($showempty)) {
515 $textforempty = $showempty;
517 if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
518 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
520 $out .= '<option
class=
"optiongrey" value=
"'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected
' : '').'>
'.$textforempty.'</option>
'."\n";
523 // Get list of users allowed to be viewed
524 $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as status, u.login, u.photo, u.gender, u.entity, u.admin";
525 $sql_usr .= " FROM ".$this->db->prefix()."user as u";
527 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE
')) {
528 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
529 $sql_usr .= " WHERE u.entity IS NOT NULL"; // Show all users
531 $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
')."))";
532 $sql_usr .= " OR u.entity = 0"; // Show always superadmin
535 $sql_usr .= " WHERE u.entity IN (".getEntity('user').")";
538 if (!$user->hasRight('user', 'user', 'lire
')) {
539 $sql_usr .= " AND u.rowid = ".((int) $user->id);
541 if (!empty($user->socid)) {
542 $sql_usr .= " AND u.fk_soc = ".((int) $user->socid);
544 if (getDolUserString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX
'))) {
545 $sql_usr .= " AND u.employee <> 0";
547 if (getDolUserString('USER_HIDE_EXTERNAL_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX
'))) {
548 $sql_usr .= " AND u.fk_soc IS NULL";
550 if (getDolUserString('USER_HIDE_INACTIVE_IN_COMBOBOX
', getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX
'))) { // Can be set in setup of module User.
551 $sql_usr .= " AND u.statut <> 0";
554 //Add hook to filter on user (for example on usergroup define in custom modules)
555 if (!empty($reshook)) {
556 $sql_usr .= $hookmanager->resArray[0]; // Trust the hook: @phan-suppress-current-line SqlInjection
559 // Add existing sales representatives of thirdparty of external user
560 if (!$user->hasRight('user', 'user', 'lire
') && $user->socid) {
561 $sql_usr .= " UNION ";
562 $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin";
563 $sql_usr .= " FROM ".$this->db->prefix()."user as u2, ".$this->db->prefix()."societe_commerciaux as sc";
565 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE
')) {
566 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
567 $sql_usr .= " WHERE u2.entity IS NOT NULL"; // Show all users
569 $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
')."))";
572 $sql_usr .= " WHERE u2.entity IN (".getEntity('user').")";
575 $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc = ".((int) $user->socid);
577 //Add hook to filter on user (for example on usergroup define in custom modules)
578 if (!empty($reshook)) {
579 $sql_usr .= $hookmanager->resArray[1]; // Trust the hook: @phan-suppress-current-line SqlInjection
583 if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION
')) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
584 $sql_usr .= " ORDER BY status DESC, firstname ASC, lastname ASC";
586 $sql_usr .= " ORDER BY status DESC, lastname ASC, firstname ASC";
588 //print $sql_usr;exit;
590 $resql_usr = $this->db->query($sql_usr);
592 $userstatic = new User($this->db);
594 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
595 $userstatic->id = $obj_usr->rowid;
596 $userstatic->lastname = $obj_usr->lastname;
597 $userstatic->firstname = $obj_usr->firstname;
598 $userstatic->photo = $obj_usr->photo;
599 $userstatic->status = $obj_usr->status;
600 $userstatic->entity = $obj_usr->entity;
601 $userstatic->admin = $obj_usr->admin;
603 $labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
604 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) {
605 $labeltoshow = $obj_usr->login;
608 $out .= '<option value=
"'.$obj_usr->rowid.'"';
609 if ($obj_usr->rowid == $selected) {
612 $out .= ' data-html=
"';
613 $outhtml = $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' ';
614 if ($showstatus >= 0 && $obj_usr->status == 0) {
615 $outhtml .= '<strike class="opacitymediumxxx
">';
617 $outhtml .= $labeltoshow;
618 if ($showstatus >= 0 && $obj_usr->status == 0) {
619 $outhtml .= '</strike>';
621 $out .= dol_escape_htmltag($outhtml);
624 $out .= $labeltoshow;
625 // Complete name with more info
627 if (getDolGlobalString('MAIN_SHOW_LOGIN
')) {
628 $out .= ($moreinfo ? ' -
' : ' (
').$obj_usr->login;
631 if ($showstatus >= 0) {
632 if ($obj_usr->status == 1 && $showstatus == 1) {
633 $out .= ($moreinfo ? ' -
' : ' (
').$langs->trans('Enabled
');
636 if ($obj_usr->status == 0) {
637 $out .= ($moreinfo ? ' -
' : ' (
').$langs->trans('Disabled
');
641 $out .= ($moreinfo ? ')
' : '');
644 $this->db->free($resql_usr);
646 dol_print_error($this->db);
649 if ($norepresentative) {
650 $langs->load("companies");
651 $out .= '<option value=
"-2"'.($selected == -2 ? ' selected
' : '').'>-
'.$langs->trans("NoSalesRepresentativeAffected").' -</option>
';
656 // Enhance with select2
657 if ($conf->use_javascript_ajax) {
658 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
660 $comboenhancement = ajax_combobox($htmlname);
661 if ($comboenhancement) {
662 $out .= $comboenhancement;
684 public function selectProjectTasks($selectedtask = 0, $projectid = 0, $htmlname = 'task_parent
', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '')
686 global $user, $langs;
688 require_once DOL_DOCUMENT_ROOT.'/projet/
class/task.class.php
';
690 //print $modeproject.'-
'.$modetask;
691 $task = new Task($this->db);
692 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus);
694 print '<select
class=
"flat'.($morecss ? ' '.$morecss : '').'" name=
"'.$htmlname.'" id=
"'.$htmlname.'">
';
696 print '<option value=
"0"> </option>
';
700 $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
703 print ajax_combobox($htmlname);
705 print '<div
class=
"warning">
'.$langs->trans("NoProject").'</div>
';
721 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
723 global $langs, $user, $conf;
727 $numlines = count($lines);
728 for ($i = 0; $i < $numlines; $i++) {
729 if ($lines[$i]->fk_task_parent == $parent) {
730 //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines
732 // Break on a new project
733 if ($parent == 0) { // We are on a task at first level
734 if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project
736 print '<option value=
"0" disabled>----------</option>
';
738 print '<option value=
"'.$lines[$i]->fk_project.'_0"';
739 if ($selectedproject == $lines[$i]->fk_project) {
743 $labeltoshow = $lines[$i]->projectref;
744 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
745 if (empty($lines[$i]->public)) {
746 //$labeltoshow .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("PrivateProject").')</span>
';
747 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project
', 'class=
"pictofixedwidth"').$labeltoshow;
749 //$labeltoshow .= ' <span
class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("SharedProject").')</span>
';
750 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub
', 'class=
"pictofixedwidth"').$labeltoshow;
753 print ' data-html=
"'.dol_escape_htmltag($labeltoshow).'"';
754 print '>
'; // Project -> Task
758 $lastprojectid = $lines[$i]->fk_project;
763 $newdisablechildoftaskid = $disablechildoftaskid;
766 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
767 // Check if we must disable entry
769 if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) {
771 if ($lines[$i]->fk_task_parent == $disablechildoftaskid) {
772 $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
776 print '<option value=
"'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
777 if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_
'.$lines[$i]->id == $selectedtask)) {
784 $labeltoshow = $lines[$i]->projectref;
785 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
786 if (empty($lines[$i]->public)) {
787 //$labeltoshow .= ' <span class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("PrivateProject").')</span>
';
788 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project
', 'class=
"pictofixedwidth"').$labeltoshow;
790 //$labeltoshow .= ' <span class=
"opacitymedium">(
'.$langs->trans("Visibility").':
'.$langs->trans("SharedProject").')</span>
';
791 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub
', 'class=
"pictofixedwidth"').$labeltoshow;
793 if ($lines[$i]->id) {
794 $labeltoshow .= ' >
';
796 for ($k = 0; $k < $level; $k++) {
797 $labeltoshow .= " ";
799 $labeltoshow .= $lines[$i]->ref.' '.$lines[$i]->label;
801 print ' data-html=
"'.dol_escape_htmltag($labeltoshow).'"';
809 if ($lines[$i]->id) {
810 $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
826 public static function showColor($color, $textifnotdefined = '
')
829 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
830 if (colorIsLight($color)) {
834 $color = colorArrayToHex(colorStringToArray($color, array()), '');
837 return '<input
type=
"text" class=
"colorthumb" disabled style=
"padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value=
"'.$color.'">
';
839 return $textifnotdefined;
843 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
856 public function select_color($set_color = '
', $prefix = 'f_color
', $form_name = '', $showcolorbox = 1, $arrayofcolors = [])
859 print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
876 public static function selectColor($set_color = '
', $prefix = 'f_color
', $form_name = '', $showcolorbox = 1, $arrayofcolors = [], $morecss = '', $setpropertyonselect = '', $default = '')
878 // Deprecation warning
880 dol_syslog(__METHOD__.": form_name parameter is deprecated", LOG_WARNING);
883 global $langs, $conf;
887 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) {
888 // Case of selection of any color
889 $langs->load("other");
890 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR
')) {
891 $out .= '<link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css" />
';
892 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript" src=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/jpicker/jpicker-1.1.6.js"></script>
';
893 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
894 jQuery(document).ready(function(){
895 var originalhex =
null;
896 $(\
'#colorpicker'.$prefix.
'\').jPicker( {
898 title: \
''.dol_escape_js($langs->trans(
"SelectAColor")).
'\',
901 type: \
'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide", "show", "fade" */
904 show: \'fast\', /* duration of "show" effect. Acceptable values are "fast", "slow", or time in ms */
905 hide: \'fast\' /* duration of "hide" effect. Acceptable values are "fast", "slow", or time in ms */
910 x: \'screenCenter\', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */
911 y: \'center\' /* acceptable values "top", "bottom", "center", or relative px value */
915 clientPath: \''.DOL_URL_ROOT.
'/public/includes/jquery/plugins/jpicker/images/\',
916 picker: { file: \'../../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
918 localization: // alter these to change the text presented by the picker (e.g. different language)
923 newColor: \
''.dol_escape_js($langs->trans(
"New")).
'\',
924 currentColor: \
''.dol_escape_js($langs->trans(
"Current")).
'\',
925 ok: \
''.dol_escape_js($langs->trans(
"Validate")).
'\',
926 cancel: \
''.dol_escape_js($langs->trans(
"Cancel")).
'\'
930 function(color, context) { console.log(
"close color selector"); },
931 function(color, context) { var hex = color.val(\
'hex\'); console.log("new color selected in jpicker "+hex+\' setpropertyonselect='.
dol_escape_js($setpropertyonselect).
'\');
';
932 if ($setpropertyonselect) {
933 $out .= 'if (originalhex ==
null) {
';
934 $out .= ' originalhex = getComputedStyle(document.querySelector(
":root")).getPropertyValue(\
'--'.
dol_escape_js($setpropertyonselect).
'\');
';
935 $out .= ' console.log(
"original color is saved into originalhex = "+originalhex);
';
937 $out .= 'if (hex !=
null) {
';
938 $out .= ' document.documentElement.style.setProperty(\
'--'.
dol_escape_js($setpropertyonselect).
'\', \
'#\'+hex);';
942 function(color, context) {
943 console.log("cancel selection of color");';
944 if ($setpropertyonselect) {
945 $out .=
'if (originalhex != null) {
946 console.log("Restore old color "+originalhex);
947 document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).
'\', originalhex);
955 $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).'" />
';
957 $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF
'));
958 $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).'" />
';
959 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
960 jQuery(document).ready(
function(){
961 var originalhex =
null;
962 jQuery(
"#colorpicker'.$prefix.'").on(\
'change\', function() {
963 var hex = jQuery("#colorpicker'.$prefix.
'").val();
964 console.log("new color selected in input color "+hex+\' setpropertyonselect='.
dol_escape_js($setpropertyonselect).
'\');
';
965 if ($setpropertyonselect) {
966 $out .= 'if (originalhex ==
null) {
';
967 $out .= ' originalhex = getComputedStyle(document.querySelector(
":root")).getPropertyValue(\
'--'.
dol_escape_js($setpropertyonselect).
'\');
';
968 $out .= ' console.log(
"original color is saved into originalhex = "+originalhex);
';
970 $out .= 'if (hex !=
null) {
';
971 $out .= ' document.documentElement.style.setProperty(\
'--'.
dol_escape_js($setpropertyonselect).
'\', hex);
';
980 // In most cases, this is not used. We used instead function with no specific list of colors
981 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) {
982 $out .= '<link rel=
"stylesheet" href=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type=
"text/css" media=
"screen" />
';
983 $out .= '<script nonce=
"'.getNonce().'" src=
"'.DOL_URL_ROOT.'/public/includes/jquery/plugins/colorpicker/jquery.colorpicker.js" type=
"text/javascript"></script>
';
984 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
985 jQuery(document).ready(
function(){
986 jQuery(\
'#colorpicker'.$prefix.
'\').colorpicker({
994 $out .= '<select
id=
"colorpicker'.$prefix.'" class=
"colorpicker flat'.($morecss ? ' '.$morecss : '').'" name=
"'.$prefix.'">
';
995 //print '<option value=
"-1"> </option>
';
996 foreach ($arrayofcolors as $val) {
997 $out .= '<option value=
"'.$val.'"';
998 if ($set_color == $val) {
1001 $out .= '>
'.$val.'</option>
';
1003 $out .= '</select>
';
1009 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1020 public function CreateColorIcon($color, $module, $name, $x = 12, $y = 12)
1025 $file = $conf->$module->dir_temp.'/
'.$name.'.png
';
1027 // We create temp directory
1028 if (!file_exists($conf->$module->dir_temp)) {
1029 dol_mkdir($conf->$module->dir_temp);
1032 // On cree l'image en vraies couleurs
1033 $image = imagecreatetruecolor($x, $y);
1035 $color = substr($color, 1, 6);
1037 $red = hexdec(substr($color, 0, 2));
1038 $green = hexdec(substr($color, 2, 2));
1039 $blue = hexdec(substr($color, 4, 2));
1041 $couleur = imagecolorallocate($image, $red, $green, $blue);
1043 imagefill($image, 0, 0, $couleur);
1045 imagepng($image, $file);
1046 imagedestroy($image);
1064 0 => $langs->trans(
"Day0"),
1065 1 => $langs->trans(
"Day1"),
1066 2 => $langs->trans(
"Day2"),
1067 3 => $langs->trans(
"Day3"),
1068 4 => $langs->trans(
"Day4"),
1069 5 => $langs->trans(
"Day5"),
1070 6 => $langs->trans(
"Day6")
1073 $select_week =
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1075 $select_week .=
'<option value="-1"> </option>';
1077 foreach ($week as $key => $val) {
1078 if ($selected == $key) {
1079 $select_week .=
'<option value="'.$key.
'" selected>';
1081 $select_week .=
'<option value="'.$key.
'">';
1083 $select_week .= $val;
1084 $select_week .=
'</option>';
1086 $select_week .=
'</select>';
1090 return $select_week;
1103 public function selectDay($selected =
'', $htmlname =
'dayid', $useempty = 0, $morecss =
'minwidth50 maxwidth75imp valignmiddle', $addjscombo =
false)
1105 $select_day =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1107 $select_day .=
'<option value="0"> </option>';
1109 for ($i = 1; $i <= 31; $i++) {
1110 if ((
int) $selected == $i) {
1111 $select_day .=
'<option value="'.$i.
'" selected>';
1113 $select_day .=
'<option value="'.$i.
'">';
1115 $select_day .= sprintf(
"%02d", $i);
1116 $select_day .=
'</option>';
1118 $select_day .=
'</select>';
1123 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1142 public function select_month($selected =
'', $htmlname =
'monthid', $useempty = 0, $longlabel = 0, $morecss =
'minwidth50 maxwidth75imp valignmiddle', $addjscombo =
false)
1147 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
1155 $select_month =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1157 if (is_numeric($useempty)) {
1158 $select_month .=
'<option value="0"> </option>';
1160 $select_month .=
'<option value="-1">'.$useempty.
'</option>';
1163 foreach ($montharray as $key => $val) {
1164 if ((
int) $selected == $key) {
1165 $select_month .=
'<option value="'.$key.
'" selected>';
1167 $select_month .=
'<option value="'.$key.
'">';
1169 $select_month .= $val;
1170 $select_month .=
'</option>';
1172 $select_month .=
'</select>';
1177 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1181 return $select_month;
1201 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)
1204 print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
1222 public function selectyear($selected =
'', $htmlname =
'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option =
'', $morecss =
'valignmiddle width75', $addjscombo =
false)
1226 $currentyear = idate(
"Y") + $offset;
1227 $max_year = $currentyear + $max_year;
1228 $min_year = $currentyear - $min_year;
1229 if (empty($selected) && empty($useempty)) {
1230 $selected = $currentyear;
1233 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$option.
' >';
1235 $selected_html =
'';
1236 if ((
string) $selected ==
'') {
1237 $selected_html =
' selected';
1239 $out .=
'<option value=""'.$selected_html.
'> </option>';
1242 for ($y = $max_year; $y >= $min_year; $y--) {
1243 $selected_html =
'';
1244 if ((
int) $selected > 0 && $y == (
int) $selected) {
1245 $selected_html =
' selected';
1247 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1250 for ($y = $min_year; $y <= $max_year; $y++) {
1251 $selected_html =
'';
1252 if ((
int) $selected > 0 && $y == (
int) $selected) {
1253 $selected_html =
' selected';
1255 $out .=
'<option value="'.$y.
'"'.$selected_html.
' >'.$y.
'</option>';
1258 $out .=
"</select>\n";
1263 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1281 global
$conf, $langs, $db;
1283 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1286 @phan-var-force ModeleBoxes[] $boxactivated
1287 @phan-var-force int[] $boxidactivatedforuser
1290 $confuserzone =
'MAIN_BOXES_'.$areacode;
1297 $selectboxlist =
'';
1298 $boxactivated =
InfoBox::listBoxes($db,
'activated', (
int) $areacode, (empty($user->conf->$confuserzone) ?
null : $user), array(), 0);
1300 $boxidactivatedforuser = array();
1301 foreach ($boxactivated as $box) {
1302 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1303 $boxidactivatedforuser[$box->id] = $box->id;
1306 if (!empty($box->lang)) {
1307 $langs->loadLangs(array($box->lang));
1308 $box->boxlabel = $langs->transnoentitiesnoconv($box->boxlabel);
1314 $arrayboxtoactivatelabel = array();
1317 $langs->load(
"boxes");
1318 foreach ($boxactivated as $box) {
1319 if (!empty($boxidactivatedforuser[$box->id])) {
1323 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1325 if (preg_match(
'/graph/', $box->class) &&
$conf->browser->layout !=
'phone') {
1326 $label .=
' <span class="fas fa-chart-bar"></span>';
1328 $arrayboxtoactivatelabel[$box->id] = array(
'label' => $label,
'data-html' => img_picto(
'', $box->boximg,
'class="pictofixedwidth valignmiddle"').
'<span class="valignmiddle">'.$langs->trans($label).
'</span>');
1330 foreach ($boxidactivatedforuser as $boxid) {
1331 if (empty($boxorder)) {
1334 $boxorder .= $boxid.
',';
1340 $widthforwidget =
'width200';
1341 $selectboxlist .=
'<!-- Form with select box list -->'.
"\n";
1342 $selectboxlist .=
'<form id="addbox" class="parentonrightofpage" name="addbox" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
1343 $selectboxlist .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1344 $selectboxlist .=
'<input type="hidden" name="addbox" value="addbox">';
1345 $selectboxlist .=
'<input type="hidden" name="userid" value="'.$user->id.
'">';
1346 $selectboxlist .=
'<input type="hidden" name="areacode" value="'.$areacode.
'">';
1347 $selectboxlist .=
'<input type="hidden" name="boxorder" value="'.$boxorder.
'">';
1348 $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);
1349 if (!empty(
$conf->use_javascript_ajax)) {
1350 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1351 $selectboxlist .=
ajax_combobox(
"boxcombo", array(), 0, 0,
'resolve',
'-1',
'onrightofpage '.$widthforwidget);
1353 if (empty(
$conf->use_javascript_ajax)) {
1354 $selectboxlist .=
' <input type="submit" class="button" value="'.$langs->trans(
"AddBox").
'">';
1356 $selectboxlist .=
'</form>';
1360 if (!empty(
$conf->use_javascript_ajax)) {
1361 $selectboxlist .=
'<script nonce="'.getNonce().
'" type="text/javascript">
1363 // To update list of activated boxes
1364 function updateBoxOrder(closing) {
1365 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1366 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1367 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1368 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
1371 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1374 // We force reload to be sure to get all boxes into list
1375 window.location.search=\'mainmenu='.
GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'&action=delbox&token='.
newToken().
'\';
1380 url: \
''.DOL_URL_ROOT.
'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.
'&userid=\'+'.$user->id.
',
1386 jQuery(document).ready(function() {
1387 jQuery("#boxcombo").change(function() {
1388 var boxid=jQuery("#boxcombo").val();
1390 console.log("A box widget has been selected for addition, we call ajax page to add it.")
1391 var left_list = cleanSerialize(jQuery("#boxhalfleft").sortable("serialize"));
1392 var right_list = cleanSerialize(jQuery("#boxhalfright").sortable("serialize"));
1393 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1395 url: \''.DOL_URL_ROOT.
'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.
'&userid='.$user->id.
'\'
1396 }).done(
function() {
1397 window.location.search=\
'mainmenu='.GETPOST(
"mainmenu",
"aZ09").
'&leftmenu='.
GETPOST(
'leftmenu',
"aZ09").
'\';
1401 if (!count($arrayboxtoactivatelabel)) {
1402 $selectboxlist .= 'jQuery(
"#boxcombo").hide();
';
1406 jQuery(
"#boxhalfleft, #boxhalfright").sortable({
1407 handle: \
'.boxhandle\',
1408 revert: \'invalid\',
1409 items: \'.boxdraggable\',
1410 containment: \'document\',
1411 connectWith: \'#boxhalfleft, #boxhalfright\',
1412 stop: function(event, ui) {
1413 console.log("We moved box so we call updateBoxOrder with ajax actions");
1414 updateBoxOrder(1); /* 1 to avoid message after a move */
1418 jQuery(".boxclose").click(function() {
1419 var self = this; // because JQuery can modify this
1420 var boxid = self.id.substring(8);
1422 var label = jQuery(\'#boxlabelentry\'+boxid).val();
1423 console.log("We close box "+boxid);
1424 jQuery(\'#boxto_\'+boxid).remove();
1425 jQuery(\'#boxcombo\').append(new Option(label, boxid));
1426 updateBoxOrder(1); /* 1 to avoid message after a remove */
1432 $selectboxlist .=
'</script>'.
"\n";
1438 $nbboxactivated = count($boxidactivatedforuser);
1440 if ($nbboxactivated) {
1442 $langs->loadLangs(array(
"boxes",
"projects"));
1446 $boxlista .=
"\n<!-- Box left container -->\n";
1452 foreach ($boxactivated as $key => $box) {
1453 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1456 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1457 $box->box_order =
'A'.sprintf(
"%02d", ($ii + 1));
1459 if (preg_match(
'/^A/i', $box->box_order)) {
1464 $box->loadBox($box_max_lines);
1465 $boxlista .= $box->showBox(
null,
null, 1);
1469 if (
$conf->browser->layout !=
'phone') {
1470 $emptybox->box_id =
'A';
1471 $emptybox->info_box_head = array();
1472 $emptybox->info_box_contents = array();
1473 $boxlista .= $emptybox->showBox(array(), array(), 1);
1475 $boxlista .=
"<!-- End box left container -->\n";
1477 $boxlistb .=
"\n<!-- Box right container -->\n";
1480 foreach ($boxactivated as $key => $box) {
1481 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1484 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1485 $box->box_order =
'B'.sprintf(
"%02d", ($ii + 1));
1487 if (preg_match(
'/^B/i', $box->box_order)) {
1492 $box->loadBox($box_max_lines);
1493 $boxlistb .= $box->showBox(
null,
null, 1);
1497 if (
$conf->browser->layout !=
'phone') {
1498 $emptybox->box_id =
'B';
1499 $emptybox->info_box_head = array();
1500 $emptybox->info_box_contents = array();
1501 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1504 $boxlistb .=
"<!-- End box right container -->\n";
1507 return array(
'selectboxlist' => count($boxactivated) ? $selectboxlist :
'',
'boxactivated' => $boxactivated,
'boxlista' => $boxlista,
'boxlistb' => $boxlistb);
1524 public function select_dictionary($htmlname, $dictionarytable, $keyfield =
'code', $labelfield =
'label', $selected =
'', $useempty = 0, $moreattrib =
'')
1529 $langs->load(
"admin");
1531 $sql =
"SELECT rowid, ".$this->db->sanitize($keyfield).
", ".$this->db->sanitize($labelfield);
1532 $sql .=
" FROM ".$this->db->prefix().$dictionarytable;
1533 $sql .= $this->db->order($labelfield);
1535 dol_syslog(get_class($this).
"::select_dictionary", LOG_DEBUG);
1536 $result = $this->db->query($sql);
1538 $num = $this->db->num_rows($result);
1541 print
'<select id="select'.$htmlname.
'" class="flat selectdictionary" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
1542 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
1543 print
'<option value="-1"> </option>';
1547 $obj = $this->db->fetch_object($result);
1548 if ($selected == $obj->rowid || $selected == $obj->{$keyfield}) {
1549 print
'<option value="'.$obj->{$keyfield}.
'" selected>';
1551 print
'<option value="'.$obj->{$keyfield}.
'">';
1553 $label = ($langs->trans($dictionarytable.$obj->{$keyfield}) != $dictionarytable.$obj->{$labelfield} ? $langs->trans($dictionarytable.$obj->{$keyfield}) : $obj->{$labelfield});
1560 print $langs->trans(
"DictionaryEmpty");
1563 dol_print_error($this->db);
1577 public function selectAutoManual($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0)
1581 $automatic =
"automatic";
1588 $disabled = ($disabled ?
' disabled' :
'');
1590 $resultautomanual =
'<select class="flat width100" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
1592 $resultautomanual .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
1594 if ((
"$value" ==
'automatic') || ($value == 1)) {
1595 $resultautomanual .=
'<option value="'.$automatic.
'" selected>'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1596 $resultautomanual .=
'<option value="'.$manual.
'">'.$langs->trans(
"Manual").
'</option>'.
"\n";
1598 $selected = (($useempty && $value !=
'0' && $value !=
'manual') ?
'' :
' selected');
1599 $resultautomanual .=
'<option value="'.$automatic.
'">'.$langs->trans(
"Automatic").
'</option>'.
"\n";
1600 $resultautomanual .=
'<option value="'.$manual.
'"'.$selected.
'>'.$langs->trans(
"Manual").
'</option>'.
"\n";
1602 $resultautomanual .=
'</select>'.
"\n";
1603 return $resultautomanual;
1621 $arrayofgroupbylabel = array();
1622 foreach ($arrayofgroupby as $key => $val) {
1623 $arrayofgroupbylabel[$key] = $val[
'label'];
1625 $result = $form->selectarray(
'search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
1644 $arrayofxaxislabel = array();
1645 foreach ($arrayofxaxis as $key => $val) {
1646 $arrayofxaxislabel[$key] = $val[
'label'];
1648 $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.
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.
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.