dolibarr 19.0.3
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 Frédéric France <frederic.france@netlogic.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
64 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
65 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreception" value="'.getDolGlobalString("RECEPTION_MOONSTONE_MASK").'">', $tooltip, 1, 1).'</td>';
66 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
67 $texte .= '</tr>';
68 $texte .= '</table>';
69 $texte .= '</form>';
70
71 return $texte;
72 }
73
79 public function getExample()
80 {
81 global $langs, $mysoc;
82
83 $old_code_client = $mysoc->code_client;
84 $old_code_type = $mysoc->typent_code;
85 $mysoc->code_client = 'CCCCCCCCCC';
86 $mysoc->typent_code = 'TTTTTTTTTT';
87 $numExample = $this->getNextValue($mysoc, null);
88 $mysoc->code_client = $old_code_client;
89 $mysoc->typent_code = $old_code_type;
90
91 if (!$numExample) {
92 $numExample = $langs->trans('NotConfigured');
93 }
94 return $numExample;
95 }
96
104 public function getNextValue($objsoc, $reception)
105 {
106 global $db;
107
108 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
109
110 $mask = getDolGlobalString("RECEPTION_MOONSTONE_MASK");
111
112 if (!$mask) {
113 $this->error = 'NotConfigured';
114 return 0;
115 }
116
117 if (!empty($reception)) {
118 $date = $reception->date_reception;
119 } else {
120 $date = dol_now();
121 }
122
123 $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
124
125 return $numFinal;
126 }
127
128 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
136 public function reception_get_num($objsoc, $objforref)
137 {
138 // phpcs:enable
139 return $this->getNextValue($objsoc, $objforref);
140 }
141}
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.
reception_get_num($objsoc, $objforref)
Return next free 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.