dolibarr 21.0.0-beta
categories.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
35{
36 global $langs, $conf, $user;
37
38 // Load translation files required by the page
39 $langs->loadLangs(array('categories', 'products'));
40
41 $h = 0;
42 $head = array();
43
44 $head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&amp;type='.$type;
45 $head[$h][1] = $langs->trans("Category");
46 $head[$h][2] = 'card';
47 $h++;
48
49 $head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&amp;type='.$type;
50 $head[$h][1] = $langs->trans("Photos");
51 $head[$h][2] = 'photos';
52 $h++;
53
54 if (getDolGlobalInt('MAIN_MULTILANGS')) {
55 $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&amp;type='.$type;
56 $head[$h][1] = $langs->trans("Translation");
57 $nbTranslations = (!is_null($object->multilangs) && is_countable($object->multilangs)) ? count($object->multilangs) : 0;
58 if ($nbTranslations > 0) {
59 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbTranslations.'</span>';
60 }
61 $head[$h][2] = 'translation';
62 $h++;
63 }
64
65 $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id.'&amp;type='.$type;
66 $head[$h][1] = $langs->trans("Info");
67 $head[$h][2] = 'info';
68 $h++;
69
70 // Show more tabs from modules
71 // Entries must be declared in modules descriptor with line
72 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
73 // $this->tabs = array('entity:-tabname); to remove a tab
74 complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type);
75
76 complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type, 'remove');
77
78 return $head;
79}
80
81
88{
89 global $langs, $conf, $user, $db;
90
91 $extrafields = new ExtraFields($db);
92 $extrafields->fetch_name_optionals_label('categorie');
93
94 $langs->load("categories");
95
96 $h = 0;
97 $head = array();
98
99 $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie.php';
100 $head[$h][1] = $langs->trans("Setup");
101 $head[$h][2] = 'setup';
102 $h++;
103
104 $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php';
105 $head[$h][1] = $langs->trans("ExtraFieldsCategories");
106 $nbExtrafields = $extrafields->attributes['categorie']['count'];
107 if ($nbExtrafields > 0) {
108 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
109 }
110 $head[$h][2] = 'attributes_categories';
111 $h++;
112
113 // Show more tabs from modules
114 // Entries must be declared in modules descriptor with line
115 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
116 // $this->tabs = array('entity:-tabname); to remove a tab
117 complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin');
118
119 complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin', 'remove');
120
121 return $head;
122}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
categoriesadmin_prepare_head()
Prepare array with list of tabs.
Class to manage categories.
Class to manage standard extra fields.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79