dolibarr 24.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
32dol_include_once('/core/modules/takepos/modules_takepos.php');
33
38{
43 public $version = 'dolibarr';
44
48 public $error = '';
49
54 public $nom = 'Universal';
55
62 public function info($langs)
63 {
64 global $db, $langs;
65
66 $langs->load('cashdesk@cashdesk');
67
68 $form = new Form($db);
69
70 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
73 $texte .= '<input type="hidden" name="action" value="updateMask">';
74 $texte .= '<input type="hidden" name="maskconst" value="TAKEPOS_REF_UNIVERSAL_MASK">';
75 $texte .= '<input type="hidden" name="page_y" value="">';
76
77 $texte .= '<table class="nobordernopadding centpercent">';
78
79 $tooltip = '<div class="small lineheightmedium">';
80 $tooltip .= $langs->trans('GenericMaskCodes', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk'));
81 $tooltip .= $langs->trans("GenericMaskCodes1");
82 $tooltip .= '<br>';
83 $tooltip .= $langs->trans('GenericMaskCodes2');
84 $tooltip .= $langs->trans('CashDeskGenericMaskCodes6');
85 $tooltip .= '<br><br>';
86 $tooltip .= $langs->trans('GenericMaskCodes3');
87 $tooltip .= '<br>';
88 $tooltip .= $langs->trans('GenericMaskCodes4a', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk'));
89 $tooltip .= $langs->trans('GenericMaskCodes5');
90 //$tooltip .= $langs->trans("GenericMaskCodes5b");
91 $tooltip .= '</div>';
92
93 // Setting up the prefix
94 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
95 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.getDolGlobalString('TAKEPOS_REF_UNIVERSAL_MASK').'">', $tooltip, 1, 'help', 'valignmiddle xxx', 0, 3, $this->name).'</td>';
96
97 $texte .= '<td class="left" rowspan="2"><input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
98
99 $texte .= '</tr>';
100
101 $texte .= '</table>';
102 $texte .= '</form>';
103
104 return $texte;
105 }
106
112 public function getExample()
113 {
114 global $langs, $mysoc;
115
116 $old_code_client = $mysoc->code_client;
117 $mysoc->code_client = 'CCCCCCCCCC';
118 $numExample = $this->getNextValue($mysoc, null);
119 $mysoc->code_client = $old_code_client;
120
121 if (!$numExample) {
122 $numExample = $langs->trans('NotConfigured');
123 }
124 return $numExample;
125 }
126
135 public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
136 {
137 global $db;
138
139 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
140
141 // We define search criteria counter
142 $mask = getDolGlobalString('TAKEPOS_REF_UNIVERSAL_MASK');
143
144 if (!$mask) {
145 $this->error = 'NotConfigured';
146 return 0;
147 }
148
149 // Get entities
150 $entity = getEntity('invoicenumber', 1, $invoice);
151
152 $date = (empty($invoice->date) ? dol_now() : $invoice->date);
153 $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
154 $mask = str_replace('{TN}', (string) $pos_source, $mask);
155 $numFinal = get_next_value($db, $mask, 'facture', 'ref', '', $objsoc, $date, $mode, false, null, $entity);
156
157 return $numFinal;
158 }
159
160
169 public function getNumRef($objsoc, $objforref)
170 {
171 return $this->getNextValue($objsoc, $objforref);
172 }
173}
Class to manage generation of HTML components Only common components must be here.
Parent Class of the models to number the cash register receipts.
Class to manage ref numbering of takepos cards with rule universal.
getExample()
Return an example of numbering.
getNumRef($objsoc, $objforref)
Return next free value.
getNextValue($objsoc=null, $invoice=null, $mode='next')
Return next free value.
info($langs)
return description of the numbering model
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null, $objbookkeeping=null)
Return last or next value for a mask (according to area we should not reset)
dol_now($mode='gmt')
Return date for now.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133