dolibarr 20.0.0
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
26require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
27
32{
33 public $version = 'dolibarr';
34 public $error = '';
35 public $nom = 'Moonstone';
36
43 public function info($langs)
44 {
45 global $langs, $db;
46
47 $langs->load("bills");
48
49 $form = new Form($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="'.newToken().'">';
54 $texte .= '<input type="hidden" name="action" value="updateMask">';
55 $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
56 $texte .= '<table class="nobordernopadding" width="100%">';
57
58 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
59 $tooltip .= $langs->trans("GenericMaskCodes2");
60 $tooltip .= $langs->trans("GenericMaskCodes3");
61 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
62 $tooltip .= $langs->trans("GenericMaskCodes5");
63 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
64
65 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
66 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreception" value="'.getDolGlobalString("RECEPTION_MOONSTONE_MASK").'">', $tooltip, 1, 1).'</td>';
67 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
68 $texte .= '</tr>';
69 $texte .= '</table>';
70 $texte .= '</form>';
71
72 return $texte;
73 }
74
80 public function getExample()
81 {
82 global $langs, $mysoc;
83
84 $old_code_client = $mysoc->code_client;
85 $old_code_type = $mysoc->typent_code;
86 $mysoc->code_client = 'CCCCCCCCCC';
87 $mysoc->typent_code = 'TTTTTTTTTT';
88 $numExample = $this->getNextValue($mysoc, null);
89 $mysoc->code_client = $old_code_client;
90 $mysoc->typent_code = $old_code_type;
91
92 if (!$numExample) {
93 $numExample = $langs->trans('NotConfigured');
94 }
95 return $numExample;
96 }
97
105 public function getNextValue($objsoc, $reception)
106 {
107 global $db;
108
109 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
110
111 $mask = getDolGlobalString("RECEPTION_MOONSTONE_MASK");
112
113 if (!$mask) {
114 $this->error = 'NotConfigured';
115 return 0;
116 }
117
118 if (!empty($reception)) {
119 $date = $reception->date_reception;
120 } else {
121 $date = dol_now();
122 }
123
124 $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
125
126 return $numFinal;
127 }
128}
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 dolibarr global constant string value.