dolibarr  13.0.2
html.formprojet.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2013 Florian Henry <florian.henry@open-concept.pro>
3  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
4  * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
31 {
35  public $db;
36 
40  public $error = '';
41 
42 
48  public function __construct($db)
49  {
50  $this->db = $db;
51  }
52 
53  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
74  public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '')
75  {
76  // phpcs:enable
77  global $langs, $conf, $form;
78 
79  $out = '';
80 
81  if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
82  {
83  $placeholder = '';
84 
85  if ($selected && empty($selected_input_value))
86  {
87  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
88  $project = new Project($this->db);
89  $project->fetch($selected);
90  $selected_input_value = $project->ref;
91  }
92  $urloption = 'socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed;
93  $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
94  // 'update' => array(
95  // 'projectid' => 'id'
96  // )
97  ));
98 
99  $out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
100  } else {
101  $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
102  }
103  if ($discard_closed > 0)
104  {
105  if (class_exists('Form'))
106  {
107  if (!is_object($form)) $form = new Form($this->db);
108  $out .= $form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
109  }
110  }
111 
112  if (empty($nooutput))
113  {
114  print $out;
115  return '';
116  } else return $out;
117  }
118 
119  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
140  public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500')
141  {
142  // phpcs:enable
143  global $user, $conf, $langs;
144 
145  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
146 
147  if (empty($htmlid)) $htmlid = $htmlname;
148 
149  $out = '';
150  $outarray = array();
151 
152  $hideunselectables = false;
153  if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
154 
155  $projectsListId = false;
156  if (empty($user->rights->projet->all->lire))
157  {
158  $projectstatic = new Project($this->db);
159  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
160  }
161 
162  // Search all projects
163  $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias';
164  $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
165  $sql .= " WHERE p.entity IN (".getEntity('project').")";
166  if ($projectsListId !== false) $sql .= " AND p.rowid IN (".$projectsListId.")";
167  if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
168  if ($socid > 0)
169  {
170  if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
171  elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
172  {
173  $sql .= " AND (p.fk_soc IN (".$socid.", ".((int) $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") OR p.fk_soc IS NULL)";
174  }
175  }
176  if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
177  $sql .= " ORDER BY p.ref ASC";
178 
179  $resql = $this->db->query($sql);
180  if ($resql)
181  {
182  // Use select2 selector
183  if (!empty($conf->use_javascript_ajax))
184  {
185  include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
186  $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
187  $out .= $comboenhancement;
188  $morecss .= ' minwidth100';
189  }
190 
191  if (empty($option_only)) {
192  $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">';
193  }
194  if (!empty($show_empty)) {
195  $out .= '<option value="0">&nbsp;</option>';
196  }
197  $num = $this->db->num_rows($resql);
198  $i = 0;
199  if ($num)
200  {
201  while ($i < $num)
202  {
203  $obj = $this->db->fetch_object($resql);
204  // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
205  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire)
206  {
207  // Do nothing
208  } else {
209  if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) // We discard closed except if selected
210  {
211  $i++;
212  continue;
213  }
214 
215  $labeltoshow = dol_trunc($obj->ref, 18);
216  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
217  //else $labeltoshow.=' ('.$langs->trans("Private").')';
218  $labeltoshow .= ', '.dol_trunc($obj->title, $maxlength);
219  if ($obj->name)
220  {
221  $labeltoshow .= ' - '.$obj->name;
222  if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')';
223  }
224 
225  $disabled = 0;
226  if ($obj->fk_statut == 0)
227  {
228  $disabled = 1;
229  $labeltoshow .= ' - '.$langs->trans("Draft");
230  } elseif ($obj->fk_statut == 2)
231  {
232  if ($discard_closed == 2) $disabled = 1;
233  $labeltoshow .= ' - '.$langs->trans("Closed");
234  } elseif (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
235  {
236  $disabled = 1;
237  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
238  }
239 
240  if (!empty($selected) && $selected == $obj->rowid)
241  {
242  $out .= '<option value="'.$obj->rowid.'" selected';
243  //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
244  $out .= '>'.$labeltoshow.'</option>';
245  } else {
246  if ($hideunselectables && $disabled && ($selected != $obj->rowid))
247  {
248  $resultat = '';
249  } else {
250  $resultat = '<option value="'.$obj->rowid.'"';
251  if ($disabled) $resultat .= ' disabled';
252  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
253  //else $labeltoshow.=' ('.$langs->trans("Private").')';
254  $resultat .= '>';
255  $resultat .= $labeltoshow;
256  $resultat .= '</option>';
257  }
258  $out .= $resultat;
259 
260  $outarray[] = array(
261  'key' => (int) $obj->rowid,
262  'value' => $obj->ref,
263  'ref' => $obj->ref,
264  'labelx' => $labeltoshow,
265  'label' => ((bool) $disabled) ? '<span class="opacitymedium">'.$labeltoshow.'</span>' : $labeltoshow,
266  'disabled' => (bool) $disabled
267  );
268  }
269  }
270  $i++;
271  }
272  }
273 
274  $this->db->free($resql);
275 
276  if (!$mode) {
277  if (empty($option_only)) $out .= '</select>';
278  if (empty($nooutput))
279  {
280  print $out;
281  return '';
282  } else return $out;
283  } else {
284  return $outarray;
285  }
286  } else {
287  dol_print_error($this->db);
288  return -1;
289  }
290  }
291 
310  public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
311  {
312  global $user, $conf, $langs;
313 
314  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
315 
316  if (is_null($usertofilter))
317  {
318  $usertofilter = $user;
319  }
320 
321  $out = '';
322 
323  $hideunselectables = false;
324  if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
325 
326  if (empty($projectsListId))
327  {
328  if (empty($usertofilter->rights->projet->all->lire))
329  {
330  $projectstatic = new Project($this->db);
331  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
332  }
333  }
334 
335  // Search all projects
336  $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,';
337  $sql .= ' s.nom as name';
338  $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
339  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,';
340  $sql .= ' '.MAIN_DB_PREFIX.'projet_task as t';
341  $sql .= " WHERE p.entity IN (".getEntity('project').")";
342  $sql .= " AND t.fk_projet = p.rowid";
343  if ($projectsListId) $sql .= " AND p.rowid IN (".$projectsListId.")";
344  if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
345  if ($socid > 0) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
346  $sql .= " ORDER BY p.ref, t.ref ASC";
347 
348  $resql = $this->db->query($sql);
349  if ($resql)
350  {
351  // Use select2 selector
352  if (empty($option_only) && !empty($conf->use_javascript_ajax))
353  {
354  include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
355  $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
356  $out .= $comboenhancement;
357  $morecss = 'minwidth200 maxwidth500';
358  }
359 
360  if (empty($option_only)) {
361  $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlname.'" name="'.$htmlname.'">';
362  }
363  if (!empty($show_empty)) {
364  $out .= '<option value="0" class="optiongrey">';
365  if (!is_numeric($show_empty)) {
366  //if (! empty($conf->use_javascript_ajax)) $out .= '<span class="opacitymedium">aaa';
367  $out .= $show_empty;
368  //if (! empty($conf->use_javascript_ajax)) $out .= '</span>';
369  } else $out .= '&nbsp;';
370  $out .= '</option>';
371  }
372 
373  $num = $this->db->num_rows($resql);
374  $i = 0;
375  if ($num)
376  {
377  while ($i < $num)
378  {
379  $obj = $this->db->fetch_object($resql);
380  // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
381  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire))
382  {
383  // Do nothing
384  } else {
385  if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED)
386  {
387  $i++;
388  continue;
389  }
390 
391  $labeltoshow = ''; $titletoshow = '';
392 
393  $disabled = 0;
394  if ($obj->fk_statut == Project::STATUS_DRAFT)
395  {
396  $disabled = 1;
397  } elseif ($obj->fk_statut == Project::STATUS_CLOSED)
398  {
399  if ($discard_closed == 2) $disabled = 1;
400  } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
401  {
402  $disabled = 1;
403  }
404 
405  if ($showproject == 'all')
406  {
407  $labeltoshow .= dol_trunc($obj->ref, 18); // Project ref
408  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
409  //else $labeltoshow.=' ('.$langs->trans("Private").')';
410  $labeltoshow .= ' '.dol_trunc($obj->title, $maxlength);
411  $titletoshow = $labeltoshow;
412 
413  if ($obj->name) {
414  $labeltoshow .= ' ('.$obj->name.')';
415  $titletoshow .= ' <span class="opacitymedium">('.$obj->name.')</span>';
416  }
417 
418  $disabled = 0;
419  if ($obj->fk_statut == Project::STATUS_DRAFT) {
420  $disabled = 1;
421  $labeltoshow .= ' - '.$langs->trans("Draft");
422  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Draft").'</span>';
423  } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
424  if ($discard_closed == 2) $disabled = 1;
425  $labeltoshow .= ' - '.$langs->trans("Closed");
426  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Closed").'</span>';
427  } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
428  $disabled = 1;
429  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
430  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("LinkedToAnotherCompany").'</span>';
431  }
432  $labeltoshow .= ' - ';
433  $titletoshow .= ' - ';
434  }
435 
436  // Label for task
437  $labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
438  $titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
439 
440  if (!empty($selected) && $selected == $obj->rowid)
441  {
442  $out .= '<option value="'.$obj->rowid.'" selected';
443  $out .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
444  //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
445  $out .= '>'.$labeltoshow.'</option>';
446  } else {
447  if ($hideunselectables && $disabled && ($selected != $obj->rowid))
448  {
449  $resultat = '';
450  } else {
451  $resultat = '<option value="'.$obj->rowid.'"';
452  if ($disabled) $resultat .= ' disabled';
453  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
454  //else $labeltoshow.=' ('.$langs->trans("Private").')';
455  $resultat .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
456  $resultat .= '>';
457  $resultat .= $labeltoshow;
458  $resultat .= '</option>';
459  }
460  $out .= $resultat;
461  }
462  }
463  $i++;
464  }
465  }
466  if (empty($option_only)) {
467  $out .= '</select>';
468  }
469 
470  print $out;
471 
472  $this->db->free($resql);
473  return $num;
474  } else {
475  dol_print_error($this->db);
476  return -1;
477  }
478  }
479 
480 
481  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
492  public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet")
493  {
494  // phpcs:enable
495  global $conf, $langs;
496 
497  if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
498 
499  $linkedtothirdparty = false;
500  if (!in_array($table_element, array('don', 'expensereport_det', 'expensereport', 'loan', 'stock_mouvement', 'payment_salary', 'payment_various', 'chargesociales'))) $linkedtothirdparty = true;
501 
502  $sqlfilter = '';
503 
504  //print $table_element;
505  switch ($table_element)
506  {
507  case "loan":
508  $sql = "SELECT t.rowid, t.label as ref";
509  break;
510  case "facture":
511  $sql = "SELECT t.rowid, t.ref as ref";
512  break;
513  case "facture_fourn":
514  $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
515  break;
516  case "commande_fourn":
517  case "commande_fournisseur":
518  $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
519  break;
520  case "facture_rec":
521  $sql = "SELECT t.rowid, t.titre as ref";
522  break;
523  case "actioncomm":
524  $sql = "SELECT t.id as rowid, t.label as ref";
525  $projectkey = "fk_project";
526  break;
527  case "expensereport":
528  return '';
529  case "expensereport_det":
530  /*$sql = "SELECT rowid, '' as ref"; // table is llx_expensereport_det
531  $projectkey="fk_projet";
532  break;*/
533  return '';
534  case "commande":
535  case "contrat":
536  case "fichinter":
537  $sql = "SELECT t.rowid, t.ref";
538  break;
539  case 'stock_mouvement':
540  $sql = 'SELECT t.rowid, t.label as ref';
541  $projectkey = 'fk_origin';
542  break;
543  case "payment_salary":
544  $sql = "SELECT t.rowid, t.num_payment as ref"; // TODO In a future fill and use real ref field
545  break;
546  case "payment_various":
547  $sql = "SELECT t.rowid, t.num_payment as ref";
548  break;
549  case "chargesociales":
550  default:
551  $sql = "SELECT t.rowid, t.ref";
552  break;
553  }
554  if ($linkedtothirdparty) $sql .= ", s.nom as name";
555  $sql .= " FROM ".MAIN_DB_PREFIX.$table_element." as t";
556  if ($linkedtothirdparty) $sql .= ", ".MAIN_DB_PREFIX."societe as s";
557  $sql .= " WHERE ".$projectkey." is null";
558  if (!empty($socid) && $linkedtothirdparty)
559  {
560  if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid;
561  else $sql .= " AND t.fk_soc IN (".$socid.")";
562  }
563  if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) $sql .= ' AND t.entity IN ('.getEntity('project').')';
564  if ($linkedtothirdparty) $sql .= " AND s.rowid = t.fk_soc";
565  if ($sqlfilter) $sql .= " AND ".$sqlfilter;
566  $sql .= " ORDER BY ref DESC";
567 
568  dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
569  $resql = $this->db->query($sql);
570  if ($resql)
571  {
572  $num = $this->db->num_rows($resql);
573  $i = 0;
574  if ($num > 0)
575  {
576  $sellist = '<select class="flat elementselect css'.$table_element.($morecss ? ' '.$morecss : '').'" name="elementselect">';
577  $sellist .= '<option value="-1"></option>';
578  while ($i < $num)
579  {
580  $obj = $this->db->fetch_object($resql);
581  $ref = $obj->ref ? $obj->ref : $obj->rowid;
582  if (!empty($obj->ref_supplier)) $ref .= ' ('.$obj->ref_supplier.')';
583  if (!empty($obj->name)) $ref .= ' - '.$obj->name;
584  $sellist .= '<option value="'.$obj->rowid.'">'.$ref.'</option>';
585  $i++;
586  }
587  $sellist .= '</select>';
588  }
589  /*else
590  {
591  $sellist = '<select class="flat" name="elementselect">';
592  $sellist.= '<option value="0" disabled>'.$langs->trans("None").'</option>';
593  $sellist.= '</select>';
594  }*/
595  $this->db->free($resql);
596 
597  return $sellist;
598  } else {
599  dol_print_error($this->db);
600  $this->error = $this->db->lasterror();
601  $this->errors[] = $this->db->lasterror();
602  dol_syslog(get_class($this)."::select_element ".$this->error, LOG_ERR);
603  return -1;
604  }
605  }
606 
607 
622  public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0)
623  {
624  global $conf, $langs, $user;
625 
626  $sql = "SELECT rowid, code, label, percent";
627  $sql .= " FROM ".MAIN_DB_PREFIX.'c_lead_status';
628  $sql .= " WHERE active = 1";
629  $sql .= " ORDER BY position";
630 
631  $resql = $this->db->query($sql);
632  if ($resql)
633  {
634  $num = $this->db->num_rows($resql);
635  $i = 0;
636  if ($num > 0)
637  {
638  $sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
639  if ($showempty) {
640  // Without &nbsp, strange move of screen when switching value
641  $sellist .= '<option value="-1">&nbsp;</option>';
642  }
643  if ($showallnone) {
644  $sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").' --</option>';
645  $sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").' --</option>';
646  $sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").' --</option>';
647  $sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").' --</option>';
648  }
649  while ($i < $num)
650  {
651  $obj = $this->db->fetch_object($resql);
652 
653  $sellist .= '<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"';
654  if ($obj->rowid == $preselected) $sellist .= ' selected="selected"';
655  $sellist .= '>';
656  if ($useshortlabel)
657  {
658  $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
659  } else {
660  $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
661  if ($showpercent) $finallabel .= ' ('.$obj->percent.'%)';
662  }
663  $sellist .= $finallabel;
664  $sellist .= '</option>';
665  $i++;
666  }
667  $sellist .= '</select>';
668 
669  if ($user->admin && !$noadmininfo) $sellist .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
670 
671  if ($addcombojs) $sellist .= ajax_combobox($htmlname);
672  }
673  /*else
674  {
675  $sellist = '<select class="flat" name="elementselect">';
676  $sellist.= '<option value="0" disabled>'.$langs->trans("None").'</option>';
677  $sellist.= '</select>';
678  }*/
679  $this->db->free($resql);
680 
681  return $sellist;
682  } else {
683  $this->error = $this->db->lasterror();
684  $this->errors[] = $this->db->lasterror();
685  dol_syslog(get_class($this)."::selectOpportunityStatus ".$this->error, LOG_ERR);
686  return -1;
687  }
688  }
689 }
ajax_autocompleter($selected, $htmlname, $url, $urloption= '', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams= '')
Generic function that return javascript to add to a page to transform a common input field into an au...
Definition: ajax.lib.php:47
selectOpportunityStatus($htmlname, $preselected= '-1', $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0, $morecss= '', $noadmininfo=0, $addcombojs=0)
Build a HTML select list of element of same thirdparty to suggest to link them to project...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
__construct($db)
Constructor.
const STATUS_CLOSED
Closed status.
select_element($table_element, $socid=0, $morecss= '', $limitonstatus=-2, $projectkey="fk_projet")
Build a HTML select list of element of same thirdparty to suggest to link them to project...
$conf db
API class for accounts.
Definition: inc.php:54
select_projects_list($socid=-1, $selected= '', $htmlname= 'projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey= '', $nooutput=0, $forceaddid=0, $htmlid= '', $morecss= 'maxwidth500')
Returns an array with projects qualified for a third party.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage building of HTML components.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
selectTasks($socid=-1, $selected= '', $htmlname= 'taskid', $maxlength=24, $option_only=0, $show_empty= '1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss= 'maxwidth500', $projectsListId= '', $showproject= 'all', $usertofilter=null)
Output a combo list with tasks qualified for a third party.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
select_projects($socid=-1, $selected= '', $htmlname= 'projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey= '', $nooutput=0, $forceaddid=0, $morecss= '', $htmlid= '')
Output a combo list with projects qualified for a third party / user.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
const STATUS_DRAFT
Draft status.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.