dolibarr 18.0.6
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 <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
26
27
32{
37 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38
42 public $error = '';
43
49 public $nom = 'Sand';
50
54 public $name = 'Sand';
55
56
62 public function info()
63 {
64 global $db, $conf, $langs;
65
66 $langs->load("bills");
67
68 $form = new Form($db);
69
70 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
73 $texte .= '<input type="hidden" name="action" value="updateMask">';
74 $texte .= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">';
75 $texte .= '<table class="nobordernopadding" width="100%">';
76
77 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport"));
78 //$tooltip.=$langs->trans("GenericMaskCodes2");
79 $tooltip .= $langs->trans("GenericMaskCodes3");
80 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport"));
81 $tooltip .= $langs->trans("GenericMaskCodes5");
82
83 // Parametrage du prefix
84 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
85 $mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK;
86 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.$mask.'">', $tooltip, 1, 1).'</td>';
87
88 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button" value="'.$langs->trans("Modify").'"></td>';
89
90 $texte .= '</tr>';
91
92 $texte .= '</table>';
93 $texte .= '</form>';
94
95 return $texte;
96 }
97
103 public function getExample()
104 {
105 global $db, $conf, $langs, $user;
106
107 $exp = new ExpenseReport($db);
108 $exp->initAsSpecimen();
109 $exp->fk_user_author = $user->id;
110
111 $numExample = $this->getNextValue($exp);
112
113 if (!$numExample) {
114 $numExample = $langs->trans('NotConfigured');
115 }
116 return $numExample;
117 }
118
125 public function getNextValue($object)
126 {
127 global $db, $conf;
128
129 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
130
131 // We get cursor rule
132 $mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK;
133
134 if (!$mask) {
135 $this->error = 'NotConfigured';
136 return 0;
137 }
138
139 $date = $object->date_valid; // $object->date does not exists
140 if (empty($date)) {
141 $this->error = 'Date valid not defined';
142 return 0;
143 }
144
145 $fuser = null;
146 if ($object->fk_user_author > 0) {
147 $fuser = new User($db);
148 $fuser->fetch($object->fk_user_author);
149 }
150
151 $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser);
152
153 return $numFinal;
154 }
155}
Class to manage Trips and Expenses.
Class to manage generation of HTML components Only common components must be here.
Parent class for numbering masks of expense reports.
Class to manage Dolibarr users.
Class to manage expense report numbering rules Sand.
info()
Returns the description of the numbering model.
getExample()
Return an example of numbering.
getNextValue($object)
Return next free value.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null)
Return last or next value for a mask (according to area we should not reset)