dolibarr  16.0.5
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  public $nboftasks;
43 
44 
50  public function __construct($db)
51  {
52  $this->db = $db;
53  }
54 
55  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
76  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 = '')
77  {
78  // phpcs:enable
79  global $langs, $conf, $form;
80 
81  $selected_input_value = '';
82  if (is_object($selected)) {
83  $selected_input_value = $selected->ref;
84  $selected = $selected->id;
85  }
86 
87  $out = '';
88 
89  if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
90  $placeholder = '';
91 
92  if ($selected && empty($selected_input_value)) {
93  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
94  $project = new Project($this->db);
95  $project->fetch($selected);
96  $selected_input_value = $project->ref;
97  }
98  $urloption = 'socid='.((int) $socid).'&htmlname='.urlencode($htmlname).'&discardclosed='.((int) $discard_closed);
99 
100  $out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
101 
102  $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
103  // 'update' => array(
104  // 'projectid' => 'id'
105  // )
106  ));
107  } else {
108  $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
109  }
110  if ($discard_closed > 0) {
111  if (!empty($form)) {
112  $out .= $form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
113  }
114  }
115 
116  if (empty($nooutput)) {
117  print $out;
118  return '';
119  } else {
120  return $out;
121  }
122  }
123 
124  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
145  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')
146  {
147  // phpcs:enable
148  global $user, $conf, $langs;
149 
150  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
151 
152  if (empty($htmlid)) {
153  $htmlid = $htmlname;
154  }
155 
156  $out = '';
157  $outarray = array();
158 
159  $hideunselectables = false;
160  if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
161  $hideunselectables = true;
162  }
163 
164  $projectsListId = false;
165  if (empty($user->rights->projet->all->lire)) {
166  $projectstatic = new Project($this->db);
167  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
168  }
169 
170  // Search all projects
171  $sql = "SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias";
172  $sql .= " FROM ".$this->db->prefix()."projet as p LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc";
173  $sql .= " WHERE p.entity IN (".getEntity('project').")";
174  if ($projectsListId !== false) {
175  $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
176  }
177  if ($socid == 0) {
178  $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
179  }
180  if ($socid > 0) {
181  if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) {
182  $sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
183  } 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.
184  $sql .= " AND (p.fk_soc IN (".$this->db->sanitize(((int) $socid).", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") OR p.fk_soc IS NULL)";
185  }
186  }
187  if (!empty($filterkey)) {
188  $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
189  }
190  $sql .= " ORDER BY p.ref ASC";
191 
192  $resql = $this->db->query($sql);
193  if ($resql) {
194  if (!empty($conf->use_javascript_ajax)) {
195  $morecss .= ' minwidth100';
196  }
197  if (empty($option_only)) {
198  $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">';
199  }
200  if (!empty($show_empty)) {
201  $out .= '<option value="0">&nbsp;</option>';
202  }
203  $num = $this->db->num_rows($resql);
204  $i = 0;
205  if ($num) {
206  while ($i < $num) {
207  $obj = $this->db->fetch_object($resql);
208  // 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.
209  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) {
210  // Do nothing
211  } else {
212  if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) { // We discard closed except if selected
213  $i++;
214  continue;
215  }
216 
217  $labeltoshow = dol_trunc($obj->ref, 18);
218  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
219  //else $labeltoshow.=' ('.$langs->trans("Private").')';
220  $labeltoshow .= ', '.dol_trunc($obj->title, $maxlength);
221  if ($obj->name) {
222  $labeltoshow .= ' - '.$obj->name;
223  if ($obj->name_alias) {
224  $labeltoshow .= ' ('.$obj->name_alias.')';
225  }
226  }
227 
228  $disabled = 0;
229  if ($obj->fk_statut == 0) {
230  $disabled = 1;
231  $labeltoshow .= ' - '.$langs->trans("Draft");
232  } elseif ($obj->fk_statut == 2) {
233  if ($discard_closed == 2) {
234  $disabled = 1;
235  }
236  $labeltoshow .= ' - '.$langs->trans("Closed");
237  } elseif (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
238  $disabled = 1;
239  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
240  }
241 
242  if (!empty($selected) && $selected == $obj->rowid) {
243  $out .= '<option value="'.$obj->rowid.'" selected';
244  //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
245  $out .= '>'.$labeltoshow.'</option>';
246  } else {
247  if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
248  $resultat = '';
249  } else {
250  $resultat = '<option value="'.$obj->rowid.'"';
251  if ($disabled) {
252  $resultat .= ' disabled';
253  }
254  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
255  //else $labeltoshow.=' ('.$langs->trans("Private").')';
256  $resultat .= '>';
257  $resultat .= $labeltoshow;
258  $resultat .= '</option>';
259  }
260  $out .= $resultat;
261 
262  $outarray[] = array(
263  'key' => (int) $obj->rowid,
264  'value' => $obj->ref,
265  'ref' => $obj->ref,
266  'labelx' => $labeltoshow,
267  'label' => ((bool) $disabled) ? '<span class="opacitymedium">'.$labeltoshow.'</span>' : $labeltoshow,
268  'disabled' => (bool) $disabled
269  );
270  }
271  }
272  $i++;
273  }
274  }
275 
276  $this->db->free($resql);
277 
278  if (!$mode) {
279  if (empty($option_only)) {
280  $out .= '</select>';
281  }
282 
283  // Use select2 selector
284  if (!empty($conf->use_javascript_ajax)) {
285  include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
286  $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
287  $out .= $comboenhancement;
288  $morecss .= ' minwidth100';
289  }
290 
291  if (empty($nooutput)) {
292  print $out;
293  return '';
294  } else {
295  return $out;
296  }
297  } else {
298  return $outarray;
299  }
300  } else {
301  dol_print_error($this->db);
302  return -1;
303  }
304  }
305 
324  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 = '', $showmore = 'all', $usertofilter = null)
325  {
326  global $user, $conf, $langs;
327 
328  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
329 
330  if (is_null($usertofilter)) {
331  $usertofilter = $user;
332  }
333 
334  $out = '';
335 
336  $hideunselectables = false;
337  if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
338  $hideunselectables = true;
339  }
340 
341  if (empty($projectsListId)) {
342  if (empty($usertofilter->rights->projet->all->lire)) {
343  $projectstatic = new Project($this->db);
344  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
345  }
346  }
347 
348  // Search all projects
349  $sql = "SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,";
350  $sql .= " p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,";
351  $sql .= " s.nom as name";
352  $sql .= " FROM ".$this->db->prefix()."projet as p";
353  $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc,";
354  $sql .= " ".$this->db->prefix()."projet_task as t";
355  $sql .= " WHERE p.entity IN (".getEntity('project').")";
356  $sql .= " AND t.fk_projet = p.rowid";
357  if ($projectsListId) {
358  $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
359  }
360  if ($socid == 0) {
361  $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
362  }
363  if ($socid > 0) {
364  $sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
365  }
366  $sql .= " ORDER BY p.ref, t.ref ASC";
367 
368  $resql = $this->db->query($sql);
369  if ($resql) {
370  // Use select2 selector
371  if (empty($option_only) && !empty($conf->use_javascript_ajax)) {
372  include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
373  $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
374  $out .= $comboenhancement;
375  $morecss .= ' minwidth200 maxwidth500';
376  }
377 
378  if (empty($option_only)) {
379  $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlname.'" name="'.$htmlname.'">';
380  }
381  if (!empty($show_empty)) {
382  $out .= '<option value="0" class="optiongrey">';
383  if (!is_numeric($show_empty)) {
384  //if (! empty($conf->use_javascript_ajax)) $out .= '<span class="opacitymedium">aaa';
385  $out .= $show_empty;
386  //if (! empty($conf->use_javascript_ajax)) $out .= '</span>';
387  } else {
388  $out .= '&nbsp;';
389  }
390  $out .= '</option>';
391  }
392 
393  $num = $this->db->num_rows($resql);
394  $i = 0;
395  if ($num) {
396  while ($i < $num) {
397  $obj = $this->db->fetch_object($resql);
398  // 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.
399  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) {
400  // Do nothing
401  } else {
402  if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
403  $i++;
404  continue;
405  }
406 
407  $labeltoshow = '';
408  $titletoshow = '';
409 
410  $disabled = 0;
411  if ($obj->fk_statut == Project::STATUS_DRAFT) {
412  $disabled = 1;
413  } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
414  if ($discard_closed == 2) {
415  $disabled = 1;
416  }
417  } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
418  $disabled = 1;
419  }
420 
421  if (preg_match('/all/', $showmore)) {
422  $labeltoshow .= dol_trunc($obj->ref, 18); // Project ref
423  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
424  //else $labeltoshow.=' ('.$langs->trans("Private").')';
425  $labeltoshow .= ' '.dol_trunc($obj->title, $maxlength);
426  $titletoshow = $labeltoshow;
427 
428  if ($obj->name) {
429  $labeltoshow .= ' ('.$obj->name.')';
430  $titletoshow .= ' <span class="opacitymedium">('.$obj->name.')</span>';
431  }
432 
433  $disabled = 0;
434  if ($obj->fk_statut == Project::STATUS_DRAFT) {
435  $disabled = 1;
436  $labeltoshow .= ' - '.$langs->trans("Draft");
437  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Draft").'</span>';
438  } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
439  if ($discard_closed == 2) {
440  $disabled = 1;
441  }
442  $labeltoshow .= ' - '.$langs->trans("Closed");
443  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Closed").'</span>';
444  } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
445  $disabled = 1;
446  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
447  $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("LinkedToAnotherCompany").'</span>';
448  }
449  $labeltoshow .= ' - ';
450  $titletoshow .= ' - ';
451  }
452 
453  // Label for task
454  $labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
455  $titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
456  if ($obj->usage_task && preg_match('/progress/', $showmore)) {
457  $labeltoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
458  $titletoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
459  }
460 
461  if (!empty($selected) && $selected == $obj->rowid) {
462  $out .= '<option value="'.$obj->rowid.'" selected';
463  $out .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
464  //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
465  $out .= '>'.$labeltoshow.'</option>';
466  } else {
467  if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
468  $resultat = '';
469  } else {
470  $resultat = '<option value="'.$obj->rowid.'"';
471  if ($disabled) {
472  $resultat .= ' disabled';
473  }
474  //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
475  //else $labeltoshow.=' ('.$langs->trans("Private").')';
476  $resultat .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
477  $resultat .= '>';
478  $resultat .= $labeltoshow;
479  $resultat .= '</option>';
480  }
481  $out .= $resultat;
482  }
483  }
484  $i++;
485  }
486  }
487  if (empty($option_only)) {
488  $out .= '</select>';
489  }
490 
491  $this->nboftasks = $num;
492 
493  print $out;
494 
495  $this->db->free($resql);
496  return $num;
497  } else {
498  dol_print_error($this->db);
499  return -1;
500  }
501  }
502 
503 
504  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
516  public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet", $placeholder = '')
517  {
518  // phpcs:enable
519  global $conf, $langs;
520 
521  if ($table_element == 'projet_task') {
522  return ''; // Special cas of element we never link to a project (already always done)
523  }
524 
525  $linkedtothirdparty = false;
526  if (!in_array($table_element, array(
527  'don',
528  'expensereport_det',
529  'expensereport', 'loan',
530  'stock_mouvement',
531  'payment_salary',
532  'payment_various',
533  'salary',
534  'chargesociales',
535  'entrepot')
536  )) {
537  $linkedtothirdparty = true;
538  }
539 
540  $sqlfilter = '';
541 
542  //print $table_element;
543  switch ($table_element) {
544  case "loan":
545  $sql = "SELECT t.rowid, t.label as ref";
546  break;
547  case "facture":
548  $sql = "SELECT t.rowid, t.ref as ref";
549  break;
550  case "facture_fourn":
551  $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
552  break;
553  case "commande_fourn":
554  case "commande_fournisseur":
555  $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
556  break;
557  case "facture_rec":
558  $sql = "SELECT t.rowid, t.titre as ref";
559  break;
560  case "actioncomm":
561  $sql = "SELECT t.id as rowid, t.label as ref";
562  $projectkey = "fk_project";
563  break;
564  case "expensereport":
565  return '';
566  case "expensereport_det":
567  /*$sql = "SELECT rowid, '' as ref"; // table is llx_expensereport_det
568  $projectkey="fk_projet";
569  break;*/
570  return '';
571  case "commande":
572  case "contrat":
573  case "fichinter":
574  $sql = "SELECT t.rowid, t.ref";
575  break;
576  case 'stock_mouvement':
577  $sql = "SELECT t.rowid, t.label as ref";
578  $projectkey = 'fk_origin';
579  break;
580  case "payment_salary":
581  $sql = "SELECT t.rowid, t.num_payment as ref"; // TODO In a future fill and use real ref field
582  break;
583  case "payment_various":
584  $sql = "SELECT t.rowid, t.num_payment as ref";
585  break;
586  case "chargesociales":
587  default:
588  $sql = "SELECT t.rowid, t.ref";
589  break;
590  }
591  if ($linkedtothirdparty) {
592  $sql .= ", s.nom as name";
593  }
594  $sql .= " FROM ".$this->db->prefix().$table_element." as t";
595  if ($linkedtothirdparty) {
596  $sql .= ", ".$this->db->prefix()."societe as s";
597  }
598  $sql .= " WHERE ".$projectkey." is null";
599  if (!empty($socid) && $linkedtothirdparty) {
600  if (is_numeric($socid)) {
601  $sql .= " AND t.fk_soc = ".((int) $socid);
602  } else {
603  $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socid).")";
604  }
605  }
606  if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) {
607  $sql .= ' AND t.entity IN ('.getEntity('project').')';
608  }
609  if ($linkedtothirdparty) {
610  $sql .= " AND s.rowid = t.fk_soc";
611  }
612  if ($sqlfilter) {
613  $sql .= " AND ".$sqlfilter;
614  }
615  $sql .= " ORDER BY ref DESC";
616 
617  dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
618  $resql = $this->db->query($sql);
619  if ($resql) {
620  $num = $this->db->num_rows($resql);
621  $i = 0;
622  if ($num > 0) {
623  $sellist = '<select class="flat elementselect css'.$table_element.($morecss ? ' '.$morecss : '').'" name="elementselect">';
624  $sellist .= '<option value="-1"'.($placeholder ? ' class="optiongrey"' : '').'>'.$placeholder.'</option>';
625  while ($i < $num) {
626  $obj = $this->db->fetch_object($resql);
627  $ref = $obj->ref ? $obj->ref : $obj->rowid;
628  if (!empty($obj->ref_supplier)) {
629  $ref .= ' ('.$obj->ref_supplier.')';
630  }
631  if (!empty($obj->name)) {
632  $ref .= ' - '.$obj->name;
633  }
634  $sellist .= '<option value="'.$obj->rowid.'">'.$ref.'</option>';
635  $i++;
636  }
637  $sellist .= '</select>';
638  }
639  /*else
640  {
641  $sellist = '<select class="flat" name="elementselect">';
642  $sellist.= '<option value="0" disabled>'.$langs->trans("None").'</option>';
643  $sellist.= '</select>';
644  }*/
645  $this->db->free($resql);
646 
647  return $sellist;
648  } else {
649  dol_print_error($this->db);
650  $this->error = $this->db->lasterror();
651  $this->errors[] = $this->db->lasterror();
652  dol_syslog(get_class($this)."::select_element ".$this->error, LOG_ERR);
653  return -1;
654  }
655  }
656 
657 
672  public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0)
673  {
674  global $conf, $langs, $user;
675 
676  $sql = "SELECT rowid, code, label, percent";
677  $sql .= " FROM ".$this->db->prefix().'c_lead_status';
678  $sql .= " WHERE active = 1";
679  $sql .= " ORDER BY position";
680 
681  $resql = $this->db->query($sql);
682  if ($resql) {
683  $num = $this->db->num_rows($resql);
684  $i = 0;
685  if ($num > 0) {
686  $sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
687  if ($showempty) {
688  // Without &nbsp, strange move of screen when switching value
689  $sellist .= '<option value="-1">&nbsp;</option>';
690  }
691  if ($showallnone) {
692  $sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").' --</option>';
693  $sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").' --</option>';
694  $sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").' --</option>';
695  $sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").' --</option>';
696  }
697  while ($i < $num) {
698  $obj = $this->db->fetch_object($resql);
699 
700  $sellist .= '<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"';
701  if ($obj->rowid == $preselected) {
702  $sellist .= ' selected="selected"';
703  }
704  $sellist .= '>';
705  if ($useshortlabel) {
706  $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
707  } else {
708  $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
709  if ($showpercent) {
710  $finallabel .= ' ('.$obj->percent.'%)';
711  }
712  }
713  $sellist .= $finallabel;
714  $sellist .= '</option>';
715  $i++;
716  }
717  $sellist .= '</select>';
718 
719  if ($user->admin && !$noadmininfo) {
720  $sellist .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
721  }
722 
723  if ($addcombojs) {
724  $sellist .= ajax_combobox($htmlname);
725  }
726  }
727  /*else
728  {
729  $sellist = '<select class="flat" name="elementselect">';
730  $sellist.= '<option value="0" disabled>'.$langs->trans("None").'</option>';
731  $sellist.= '</select>';
732  }*/
733  $this->db->free($resql);
734 
735  return $sellist;
736  } else {
737  $this->error = $this->db->lasterror();
738  $this->errors[] = $this->db->lasterror();
739  dol_syslog(get_class($this)."::selectOpportunityStatus ".$this->error, LOG_ERR);
740  return -1;
741  }
742  }
743 }
FormProjets\select_projects
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.
Definition: html.formprojet.class.php:76
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:438
db
$conf db
API class for accounts.
Definition: inc.php:41
dol_trunc
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
Definition: functions.lib.php:3805
ajax_autocompleter
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
Project
Class to manage projects.
Definition: project.class.php:35
FormProjets\select_element
select_element($table_element, $socid=0, $morecss='', $limitonstatus=-2, $projectkey="fk_projet", $placeholder='')
Build a HTML select list of element of same thirdparty to suggest to link them to project.
Definition: html.formprojet.class.php:516
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
FormProjets\select_projects_list
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.
Definition: html.formprojet.class.php:145
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormProjets\selectTasks
selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $projectsListId='', $showmore='all', $usertofilter=null)
Output a combo list with tasks qualified for a third party.
Definition: html.formprojet.class.php:324
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
FormProjets\selectOpportunityStatus
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.
Definition: html.formprojet.class.php:672
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
natural_search
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...
Definition: functions.lib.php:9420
FormProjets\__construct
__construct($db)
Constructor.
Definition: html.formprojet.class.php:50
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
Project\STATUS_CLOSED
const STATUS_CLOSED
Closed status.
Definition: project.class.php:308
Project\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: project.class.php:298
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25