dolibarr 21.0.0-alpha
stock.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
32{
33 global $langs, $conf, $user;
34
35 $h = 0;
36 $head = array();
37
38 $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id;
39 $head[$h][1] = $langs->trans("Warehouse");
40 $head[$h][2] = 'card';
41 $h++;
42
43 if ($user->hasRight('stock', 'mouvement', 'lire')) {
44 $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id;
45 $head[$h][1] = $langs->trans("StockMovements");
46 $head[$h][2] = 'movements';
47 $h++;
48 }
49
50 /*
51 $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id;
52 $head[$h][1] = $langs->trans("EnhancedValue");
53 $head[$h][2] = 'value';
54 $h++;
55 */
56
57 /* Disabled because will never be implemented. Table always empty.
58 if (!empty($conf->global->STOCK_USE_WAREHOUSE_BY_USER))
59 {
60 // Should not be enabled by default because does not work yet correctly because
61 // personal stocks are not tagged into table llx_entrepot
62 $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$object->id;
63 $head[$h][1] = $langs->trans("Users");
64 $head[$h][2] = 'user';
65 $h++;
66 }
67 */
68
69 // Show more tabs from modules
70 // Entries must be declared in modules descriptor with line
71 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
72 // $this->tabs = array('entity:-tabname); to remove a tab
73 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'core');
74
75 $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id;
76 $head[$h][1] = $langs->trans("Info");
77 $head[$h][2] = 'info';
78 $h++;
79
80 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'external');
81
82 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove');
83
84 return $head;
85}
86
93{
94 global $langs, $conf, $user, $db;
95
96 $extrafields = new ExtraFields($db);
97 $extrafields->fetch_name_optionals_label('entrepot');
98 $extrafields->fetch_name_optionals_label('stock_mouvement');
99 $extrafields->fetch_name_optionals_label('inventory');
100
101 $h = 0;
102 $head = array();
103
104 $head[$h][0] = DOL_URL_ROOT.'/admin/stock.php';
105 $head[$h][1] = $langs->trans("Miscellaneous");
106 $head[$h][2] = 'general';
107 $h++;
108
109 // Show more tabs from modules
110 // Entries must be declared in modules descriptor with line
111 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
112 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
113 complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin');
114
115 $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php';
116 $head[$h][1] = $langs->trans("ExtraFields");
117 $nbExtrafields = $extrafields->attributes['entrepot']['count'];
118 if ($nbExtrafields > 0) {
119 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
120 }
121 $head[$h][2] = 'attributes';
122 $h++;
123
124 $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php';
125 $head[$h][1] = $langs->trans("StockMouvementExtraFields");
126 $nbExtrafields = $extrafields->attributes['stock_mouvement']['count'];
127 if ($nbExtrafields > 0) {
128 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
129 }
130 $head[$h][2] = 'stockMouvementAttributes';
131 $h++;
132
133 $head[$h][0] = DOL_URL_ROOT.'/product/admin/inventory_extrafields.php';
134 $head[$h][1] = $langs->trans("InventoryExtraFields");
135 $nbExtrafields = $extrafields->attributes['inventory']['count'];
136 if ($nbExtrafields > 0) {
137 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
138 }
139 $head[$h][2] = 'inventoryAttributes';
140 $h++;
141
142 complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
143
144 return $head;
145}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage standard extra fields.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
stock_admin_prepare_head()
Return array head with list of tabs to view object information.
Definition stock.lib.php:92
stock_prepare_head($object)
Prepare array with list of tabs.
Definition stock.lib.php:31