68 public function getHTMLScannerForm($jstoexecuteonadd =
'barcodescannerjs', $mode =
'all', $warehouseselect = 0)
74 $out .=
'<!-- Popup for mass barcode scanning -->'.
"\n";
75 $out .=
'<div class="div-for-modal-topright" style="padding: 15px">';
76 $out .=
'<center>'.img_picto(
'',
'barcode',
'class="pictofixedwidth"').
'<strong>Barcode scanner tool...</strong></center><br>';
78 if ($mode ==
'product') {
79 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct">';
80 } elseif ($mode ==
'lot') {
81 $out .=
'<input type="hidden" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial">';
83 $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>';
84 $out .=
'<input type="radio" name="barcodemode" value="barcodeforproduct" id="barcodeforproduct"> <label for="barcodeforproduct">Scan a product barcode</label><br>';
85 $out .=
'<input type="radio" name="barcodemode" value="barcodeforlotserial" id="barcodeforlotserial"> <label for="barcodeforlotserial">Scan a product lot or serial number</label><br>';
87 $stringaddbarcode = $langs->trans(
"QtyToAddAfterBarcodeScan",
"tmphtml");
88 $htmltoreplaceby =
'<select name="selectaddorreplace"><option selected value="add">'.$langs->trans(
"Add").
'</option><option value="replace">'.$langs->trans(
"ToReplace").
'</option></select>';
89 $stringaddbarcode = str_replace(
"tmphtml", $htmltoreplaceby, $stringaddbarcode);
90 $out .= $stringaddbarcode.
': <input type="text" name="barcodeproductqty" class="width40 right" value="1"><br>';
91 if ($warehouseselect > 0) {
92 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
94 $formproduct->loadWarehouses();
95 $out .=
img_picto(
'',
'stock',
'class="pictofixedwidth"');
96 $out .= $formproduct->selectWarehouses(
'',
"warehousenew",
'', 0, 0, 0,
'', 0, 1);
100 $out .=
'<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ScanOrTypeOrCopyPasteYourBarCodes")).
'"></textarea>';
110 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" id ="exec'.dol_escape_js($jstoexecuteonadd).
'" name="addscan" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
111 $out .=
'<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"CloseWindow")).
'">';
114 $out .=
'<div type="text" id="scantoolmessage" class="scantoolmessage ok nopadding"></div>';
116 $out .=
'<script nonce="'.getNonce().
'">';
117 $out .=
'jQuery("#barcodeforautodetect, #barcodeforproduct, #barcodeforlotserial").click(function(){';
118 $out .=
'console.log("select choice");';
119 $out .=
'jQuery("#scantoolmessage").text("");';
121 $out .=
'$("#exec'.dol_escape_js($jstoexecuteonadd).
'").click(function(){
122 console.log("We call js to execute \''.
dol_escape_js($jstoexecuteonadd).
'\'");
123 '.dol_escape_js($jstoexecuteonadd).'();
124 return false; /* We want to stay on the scan tool */
145 public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null)
148 global $conf, $langs, $user;
150 $sql = "SELECT
rowid, label, fk_user
";
151 $sql .= " FROM
".$this->db->prefix()."export_model
";
152 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
153 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
154 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
156 $sql .= " ORDER BY label
";
157 $result = $this->db->query($sql);
159 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
161 print '<option value="-1
"> </option>';
164 $tmpuser = new User($this->db);
166 $num = $this->db->num_rows($result);
169 $obj = $this->db->fetch_object($result);
171 $label = $obj->label;
172 if ($obj->fk_user == 0) {
173 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
174 } elseif ($obj->fk_user > 0) {
175 $tmpuser->fetch($obj->fk_user);
176 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
179 if ($selected == $obj->rowid) {
180 print '<option value="'.$obj->rowid.'" selected data-html="'.dol_escape_htmltag($label).'">';
182 print '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($label).'">';
189 print ajax_combobox($htmlname);
191 dol_print_error($this->db);
207 public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null)
210 global $conf, $langs, $user;
212 $sql = "SELECT
rowid, label, fk_user
";
213 $sql .= " FROM
".$this->db->prefix()."import_model
";
214 $sql .= " WHERE
type =
'".$this->db->escape($type)."'";
215 if (!getDolGlobalString('EXPORTS_SHARE_MODELS')) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner.
216 $sql .= " AND fk_user IN (0,
".((int) $fk_user).")
";
218 $sql .= " ORDER BY label
";
219 $result = $this->db->query($sql);
221 print '<select class="flat minwidth200
" name="'.$htmlname.'" id="'.$htmlname.'">';
223 print '<option value="-1
"> </option>';
226 $tmpuser = new User($this->db);
228 $num = $this->db->num_rows($result);
231 $obj = $this->db->fetch_object($result);
233 $label = $obj->label;
234 if ($obj->fk_user == 0) {
235 $label .= ' <span class="opacitymedium
">('.$langs->trans("Everybody
").')</span>';
236 } elseif ($obj->fk_user > 0) {
237 $tmpuser->fetch($obj->fk_user);
238 $label .= ' <span class="opacitymedium
">('.$tmpuser->getFullName($langs).')</span>';
241 if ($selected == $obj->rowid) {
242 print '<option value="'.$obj->rowid.'" selected data-html="'.dol_escape_htmltag($label).'">';
244 print '<option value="'.$obj->rowid.'" data-html="'.dol_escape_htmltag($label).'">';
251 print ajax_combobox($htmlname);
253 dol_print_error($this->db);
266 public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id')
271 $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,
";
272 $sql .= " c.label as country
";
273 $sql .= " FROM
".$this->db->prefix()."c_ecotaxe as e,
".$this->db->prefix()."c_country as c
";
274 $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid
";
275 $sql .= " ORDER BY country, e.organization ASC, e.code ASC
";
277 dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG);
278 $resql = $this->db->query($sql);
280 print '<select class="flat
" name="'.$htmlname.'">';
281 $num = $this->db->num_rows($resql);
283 print '<option value="-1
"> </option>'."\n
";
286 $obj = $this->db->fetch_object($resql);
287 if ($selected && $selected == $obj->rowid) {
288 print '<option value="'.$obj->rowid.'" selected>';
290 print '<option value="'.$obj->rowid.'">';
291 //print '<option onmouseover="showtip(\
''.$obj->label.
'\')
" onMouseout="hidetip()
" value="'.$obj->rowid.'">';
293 $selectOptionValue = $obj->code.' - '.$obj->label.' : '.price($obj->price).' '.$langs->trans("HT
").' ('.$obj->organization.')';
294 print $selectOptionValue;
302 dol_print_error($this->db);
317 public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '')
324 $sql = "SELECT r.taux, r.revenuestamp_type
";
325 $sql .= " FROM
".$this->db->prefix()."c_revenuestamp as r,
".$this->db->prefix()."c_country as c
";
326 $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid
";
327 $sql .= " AND c.code =
'".$this->db->escape($country_code)."'";
329 dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG);
330 $resql = $this->db->query($sql);
332 $out .= '<select class="flat
" name="'.$htmlname.'">';
333 $num = $this->db->num_rows($resql);
335 $out .= '<option value="0
"> </option>'."\n
";
338 $obj = $this->db->fetch_object($resql);
339 if (($selected && $selected == $obj->taux) || $num == 1) {
340 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').' selected>';
342 $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent
' ? '%
' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent
"' : '').'>';
344 $out .= $obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '');
352 dol_print_error($this->db);
371 public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0)
374 $return = '<select class="flat maxwidth75 right
" name="'.$htmlname.'" '.($disabled ? 'disabled' : '').'>';
376 $return .= '<option value="-1
"'.(($selected == -1 || $selected == '') ? ' selected' : '').'> </option>';
379 for ($i = $start; $i <= $end; $i += $increment) {
380 if ($selected != '' && (int) $selected == $i) {
381 $return .= '<option value="'.$i.'" selected>';
383 $return .= '<option value="'.$i.'">';
386 $return .= '</option>';
389 $return .= '</select>';
407 public function select_categories($type, $selected = 0, $htmlname = 'search_categ', $nocateg = 0, $showempty = 1, $morecss = '')
410 global $conf, $langs;
411 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
413 // For backward compatibility
414 if (is_numeric($type)) {
415 dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
418 // Load list of "categories
"
419 $static_categs = new Categorie($this->db);
420 $tab_categs = $static_categs->get_full_arbo($type);
424 // Print a select with each of them
425 $moreforfilter .= '<select class="flat minwidth100
'.($morecss ? ' '.$morecss : '').'" id="select_categ_
'.$htmlname.'" name="'.$htmlname.'">';
428 if (!empty($conf->use_javascript_ajax)) {
429 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
431 if (!is_numeric($showempty)) {
432 $textforempty = $showempty;
434 $moreforfilter .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '');
435 //$moreforfilter .= ' data-html="'.dol_escape_htmltag($textforempty).'"';
436 $moreforfilter .= '>'.dol_escape_htmltag($textforempty).'</option>'."\n
";
439 if (is_array($tab_categs)) {
440 foreach ($tab_categs as $categ) {
441 $moreforfilter .= '<option value="'.$categ['id'].'"';
442 if ($categ['id'] == $selected) {
443 $moreforfilter .= ' selected';
445 $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category
', 'class=
"pictofixedwidth" style=
"color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel
'], 50, 'middle
')).'"';
446 $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').'</option>';
450 $langs->load("categories
");
451 $moreforfilter .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NotCategorized
").' -</option>';
453 $moreforfilter .= '</select>';
455 // Enhance with select2
456 if ($conf->use_javascript_ajax) {
457 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
458 $comboenhancement = ajax_combobox('select_categ_'.$htmlname);
459 $moreforfilter .= $comboenhancement;
462 return $moreforfilter;
479 public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
482 global $conf, $langs, $hookmanager;
485 $langs->load('users');
489 $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action);
491 // Select each sales and print them in a select input
492 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
495 if (!is_numeric($showempty)) {
496 $textforempty = $showempty;
498 if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
499 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
501 $out .= '<option class="optiongrey
" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '').'>'.$textforempty.'</option>'."\n
";
504 // Get list of users allowed to be viewed
505 $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut as
status, u.login, u.photo, u.gender, u.entity, u.admin
";
506 $sql_usr .= " FROM
".$this->db->prefix()."user as u
";
508 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
509 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
510 $sql_usr .= " WHERE u.entity IS NOT NULL
"; // Show all users
512 $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')."))
";
513 $sql_usr .= " OR u.entity = 0
"; // Show always superadmin
516 $sql_usr .= " WHERE u.entity IN (
".getEntity('user').")
";
519 if (!$user->hasRight('user', 'user', 'lire')) {
520 $sql_usr .= " AND u.rowid =
".((int) $user->id);
522 if (!empty($user->socid)) {
523 $sql_usr .= " AND u.fk_soc =
".((int) $user->socid);
526 //Add hook to filter on user (for exemple on usergroup define in custom modules)
527 if (!empty($reshook)) {
528 $sql_usr .= $hookmanager->resArray[0];
531 // Add existing sales representatives of thirdparty of external user
532 if (!$user->hasRight('user', 'user', 'lire') && $user->socid) {
533 $sql_usr .= " UNION
";
534 $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut as
status, u2.login, u2.photo, u2.gender, u2.entity, u2.admin
";
535 $sql_usr .= " FROM
".$this->db->prefix()."user as u2,
".$this->db->prefix()."societe_commerciaux as sc
";
537 if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) {
538 if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
539 $sql_usr .= " WHERE u2.entity IS NOT NULL
"; // Show all users
541 $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')."))
";
544 $sql_usr .= " WHERE u2.entity IN (
".getEntity('user').")
";
547 $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc =
".((int) $user->socid);
549 //Add hook to filter on user (for exemple on usergroup define in custom modules)
550 if (!empty($reshook)) {
551 $sql_usr .= $hookmanager->resArray[1];
555 if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION')) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
556 $sql_usr .= " ORDER BY
status DESC, firstname ASC, lastname ASC
";
558 $sql_usr .= " ORDER BY
status DESC, lastname ASC, firstname ASC
";
560 //print $sql_usr;exit;
562 $resql_usr = $this->db->query($sql_usr);
564 $userstatic = new User($this->db);
566 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
567 $userstatic->id = $obj_usr->rowid;
568 $userstatic->lastname = $obj_usr->lastname;
569 $userstatic->firstname = $obj_usr->firstname;
570 $userstatic->photo = $obj_usr->photo;
571 $userstatic->statut = $obj_usr->status;
572 $userstatic->entity = $obj_usr->entity;
573 $userstatic->admin = $obj_usr->admin;
575 $labeltoshow = dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
576 if (empty($obj_usr->firstname) && empty($obj_usr->lastname)) {
577 $labeltoshow = $obj_usr->login;
580 $out .= '<option value="'.$obj_usr->rowid.'"';
581 if ($obj_usr->rowid == $selected) {
584 $out .= ' data-html="';
585 $outhtml = $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login
', '', 1).' ';
586 if ($showstatus >= 0 && $obj_usr->status == 0) {
587 $outhtml .= '<strike
class=
"opacitymediumxxx">
';
589 $outhtml .= $labeltoshow;
590 if ($showstatus >= 0 && $obj_usr->status == 0) {
591 $outhtml .= '</strike>
';
593 $out .= dol_escape_htmltag($outhtml);
596 $out .= $labeltoshow;
597 // Complete name with more info
599 if (getDolGlobalString('MAIN_SHOW_LOGIN')) {
600 $out .= ($moreinfo ? ' - ' : ' (').$obj_usr->login;
603 if ($showstatus >= 0) {
604 if ($obj_usr->status == 1 && $showstatus == 1) {
605 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
608 if ($obj_usr->status == 0) {
609 $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
613 $out .= ($moreinfo ? ')' : '');
616 $this->db->free($resql_usr);
618 dol_print_error($this->db);
621 if ($norepresentative) {
622 $langs->load("companies
");
623 $out .= '<option value="-2
"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NoSalesRepresentativeAffected
").' -</option>';
628 // Enhance with select2
629 if ($conf->use_javascript_ajax) {
630 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
632 $comboenhancement = ajax_combobox($htmlname);
633 if ($comboenhancement) {
634 $out .= $comboenhancement;
656 public function selectProjectTasks($selectedtask = '', $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '')
658 global $user, $langs;
660 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
662 //print $modeproject.'-'.$modetask;
663 $task = new Task($this->db);
664 $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus);
666 print '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
668 print '<option value="0
"> </option>';
672 $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
675 print ajax_combobox($htmlname);
677 print '<div class="warning
">'.$langs->trans("NoProject
").'</div>';
693 private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0)
695 global $langs, $user, $conf;
699 $numlines = count($lines);
700 for ($i = 0; $i < $numlines; $i++) {
701 if ($lines[$i]->fk_task_parent == $parent) {
702 //var_dump($selectedproject."--
".$selectedtask."--
".$lines[$i]->fk_project."_
".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines
704 // Break on a new project
705 if ($parent == 0) { // We are on a task at first level
706 if ($lines[$i]->fk_project != $lastprojectid) { // Break found on project
708 print '<option value="0
" disabled>----------</option>';
710 print '<option value="'.$lines[$i]->fk_project.'_0
"';
711 if ($selectedproject == $lines[$i]->fk_project) {
715 $labeltoshow = $lines[$i]->projectref;
716 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
717 if (empty($lines[$i]->public)) {
718 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
719 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
721 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
722 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
725 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
726 print '>'; // Project -> Task
730 $lastprojectid = $lines[$i]->fk_project;
735 $newdisablechildoftaskid = $disablechildoftaskid;
738 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
739 // Check if we must disable entry
741 if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_task_parent == $disablechildoftaskid))) {
743 if ($lines[$i]->fk_task_parent == $disablechildoftaskid) {
744 $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
748 print '<option value="'.$lines[$i]->fk_project.'_
'.$lines[$i]->id.'"';
749 if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) {
756 $labeltoshow = $lines[$i]->projectref;
757 //$labeltoshow .= ' '.$lines[$i]->projectlabel;
758 if (empty($lines[$i]->public)) {
759 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("PrivateProject
").')</span>';
760 $labeltoshow = img_picto($lines[$i]->projectlabel, 'project', 'class="pictofixedwidth
"').$labeltoshow;
762 //$labeltoshow .= ' <span class="opacitymedium
">('.$langs->trans("Visibility
").': '.$langs->trans("SharedProject
").')</span>';
763 $labeltoshow = img_picto($lines[$i]->projectlabel, 'projectpub', 'class="pictofixedwidth
"').$labeltoshow;
765 if ($lines[$i]->id) {
766 $labeltoshow .= ' > ';
768 for ($k = 0; $k < $level; $k++) {
769 $labeltoshow .= "
";
771 $labeltoshow .= $lines[$i]->ref.' '.$lines[$i]->label;
773 print ' data-html="'.dol_escape_htmltag($labeltoshow).'"';
781 if ($lines[$i]->id) {
782 $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
798 public static function showColor($color, $textifnotdefined = '')
801 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
802 if (colorIsLight($color)) {
806 $color = colorArrayToHex(colorStringToArray($color, array()), '');
809 return '<input type="text
" class="colorthumb
" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #
'.$textcolor.'; background-color: #
'.$color.'" value="'.$color.'">';
811 return $textifnotdefined;
828 public function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '')
831 print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
848 public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '', $morecss = '', $setpropertyonselect = '', $default = '')
850 // Deprecation warning
852 dol_syslog(__METHOD__.": form_name parameter is deprecated
", LOG_WARNING);
855 global $langs, $conf;
859 if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) {
860 // Case of selection of any color
861 $langs->load("other
");
862 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax) && !getDolGlobalInt('MAIN_USE_HTML5_COLOR_SELECTOR')) {
863 $out .= '<link rel="stylesheet
" media="screen
" type="text/css
" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css
" />';
864 $out .= '<script nonce="'.getNonce().'" type="text/javascript
" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/jpicker-1.1.6.js
"></script>';
865 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
866 jQuery(document).ready(function(){
867 var originalhex = null;
868 $(\'#colorpicker'.$prefix.'\').jPicker( {
870 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\', /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color
" if left null */
873 type: \'show\', /* effect used to show/hide an expandable picker. Acceptable values "slide
", "show
", "fade
" */
876 show: \'fast\', /* duration of "show
" effect. Acceptable values are "fast
", "slow
", or time in ms */
877 hide: \'fast\' /* duration of "hide
" effect. Acceptable values are "fast
", "slow
", or time in ms */
882 x: \'screenCenter\', /* acceptable values "left
", "center
", "right
", "screenCenter
", or relative px value */
883 y: \'center\' /* acceptable values "top
", "bottom
", "center
", or relative px value */
887 clientPath: \''.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/images/\',
888 picker: { file: \'../../../../../theme/common/colorpicker.png\', width: 14, height: 14 }
890 localization: // alter these to change the text presented by the picker (e.g. different language)
894 title: \''.dol_escape_js($langs->trans("SelectAColor
")).'\',
895 newColor: \''.dol_escape_js($langs->trans("New
")).'\',
896 currentColor: \''.dol_escape_js($langs->trans("Current
")).'\',
897 ok: \''.dol_escape_js($langs->trans("Validate")).'\',
898 cancel: \''.dol_escape_js($langs->trans("Cancel
")).'\'
902 function(color, context) { console.log("close color selector
"); },
903 function(color, context) { var hex = color.val(\'hex\'); console.log("new color selected in jpicker
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
904 if ($setpropertyonselect) {
905 $out .= 'if (originalhex == null) {';
906 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
907 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
909 $out .= 'if (hex != null) {';
910 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', \'#\'+hex);';
914 function(color, context) {
915 console.log("cancel selection of color
");';
916 if ($setpropertyonselect) {
917 $out .= 'if (originalhex != null) {
918 console.log("Restore old color
"+originalhex);
919 document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', originalhex);
927 $out .= '<input id="colorpicker
'.$prefix.'" name="'.$prefix.'" size="6
" maxlength="7
" class="flat valignmiddle
'.($morecss ? ' '.$morecss : '').'" type="text
" value="'.dol_escape_htmltag($set_color).'" />';
929 $color = ($set_color !== '' ? $set_color : ($default !== '' ? $default : 'FFFFFF'));
930 $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).'" />';
931 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
932 jQuery(document).ready(function(){
933 var originalhex = null;
934 jQuery("#colorpicker
'.$prefix.'").on(\'change\', function() {
935 var hex = jQuery("#colorpicker
'.$prefix.'").val();
936 console.log("new color selected in input color
"+hex+" setpropertyonselect=
'.dol_escape_js($setpropertyonselect).'");';
937 if ($setpropertyonselect) {
938 $out .= 'if (originalhex == null) {';
939 $out .= ' originalhex = getComputedStyle(document.querySelector(":root
")).getPropertyValue(\'--'.dol_escape_js($setpropertyonselect).'\');';
940 $out .= ' console.log("original color is saved into originalhex =
"+originalhex);';
942 $out .= 'if (hex != null) {';
943 $out .= ' document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', hex);';
952 // In most cases, this is not used. We used instead function with no specific list of colors
953 if (empty($conf->dol_use_jmobile) && !empty($conf->use_javascript_ajax)) {
954 $out .= '<link rel="stylesheet
" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css
" type="text/css
" media="screen
" />';
955 $out .= '<script nonce="'.getNonce().'" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.js
" type="text/javascript
"></script>';
956 $out .= '<script nonce="'.getNonce().'" type="text/javascript
">
957 jQuery(document).ready(function(){
958 jQuery(\'#colorpicker'.$prefix.'\').colorpicker({
966 $out .= '<select id="colorpicker
'.$prefix.'" class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$prefix.'">';
967 //print '<option value="-1
"> </option>';
968 foreach ($arrayofcolors as $val) {
969 $out .= '<option value="'.$val.'"';
970 if ($set_color == $val) {
973 $out .= '>'.$val.'</option>';
992 public function CreateColorIcon($color, $module, $name, $x = '12', $y = '12')
997 $file = $conf->$module->dir_temp.'/'.$name.'.png';
999 // We create temp directory
1000 if (!file_exists($conf->$module->dir_temp)) {
1001 dol_mkdir($conf->$module->dir_temp);
1004 // On cree l'image en vraies couleurs
1005 $image = imagecreatetruecolor($x, $y);
1007 $color = substr($color, 1, 6);
1009 $rouge = hexdec(substr($color, 0, 2)); //conversion du canal rouge
1010 $vert = hexdec(substr($color, 2, 2)); //conversion du canal vert
1011 $bleu = hexdec(substr($color, 4, 2)); //conversion du canal bleu
1013 $couleur = imagecolorallocate($image, $rouge, $vert, $bleu);
1014 //print $rouge.$vert.$bleu;
1015 imagefill($image, 0, 0, $couleur); //on remplit l'image
1016 // On cree la couleur et on l'attribue a une variable pour ne pas la perdre
1017 ImagePng($image, $file); //renvoie une image sous format png
1018 ImageDestroy($image);
1077 public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false)
1082 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
1085 $montharray = monthArray($langs, 0); // Get array
1087 $montharray = monthArray($langs, 1);
1090 $select_month = '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
1092 $select_month .= '<option value="0
"> </option>';
1094 foreach ($montharray as $key => $val) {
1095 if ($selected == $key) {
1096 $select_month .= '<option value="'.$key.'" selected>';
1098 $select_month .= '<option value="'.$key.'">';
1100 $select_month .= $val;
1101 $select_month .= '</option>';
1103 $select_month .= '</select>';
1105 // Add code for jquery to use multiselect
1107 // Enhance with select2
1108 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1109 $select_month .= ajax_combobox($htmlname);
1112 return $select_month;
1132 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)
1135 print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo);
1153 public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false)
1157 $currentyear = date("Y
") + $offset;
1158 $max_year = $currentyear + $max_year;
1159 $min_year = $currentyear - $min_year;
1160 if (empty($selected) && empty($useempty)) {
1161 $selected = $currentyear;
1164 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$option.' >';
1166 $selected_html = '';
1167 if ($selected == '') {
1168 $selected_html = ' selected';
1170 $out .= '<option value=""'.$selected_html.'> </option>';
1173 for ($y = $max_year; $y >= $min_year; $y--) {
1174 $selected_html = '';
1175 if ($selected > 0 && $y == $selected) {
1176 $selected_html = ' selected';
1178 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1181 for ($y = $min_year; $y <= $max_year; $y++) {
1182 $selected_html = '';
1183 if ($selected > 0 && $y == $selected) {
1184 $selected_html = ' selected';
1186 $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
1189 $out .= "</select>\n
";
1191 // Add code for jquery to use multiselect
1193 // Enhance with select2
1194 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1195 $out .= ajax_combobox($htmlname);
1210 public static function getBoxesArea($user, $areacode)
1212 global $conf, $langs, $db;
1214 include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
1216 $confuserzone = 'MAIN_BOXES_'.$areacode;
1218 // $boxactivated will be array of boxes enabled into global setup
1219 // $boxidactivatedforuser will be array of boxes choosed by user
1221 $selectboxlist = '';
1222 $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)
1224 $boxidactivatedforuser = array();
1225 foreach ($boxactivated as $box) {
1226 if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1227 $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user
1231 // Define selectboxlist
1232 $arrayboxtoactivatelabel = array();
1233 if (!empty($user->conf->$confuserzone)) {
1235 $langs->load("boxes
"); // Load label of boxes
1236 foreach ($boxactivated as $box) {
1237 if (!empty($boxidactivatedforuser[$box->id])) {
1238 continue; // Already visible for user
1240 $label = $langs->transnoentitiesnoconv($box->boxlabel);
1241 //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph
").')';
1242 if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') {
1243 $label = $label.' <span class="fas fa-chart-bar
"></span>';
1245 $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
1247 foreach ($boxidactivatedforuser as $boxid) {
1248 if (empty($boxorder)) {
1251 $boxorder .= $boxid.',';
1254 //var_dump($boxidactivatedforuser);
1256 // Class Form must have been already loaded
1257 $selectboxlist .= '<!-- Form with select box list -->'."\n
";
1258 $selectboxlist .= '<form id="addbox
" name="addbox
" method="POST
" action="'.$_SERVER["PHP_SELF"].'">';
1259 $selectboxlist .= '<input type="hidden
" name="token
" value="'.newToken().'">';
1260 $selectboxlist .= '<input type="hidden
" name="addbox
" value="addbox
">';
1261 $selectboxlist .= '<input type="hidden
" name="userid
" value="'.$user->id.'">';
1262 $selectboxlist .= '<input type="hidden
" name="areacode
" value="'.$areacode.'">';
1263 $selectboxlist .= '<input type="hidden
" name="boxorder
" value="'.$boxorder.'">';
1264 $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd
").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone hideonprint', 0, 'hidden selected', 0, 0);
1265 if (empty($conf->use_javascript_ajax)) {
1266 $selectboxlist .= ' <input type="submit
" class="button" value="'.$langs->trans("AddBox").'">';
1268 $selectboxlist .= '</form>';
1269 if (!empty($conf->use_javascript_ajax)) {
1270 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1271 $selectboxlist .= ajax_combobox("boxcombo
");
1275 // Javascript code for dynamic actions
1276 if (!empty($conf->use_javascript_ajax)) {
1277 $selectboxlist .= '<script nonce="'.getNonce().'" type="text/javascript
">
1279 // To update list of activated boxes
1280 function updateBoxOrder(closing) {
1281 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1282 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1283 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1284 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
1287 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1290 // We force reload to be sure to get all boxes into list
1291 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'&action=delbox&token='.newToken().'\';
1296 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=\'+closing+\'&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
1302 jQuery(document).ready(function() {
1303 jQuery("#boxcombo
").change(function() {
1304 var boxid=jQuery("#boxcombo
").val();
1306 console.log("A box widget has been selected
for addition, we call ajax page to add it.
")
1307 var left_list = cleanSerialize(jQuery("#boxhalfleft
").sortable("serialize
"));
1308 var right_list = cleanSerialize(jQuery("#boxhalfright
").sortable("serialize
"));
1309 var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
1311 url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\'
1312 }).done(function() {
1313 window.location.search=\'mainmenu='.GETPOST("mainmenu
", "aZ09
").'&leftmenu='.GETPOST('leftmenu', "aZ09
").'\';
1317 if (!count($arrayboxtoactivatelabel)) {
1318 $selectboxlist .= 'jQuery("#boxcombo
").hide();';
1322 jQuery("#boxhalfleft, #boxhalfright
").sortable({
1323 handle: \'.boxhandle\',
1324 revert: \'invalid\',
1325 items: \'.boxdraggable\',
1326 containment: \'document\',
1327 connectWith: \'#boxhalfleft, #boxhalfright\',
1328 stop: function(event, ui) {
1329 console.log("We moved box so we call updateBoxOrder with ajax actions
");
1330 updateBoxOrder(1); /* 1 to avoid message after a move */
1334 jQuery(".boxclose
").click(function() {
1335 var self = this; // because JQuery can modify this
1336 var boxid = self.id.substring(8);
1338 var label = jQuery(\'#boxlabelentry\'+boxid).val();
1339 console.log("We close box
"+boxid);
1340 jQuery(\'#boxto_\'+boxid).remove();
1341 jQuery(\'#boxcombo\').append(new Option(label, boxid));
1342 updateBoxOrder(1); /* 1 to avoid message after a remove */
1348 $selectboxlist .= '</script>'."\n
";
1351 // Define boxlista and boxlistb
1354 $nbboxactivated = count($boxidactivatedforuser);
1356 if ($nbboxactivated) {
1357 // Load translation files required by the page
1358 $langs->loadLangs(array("boxes
", "projects
"));
1360 $emptybox = new ModeleBoxes($db);
1362 $boxlista .= "\n<!-- Box left container -->\n
";
1364 // Define $box_max_lines
1366 if (getDolGlobalString('MAIN_BOXES_MAXLINES')) {
1367 $box_max_lines = $conf->global->MAIN_BOXES_MAXLINES;
1371 foreach ($boxactivated as $key => $box) {
1372 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1375 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1376 $box->box_order = 'A'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1378 if (preg_match('/^A/i', $box->box_order)) { // column A
1380 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1381 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1383 $box->loadBox($box_max_lines);
1384 $boxlista .= $box->showBox(null, null, 1);
1388 if ($conf->browser->layout != 'phone') {
1389 $emptybox->box_id = 'A';
1390 $emptybox->info_box_head = array();
1391 $emptybox->info_box_contents = array();
1392 $boxlista .= $emptybox->showBox(array(), array(), 1);
1394 $boxlista .= "<!-- End box left container -->\n
";
1396 $boxlistb .= "\n<!-- Box right container -->\n
";
1399 foreach ($boxactivated as $key => $box) {
1400 if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1403 if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1404 $box->box_order = 'B'.sprintf("%02d
", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0
1406 if (preg_match('/^B/i', $box->box_order)) { // colonne B
1408 //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1409 //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1411 $box->loadBox($box_max_lines);
1412 $boxlistb .= $box->showBox(null, null, 1);
1416 if ($conf->browser->layout != 'phone') {
1417 $emptybox->box_id = 'B';
1418 $emptybox->info_box_head = array();
1419 $emptybox->info_box_contents = array();
1420 $boxlistb .= $emptybox->showBox(array(), array(), 1);
1423 $boxlistb .= "<!-- End box right container -->\n
";
1426 return array('selectboxlist'=>count($boxactivated) ? $selectboxlist : '', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb);
1536 public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1')
1538 global $langs, $extrafields, $form;
1540 $arrayofgroupbylabel = array();
1541 foreach ($arrayofgroupby as $key => $val) {
1542 $arrayofgroupbylabel[$key] = $val['label'];
1544 $result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
1559 public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1', $morecss = 'minwidth250 maxwidth500')
1563 $arrayofxaxislabel = array();
1564 foreach ($arrayofxaxis as $key => $val) {
1565 $arrayofxaxislabel[$key] = $val['label'];
1567 $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);