dolibarr  13.0.2
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) print '<option value="-1">&nbsp;</option>';
70  $arrayoflabels = $tmpep->statuts;
71  if ($useshortlabel) $arrayoflabels = $tmpep->statuts_short;
72  foreach ($arrayoflabels as $key => $val)
73  {
74  if ($selected != '' && $selected == $key)
75  {
76  print '<option value="'.$key.'" selected>';
77  } else {
78  print '<option value="'.$key.'">';
79  }
80  print $langs->trans($val);
81  print '</option>';
82  }
83  print '</select>';
84  print ajax_combobox($htmlname);
85  }
86 
96  public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1)
97  {
98  // phpcs:enable
99  global $langs, $user;
100  $langs->load("trips");
101 
102  $out = '';
103 
104  $out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
105  if ($showempty)
106  {
107  $out .= '<option value="-1"';
108  if ($selected == -1) $out .= ' selected';
109  $out .= '>&nbsp;</option>';
110  }
111 
112  $sql = "SELECT c.id, c.code, c.label as type FROM ".MAIN_DB_PREFIX."c_type_fees as c";
113  if ($active >= 0) $sql .= " WHERE c.active = ".$active;
114  $sql .= " ORDER BY c.label ASC";
115  $resql = $this->db->query($sql);
116  if ($resql)
117  {
118  $num = $this->db->num_rows($resql);
119  $i = 0;
120 
121  while ($i < $num)
122  {
123  $obj = $this->db->fetch_object($resql);
124  $out .= '<option value="'.$obj->id.'"';
125  if ($obj->code == $selected || $obj->id == $selected) $out .= ' selected';
126  $out .= '>';
127  if ($obj->code != $langs->trans($obj->code)) $out .= $langs->trans($obj->code);
128  else $out .= $langs->trans($obj->type);
129  $i++;
130  }
131  }
132  $out .= '</select>';
133  $out .= ajax_combobox($htmlname);
134 
135  return $out;
136  }
137 }
Class to manage generation of HTML components for contract module.
selectTypeExpenseReport($selected= '', $htmlname= 'type', $showempty=0, $active=1)
Return list of types of notes with select value = id.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
$conf db
API class for accounts.
Definition: inc.php:54
Class to manage Trips and Expenses.
print
Draft customers invoices.
Definition: index.php:89
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
selectExpensereportStatus($selected= '', $htmlname= 'fk_statut', $useempty=1, $useshortlabel=0)
Retourne la liste deroulante des differents etats d&#39;une note de frais.