dolibarr 21.0.0-beta
mod_reception_moonstone.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
3 * Copyright (C) 2019-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/reception/modules_reception.php';
28
33{
34 public $version = 'dolibarr';
35 public $error = '';
39 public $nom = 'Moonstone';
40
47 public function info($langs)
48 {
49 global $langs, $db;
50
51 $langs->load("bills");
52
53 $form = new Form($db);
54
55 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
56 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
57 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
58 $texte .= '<input type="hidden" name="action" value="updateMask">';
59 $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
60 $texte .= '<table class="nobordernopadding" width="100%">';
61
62 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
63 $tooltip .= $langs->trans("GenericMaskCodes2");
64 $tooltip .= $langs->trans("GenericMaskCodes3");
65 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
66 $tooltip .= $langs->trans("GenericMaskCodes5");
67 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
68
69 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
70 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreception" value="'.getDolGlobalString("RECEPTION_MOONSTONE_MASK").'">', $tooltip, 1, 1).'</td>';
71 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
72 $texte .= '</tr>';
73 $texte .= '</table>';
74 $texte .= '</form>';
75
76 return $texte;
77 }
78
84 public function getExample()
85 {
86 global $langs, $mysoc;
87
88 $old_code_client = $mysoc->code_client;
89 $old_code_type = $mysoc->typent_code;
90 $mysoc->code_client = 'CCCCCCCCCC';
91 $mysoc->typent_code = 'TTTTTTTTTT';
92 $numExample = $this->getNextValue($mysoc, null);
93 $mysoc->code_client = $old_code_client;
94 $mysoc->typent_code = $old_code_type;
95
96 if (!$numExample) {
97 $numExample = $langs->trans('NotConfigured');
98 }
99 return $numExample;
100 }
101
109 public function getNextValue($objsoc, $reception)
110 {
111 global $db;
112
113 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
114
115 $mask = getDolGlobalString("RECEPTION_MOONSTONE_MASK");
116
117 if (!$mask) {
118 $this->error = 'NotConfigured';
119 return 0;
120 }
121
122 if (!empty($reception)) {
123 $date = $reception->date_reception;
124 } else {
125 $date = dol_now();
126 }
127
128 $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
129
130 return $numFinal;
131 }
132}
Class to manage generation of HTML components Only common components must be here.
Parent Class of numbering models of sending receipts references.
Class to manage reception numbering rules Moonstone.
info($langs)
Return default description of numbering model.
getNextValue($objsoc, $reception)
Return next value.
getExample()
Return numbering example.
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)
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.