dolibarr  7.0.0-beta
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@capnetworks.com>
5  * Copyright (C) 2013 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 {
39  var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
40  var $error = '';
41  var $nom = 'Tulip';
42 
43 
49  function info()
50  {
51  global $conf,$langs;
52 
53  $langs->load("bills");
54  $langs->load("admin");
55 
56  $form = new Form($this->db);
57 
58  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
59  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
60  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
61  $texte.= '<input type="hidden" name="action" value="updateMask">';
62  $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
63  $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
64  $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
65  $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
66  $texte.= '<table class="nobordernopadding" width="100%">';
67 
68  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
69  $tooltip.=$langs->trans("GenericMaskCodes2");
70  $tooltip.=$langs->trans("GenericMaskCodes3");
71  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
72  $tooltip.=$langs->trans("GenericMaskCodes5");
73 
74  // Parametrage du prefix
75  $texte.= '<tr><td>'.$langs->trans("Mask");
76  //$texte.= ' ('.$langs->trans("InvoiceStandard").')';
77  $texte.= ':</td>';
78  $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>';
79 
80  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
81 
82  $texte.= '</tr>';
83 
84  if ($conf->global->MAIN_FEATURE_LEVEL >= 2)
85  {
86  // Parametrage du prefix des replacement
87  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
88  $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>';
89  $texte.= '</tr>';
90 
91  // Parametrage du prefix des avoirs
92  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
93  $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>';
94  $texte.= '</tr>';
95 
96  // Parametrage du prefix des acomptes
97  $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
98  $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>';
99  $texte.= '</tr>';
100  }
101 
102  $texte.= '</table>';
103  $texte.= '</form>';
104 
105  return $texte;
106  }
107 
113  function getExample()
114  {
115  global $conf,$langs,$mysoc;
116 
117  $old_code_client=$mysoc->code_client;
118  $mysoc->code_client='CCCCCCCCCC';
119  $numExample = $this->getNextValue($mysoc,'');
120  $mysoc->code_client=$old_code_client;
121 
122  if (! $numExample)
123  {
124  $numExample = $langs->trans('NotConfigured');
125  }
126  return $numExample;
127  }
128 
137  function getNextValue($objsoc,$object,$mode='next')
138  {
139  global $db,$conf;
140 
141  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
142 
143  // Get Mask value
144  $mask = '';
145  if (is_object($object) && $object->type == 1)
146  {
147  $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
148  if (! $mask)
149  {
150  $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
151  }
152  }
153  else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
154  else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
155  else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
156  if (! $mask)
157  {
158  $this->error='NotConfigured';
159  return 0;
160  }
161 
162  // Supplier invoices take invoice date instead of creation date for the mask
163  $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
164 
165  return $numFinal;
166  }
167 
176  function getNumRef($objsoc,$objforref,$mode='next')
177  {
178  return $this->getNextValue($objsoc,$objforref,$mode);
179  }
180 }
181 
Parent Class of numbering models of suppliers invoices references.
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage generation of HTML components Only common components must be here.
Tulip Class of numbering models of suppliers invoices references.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null)
Return last or next value for a mask (according to area we should not reset)
getNumRef($objsoc, $objforref, $mode='next')
Return next free value.
info()
Returns the description of the model numbering.
getNextValue($objsoc, $object, $mode='next')
Return next value.
getExample()
Returns a numbering example.