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