dolibarr  13.0.2
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@open-dsi.fr>
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 <https://www.gnu.org/licenses/>.
21  * or see https://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  public 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="'.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 class="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 class="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 class="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 class="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 class="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  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  {
143  $numExample = $langs->trans('NotConfigured');
144  }
145  return $numExample;
146  }
147 
156  public 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  } elseif (is_object($object) && $object->type == 2) $mask = $conf->global->SUPPLIER_CREDIT_TULIP_MASK;
172  elseif (is_object($object) && $object->type == 3) $mask = $conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
173  else $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK;
174  if (!$mask)
175  {
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 
194  public function getNumRef($objsoc, $objforref, $mode = 'next')
195  {
196  return $this->getNextValue($objsoc, $objforref, $mode);
197  }
198 }
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)
Parent Class of numbering models of suppliers invoices references.
$conf db
API class for accounts.
Definition: inc.php:54
Class to manage generation of HTML components Only common components must be here.
Tulip Class of numbering models of suppliers invoices references.
info()
Returns the description of the model numbering.
getExample()
Returns a numbering example.