dolibarr 21.0.0-alpha
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 .= '<table class="nobordernopadding" width="100%">';
89
90 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
91 $tooltip .= $langs->trans("GenericMaskCodes2");
92 $tooltip .= '<br>';
93 $tooltip .= $langs->trans("GenericMaskCodes3");
94 $tooltip .= '<br>';
95 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
96 $tooltip .= $langs->trans("GenericMaskCodes5");
97 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
98
99 // Setting the prefix
100 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
101 $texte .= ':</td>';
102 $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>';
103
104 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
105
106 $texte .= '</tr>';
107
108 // Prefix setting of credit note
109 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
110 $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>';
111 $texte .= '</tr>';
112
113 if (!getDolGlobalString('INVOICE_DISABLE_REPLACEMENT') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
114 // Prefix setting of replacement
115 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
116 $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>';
117 $texte .= '</tr>';
118 }
119
120 // Prefix setting of deposit
121 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
122 $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>';
123 $texte .= '</tr>';
124
125 $texte .= '</table>';
126 $texte .= '</form>';
127
128 return $texte;
129 }
130
136 public function getExample()
137 {
138 global $langs, $mysoc;
139
140 $old_code_client = $mysoc->code_client;
141 $mysoc->code_client = 'CCCCCCCCCC';
142 $numExample = $this->getNextValue($mysoc, null);
143 $mysoc->code_client = $old_code_client;
144
145 if (!$numExample) {
146 $numExample = $langs->trans('NotConfigured');
147 }
148 return $numExample;
149 }
150
159 public function getNextValue($objsoc, $object, $mode = 'next')
160 {
161 global $db;
162
163 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
164
165 // Get Mask value
166 $mask = '';
167 if (is_object($object) && $object->type == 1) {
168 $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK");
169 if (!$mask) {
170 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
171 }
172 } elseif (is_object($object) && $object->type == 2) {
173 $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK");
174 } elseif (is_object($object) && $object->type == 3) {
175 $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK");
176 } else {
177 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
178 }
179 if (!$mask) {
180 $this->error = 'NotConfigured';
181 return 0;
182 }
183
184 // Supplier invoices take invoice date instead of creation date for the mask
185 $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date);
186
187 return $numFinal;
188 }
189
199 public function getNumRef($objsoc, $objforref, $mode = 'next')
200 {
201 return $this->getNextValue($objsoc, $objforref, $mode);
202 }
203}
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 a Dolibarr global constant string value.