dolibarr  20.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 <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
64  public function select_interventions($socid = -1, $selected = 0, $htmlname = 'interventionid', $maxlength = 16, $showempty = 1, $draftonly = false)
65  {
66  // phpcs:enable
67  global $user, $conf, $langs;
68 
69  $out = '';
70 
71  $hideunselectables = false;
72 
73  // Search all contacts
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;
77  if ($socid != '') {
78  if ($socid == '0') {
79  $sql .= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
80  } else {
81  $sql .= " AND f.fk_soc = ".((int) $socid);
82  }
83  }
84  if ($draftonly) {
85  $sql .= " AND f.fk_statut = 0";
86  }
87 
88  dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG);
89  $resql = $this->db->query($sql);
90  if ($resql) {
91  $out .= '<select id="interventionid" class="flat" name="'.dol_escape_htmltag($htmlname).'">';
92  if ($showempty) {
93  $out .= '<option value="0">';
94  if (!is_numeric($showempty)) {
95  $out .= $showempty;
96  } else {
97  $out .= '&nbsp;';
98  }
99  $out .= '</option>';
100  }
101  $num = $this->db->num_rows($resql);
102  $i = 0;
103  if ($num) {
104  while ($i < $num) {
105  $obj = $this->db->fetch_object($resql);
106  // 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.
107  if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->hasRight('societe', 'lire')) {
108  // Do nothing
109  } else {
110  $labeltoshow = dol_trunc($obj->ref, 18);
111  if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) {
112  $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
113  } else {
114  $disabled = 0;
115  if (!$obj->fk_statut > 0 && ! $draftonly) {
116  $disabled = 1;
117  $labeltoshow .= ' ('.$langs->trans("Draft").')';
118  }
119  if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
120  $disabled = 1;
121  $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
122  }
123 
124  if ($hideunselectables && $disabled) {
125  $resultat = '';
126  } else {
127  $resultat = '<option value="'.$obj->rowid.'"';
128  if ($disabled) {
129  $resultat .= ' disabled';
130  }
131  $resultat .= '>'.$labeltoshow;
132  $resultat .= '</option>';
133  }
134  $out .= $resultat;
135  }
136  }
137  $i++;
138  }
139  }
140  $out .= '</select>';
141  $this->db->free($resql);
142  return $out;
143  } else {
144  dol_print_error($this->db);
145  return '';
146  }
147  }
148 }
Class to manage generation of HTML components for contract module.
select_interventions($socid=-1, $selected=0, $htmlname='interventionid', $maxlength=16, $showempty=1, $draftonly=false)
Show a combo list with contracts qualified for a third party.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
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.