dolibarr 25.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 = '';
39 public $nom = 'Moonstone';
40
44 public $position = 20;
45
46
53 public function info($langs)
54 {
55 global $langs, $db;
56
57 $langs->load("bills");
58
59 $form = new Form($db);
60
61 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
62 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
63 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
64 $texte .= '<input type="hidden" name="action" value="updateMask">';
65 $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
66 $texte .= '<input type="hidden" name="page_y" value="">';
67
68 $texte .= '<table class="nobordernopadding centpercent">';
69
70 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
71 $tooltip .= $langs->trans("GenericMaskCodes1");
72 $tooltip .= '<br>';
73 $tooltip .= $langs->trans("GenericMaskCodes2");
74 $tooltip .= '<br>';
75 $tooltip .= $langs->trans("GenericMaskCodes3");
76 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
77 $tooltip .= $langs->trans("GenericMaskCodes5");
78 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
79
80 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
81 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreception" value="'.getDolGlobalString("RECEPTION_MOONSTONE_MASK").'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
82 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
83 $texte .= '</tr>';
84 $texte .= '</table>';
85 $texte .= '</form>';
86
87 return $texte;
88 }
89
95 public function getExample()
96 {
97 global $langs, $mysoc;
98
99 $old_code_client = $mysoc->code_client;
100 $old_code_type = $mysoc->typent_code;
101 $mysoc->code_client = 'CCCCCCCCCC';
102 $mysoc->typent_code = 'TTTTTTTTTT';
103 $numExample = $this->getNextValue($mysoc, null);
104 $mysoc->code_client = $old_code_client;
105 $mysoc->typent_code = $old_code_type;
106
107 if (!$numExample) {
108 $numExample = $langs->trans('NotConfigured');
109 }
110 return $numExample;
111 }
112
120 public function getNextValue($objsoc, $reception)
121 {
122 global $db;
123
124 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
125
126 $mask = getDolGlobalString("RECEPTION_MOONSTONE_MASK");
127
128 if (!$mask) {
129 $this->error = 'NotConfigured';
130 return 0;
131 }
132
133 if (!empty($reception)) {
134 $date = $reception->date_reception;
135 } else {
136 $date = dol_now();
137 }
138
139 $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
140
141 return $numFinal;
142 }
143}
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.
global $mysoc
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null, $objbookkeeping=null)
Return last or next value for a mask (according to area we should not reset)
dol_now($mode='gmt')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140