dolibarr 25.0.0-alpha
inventory.lib.php
Go to the documentation of this file.
1<?php
2/* <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2026 Jose Martinez <jose.martinez@pichinov.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
33{
34 global $langs, $conf;
35
36 $langs->load("inventory");
37
38 $h = 0;
39 $head = array();
40
41 $head[$h][0] = DOL_URL_ROOT."/admin/inventory.php";
42 $head[$h][1] = $langs->trans("Parameters");
43 $head[$h][2] = 'settings';
44 $h++;
45
46
47 // Show more tabs from modules
48 // Entries must be declared in modules descriptor with line
49 //$this->tabs = array(
50 // 'entity:+tabname:Title:@inventory:/inventory/mypage.php?id=__ID__'
51 //); // to add new tab
52 //$this->tabs = array(
53 // 'entity:-tabname:Title:@inventory:/inventory/mypage.php?id=__ID__'
54 //); // to remove a tab
55 complete_head_from_modules($conf, $langs, null, $head, $h, 'inventory');
56
57 complete_head_from_modules($conf, $langs, null, $head, $h, 'inventory', 'remove');
58
59 return $head;
60}
61
71function inventoryPrepareHead(&$inventory, $title = 'Inventory', $get = '')
72{
73 global $langs, $conf;
74
75 $head = array(
76 array(dol_buildpath('/product/inventory/card.php?id='.$inventory->id.$get, 1), $langs->trans('Card'), 'card'),
77 array(dol_buildpath('/product/inventory/inventory.php?id='.$inventory->id.$get, 1), $langs->trans('Inventory'), 'inventory')
78 );
79
80 $h = 2;
81
82 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
83 $upload_dir = $conf->stock->multidir_output[$inventory->entity ? $inventory->entity : $conf->entity].'/inventory/'.dol_sanitizeFileName((string) $inventory->ref);
84 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
85 $head[$h][0] = dol_buildpath('/product/inventory/inventory_document.php?id='.$inventory->id.$get, 1);
86 $head[$h][1] = $langs->trans('Documents');
87 if ($nbFiles > 0) {
88 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbFiles.'</span>';
89 }
90 $head[$h][2] = 'document';
91 $h++;
92
93 complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory');
94 complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory', 'remove');
95
96 return $head;
97}
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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).
inventoryPrepareHead(&$inventory, $title='Inventory', $get='')
Define head array for tabs of inventory tools setup pages.
inventoryAdminPrepareHead()
Define head array for tabs of inventory tools setup pages.