dolibarr 20.0.2
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 * or see https://www.gnu.org/
23 */
24
31require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
32
33
39{
44 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
45
49 public $error = '';
50
56 public $nom = 'Tulip';
57
61 public $name = 'Tulip';
62
63
70 public function info($langs)
71 {
72 global $langs, $db;
73
74 // Load translation files required by the page
75 $langs->loadLangs(array("bills", "admin"));
76
77 $form = new Form($db);
78
79 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
80 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
81 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
82 $texte .= '<input type="hidden" name="action" value="updateMask">';
83 $texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
84 $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
85 $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
86 $texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
87 $texte .= '<table class="nobordernopadding" width="100%">';
88
89 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
90 $tooltip .= $langs->trans("GenericMaskCodes2");
91 $tooltip .= '<br>';
92 $tooltip .= $langs->trans("GenericMaskCodes3");
93 $tooltip .= '<br>';
94 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
95 $tooltip .= $langs->trans("GenericMaskCodes5");
96 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
97
98 // Setting the prefix
99 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
100 $texte .= ':</td>';
101 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskinvoice" value="'.getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK").'">', $tooltip, 1, 1, '', 0, 3, 'tooltipstandardtulip').'</td>';
102
103 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
104
105 $texte .= '</tr>';
106
107 // Prefix setting of credit note
108 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
109 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcredit" value="'.getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK").'">', $tooltip, 1, 1, '', 0, 3, 'tooltipcredittuplie').'</td>';
110 $texte .= '</tr>';
111
112 if (!getDolGlobalString('INVOICE_DISABLE_REPLACEMENT') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
113 // Prefix setting of replacement
114 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
115 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreplacement" value="'.getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK").'">', $tooltip, 1, 1, '', 0, 3, 'tooltipreplacementtulip').'</td>';
116 $texte .= '</tr>';
117 }
118
119 // Prefix setting of deposit
120 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
121 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskdeposit" value="'.getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK").'">', $tooltip, 1, 1, '', 0, 3, 'tooltipdownpaymenttulip').'</td>';
122 $texte .= '</tr>';
123
124 $texte .= '</table>';
125 $texte .= '</form>';
126
127 return $texte;
128 }
129
135 public function getExample()
136 {
137 global $langs, $mysoc;
138
139 $old_code_client = $mysoc->code_client;
140 $mysoc->code_client = 'CCCCCCCCCC';
141 $numExample = $this->getNextValue($mysoc, '');
142 $mysoc->code_client = $old_code_client;
143
144 if (!$numExample) {
145 $numExample = $langs->trans('NotConfigured');
146 }
147 return $numExample;
148 }
149
158 public function getNextValue($objsoc, $object, $mode = 'next')
159 {
160 global $db;
161
162 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
163
164 // Get Mask value
165 $mask = '';
166 if (is_object($object) && $object->type == 1) {
167 $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK");
168 if (!$mask) {
169 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
170 }
171 } elseif (is_object($object) && $object->type == 2) {
172 $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK");
173 } elseif (is_object($object) && $object->type == 3) {
174 $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK");
175 } else {
176 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
177 }
178 if (!$mask) {
179 $this->error = 'NotConfigured';
180 return 0;
181 }
182
183 // Supplier invoices take invoice date instead of creation date for the mask
184 $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, is_object($object) ?$object->date :'');
185
186 return $numFinal;
187 }
188
198 public function getNumRef($objsoc, $objforref, $mode = 'next')
199 {
200 return $this->getNextValue($objsoc, $objforref, $mode);
201 }
202}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.