dolibarr 21.0.0-alpha
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 = '';
36 public $nom = 'Moonstone';
37
44 public function info($langs)
45 {
46 global $langs, $db;
47
48 $langs->load("bills");
49
50 $form = new Form($db);
51
52 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
53 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
54 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
55 $texte .= '<input type="hidden" name="action" value="updateMask">';
56 $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
57 $texte .= '<table class="nobordernopadding" width="100%">';
58
59 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
60 $tooltip .= $langs->trans("GenericMaskCodes2");
61 $tooltip .= $langs->trans("GenericMaskCodes3");
62 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
63 $tooltip .= $langs->trans("GenericMaskCodes5");
64 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
65
66 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
67 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreception" value="'.getDolGlobalString("RECEPTION_MOONSTONE_MASK").'">', $tooltip, 1, 1).'</td>';
68 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
69 $texte .= '</tr>';
70 $texte .= '</table>';
71 $texte .= '</form>';
72
73 return $texte;
74 }
75
81 public function getExample()
82 {
83 global $langs, $mysoc;
84
85 $old_code_client = $mysoc->code_client;
86 $old_code_type = $mysoc->typent_code;
87 $mysoc->code_client = 'CCCCCCCCCC';
88 $mysoc->typent_code = 'TTTTTTTTTT';
89 $numExample = $this->getNextValue($mysoc, null);
90 $mysoc->code_client = $old_code_client;
91 $mysoc->typent_code = $old_code_type;
92
93 if (!$numExample) {
94 $numExample = $langs->trans('NotConfigured');
95 }
96 return $numExample;
97 }
98
106 public function getNextValue($objsoc, $reception)
107 {
108 global $db;
109
110 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
111
112 $mask = getDolGlobalString("RECEPTION_MOONSTONE_MASK");
113
114 if (!$mask) {
115 $this->error = 'NotConfigured';
116 return 0;
117 }
118
119 if (!empty($reception)) {
120 $date = $reception->date_reception;
121 } else {
122 $date = dol_now();
123 }
124
125 $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
126
127 return $numFinal;
128 }
129}
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.