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