dolibarr  18.0.0-alpha
html.formexpensereport.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 
62  public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0)
63  {
64  global $langs;
65 
66  $tmpep = new ExpenseReport($this->db);
67 
68  print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
69  if ($useempty) {
70  print '<option value="-1">&nbsp;</option>';
71  }
72  $arrayoflabels = $tmpep->statuts;
73  if ($useshortlabel) {
74  $arrayoflabels = $tmpep->statuts_short;
75  }
76  foreach ($arrayoflabels as $key => $val) {
77  if ($selected != '' && $selected == $key) {
78  print '<option value="'.$key.'" selected>';
79  } else {
80  print '<option value="'.$key.'">';
81  }
82  print $langs->trans($val);
83  print '</option>';
84  }
85  print '</select>';
86  print ajax_combobox($htmlname);
87  }
88 
98  public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1)
99  {
100  // phpcs:enable
101  global $langs, $user;
102  $langs->load("trips");
103 
104  $out = '';
105 
106  $out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
107  if ($showempty) {
108  $out .= '<option value="-1"';
109  if ($selected == -1) {
110  $out .= ' selected';
111  }
112  $out .= '>&nbsp;</option>';
113  }
114 
115  $sql = "SELECT c.id, c.code, c.label as type FROM ".$this->db->prefix()."c_type_fees as c";
116  if ($active >= 0) {
117  $sql .= " WHERE c.active = ".((int) $active);
118  }
119  $sql .= " ORDER BY c.label ASC";
120  $resql = $this->db->query($sql);
121  if ($resql) {
122  $num = $this->db->num_rows($resql);
123  $i = 0;
124 
125  while ($i < $num) {
126  $obj = $this->db->fetch_object($resql);
127  $out .= '<option value="'.$obj->id.'"';
128  if ($obj->code == $selected || $obj->id == $selected) {
129  $out .= ' selected';
130  }
131  $out .= '>';
132  if ($obj->code != $langs->trans($obj->code)) {
133  $out .= $langs->trans($obj->code);
134  } else {
135  $out .= $langs->trans($obj->type);
136  }
137  $i++;
138  }
139  }
140  $out .= '</select>';
141  $out .= ajax_combobox($htmlname);
142 
143  return $out;
144  }
145 }
db
$conf db
API class for accounts.
Definition: inc.php:41
$sql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:745
FormExpenseReport\selectTypeExpenseReport
selectTypeExpenseReport($selected='', $htmlname='type', $showempty=0, $active=1)
Return list of types of notes with select value = id.
Definition: html.formexpensereport.class.php:98
FormExpenseReport
Class to manage generation of HTML components for contract module.
Definition: html.formexpensereport.class.php:28
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
FormExpenseReport\__construct
__construct($db)
Constructor.
Definition: html.formexpensereport.class.php:46
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
FormExpenseReport\selectExpensereportStatus
selectExpensereportStatus($selected='', $htmlname='fk_statut', $useempty=1, $useshortlabel=0)
Retourne la liste deroulante des differents etats d'une note de frais.
Definition: html.formexpensereport.class.php:62