dolibarr  16.0.1
mod_takepos_ref_universal.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) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
6  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2020 Open-DSI <support@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 <http://www.gnu.org/licenses/>.
21  * or see http://www.gnu.org/
22  */
23 
29 dol_include_once('/core/modules/takepos/modules_takepos.php');
30 
35 {
40  public $version = 'dolibarr';
41 
45  public $error = '';
46 
51  public $nom = 'Universal';
52 
58  public function info()
59  {
60  global $db, $langs;
61 
62  $langs->load('cashdesk@cashdesk');
63 
64  $form = new Form($db);
65 
66  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
67  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
68  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
69  $texte .= '<input type="hidden" name="action" value="updateMask">';
70  $texte .= '<input type="hidden" name="maskconst" value="TAKEPOS_REF_UNIVERSAL_MASK">';
71  $texte .= '<table class="nobordernopadding" width="100%">';
72 
73  $tooltip = $langs->trans('GenericMaskCodes', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk'));
74  $tooltip .= $langs->trans('GenericMaskCodes2');
75  $tooltip .= $langs->trans('GenericMaskCodes3');
76  $tooltip .= $langs->trans('GenericMaskCodes4a', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk'));
77  $tooltip .= $langs->trans('GenericMaskCodes5');
78  $tooltip .= $langs->trans('CashDeskGenericMaskCodes6');
79 
80  // Parametrage du prefix
81  $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
82  $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.getDolGlobalString('TAKEPOS_REF_UNIVERSAL_MASK').'">', $tooltip, 1, 1).'</td>';
83 
84  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
85 
86  $texte .= '</tr>';
87 
88  $texte .= '</table>';
89  $texte .= '</form>';
90 
91  return $texte;
92  }
93 
99  public function getExample()
100  {
101  global $conf, $langs, $mysoc;
102 
103  $old_code_client = $mysoc->code_client;
104  $mysoc->code_client = 'CCCCCCCCCC';
105  $numExample = $this->getNextValue($mysoc, '');
106  $mysoc->code_client = $old_code_client;
107 
108  if (!$numExample) {
109  $numExample = $langs->trans('NotConfigured');
110  }
111  return $numExample;
112  }
113 
122  public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
123  {
124  global $db;
125 
126  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
127 
128  // On defini critere recherche compteur
129  $mask = getDolGlobalString('TAKEPOS_REF_UNIVERSAL_MASK');
130 
131  if (!$mask) {
132  $this->error = 'NotConfigured';
133  return 0;
134  }
135 
136  // Get entities
137  $entity = getEntity('invoicenumber', 1, $invoice);
138 
139  $date = (empty($invoice->date) ? dol_now() : $invoice->date);
140  $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
141  $mask = str_replace('{TN}', $pos_source, $mask);
142  $numFinal = get_next_value($db, $mask, 'facture', 'ref', '', $objsoc, $date, $mode, false, null, $entity);
143 
144  return $numFinal;
145  }
146 
147 
155  public function getNumRef($objsoc, $objforref)
156  {
157  return $this->getNextValue($objsoc, $objforref);
158  }
159 }
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
dol_now($mode= 'auto')
Return date for now.
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)
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
getNumRef($objsoc, $objforref)
Return next free value.
Class to manage generation of HTML components Only common components must be here.
Classe mere des modeles de numerotation des tickets de caisse.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
getExample()
Renvoi un exemple de numerotation.
info()
Renvoi la description du modele de numerotation.
Class to manage ref numbering of takepos cards with rule universal.
getNextValue($objsoc=null, $invoice=null, $mode= 'next')
Return next free value.