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 global
$conf, $langs;
551 if ($table_element ==
'projet_task') {
555 $linkedtothirdparty =
false;
561 'expensereport',
'loan',
569 $linkedtothirdparty =
true;
575 switch ($table_element) {
577 $sql =
"SELECT t.rowid, t.label as ref";
580 $sql =
"SELECT t.rowid, t.ref as ref";
582 case "facture_fourn":
583 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
585 case "commande_fourn":
586 case "commande_fournisseur":
587 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
590 $sql =
"SELECT t.rowid, t.titre as ref";
593 $sql =
"SELECT t.id as rowid, t.label as ref";
594 $projectkey =
"fk_project";
596 case "expensereport":
598 case "expensereport_det":
606 $sql =
"SELECT t.rowid, t.ref";
608 case 'stock_mouvement':
609 $sql =
"SELECT t.rowid, t.label as ref";
610 $projectkey =
'fk_origin';
612 case "payment_salary":
613 $sql =
"SELECT t.rowid, t.num_payment as ref";
615 case "payment_various":
616 $sql =
"SELECT t.rowid, t.num_payment as ref";
618 case "chargesociales":
620 $sql =
"SELECT t.rowid, t.ref";
623 if ($linkedtothirdparty) {
624 $sql .=
", s.nom as name";
626 $sql .=
" FROM " . $this->db->prefix() . $table_element .
" as t";
627 if ($linkedtothirdparty) {
628 $sql .=
", " . $this->db->prefix() .
"societe as s";
630 $sql .=
" WHERE " . $projectkey .
" is null";
631 if (!empty($socid) && $linkedtothirdparty) {
632 if (is_numeric($socid)) {
633 $sql .=
" AND t.fk_soc = " . ((int) $socid);
635 $sql .=
" AND t.fk_soc IN (" . $this->db->sanitize($socid) .
")";
638 if (!in_array($table_element, array(
'expensereport_det',
'stock_mouvement'))) {
639 $sql .=
' AND t.entity IN (' .
getEntity(
'project') .
')';
641 if ($linkedtothirdparty) {
642 $sql .=
" AND s.rowid = t.fk_soc";
645 $sql .=
" AND " . $sqlfilter;
647 $sql .=
" ORDER BY ref DESC";
649 dol_syslog(get_class($this) .
'::select_element', LOG_DEBUG);
650 $resql = $this->db->query($sql);
652 $num = $this->db->num_rows($resql);
657 $sellist =
'<select class="flat elementselect css' . $table_element . ($morecss ?
' ' . $morecss :
'') .
'" name="elementselect">';
658 $sellist .=
'<option value="-1"' . ($placeholder ?
' class="optiongrey"' :
'') .
'>' . $placeholder .
'</option>';
660 $obj = $this->db->fetch_object($resql);
661 $ref = $obj->ref ? $obj->ref : $obj->rowid;
662 if (!empty($obj->ref_supplier)) {
663 $ref .=
' (' . $obj->ref_supplier .
')';
665 if (!empty($obj->name)) {
666 $ref .=
' - ' . $obj->name;
668 $sellist .=
'<option value="' . $obj->rowid .
'">' . $ref .
'</option>';
671 $sellist .=
'</select>';
679 $this->db->free($resql);
684 $this->error = $this->db->lasterror();
685 $this->errors[] = $this->db->lasterror();
686 dol_syslog(get_class($this) .
"::select_element " . $this->error, LOG_ERR);
706 public function selectOpportunityStatus($htmlname, $preselected = -1, $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss =
'', $noadmininfo = 0, $addcombojs = 0)
708 global
$conf, $langs, $user;
710 $sql =
"SELECT rowid, code, label, percent";
711 $sql .=
" FROM " . $this->db->prefix() .
'c_lead_status';
712 $sql .=
" WHERE active = 1";
713 $sql .=
" ORDER BY position";
715 $resql = $this->db->query($sql);
717 $num = $this->db->num_rows($resql);
721 $sellist =
'<select class="flat oppstatus' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
724 $sellist .=
'<option value="-1"> </option>';
727 $sellist .=
'<option value="all"' . ($preselected ==
'all' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OnlyOpportunitiesShort") .
'</option>';
728 $sellist .=
'<option value="openedopp"' . ($preselected ==
'openedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OpenedOpportunitiesShort") .
'</option>';
729 $sellist .=
'<option value="notopenedopp"' . ($preselected ==
'notopenedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotOpenedOpportunitiesShort") .
'</option>';
730 $sellist .=
'<option value="none"' . ($preselected ==
'none' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotAnOpportunityShort") .
'</option>';
733 $obj = $this->db->fetch_object($resql);
735 $sellist .=
'<option value="' . $obj->rowid .
'" defaultpercent="' . $obj->percent .
'" elemcode="' . $obj->code .
'"';
736 if ($obj->rowid == $preselected) {
737 $sellist .=
' selected="selected"';
740 if ($useshortlabel) {
741 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
743 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
745 $finallabel .=
' (' . $obj->percent .
'%)';
748 $sellist .= $finallabel;
749 $sellist .=
'</option>';
752 $sellist .=
'</select>';
754 if ($user->admin && !$noadmininfo) {
755 $sellist .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
768 $this->db->free($resql);
772 $this->error = $this->db->lasterror();
773 $this->errors[] = $this->db->lasterror();
774 dol_syslog(get_class($this) .
"::selectOpportunityStatus " . $this->error, LOG_ERR);
792 $statustohow = array(
798 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
799 $tmpproject =
new Project($this->db);
801 foreach ($statustohow as $key => $value) {
802 $tmpproject->statut = $key;
803 $tmpproject->status = $key;
804 $options[$value] = $tmpproject->getLibStatut($short);
807 if (is_array($selected)) {
808 $selectedarray = $selected;
809 } elseif ($selected == 99) {
810 $selectedarray = array(0,1);
812 $selectedarray = explode(
',', $selected);
830 public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice =
'invoiceid', $htmlNameInvoiceLine =
'invoicelineid', $morecss =
'maxwidth500', $filters = array(), $lineOnly = 0)
832 global $user,
$conf, $langs;
834 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
837 if (empty($lineOnly)) {
839 $sql =
"SELECT f.rowid, f.ref as fref,";
840 $sql .=
' s.nom as name';
841 $sql .=
' FROM ' . $this->db->prefix() .
'projet as p';
842 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'societe as s ON s.rowid = p.fk_soc';
843 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facture as f ON f.fk_projet = p.rowid';
844 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
845 if (!empty($filters)) {
846 foreach ($filters as $key => $value) {
847 if ($key ==
'p.rowid') {
848 $sql .=
" AND p.rowid=" . (int) $value;
850 if ($key ==
'f.rowid') {
851 $sql .=
" AND f.rowid=" . (int) $value;
855 $sql .=
" ORDER BY p.ref, f.ref ASC";
857 $resql = $this->db->query($sql);
860 if (!empty(
$conf->use_javascript_ajax)) {
861 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
862 $comboenhancement =
ajax_combobox($htmlNameInvoice, array(array(
'method' =>
'getLines',
'url' =>
dol_buildpath(
'/core/ajax/ajaxinvoiceline.php', 1),
'htmlname' => $htmlNameInvoiceLine)), 0, 0);
863 $out .= $comboenhancement;
864 $morecss =
'minwidth200imp maxwidth500';
867 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlNameInvoice .
'" name="' . $htmlNameInvoice .
'">';
868 $num = $this->db->num_rows($resql);
870 while ($obj = $this->db->fetch_object($resql)) {
871 $labeltoshow = $obj->fref;
873 $labeltoshow .=
' - ' . $obj->name;
876 $out .=
'<option value="' . $obj->rowid .
'" ';
877 if (!empty($selectedInvoiceId) && $selectedInvoiceId == $obj->rowid) {
878 $out .=
' selected ';
880 $out .=
'>' . $labeltoshow .
'</option>';
891 $sql =
"SELECT fd.rowid, fd.label, fd.description";
892 $sql .=
' FROM ' . $this->db->prefix() .
'projet as p';
893 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'societe as s ON s.rowid = p.fk_soc';
894 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facture as f ON f.fk_projet = p.rowid';
895 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'facturedet as fd ON fd.fk_facture = f.rowid';
896 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
897 if (!empty($filters)) {
898 foreach ($filters as $key => $value) {
899 if ($key ==
'p.rowid') {
900 $sql .=
" AND p.rowid=" . (int) $value;
904 if (!empty($selectedInvoiceId)) {
905 $sql .=
" AND f.rowid=" . (int) $selectedInvoiceId;
907 $sql .=
" ORDER BY p.ref, f.ref ASC";
908 $resql = $this->db->query($sql);
911 if (empty($lineOnly)) {
912 if (!empty(
$conf->use_javascript_ajax)) {
913 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
914 $comboenhancement =
ajax_combobox($htmlNameInvoiceLine, [], 0, 0);
915 $out .= $comboenhancement;
916 $morecss =
'minwidth200imp maxwidth500';
919 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlNameInvoiceLine .
'" name="' . $htmlNameInvoiceLine .
'">';
921 $num = $this->db->num_rows($resql);
923 while ($obj = $this->db->fetch_object($resql)) {
924 $labeltoshow .= $obj->description;
926 $out .=
'<option value="' . $obj->rowid .
'" ';
927 if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) {
928 $out .=
' selected ';
930 $out .=
'>' . $labeltoshow .
'</option>';
933 if (empty($lineOnly)) {
956 public function formOpportunityStatus($page, $selected =
'', $percent_value = 0, $htmlname_status =
'none', $htmlname_percent =
'none', $filter =
'', $nooutput = 0)
959 global
$conf, $langs;
962 if ($htmlname_status !=
"none" && $htmlname_percent !=
'none') {
963 $out .=
'<form method="post" action="' . $page .
'">';
964 $out .=
'<input type="hidden" name="action" value="set_opp_status">';
965 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
966 $out .= $this->
selectOpportunityStatus($htmlname_status, $selected, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
967 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
968 $out .=
'<input class="width50 right" type="text" id="'.$htmlname_percent.
'" name="'.$htmlname_percent.
'" title="'.
dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.$percent_value.
'"> %';
970 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
974 $code =
dol_getIdFromCode($this->db, $selected,
'c_lead_status',
'rowid',
'code');
975 $out .= $langs->trans(
"OppStatus".$code);
978 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
979 $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.
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...
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...