dolibarr 18.0.6
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
68 public function info()
69 {
70 global $langs, $db;
71
72 // Load translation files required by the page
73 $langs->loadLangs(array("bills", "admin"));
74
75 $form = new Form($db);
76
77 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
80 $texte .= '<input type="hidden" name="action" value="updateMask">';
81 $texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
82 $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
83 $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
84 $texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
85 $texte .= '<table class="nobordernopadding" width="100%">';
86
87 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
88 $tooltip .= $langs->trans("GenericMaskCodes2");
89 $tooltip .= $langs->trans("GenericMaskCodes3");
90 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
91 $tooltip .= $langs->trans("GenericMaskCodes5");
92
93 // Setting the prefix
94 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95 $texte .= ':</td>';
96 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskinvoice" value="'.getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
97
98 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
99
100 $texte .= '</tr>';
101
102 // Prefix setting of credit note
103 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcredit" value="'.getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
105 $texte .= '</tr>';
106
107 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
108 // Parametrage du prefix des replacement
109 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
110 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreplacement" value="'.getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
111 $texte .= '</tr>';
112 }
113
114 // Prefix setting of deposit
115 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
116 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskdeposit" value="'.getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
117 $texte .= '</tr>';
118
119 $texte .= '</table>';
120 $texte .= '</form>';
121
122 return $texte;
123 }
124
130 public function getExample()
131 {
132 global $conf, $langs, $mysoc;
133
134 $old_code_client = $mysoc->code_client;
135 $mysoc->code_client = 'CCCCCCCCCC';
136 $numExample = $this->getNextValue($mysoc, '');
137 $mysoc->code_client = $old_code_client;
138
139 if (!$numExample) {
140 $numExample = $langs->trans('NotConfigured');
141 }
142 return $numExample;
143 }
144
153 public function getNextValue($objsoc, $object, $mode = 'next')
154 {
155 global $db, $conf;
156
157 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
158
159 // Get Mask value
160 $mask = '';
161 if (is_object($object) && $object->type == 1) {
162 $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK");
163 if (!$mask) {
164 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
165 }
166 } elseif (is_object($object) && $object->type == 2) {
167 $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK");
168 } elseif (is_object($object) && $object->type == 3) {
169 $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK");
170 } else {
171 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
172 }
173 if (!$mask) {
174 $this->error = 'NotConfigured';
175 return 0;
176 }
177
178 // Supplier invoices take invoice date instead of creation date for the mask
179 $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date);
180
181 return $numFinal;
182 }
183
192 public function getNumRef($objsoc, $objforref, $mode = 'next')
193 {
194 return $this->getNextValue($objsoc, $objforref, $mode);
195 }
196}
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()
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 dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.