dolibarr  20.0.0-beta
stock.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
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  * or see https://www.gnu.org/
17  */
18 
31 {
32  global $langs, $conf, $user;
33 
34  $h = 0;
35  $head = array();
36 
37  $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id;
38  $head[$h][1] = $langs->trans("Warehouse");
39  $head[$h][2] = 'card';
40  $h++;
41 
42  if ($user->hasRight('stock', 'mouvement', 'lire')) {
43  $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id;
44  $head[$h][1] = $langs->trans("StockMovements");
45  $head[$h][2] = 'movements';
46  $h++;
47  }
48 
49  /*
50  $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id;
51  $head[$h][1] = $langs->trans("EnhancedValue");
52  $head[$h][2] = 'value';
53  $h++;
54  */
55 
56  /* Disabled because will never be implemented. Table always empty.
57  if (!empty($conf->global->STOCK_USE_WAREHOUSE_BY_USER))
58  {
59  // Should not be enabled by default because does not work yet correctly because
60  // personal stocks are not tagged into table llx_entrepot
61  $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$object->id;
62  $head[$h][1] = $langs->trans("Users");
63  $head[$h][2] = 'user';
64  $h++;
65  }
66  */
67 
68  // Show more tabs from modules
69  // Entries must be declared in modules descriptor with line
70  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
71  // $this->tabs = array('entity:-tabname); to remove a tab
72  complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'core');
73 
74  $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id;
75  $head[$h][1] = $langs->trans("Info");
76  $head[$h][2] = 'info';
77  $h++;
78 
79  complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'add', 'external');
80 
81  complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove');
82 
83  return $head;
84 }
85 
92 {
93  global $langs, $conf, $user, $db;
94 
95  $extrafields = new ExtraFields($db);
96  $extrafields->fetch_name_optionals_label('entrepot');
97  $extrafields->fetch_name_optionals_label('stock_mouvement');
98  $extrafields->fetch_name_optionals_label('inventory');
99 
100  $h = 0;
101  $head = array();
102 
103  $head[$h][0] = DOL_URL_ROOT.'/admin/stock.php';
104  $head[$h][1] = $langs->trans("Miscellaneous");
105  $head[$h][2] = 'general';
106  $h++;
107 
108  // Show more tabs from modules
109  // Entries must be declared in modules descriptor with line
110  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
111  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
112  complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin');
113 
114  $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php';
115  $head[$h][1] = $langs->trans("ExtraFields");
116  $nbExtrafields = $extrafields->attributes['entrepot']['count'];
117  if ($nbExtrafields > 0) {
118  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
119  }
120  $head[$h][2] = 'attributes';
121  $h++;
122 
123  $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php';
124  $head[$h][1] = $langs->trans("StockMouvementExtraFields");
125  $nbExtrafields = $extrafields->attributes['stock_mouvement']['count'];
126  if ($nbExtrafields > 0) {
127  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
128  }
129  $head[$h][2] = 'stockMouvementAttributes';
130  $h++;
131 
132  $head[$h][0] = DOL_URL_ROOT.'/product/admin/inventory_extrafields.php';
133  $head[$h][1] = $langs->trans("InventoryExtraFields");
134  $nbExtrafields = $extrafields->attributes['inventory']['count'];
135  if ($nbExtrafields > 0) {
136  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
137  }
138  $head[$h][2] = 'inventoryAttributes';
139  $h++;
140 
141  complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
142 
143  return $head;
144 }
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:91
stock_prepare_head($object)
Prepare array with list of tabs.
Definition: stock.lib.php:30