dolibarr  13.0.2
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 <https://www.gnu.org/licenses/>.
16  * or see https://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.ScopeNotCamelCaps
63  public 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 = $this->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 = $this->db->num_rows($resql);
89  $i = 0;
90  if ($num)
91  {
92  while ($i < $num)
93  {
94  $obj = $this->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  } else {
100  $labeltoshow = dol_trunc($obj->ref, 18);
101  if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
102  {
103  $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
104  } else {
105  $disabled = 0;
106  if (!$obj->fk_statut > 0)
107  {
108  $disabled = 1;
109  $labeltoshow .= ' ('.$langs->trans("Draft").')';
110  }
111  if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
112  {
113  $disabled = 1;
114  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
115  }
116 
117  if ($hideunselectables && $disabled)
118  {
119  $resultat = '';
120  } else {
121  $resultat = '<option value="'.$obj->rowid.'"';
122  if ($disabled) $resultat .= ' disabled';
123  $resultat .= '>'.$labeltoshow;
124  $resultat .= '</option>';
125  }
126  $out .= $resultat;
127  }
128  }
129  $i++;
130  }
131  }
132  $out .= '</select>';
133  $this->db->free($resql);
134  return $out;
135  } else {
136  dol_print_error($this->db);
137  return '';
138  }
139  }
140 }
select_interventions($socid=-1, $selected= '', $htmlname= 'interventionid', $maxlength=16, $showempty=1)
Show a combo list with contracts qualified for a third party.
Class to manage generation of HTML components for contract module.
$conf db
API class for accounts.
Definition: inc.php:54
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $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 &#39;...&#39; if string larger than length.