dolibarr 21.0.0-beta
resource.lib.php
Go to the documentation of this file.
1<?php
2/* Module to manage locations, buildings, floors and rooms into Dolibarr ERP/CRM
3 * Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
4 * Copyright (C) 2016 Gilles Poirier <gilles.poirier@netlogic.fr>
5 * Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
35{
36 global $langs, $conf, $user;
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
41 $head[$h][1] = $langs->trans("ResourceCard");
42 $head[$h][2] = 'resource';
43 $h++;
44
45 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && (!getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_USER') || !getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'))) {
46 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
47 $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
48 $head[$h][1] = $langs->trans('ContactsAddresses');
49 if ($nbContact > 0) {
50 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
51 }
52 $head[$h][2] = 'contact';
53 $h++;
54 }
55
56 // Show more tabs from modules
57 // Entries must be declared in modules descriptor with line
58 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
59 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
60 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'add', 'core');
61
62 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
63 $nbNote = 0;
64 if (!empty($object->note_private)) {
65 $nbNote++;
66 }
67 if (!empty($object->note_public)) {
68 $nbNote++;
69 }
70 $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
71 $head[$h][1] = $langs->trans('Notes');
72 if ($nbNote > 0) {
73 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
74 }
75 $head[$h][2] = 'note';
76 $h++;
77 }
78
79 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
80 $upload_dir = $conf->resource->dir_output."/".dol_sanitizeFileName($object->ref);
81 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
82 $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
83 $head[$h][1] = $langs->trans("Documents");
84 if ($nbFiles > 0) {
85 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbFiles.'</span>';
86 }
87 $head[$h][2] = 'documents';
88 $h++;
89
90 $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id;
91 $head[$h][1] = $langs->trans("Events");
92 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
93 $head[$h][1] .= '/';
94 $head[$h][1] .= $langs->trans("Agenda");
95 }
96 $head[$h][2] = 'agenda';
97 $h++;
98
99 /*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
100 $head[$h][1] = $langs->trans('Info');
101 $head[$h][2] = 'info';
102 $h++;*/
103
104 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'add', 'external');
105
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'remove');
107
108 return $head;
109}
110
117{
118 global $conf, $db, $langs, $user;
119
120 $extrafields = new ExtraFields($db);
121 $extrafields->fetch_name_optionals_label('resource');
122
123 $h = 0;
124 $head = array();
125
126 $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
127 $head[$h][1] = $langs->trans("ResourceSetup");
128 $head[$h][2] = 'general';
129 $h++;
130
131 // Show more tabs from modules
132 // Entries must be declared in modules descriptor with line
133 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
134 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
135 complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin');
136
137 $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
138 $head[$h][1] = $langs->trans("ExtraFields");
139 $nbExtrafields = $extrafields->attributes['resource']['count'];
140 if ($nbExtrafields > 0) {
141 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
142 }
143 $head[$h][2] = 'attributes';
144 $h++;
145
146 complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin', 'remove');
147
148 return $head;
149}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage standard extra fields.
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:63
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
resource_admin_prepare_head()
Prepare head for admin tabs.
resource_prepare_head($object)
Prepare head for tabs.