dolibarr  9.0.0
html.formintervention.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012-2013 Charles-Fr BENKE <charles.fr@benke.fr>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
29 {
33  public $db;
34 
38  public $error='';
39 
40 
46  public function __construct($db)
47  {
48  $this->db = $db;
49  }
50 
51 
52  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
63  function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1)
64  {
65  // phpcs:enable
66  global $db,$user,$conf,$langs;
67 
68  $out='';
69 
70  $hideunselectables=false;
71 
72  // Search all contacts
73  $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut';
74  $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f';
75  $sql.= " WHERE f.entity = ".$conf->entity;
76  if ($socid != '')
77  {
78  if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
79  else $sql.= " AND f.fk_soc = ".$socid;
80  }
81 
82  dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG);
83  $resql=$db->query($sql);
84  if ($resql)
85  {
86  $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">';
87  if ($showempty) $out.='<option value="0">&nbsp;</option>';
88  $num = $db->num_rows($resql);
89  $i = 0;
90  if ($num)
91  {
92  while ($i < $num)
93  {
94  $obj = $db->fetch_object($resql);
95  // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
96  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
97  {
98  // Do nothing
99  }
100  else
101  {
102  $labeltoshow=dol_trunc($obj->ref,18);
103  if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
104  {
105  $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
106  }
107  else
108  {
109  $disabled=0;
110  if (! $obj->fk_statut > 0)
111  {
112  $disabled=1;
113  $labeltoshow.=' ('.$langs->trans("Draft").')';
114  }
115  if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
116  {
117  $disabled=1;
118  $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
119  }
120 
121  if ($hideunselectables && $disabled)
122  {
123  $resultat='';
124  }
125  else
126  {
127  $resultat='<option value="'.$obj->rowid.'"';
128  if ($disabled) $resultat.=' disabled';
129  $resultat.='>'.$labeltoshow;
130  $resultat.='</option>';
131  }
132  $out.=$resultat;
133  }
134  }
135  $i++;
136  }
137  }
138  $out.='</select>';
139  $db->free($resql);
140  return $out;
141  }
142  else
143  {
144  dol_print_error($db);
145  return '';
146  }
147  }
148 }
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
Class to manage generation of HTML components for contract module.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1)
Show a combo list with contracts qualified for a third party.