dolibarr 25.0.0-alpha
mod_inventory_advanced.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Jose MARTINEZ <jose.martinez@pichinov.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23require_once DOL_DOCUMENT_ROOT.'/core/modules/inventory/modules_inventory.php';
24
25
30{
35 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
36
40 public $error = '';
41
45 public $name = 'advanced';
46
50 public $position = 60;
51
52
59 public function info($langs)
60 {
61 global $langs, $db;
62
63 $langs->load("bills");
64
65 $form = new Form($db);
66
67 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
68 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
69 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
70 $texte .= '<input type="hidden" name="action" value="updateMask">';
71 $texte .= '<input type="hidden" name="maskconstinventory" value="INVENTORY_ADVANCED_MASK">';
72 $texte .= '<input type="hidden" name="page_y" value="">';
73
74 $texte .= '<table class="nobordernopadding centpercent">';
75
76 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Inventory"), $langs->transnoentities("Inventory"));
77 $tooltip .= $langs->trans("GenericMaskCodes1");
78 $tooltip .= '<br>';
79 $tooltip .= $langs->trans("GenericMaskCodes2");
80 $tooltip .= '<br>';
81 $tooltip .= $langs->trans("GenericMaskCodes3");
82 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Inventory"), $langs->transnoentities("Inventory"));
83 $tooltip .= $langs->trans("GenericMaskCodes5");
84
85 // Setting of mask
86 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
87 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskInventory" value="'.getDolGlobalString('INVENTORY_ADVANCED_MASK').'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
88
89 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" value="'.$langs->trans("Save").'" name="Button"></td>';
90
91 $texte .= '</tr>';
92
93 $texte .= '</table>';
94 $texte .= '</form>';
95
96 return $texte;
97 }
98
104 public function getExample()
105 {
106 global $conf, $db, $langs, $mysoc;
107
108 require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
109 $object = new Inventory($db);
110 $object->initAsSpecimen();
111
112 $numExample = $this->getNextValue($object);
113
114 if (!$numExample) {
115 $numExample = $langs->trans('NotConfigured');
116 }
117 return $numExample;
118 }
119
126 public function getNextValue($object)
127 {
128 global $db, $conf;
129
130 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131
132 // We get cursor rule
133 $mask = getDolGlobalString('INVENTORY_ADVANCED_MASK');
134
135 if (!$mask) {
136 $this->error = 'NotConfigured';
137 return 0;
138 }
139
140 $date = !empty($object->date_inventory) ? $object->date_inventory : (!empty($object->date_creation) ? $object->date_creation : dol_now());
141
142 $numFinal = get_next_value($db, $mask, 'inventory', 'ref', '', null, $date);
143
144 return $numFinal;
145 }
146}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage generation of HTML components Only common components must be here.
Class for Inventory.
Parent class to manage numbering of Inventory.
Class to manage the mask based numbering rule for Inventory.
info($langs)
Returns the description of the numbering model.
getExample()
Return an example of numbering.
getNextValue($object)
Return next free value.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133