29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46 public $errors = array();
85 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 =
'')
88 global $langs, $conf, $form;
90 $selected_input_value =
'';
91 if (is_object($selected)) {
92 $selected_input_value = $selected->ref;
93 $selected = $selected->id;
98 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PROJECT_USE_SEARCH_TO_SELECT')) {
101 if ($selected && empty($selected_input_value)) {
102 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
103 $project =
new Project($this->db);
104 $project->fetch($selected);
105 $selected_input_value = $project->ref;
107 $urloption =
'socid=' . ((int) $socid) .
'&htmlname=' . urlencode($htmlname) .
'&discardclosed=' . ((int) $discard_closed);
108 if ($morefilter ==
'usage_organize_event=1') {
109 $urloption .=
'&usage_organize_event=1';
111 $out .=
'<input type="text" class="minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . $placeholder .
' />';
113 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array());
115 $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);
117 if ($discard_closed > 0) {
119 $out .= $form->textwithpicto(
'', $langs->trans(
"ClosedProjectsAreHidden"));
123 if (empty($nooutput)) {
154 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 =
'')
157 global $user, $conf, $langs;
159 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
161 if (empty($htmlid)) {
168 $hideunselectables =
false;
170 $hideunselectables =
true;
172 if (
getDolGlobalInt(
'PROJECT_ALWAYS_DISCARD_CLOSED_PROJECTS_IN_SELECT')) {
176 $projectsListId =
false;
177 if (!$user->hasRight(
'projet',
'all',
'lire')) {
178 $projectstatic =
new Project($this->db);
179 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
183 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias";
184 $sql .=
" FROM " . $this->db->prefix() .
"projet as p LEFT JOIN " . $this->db->prefix() .
"societe as s ON s.rowid = p.fk_soc";
185 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
186 if ($projectsListId !==
false) {
187 $sql .=
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) .
")";
190 $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
194 $sql .=
" AND (p.fk_soc=" . ((int) $socid) .
" OR p.fk_soc IS NULL)";
196 $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)";
199 if (!empty($filterkey)) {
203 $sql .=
' AND (' . $this->db->sanitize($morefilter, 0, 1) .
')';
205 $sql .=
" ORDER BY p.ref ASC";
207 $resql = $this->db->query($sql);
209 if (!empty($conf->use_javascript_ajax)) {
210 $morecss .=
' minwidth100';
212 if (empty($option_only)) {
213 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlid .
'" name="' . $htmlname .
'">';
215 if (!empty($show_empty)) {
216 if (is_numeric($show_empty)) {
217 $out .=
'<option value="0"> </option>';
219 $out .=
'<option value="-1">'.$show_empty.
'</option>';
222 $num = $this->db->num_rows($resql);
226 $obj = $this->db->fetch_object($resql);
228 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight(
'societe',
'lire')) {
231 if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) {
239 $labeltoshow .=
', ' .
dol_trunc($obj->title, $maxlength);
241 $labeltoshow .=
' - ' . $obj->name;
242 if ($obj->name_alias) {
243 $labeltoshow .=
' (' . $obj->name_alias .
')';
248 if ($obj->fk_statut == 0) {
250 $labeltoshow .=
' - ' . $langs->trans(
"Draft");
251 } elseif ($obj->fk_statut == 2) {
252 if ($discard_closed == 2) {
255 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
256 } elseif (!
getDolGlobalString(
'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
258 $labeltoshow .=
' - ' . $langs->trans(
"LinkedToAnotherCompany");
261 if (!empty($selected) && $selected == $obj->rowid) {
262 $out .=
'<option value="' . $obj->rowid .
'" selected';
264 $out .=
'>' . $labeltoshow .
'</option>';
266 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
269 $resultat =
'<option value="' . $obj->rowid .
'"';
271 $resultat .=
' disabled';
276 $resultat .= $labeltoshow;
277 $resultat .=
'</option>';
282 'key' => (
int) $obj->rowid,
283 'value' => $obj->ref,
285 'labelx' => $labeltoshow,
286 'label' => ($disabled ?
'<span class="opacitymedium">' . $labeltoshow .
'</span>' : $labeltoshow),
287 'disabled' => (
bool) $disabled
295 $this->db->free($resql);
298 if (empty($option_only)) {
303 if (!empty($conf->use_javascript_ajax)) {
304 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
305 $comboenhancement =
ajax_combobox($htmlid, array(), 0, $forcefocus);
306 $out .= $comboenhancement;
307 $morecss .=
' minwidth100';
310 if (empty($nooutput)) {
345 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)
347 global $user, $conf, $langs;
349 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
351 if (is_null($usertofilter)) {
352 $usertofilter = $user;
357 $hideunselectables =
false;
359 $hideunselectables =
true;
362 if (empty($projectsListId)) {
363 if (!$usertofilter->hasRight(
'projet',
'all',
'lire')) {
364 $projectstatic =
new Project($this->db);
365 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
370 $sql =
"SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,";
371 $sql .=
" p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,";
372 $sql .=
" s.nom as name";
373 $sql .=
" FROM " . $this->db->prefix() .
"projet as p";
374 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON s.rowid = p.fk_soc,";
375 $sql .=
" " . $this->db->prefix() .
"projet_task as t";
376 $sql .=
" WHERE p.entity IN (" .
getEntity(
'project') .
")";
377 $sql .=
" AND t.fk_projet = p.rowid";
378 if ($projectsListId) {
379 $sql .=
" AND p.rowid IN (" . $this->db->sanitize($projectsListId) .
")";
382 $sql .=
" AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
385 $sql .=
" AND (p.fk_soc=" . ((int) $socid) .
" OR p.fk_soc IS NULL)";
387 $sql .=
" ORDER BY p.ref, t.ref ASC";
389 $resql = $this->db->query($sql);
392 if (empty($option_only) && !empty($conf->use_javascript_ajax)) {
393 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
394 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
395 $out .= $comboenhancement;
396 $morecss .=
' minwidth150imp';
399 if (empty($option_only)) {
400 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
402 if (!empty($show_empty)) {
403 $out .=
'<option value="0" class="optiongrey">';
404 if (!is_numeric($show_empty)) {
414 $num = $this->db->num_rows($resql);
418 $obj = $this->db->fetch_object($resql);
420 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight(
'societe',
'lire')) {
429 $labeltoshowhtml =
'';
435 if ($discard_closed == 2) {
438 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
442 if (preg_match(
'/all/', $showmore)) {
443 $labeltoshow .=
dol_trunc($obj->ref, 18);
446 $labeltoshow .=
' ' .
dol_trunc($obj->title, $maxlength);
447 $labeltoshowhtml = $labeltoshow;
450 $labeltoshow .=
' (' . $obj->name .
')';
451 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->name .
')</span>';
457 $labeltoshow .=
' - ' . $langs->trans(
"Draft");
458 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"Draft") .
'</span>';
460 if ($discard_closed == 2) {
463 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
464 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"Closed") .
'</span>';
465 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
467 $labeltoshow .=
' - ' . $langs->trans(
"LinkedToAnotherCompany");
468 $labeltoshowhtml .=
' - <span class="opacitymedium">' . $langs->trans(
"LinkedToAnotherCompany") .
'</span>';
470 $labeltoshow .=
' - ';
471 $labeltoshowhtml .=
' - ';
475 $labeltoshow .= $obj->tref .
' ' .
dol_trunc($obj->tlabel, $maxlength);
476 $labeltoshowhtml .= $obj->tref .
' - ' .
dol_trunc($obj->tlabel, $maxlength);
477 if ($obj->usage_task && preg_match(
'/progress/', $showmore)) {
478 $labeltoshow .=
' <span class="opacitymedium">(' . $obj->progress .
'%)</span>';
479 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->progress .
'%)</span>';
482 if (!empty($selected) && $selected == $obj->rowid) {
483 $out .=
'<option value="' . $obj->rowid .
'" selected';
486 $out .=
'>' . $labeltoshow .
'</option>';
488 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
491 $resultat =
'<option value="' . $obj->rowid .
'"';
493 $resultat .=
' disabled';
499 $resultat .= $labeltoshow;
500 $resultat .=
'</option>';
508 if (empty($option_only)) {
512 $this->nboftasks = $num;
513 $this->db->free($resql);
516 if (empty($nooutput)) {
543 public function select_element($table_element, $socid = 0, $morecss =
'', $limitonstatus = -2, $projectkey =
"fk_projet", $placeholder =
'')
546 global $conf, $langs;
548 if ($table_element ==
'projet_task') {
552 $linkedtothirdparty =
false;
558 'expensereport',
'loan',
566 $linkedtothirdparty =
true;
572 switch ($table_element) {
574 $sql =
"SELECT t.rowid, t.label as ref";
577 $sql =
"SELECT t.rowid, t.ref as ref";
579 case "facture_fourn":
580 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
582 case "commande_fourn":
583 case "commande_fournisseur":
584 $sql =
"SELECT t.rowid, t.ref, t.ref_supplier";
587 $sql =
"SELECT t.rowid, t.titre as ref";
590 $sql =
"SELECT t.id as rowid, t.label as ref";
591 $projectkey =
"fk_project";
593 case "expensereport":
595 case "expensereport_det":
603 $sql =
"SELECT t.rowid, t.ref";
605 case 'stock_mouvement':
606 $sql =
"SELECT t.rowid, t.label as ref";
607 $projectkey =
'fk_origin';
609 case "payment_salary":
610 $sql =
"SELECT t.rowid, t.num_payment as ref";
612 case "payment_various":
613 $sql =
"SELECT t.rowid, t.num_payment as ref";
615 case "chargesociales":
617 $sql =
"SELECT t.rowid, t.ref";
620 if ($linkedtothirdparty) {
621 $sql .=
", s.nom as name";
623 $sql .=
" FROM " . $this->db->prefix() . $table_element .
" as t";
624 if ($linkedtothirdparty) {
625 $sql .=
", " . $this->db->prefix() .
"societe as s";
627 $sql .=
" WHERE " . $projectkey .
" is null";
628 if (!empty($socid) && $linkedtothirdparty) {
629 if (is_numeric($socid)) {
630 $sql .=
" AND t.fk_soc = " . ((int) $socid);
632 $sql .=
" AND t.fk_soc IN (" . $this->db->sanitize($socid) .
")";
635 if (!in_array($table_element, array(
'expensereport_det',
'stock_mouvement'))) {
636 $sql .=
' AND t.entity IN (' .
getEntity(
'project') .
')';
638 if ($linkedtothirdparty) {
639 $sql .=
" AND s.rowid = t.fk_soc";
642 $sql .=
" AND " . $sqlfilter;
644 $sql .=
" ORDER BY ref DESC";
646 dol_syslog(get_class($this) .
'::select_element', LOG_DEBUG);
647 $resql = $this->db->query($sql);
649 $num = $this->db->num_rows($resql);
654 $sellist =
'<select class="flat elementselect css' . $table_element . ($morecss ?
' ' . $morecss :
'') .
'" name="elementselect">';
655 $sellist .=
'<option value="-1"' . ($placeholder ?
' class="optiongrey"' :
'') .
'>' . $placeholder .
'</option>';
657 $obj = $this->db->fetch_object($resql);
658 $ref = $obj->ref ? $obj->ref : $obj->rowid;
659 if (!empty($obj->ref_supplier)) {
660 $ref .=
' (' . $obj->ref_supplier .
')';
662 if (!empty($obj->name)) {
663 $ref .=
' - ' . $obj->name;
665 $sellist .=
'<option value="' . $obj->rowid .
'">' . $ref .
'</option>';
668 $sellist .=
'</select>';
676 $this->db->free($resql);
681 $this->error = $this->db->lasterror();
682 $this->errors[] = $this->db->lasterror();
683 dol_syslog(get_class($this) .
"::select_element " . $this->error, LOG_ERR);
703 public function selectOpportunityStatus($htmlname, $preselected =
'-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss =
'', $noadmininfo = 0, $addcombojs = 0)
705 global $conf, $langs, $user;
707 $sql =
"SELECT rowid, code, label, percent";
708 $sql .=
" FROM " . $this->db->prefix() .
'c_lead_status';
709 $sql .=
" WHERE active = 1";
710 $sql .=
" ORDER BY position";
712 $resql = $this->db->query($sql);
714 $num = $this->db->num_rows($resql);
718 $sellist =
'<select class="flat oppstatus' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
721 $sellist .=
'<option value="-1"> </option>';
724 $sellist .=
'<option value="all"' . ($preselected ==
'all' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OnlyOpportunitiesShort") .
'</option>';
725 $sellist .=
'<option value="openedopp"' . ($preselected ==
'openedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"OpenedOpportunitiesShort") .
'</option>';
726 $sellist .=
'<option value="notopenedopp"' . ($preselected ==
'notopenedopp' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotOpenedOpportunitiesShort") .
'</option>';
727 $sellist .=
'<option value="none"' . ($preselected ==
'none' ?
' selected="selected"' :
'') .
'>-- ' . $langs->trans(
"NotAnOpportunityShort") .
'</option>';
730 $obj = $this->db->fetch_object($resql);
732 $sellist .=
'<option value="' . $obj->rowid .
'" defaultpercent="' . $obj->percent .
'" elemcode="' . $obj->code .
'"';
733 if ($obj->rowid == $preselected) {
734 $sellist .=
' selected="selected"';
737 if ($useshortlabel) {
738 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
740 $finallabel = ($langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) !=
"OppStatus" . $obj->code ? $langs->transnoentitiesnoconv(
"OppStatus" . $obj->code) : $obj->label);
742 $finallabel .=
' (' . $obj->percent .
'%)';
745 $sellist .= $finallabel;
746 $sellist .=
'</option>';
749 $sellist .=
'</select>';
751 if ($user->admin && !$noadmininfo) {
752 $sellist .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
765 $this->db->free($resql);
769 $this->error = $this->db->lasterror();
770 $this->errors[] = $this->db->lasterror();
771 dol_syslog(get_class($this) .
"::selectOpportunityStatus " . $this->error, LOG_ERR);
789 $statustohow = array(
795 $tmpproject =
new Project($this->db);
797 foreach ($statustohow as $key => $value) {
798 $tmpproject->statut = $key;
799 $options[$value] = $tmpproject->getLibStatut($short);
802 if (is_array($selected)) {
803 $selectedarray = $selected;
804 } elseif ($selected == 99) {
805 $selectedarray = array(0,1);
807 $selectedarray = explode(
',', $selected);
825 public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice =
'invoiceid', $htmlNameInvoiceLine =
'invoicelineid', $morecss =
'maxwidth500', $filters = array(), $lineOnly = 0)
827 global $user, $conf, $langs;
829 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 .
'">';
916 $num = $this->db->num_rows($resql);
918 while ($obj = $this->db->fetch_object($resql)) {
919 $labeltoshow .= $obj->description;
921 $out .=
'<option value="' . $obj->rowid .
'" ';
922 if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) {
923 $out .=
' selected ';
925 $out .=
'>' . $labeltoshow .
'</option>';
928 if (empty($lineOnly)) {
951 public function formOpportunityStatus($page, $selected =
'', $percent_value = 0, $htmlname_status =
'none', $htmlname_percent =
'none', $filter =
'', $nooutput = 0)
954 global $conf, $langs;
957 if ($htmlname_status !=
"none" && $htmlname_percent !=
'none') {
958 $out .=
'<form method="post" action="' . $page .
'">';
959 $out .=
'<input type="hidden" name="action" value="set_opp_status">';
960 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
961 $out .= $this->
selectOpportunityStatus($htmlname_status, $selected, 1, 0, 0, 0,
'minwidth150 inline-block valignmiddle', 1, 1);
962 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
963 $out .=
'<input class="width50 right" type="text" id="'.$htmlname_percent.
'" name="'.$htmlname_percent.
'" title="'.
dol_escape_htmltag($langs->trans(
"OpportunityProbability")).
'" value="'.$percent_value.
'"> %';
965 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
969 $code =
dol_getIdFromCode($this->db, $selected,
'c_lead_status',
'rowid',
'code');
970 $out .= $langs->trans(
"OppStatus".$code);
973 $out .=
' / <span title="'.$langs->trans(
"OpportunityProbability").
'"> ';
974 $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.
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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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 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...