dolibarr  7.0.0-beta
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 {
30  var $db;
31  var $error;
32 
33 
39  public function __construct($db)
40  {
41  $this->db = $db;
42  }
43 
44 
55  function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1)
56  {
57  global $db,$user,$conf,$langs;
58 
59  $out='';
60 
61  $hideunselectables=false;
62 
63  // Search all contacts
64  $sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut';
65  $sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f';
66  $sql.= " WHERE f.entity = ".$conf->entity;
67  if ($socid != '')
68  {
69  if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
70  else $sql.= " AND f.fk_soc = ".$socid;
71  }
72 
73  dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG);
74  $resql=$db->query($sql);
75  if ($resql)
76  {
77  $out.='<select id="interventionid" class="flat" name="'.$htmlname.'">';
78  if ($showempty) $out.='<option value="0">&nbsp;</option>';
79  $num = $db->num_rows($resql);
80  $i = 0;
81  if ($num)
82  {
83  while ($i < $num)
84  {
85  $obj = $db->fetch_object($resql);
86  // 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.
87  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
88  {
89  // Do nothing
90  }
91  else
92  {
93  $labeltoshow=dol_trunc($obj->ref,18);
94  if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
95  {
96  $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
97  }
98  else
99  {
100  $disabled=0;
101  if (! $obj->fk_statut > 0)
102  {
103  $disabled=1;
104  $labeltoshow.=' ('.$langs->trans("Draft").')';
105  }
106  if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
107  {
108  $disabled=1;
109  $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
110  }
111 
112  if ($hideunselectables && $disabled)
113  {
114  $resultat='';
115  }
116  else
117  {
118  $resultat='<option value="'.$obj->rowid.'"';
119  if ($disabled) $resultat.=' disabled';
120  $resultat.='>'.$labeltoshow;
121  $resultat.='</option>';
122  }
123  $out.=$resultat;
124  }
125  }
126  $i++;
127  }
128  }
129  $out.='</select>';
130  $db->free($resql);
131  return $out;
132  }
133  else
134  {
135  dol_print_error($db);
136  return '';
137  }
138  }
139 }
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.
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.
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:1013
select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1)
Show a combo list with contracts qualified for a third party.