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 *
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 .= $langs->trans("GenericMaskCodes3");
92 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
93 $tooltip .= $langs->trans("GenericMaskCodes5");
94
95 // Setting the prefix
96 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
97 $texte .= ':</td>';
98 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskinvoice" value="'.getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
99
100 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
101
102 $texte .= '</tr>';
103
104 // Prefix setting of credit note
105 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
106 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcredit" value="'.getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
107 $texte .= '</tr>';
108
109 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
110 // Parametrage du prefix des replacement
111 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
112 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreplacement" value="'.getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
113 $texte .= '</tr>';
114 }
115
116 // Prefix setting of deposit
117 $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
118 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskdeposit" value="'.getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>';
119 $texte .= '</tr>';
120
121 $texte .= '</table>';
122 $texte .= '</form>';
123
124 return $texte;
125 }
126
132 public function getExample()
133 {
134 global $conf, $langs, $mysoc;
135
136 $old_code_client = $mysoc->code_client;
137 $mysoc->code_client = 'CCCCCCCCCC';
138 $numExample = $this->getNextValue($mysoc, '');
139 $mysoc->code_client = $old_code_client;
140
141 if (!$numExample) {
142 $numExample = $langs->trans('NotConfigured');
143 }
144 return $numExample;
145 }
146
155 public function getNextValue($objsoc, $object, $mode = 'next')
156 {
157 global $db, $conf;
158
159 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
160
161 // Get Mask value
162 $mask = '';
163 if (is_object($object) && $object->type == 1) {
164 $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK");
165 if (!$mask) {
166 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
167 }
168 } elseif (is_object($object) && $object->type == 2) {
169 $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK");
170 } elseif (is_object($object) && $object->type == 3) {
171 $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK");
172 } else {
173 $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK");
174 }
175 if (!$mask) {
176 $this->error = 'NotConfigured';
177 return 0;
178 }
179
180 // Supplier invoices take invoice date instead of creation date for the mask
181 $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date);
182
183 return $numFinal;
184 }
185
195 public function getNumRef($objsoc, $objforref, $mode = 'next')
196 {
197 return $this->getNextValue($objsoc, $objforref, $mode);
198 }
199}
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.