dolibarr  7.0.0-beta
mod_expensereport_sand.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Maxime Kohlhaas <support@atm-consulting.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 
25 require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php';
26 
27 
32 {
33  var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
34  var $error = '';
35  var $nom = 'Sand';
36 
37 
43  function info()
44  {
45  global $conf,$langs;
46 
47  $langs->load("bills");
48 
49  $form = new Form($this->db);
50 
51  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
52  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
53  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
54  $texte.= '<input type="hidden" name="action" value="updateMask">';
55  $texte.= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">';
56  $texte.= '<table class="nobordernopadding" width="100%">';
57 
58  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport"));
59  //$tooltip.=$langs->trans("GenericMaskCodes2");
60  $tooltip.=$langs->trans("GenericMaskCodes3");
61  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("ExpenseReport"),$langs->transnoentities("ExpenseReport"));
62  $tooltip.=$langs->trans("GenericMaskCodes5");
63 
64  // Parametrage du prefix
65  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
66  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->EXPENSEREPORT_SAND_MASK.'">',$tooltip,1,1).'</td>';
67 
68  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
69 
70  $texte.= '</tr>';
71 
72  $texte.= '</table>';
73  $texte.= '</form>';
74 
75  return $texte;
76  }
77 
83  function getExample()
84  {
85  global $conf,$langs,$user;
86 
87  $exp=new ExpenseReport($this->db);
88  $exp->initAsSpecimen();
89  $exp->fk_user_author = $user->id;
90 
91  $numExample = $this->getNextValue($exp);
92 
93  if (! $numExample)
94  {
95  $numExample = $langs->trans('NotConfigured');
96  }
97  return $numExample;
98  }
99 
106  function getNextValue($object)
107  {
108  global $db,$conf;
109 
110  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
111 
112  // We get cursor rule
113  $mask=$conf->global->EXPENSEREPORT_SAND_MASK;
114 
115  if (! $mask)
116  {
117  $this->error='NotConfigured';
118  return 0;
119  }
120 
121  $date=$object->date_valid; // $object->date does not exists
122  if (empty($date))
123  {
124  $this->error = 'Date valid not defined';
125  return 0;
126  }
127 
128  $fuser = null;
129  if ($object->fk_user_author > 0)
130  {
131  $fuser=new User($db);
132  $fuser->fetch($object->fk_user_author);
133  }
134 
135  $numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser);
136 
137  return $numFinal;
138  }
139 }
140 
getExample()
Renvoi un exemple de numerotation.
Class to manage Dolibarr users.
Definition: user.class.php:39
if(empty($reshook)) $form
View.
Definition: perms.php:103
info()
Renvoi la description du modele de numerotation.
Class to manage generation of HTML components Only common components must be here.
getNextValue($object)
Return next free value.
Parent class for numbering masks of expense reports.
Class to manage Trips and Expenses.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null)
Return last or next value for a mask (according to area we should not reset)
Class to manage expense report numbering rules Sand.