29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46 public $errors = array();
88 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 =
'', $morefilter =
'')
91 global $langs,
$conf, $form;
93 $selected_input_value =
'';
94 if (is_object($selected)) {
95 $selected_input_value = $selected->ref;
96 $selected = $selected->id;
104 if ($selected && empty($selected_input_value)) {
105 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
106 $project =
new Project($this->db);
107 $project->fetch((
int) $selected);
108 $selected_input_value = $project->ref;
110 $urloption =
'socid=' . ((int) $socid) .
'&htmlname=' . urlencode($htmlname) .
'&discardclosed=' . ((int) $discard_closed);
111 if ($morefilter ==
'usage_organize_event=1') {
112 $urloption .=
'&usage_organize_event=1';
114 $out .=
'<input type="text" class="minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . $placeholder .
' />';
116 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/projet/ajax/projects.php', $urloption,
getDolGlobalInt(
'PROJECT_USE_SEARCH_TO_SELECT'), 0, array());
118 $out .= $this->
select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss, $morefilter);
120 if ($discard_closed > 0) {
122 $out .= $form->textwithpicto(
'', $langs->trans(
"ClosedProjectsAreHidden"));
126 if (empty($nooutput)) {
157 public function select_projects_list($socid = -1, $selected = 0, $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', $morefilter =
'')
160 global $user,
$conf, $langs;
162 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
164 if (empty($htmlid)) {
171 $hideunselectables =
false;
173 $hideunselectables =
true;
175 if (
getDolGlobalInt(
'PROJECT_ALWAYS_DISCARD_CLOSED_PROJECTS_IN_SELECT')) {
179 $projectsListId =
false;
180 if (!$user->hasRight(
'projet',
'all',
'lire')) {
181 $projectstatic =
new Project($this->db);
182 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
186 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias";
187 $sql .=
" FROM " . $this->db->prefix() .
"projet as p LEFT JOIN " . $this->db->prefix() .
"societe as s ON s.rowid = p.fk_soc";
188 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
189 if ($projectsListId !==
false) {
190 $sql .=
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) .
")";
193 $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
197 $sql .=
" AND (p.fk_soc=" . ((int) $socid) .
" OR p.fk_soc IS NULL)";
199 $sql .=
" AND (p.fk_soc IN (" . $this->db->sanitize(((
int) $socid) .
", " .
getDolGlobalString(
'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) .
") OR p.fk_soc IS NULL)";
202 if (!empty($filterkey)) {
206 $sql .=
' AND (' . $this->db->sanitize($morefilter, 0, 1) .
')';
208 $sql .=
" ORDER BY p.ref ASC";
210 $resql = $this->db->query($sql);
212 if (!empty(
$conf->use_javascript_ajax)) {
213 $morecss .=
' minwidth100';
215 if (empty($option_only)) {
216 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlid .
'" name="' . $htmlname .
'">';
218 if (!empty($show_empty)) {
219 if (is_numeric($show_empty)) {
220 $out .=
'<option value="0"> </option>';
222 $out .=
'<option value="-1">'.$show_empty.
'</option>';
225 $num = $this->db->num_rows($resql);
229 $obj = $this->db->fetch_object($resql);
231 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight(
'societe',
'lire')) {
234 if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) {
242 $labeltoshow .=
', ' .
dol_trunc($obj->title, $maxlength);
244 $labeltoshow .=
' - ' . $obj->name;
245 if ($obj->name_alias) {
246 $labeltoshow .=
' (' . $obj->name_alias .
')';
251 if ($obj->fk_statut == 0) {
253 $labeltoshow .=
' - ' . $langs->trans(
"Draft");
254 } elseif ($obj->fk_statut == 2) {
255 if ($discard_closed == 2) {
258 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
259 } elseif (!
getDolGlobalString(
'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
261 $labeltoshow .=
' - ' . $langs->trans(
"LinkedToAnotherCompany");
264 if (!empty($selected) && $selected == $obj->rowid) {
265 $out .=
'<option value="' . $obj->rowid .
'" selected';
267 $out .=
'>' . $labeltoshow .
'</option>';
269 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
272 $resultat =
'<option value="' . $obj->rowid .
'"';
274 $resultat .=
' disabled';
279 $resultat .= $labeltoshow;
280 $resultat .=
'</option>';
285 'key' => (
int) $obj->rowid,
286 'value' => $obj->ref,
288 'labelx' => $labeltoshow,
289 'label' => ($disabled ?
'<span class="opacitymedium">' . $labeltoshow .
'</span>' : $labeltoshow),
290 'disabled' => (
bool) $disabled
298 $this->db->free($resql);
301 if (empty($option_only)) {
306 if (!empty(
$conf->use_javascript_ajax)) {
307 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
308 $comboenhancement =
ajax_combobox($htmlid, array(), 0, $forcefocus);
309 $out .= $comboenhancement;
310 $morecss .=
' minwidth100';
313 if (empty($nooutput)) {
348 public function selectTasks($socid = -1, $selected = 0, $htmlname =
'taskid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500', $projectsListId =
'', $showmore =
'all', $usertofilter =
null, $nooutput = 0)
350 global $user,
$conf, $langs;
352 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
354 if (is_null($usertofilter)) {
355 $usertofilter = $user;
360 $hideunselectables =
false;
362 $hideunselectables =
true;
365 if (empty($projectsListId)) {
366 if (!$usertofilter->hasRight(
'projet',
'all',
'lire')) {
367 $projectstatic =
new Project($this->db);
368 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
373 $sql =
"SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,";
374 $sql .=
" p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,";
375 $sql .=
" s.nom as name";
376 $sql .=
" FROM " . $this->db->prefix() .
"projet as p";
377 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON s.rowid = p.fk_soc,";
378 $sql .=
" " . $this->db->prefix() .
"projet_task as t";
379 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
380 $sql .=
" AND t.fk_projet = p.rowid";
381 if ($projectsListId) {
382 $sql .=
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) .
")";
385 $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
388 $sql .=
" AND (p.fk_soc=" . ((int) $socid) .
" OR p.fk_soc IS NULL)";
390 $sql .=
" ORDER BY p.ref, t.ref ASC";
392 $resql = $this->db->query($sql);
395 if (empty($option_only) && !empty(
$conf->use_javascript_ajax)) {
396 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
397 $comboenhancement =
ajax_combobox($htmlname, [], 0, $forcefocus);
398 $out .= $comboenhancement;
399 $morecss .=
' minwidth150imp';
402 if (empty($option_only)) {
403 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">'.
"\n";
405 if (!empty($show_empty)) {
406 $out .=
'<option value="0" class="optiongrey">';
407 if (!is_numeric($show_empty)) {
414 $out .=
'</option>'.
"\n";
417 $num = $this->db->num_rows($resql);
421 $obj = $this->db->fetch_object($resql);
423 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight(
'societe',
'lire')) {
432 $labeltoshowhtml =
'';
438 if ($discard_closed == 2) {
441 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
445 if (preg_match(
'/all/', $showmore)) {
446 $labeltoshow .=
dol_trunc($obj->ref, 18);
449 $labeltoshow .=
' ' .
dol_trunc($obj->title, $maxlength);
450 $labeltoshowhtml = $labeltoshow;
453 $labeltoshow .=
' (' . $obj->name .
')';
454 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->name .
')</span>';
460 $labeltoshow .=
' - ' . $langs->trans(
"Draft");
461 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"Draft") .
'</span>';
463 if ($discard_closed == 2) {
466 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
467 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"Closed") .
'</span>';
468 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
470 $labeltoshow .=
' - ' . $langs->trans(
"LinkedToAnotherCompany");
471 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"LinkedToAnotherCompany") .
'</span>';
473 $labeltoshow .=
' - ';
474 $labeltoshowhtml .=
' - ';
478 $labeltoshow .= $obj->tref .
' ' .
dol_trunc($obj->tlabel, $maxlength);
479 $labeltoshowhtml .= $obj->tref .
' - ' .
dol_trunc($obj->tlabel, $maxlength);
480 if ($obj->usage_task && preg_match(
'/progress/', $showmore)) {
481 $labeltoshow .=
' <span class="opacitymedium">(' . $obj->progress .
'%)</span>';
482 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->progress .
'%)</span>';
485 if (!empty($selected) && $selected == $obj->rowid) {
486 $out .=
'<option value="' . $obj->rowid .
'" selected';
489 $out .=
'>' . $labeltoshow .
'</option>'.
"\n";
491 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
494 $resultat =
'<option value="' . $obj->rowid .
'"';
496 $resultat .=
' disabled';
502 $resultat .= $labeltoshow;
503 $resultat .=
'</option>'.
"\n";
511 if (empty($option_only)) {
512 $out .=
'</select>'.
"\n";
515 $this->nboftasks = $num;
516 $this->db->free($resql);
519 if (empty($nooutput)) {
546 public function select_element($table_element, $socid = 0, $morecss =
'', $limitonstatus = -2, $projectkey =
"fk_projet", $placeholder =
'')
549 if ($table_element ==
'projet_task') {
553 $linkedtothirdparty =
false;
559 'expensereport',
'loan',
567 $linkedtothirdparty =
true;
571 switch ($table_element) {
573 $sql =
"SELECT t.rowid, t.label as ref";
576 $sql =
"SELECT t.rowid, t.ref as ref";
578 case "facture_fourn":
579 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
581 case "commande_fourn":
582 case "commande_fournisseur":
583 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
586 $sql =
"SELECT t.rowid, t.titre as ref";
589 $sql =
"SELECT t.id as rowid, t.label as ref";
590 $projectkey =
"fk_project";
592 case "expensereport":
594 case "expensereport_det":
602 $sql =
"SELECT t.rowid, t.ref";
604 case 'stock_mouvement':
605 $sql =
"SELECT t.rowid, t.label as ref";
606 $projectkey =
'fk_origin';
608 case "payment_salary":
609 $sql =
"SELECT t.rowid, t.num_payment as ref";
611 case "payment_various":
612 $sql =
"SELECT t.rowid, t.num_payment as ref";
614 case "chargesociales":
616 $sql =
"SELECT t.rowid, t.ref";
619 if ($linkedtothirdparty) {
620 $sql .=
", s.nom as name";
622 $sql .=
" FROM " . $this->db->prefix() . $this->db->sanitize($table_element) .
" as t";
623 if ($linkedtothirdparty) {
624 $sql .=
", " . $this->db->prefix() .
"societe as s";
626 $sql .=
" WHERE " . $this->db->sanitize($projectkey) .
" is null";
627 if (!empty($socid) && $linkedtothirdparty) {
628 if (is_numeric($socid)) {
629 $sql .=
" AND t.fk_soc = " . ((int) $socid);
631 $sql .=
" AND t.fk_soc IN (" . $this->db->sanitize($socid) .
")";
634 if (!in_array($table_element, array(
'expensereport_det',
'stock_mouvement'))) {
635 $sql .=
' AND t.entity IN (' .
getEntity(
'project') .
')';
637 if ($linkedtothirdparty) {
638 $sql .=
" AND s.rowid = t.fk_soc";
640 $sql .=
" ORDER BY ref DESC";
642 dol_syslog(get_class($this) .
'::select_element', LOG_DEBUG);
643 $resql = $this->db->query($sql);
645 $num = $this->db->num_rows($resql);
650 $sellist =
'<select class="flat elementselect css' . $table_element . ($morecss ?
' ' . $morecss :
'') .
'" name="elementselect">';
651 $sellist .=
'<option value="-1"' . ($placeholder ?
' class="optiongrey"' :
'') .
'>' . $placeholder .
'</option>';
653 $obj = $this->db->fetch_object($resql);
654 $ref = $obj->ref ? $obj->ref : $obj->rowid;
655 if (!empty($obj->ref_supplier)) {
656 $ref .=
' (' . $obj->ref_supplier .
')';
658 if (!empty($obj->name)) {
659 $ref .=
' - ' . $obj->name;
661 $sellist .=
'<option value="' . $obj->rowid .
'">' . $ref .
'</option>';
664 $sellist .=
'</select>';
672 $this->db->free($resql);
677 $this->error = $this->db->lasterror();
678 $this->errors[] = $this->db->lasterror();
679 dol_syslog(get_class($this) .
"::select_element " . $this->error, LOG_ERR);
699 public function selectOpportunityStatus($htmlname, $preselected = -1, $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss =
'', $noadmininfo = 0, $addcombojs = 0)
701 global $langs, $user;
703 $sql =
"SELECT rowid, code, label, percent";
704 $sql .=
" FROM " . $this->db->prefix() .
'c_lead_status';
705 $sql .=
" WHERE active = 1";
706 $sql .=
" ORDER BY position";
708 $resql = $this->db->query($sql);
710 $num = $this->db->num_rows($resql);
714 $sellist =
'<select class="flat oppstatus' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
717 $sellist .=
'<option value="-1"> </option>';
720 $sellist .=
'<option value="all"' . ($preselected ==
'all' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OnlyOpportunitiesShort") .
'</option>';
721 $sellist .=
'<option value="openedopp"' . ($preselected ==
'openedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OpenedOpportunitiesShort") .
'</option>';
722 $sellist .=
'<option value="notopenedopp"' . ($preselected ==
'notopenedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotOpenedOpportunitiesShort") .
'</option>';
723 $sellist .=
'<option value="none"' . ($preselected ==
'none' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotAnOpportunityShort") .
'</option>';
727 $obj = $this->db->fetch_object($resql);
729 if (($obj->code ==
'WON' || $obj->code ==
'LOST') && !$separatoradded) {
731 $sellist .=
'<option value="" disabled>--------------------</option>';
733 $sellist .=
'<option value="' . $obj->rowid .
'" defaultpercent="' . $obj->percent .
'" data-elemcode="' . $obj->code .
'"';
734 if ($obj->rowid == $preselected) {
735 $sellist .=
' selected="selected"';
738 if ($useshortlabel) {
739 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
741 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
743 $finallabel .=
' (' . $obj->percent .
'%)';
746 $sellist .= $finallabel;
747 $sellist .=
'</option>';
750 $sellist .=
'</select>';
752 if ($user->admin && !$noadmininfo) {
753 $sellist .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
761 $this->db->free($resql);
765 $this->error = $this->db->lasterror();
766 $this->errors[] = $this->db->lasterror();
767 dol_syslog(get_class($this) .
"::selectOpportunityStatus " . $this->error, LOG_ERR);
785 $statustohow = array(
791 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
792 $tmpproject =
new Project($this->db);
794 foreach ($statustohow as $key => $value) {
795 $tmpproject->statut = $key;
796 $tmpproject->status = $key;
797 $options[$value] = $tmpproject->getLibStatut($short);
800 if (is_array($selected)) {
801 $selectedarray = $selected;
802 } elseif ($selected == 99) {
803 $selectedarray = array(0,1);
805 $selectedarray = explode(
',', $selected);
823 public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice =
'invoiceid', $htmlNameInvoiceLine =
'invoicelineid', $morecss =
'maxwidth500', $filters = array(), $lineOnly = 0)
825 global $user,
$conf, $langs;
827 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
832 if (empty($lineOnly)) {
834 $sql =
"SELECT f.rowid, f.ref as fref,";
835 $sql .=
' s.nom as name';
836 $sql .=
' FROM ' . $this->db->prefix() .
'projet as p';
837 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'societe as s ON s.rowid = p.fk_soc';
838 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facture as f ON f.fk_projet = p.rowid';
839 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
840 if (!empty($filters)) {
841 foreach ($filters as $key => $value) {
842 if ($key ==
'p.rowid') {
843 $sql .=
" AND p.rowid=" . (int) $value;
845 if ($key ==
'f.rowid') {
846 $sql .=
" AND f.rowid=" . (int) $value;
850 $sql .=
" ORDER BY p.ref, f.ref ASC";
852 $resql = $this->db->query($sql);
855 if (!empty(
$conf->use_javascript_ajax)) {
856 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
857 $comboenhancement =
ajax_combobox($htmlNameInvoice, array(array(
'method' =>
'getLines',
'url' =>
dol_buildpath(
'/core/ajax/ajaxinvoiceline.php', 1),
'htmlname' => $htmlNameInvoiceLine)), 0, 0);
858 $out .= $comboenhancement;
859 $morecss =
'minwidth200imp maxwidth500';
862 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlNameInvoice .
'" name="' . $htmlNameInvoice .
'">';
863 $num = $this->db->num_rows($resql);
865 while ($obj = $this->db->fetch_object($resql)) {
866 $labeltoshow = $obj->fref;
868 $labeltoshow .=
' - ' . $obj->name;
871 $out .=
'<option value="' . $obj->rowid .
'" ';
872 if (!empty($selectedInvoiceId) && $selectedInvoiceId == $obj->rowid) {
873 $out .=
' selected ';
875 $out .=
'>' . $labeltoshow .
'</option>';
886 $sql =
"SELECT fd.rowid, fd.label, fd.description";
887 $sql .=
' FROM ' . $this->db->prefix() .
'projet as p';
888 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'societe as s ON s.rowid = p.fk_soc';
889 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facture as f ON f.fk_projet = p.rowid';
890 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facturedet as fd ON fd.fk_facture = f.rowid';
891 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
892 if (!empty($filters)) {
893 foreach ($filters as $key => $value) {
894 if ($key ==
'p.rowid') {
895 $sql .=
" AND p.rowid=" . (int) $value;
899 if (!empty($selectedInvoiceId)) {
900 $sql .=
" AND f.rowid=" . (int) $selectedInvoiceId;
902 $sql .=
" ORDER BY p.ref, f.ref ASC";
903 $resql = $this->db->query($sql);
906 if (empty($lineOnly)) {
907 if (!empty(
$conf->use_javascript_ajax)) {
908 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
909 $comboenhancement =
ajax_combobox($htmlNameInvoiceLine, [], 0, 0);
910 $out .= $comboenhancement;
911 $morecss =
'minwidth200imp maxwidth500';
914 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlNameInvoiceLine .
'" name="' . $htmlNameInvoiceLine .
'">';
917 $num = $this->db->num_rows($resql);
919 while ($obj = $this->db->fetch_object($resql)) {
920 $labeltoshow .= $obj->description;
922 $out .=
'<option value="' . $obj->rowid .
'" ';
923 if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) {
924 $out .=
' selected ';
926 $out .=
'>' . $labeltoshow .
'</option>';
929 if (empty($lineOnly)) {
952 public function formOpportunityStatus($page, $selected =
'', $percent_value = 0, $htmlname_status =
'none', $htmlname_percent =
'none', $filter =
'', $nooutput = 0)
955 global
$conf, $langs;
958 if ($htmlname_status !=
"none" && $htmlname_percent !=
'none') {
959 $out .=
'<form method="post" action="' . $page .
'">';
960 $out .=
'<input type="hidden" name="action" value="set_opp_status">';
961 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
962 $out .= $this->
selectOpportunityStatus($htmlname_status, $selected, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
963 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
964 $out .=
'<input class="width50 right" type="text" id="'.$htmlname_percent.
'" name="'.$htmlname_percent.
'" title="'.
dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.$percent_value.
'"> %';
966 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
970 $code =
dol_getIdFromCode($this->db, $selected,
'c_lead_status',
'rowid',
'code');
971 $out .= $langs->trans(
"OppStatus".$code);
974 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
975 $out .=
price($percent_value, 0, $langs, 1, 0).
' %';
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to transform a common input text or select field into ...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Class to manage projects.
const STATUS_CLOSED
Closed status.
const STATUS_DRAFT
Draft status.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...