dolibarr 19.0.3
mod_facture_fournisseur_tulip.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
6 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2016-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
30require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
31
32
38{
43 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
44
48 public $error = '';
49
55 public $nom = 'Tulip';
56
60 public $name = 'Tulip';
61
62
69 public function info($langs)
70 {
71 global $langs, $db;
72
73 // Load translation files required by the page
74 $langs->loadLangs(array("bills", "admin"));
75
76 $form = new Form($db);
77
78 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
79 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
80 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
81 $texte .= '<input type="hidden" name="action" value="updateMask">';
82 $texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
83 $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
84 $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
85 $texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
86 $texte .= '<table class="nobordernopadding" width="100%">';
87
88 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
89 $tooltip .= $langs->trans("GenericMaskCodes2");
90 $tooltip .= $langs->trans("GenericMaskCodes3");
91 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
92 $tooltip .= $langs->trans("GenericMaskCodes5");
93
94 // Setting the prefix
95 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
96 $texte .= ':</td>';
97 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskinvoice" value="'.getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
98
99 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
100
101 $texte .= '</tr>';
102
103 // Prefix setting of credit note
104 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
105 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcredit" value="'.getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
106 $texte .= '</tr>';
107
108 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
109 // Parametrage du prefix des replacement
110 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreplacement" value="'.getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
112 $texte .= '</tr>';
113 }
114
115 // Prefix setting of deposit
116 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskdeposit" value="'.getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
118 $texte .= '</tr>';
119
120 $texte .= '</table>';
121 $texte .= '</form>';
122
123 return $texte;
124 }
125
131 public function getExample()
132 {
133 global $conf, $langs, $mysoc;
134
135 $old_code_client = $mysoc->code_client;
136 $mysoc->code_client = 'CCCCCCCCCC';
137 $numExample = $this->getNextValue($mysoc, '');
138 $mysoc->code_client = $old_code_client;
139
140 if (!$numExample) {
141 $numExample = $langs->trans('NotConfigured');
142 }
143 return $numExample;
144 }
145
154 public function getNextValue($objsoc, $object, $mode = 'next')
155 {
156 global $db, $conf;
157
158 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
159
160 // Get Mask value
161 $mask = '';
162 if (is_object($object) && $object->type == 1) {
163 $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK");
164 if (!$mask) {
165 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
166 }
167 } elseif (is_object($object) && $object->type == 2) {
168 $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK");
169 } elseif (is_object($object) && $object->type == 3) {
170 $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK");
171 } else {
172 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
173 }
174 if (!$mask) {
175 $this->error = 'NotConfigured';
176 return 0;
177 }
178
179 // Supplier invoices take invoice date instead of creation date for the mask
180 $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date);
181
182 return $numFinal;
183 }
184
193 public function getNumRef($objsoc, $objforref, $mode = 'next')
194 {
195 return $this->getNextValue($objsoc, $objforref, $mode);
196 }
197}
Class to manage generation of HTML components Only common components must be here.
Parent Class of numbering models of suppliers invoices references.
Tulip Class of numbering models of suppliers invoices references.
info($langs)
Returns the description of the model numbering.
getNumRef($objsoc, $objforref, $mode='next')
Return next free value.
getNextValue($objsoc, $object, $mode='next')
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)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.