dolibarr  9.0.0
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 Alexandre Spangaro <aspangaro@zendsi.com>
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 <http://www.gnu.org/licenses/>.
21  * or see http://www.gnu.org/
22  */
23 
30 require_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  function info()
69  {
70  global $conf, $langs;
71 
72  // Load translation files required by the page
73  $langs->loadLangs(array("bills","admin"));
74 
75  $form = new Form($this->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="'.$_SESSION['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  // Parametrage du prefix
94  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95  $texte.= ':</td>';
96  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>';
97 
98  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
99 
100  $texte.= '</tr>';
101 
102  // Parametrage du prefix des avoirs
103  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
105  $texte.= '</tr>';
106 
107  if ($conf->global->MAIN_FEATURE_LEVEL >= 2)
108  {
109  // Parametrage du prefix des replacement
110  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
112  $texte.= '</tr>';
113 
114 
115  // Parametrage du prefix des acomptes
116  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
118  $texte.= '</tr>';
119  }
120 
121  $texte.= '</table>';
122  $texte.= '</form>';
123 
124  return $texte;
125  }
126 
132  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  {
143  $numExample = $langs->trans('NotConfigured');
144  }
145  return $numExample;
146  }
147 
156  function getNextValue($objsoc,$object,$mode='next')
157  {
158  global $db,$conf;
159 
160  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
161 
162  // Get Mask value
163  $mask = '';
164  if (is_object($object) && $object->type == 1)
165  {
166  $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
167  if (! $mask)
168  {
169  $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
170  }
171  }
172  else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173  else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174  else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175  if (! $mask)
176  {
177  $this->error='NotConfigured';
178  return 0;
179  }
180 
181  // Supplier invoices take invoice date instead of creation date for the mask
182  $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
183 
184  return $numFinal;
185  }
186 
195  function getNumRef($objsoc,$objforref,$mode='next')
196  {
197  return $this->getNextValue($objsoc,$objforref,$mode);
198  }
199 }
200 
Parent Class of numbering models of suppliers invoices references.
Class to manage generation of HTML components Only common components must be here.
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)
Tulip Class of numbering models of suppliers invoices references.
getNumRef($objsoc, $objforref, $mode='next')
Return next free value.
$version
Dolibarr version of the loaded document string.
info()
Returns the description of the model numbering.
getNextValue($objsoc, $object, $mode='next')
Return next value.
getExample()
Returns a numbering example.