66 public function select_interventions($socid = -1, $selected = 0, $htmlname =
'interventionid', $maxlength = 16, $showempty =
'1', $draftonly =
false)
69 global $user,
$conf, $langs;
73 $hideunselectables =
getDolGlobalInt(
'MAIN_SHOW_UNSELECTABLES_IN_SELECT_INTERVENTIONS');
76 $sql =
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
77 $sql .=
" FROM ".$this->db->prefix().
"fichinter as f";
78 $sql .=
" WHERE f.entity = ".$conf->entity;
81 $sql .=
" AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
83 $sql .=
" AND f.fk_soc = ".((int) $socid);
87 $sql .=
" AND f.fk_statut = 0";
90 dol_syslog(get_class($this).
"::select_interventions", LOG_DEBUG);
91 $resql = $this->db->query($sql);
93 $out .=
'<select id="'.dol_escape_htmltag($htmlname).
'" class="flat" name="'.
dol_escape_htmltag($htmlname).
'">';
95 $out .=
'<option value="0">';
96 if (!is_numeric($showempty)) {
103 $num = $this->db->num_rows($resql);
107 $obj = $this->db->fetch_object($resql);
109 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight(
'societe',
'lire')) {
113 if (!empty($selected) && $selected == $obj->rowid && $obj->status > 0) {
114 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
117 if (!$obj->status > 0 && ! $draftonly) {
119 $labeltoshow .=
' ('.$langs->trans(
"Draft").
')';
121 if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
123 $labeltoshow .=
' - '.$langs->trans(
"LinkedToAnotherCompany");
126 if ($hideunselectables && $disabled) {
129 $resultat =
'<option value="'.$obj->rowid.
'"';
131 $resultat .=
' disabled';
133 $resultat .=
'>'.$labeltoshow;
134 $resultat .=
'</option>';
143 $this->db->free($resql);
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...