dolibarr 19.0.3
mod_contract_magre.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
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/contract/modules_contract.php';
27
32{
37 public $version = 'dolibarr';
38
42 public $error = '';
43
49 public $nom = 'Magre';
50
54 public $name = 'Magre';
55
59 public $code_auto = 1;
60
67 public function info($langs)
68 {
69 global $langs, $db;
70
71 $langs->load("bills");
72
73 $form = new Form($db);
74
75 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
76 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
77 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
78 $texte .= '<input type="hidden" name="action" value="updateMask">';
79 $texte .= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
80 $texte .= '<table class="nobordernopadding" width="100%">';
81
82 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
83 $tooltip .= $langs->trans("GenericMaskCodes2");
84 $tooltip .= $langs->trans("GenericMaskCodes3");
85 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
86 $tooltip .= $langs->trans("GenericMaskCodes5");
87
88 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
89 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcontract" value="'.getDolGlobalString("CONTRACT_MAGRE_MASK").'">', $tooltip, 1, 1).'</td>';
90 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
91 $texte .= '</tr>';
92 $texte .= '</table>';
93 $texte .= '</form>';
94
95 return $texte;
96 }
97
103 public function getExample()
104 {
105 global $langs, $mysoc;
106
107 $old_code_client = $mysoc->code_client;
108 $mysoc->code_client = 'CCCCCCCCCC';
109 $numExample = $this->getNextValue($mysoc, '');
110 $mysoc->code_client = $old_code_client;
111
112 if (!$numExample) {
113 $numExample = $langs->trans('NotConfigured');
114 }
115 return $numExample;
116 }
117
125 public function getNextValue($objsoc, $contract)
126 {
127 global $db;
128
129 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
130
131 $mask = getDolGlobalString("CONTRACT_MAGRE_MASK");
132
133 if (!$mask) {
134 $this->error = 'NotConfigured';
135 return 0;
136 }
137
138 $numFinal = get_next_value($db, $mask, 'contrat', 'ref', '', $objsoc, $contract->date_contrat);
139
140 return $numFinal;
141 }
142
143 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
151 public function contract_get_num($objsoc, $objforref)
152 {
153 // phpcs:enable
154 return $this->getNextValue($objsoc, $objforref);
155 }
156}
Class to manage generation of HTML components Only common components must be here.
Parent class for all contract numbering modules.
Class to manage contract numbering rules Magre.
getNextValue($objsoc, $contract)
Return next value.
getExample()
Return numbering example.
info($langs)
Return default description of numbering model.
contract_get_num($objsoc, $objforref)
Return next value.
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)
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.