dolibarr 21.0.0-alpha
mod_expensereport_sand.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Maxime Kohlhaas <support@atm-consulting.fr>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
27require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
28
29
34{
39 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
40
44 public $error = '';
45
51 public $nom = 'Sand';
52
56 public $name = 'Sand';
57
58
65 public function info($langs)
66 {
67 global $db, $langs;
68
69 $langs->load("bills");
70
71 $form = new Form($db);
72
73 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
76 $texte .= '<input type="hidden" name="action" value="updateMask">';
77 $texte .= '<input type="hidden" name="maskconst" value="EXPENSEREPORT_SAND_MASK">';
78 $texte .= '<table class="nobordernopadding centpercent">';
79
80 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport"));
81 //$tooltip.=$langs->trans("GenericMaskCodes2");
82 $tooltip .= $langs->trans("GenericMaskCodes3");
83 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport"));
84 $tooltip .= $langs->trans("GenericMaskCodes5");
85 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
86
87 // Parametrage du prefix
88 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
89 $mask = getDolGlobalString('EXPENSEREPORT_SAND_MASK');
90 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.$mask.'">', $tooltip, 1, 1).'</td>';
91
92 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
93
94 $texte .= '</tr>';
95
96 $texte .= '</table>';
97 $texte .= '</form>';
98
99 return $texte;
100 }
101
107 public function getExample()
108 {
109 global $db, $langs, $user;
110
111 $exp = new ExpenseReport($db);
112 $exp->initAsSpecimen();
113 $exp->fk_user_author = $user->id;
114
115 $numExample = $this->getNextValue($exp);
116
117 if (!$numExample) {
118 $numExample = $langs->trans('NotConfigured');
119 }
120 return $numExample;
121 }
122
129 public function getNextValue($object)
130 {
131 global $db;
132
133 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
134
135 // We get cursor rule
136 $mask = getDolGlobalString('EXPENSEREPORT_SAND_MASK');
137
138 if (!$mask) {
139 $this->error = 'NotConfigured';
140 return 0;
141 }
142
143 $date = $object->date_valid; // $object->date does not exists
144 if (empty($date)) {
145 $this->error = 'Date valid not defined';
146 return 0;
147 }
148
149 $fuser = null;
150 if ($object->fk_user_author > 0) {
151 $fuser = new User($db);
152 $fuser->fetch($object->fk_user_author);
153 }
154
155 $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser);
156
157 return $numFinal;
158 }
159}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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($langs)
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)
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.