64  public function select_interventions($socid = -1, $selected = 0, $htmlname = 
'interventionid', $maxlength = 16, $showempty = 1, $draftonly = 
false)
 
   67    global $user, $conf, $langs;
 
   71    $hideunselectables = 
false;
 
   74    $sql = 
"SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut";
 
   75    $sql .= 
" FROM ".$this->db->prefix().
"fichinter as f";
 
   76    $sql .= 
" WHERE f.entity = ".$conf->entity;
 
   79        $sql .= 
" AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
 
   81        $sql .= 
" AND f.fk_soc = ".((int) $socid);
 
   85      $sql .= 
" AND f.fk_statut = 0";
 
   88    dol_syslog(get_class($this).
"::select_intervention", LOG_DEBUG);
 
   89    $resql = $this->db->query($sql);
 
   91      $out .= 
'<select id="interventionid" class="flat" name="'.dol_escape_htmltag($htmlname).
'">';
 
   93        $out .= 
'<option value="0">';
 
   94        if (!is_numeric($showempty)) {
 
  101      $num = $this->db->num_rows($resql);
 
  105          $obj = $this->db->fetch_object($resql);
 
  107          if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight(
'societe', 
'lire')) {
 
  111            if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) {
 
  112              $out .= 
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
 
  115              if (!$obj->fk_statut > 0 && ! $draftonly) {
 
  117                $labeltoshow .= 
' ('.$langs->trans(
"Draft").
')';
 
  119              if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
 
  121                $labeltoshow .= 
' - '.$langs->trans(
"LinkedToAnotherCompany");
 
  124              if ($hideunselectables && $disabled) {
 
  127                $resultat = 
'<option value="'.$obj->rowid.
'"';
 
  129                  $resultat .= 
' disabled';
 
  131                $resultat .= 
'>'.$labeltoshow;
 
  132                $resultat .= 
'</option>';
 
  141      $this->db->free($resql);