dolibarr 19.0.3
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 *
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
33function resource_prepare_head($object)
34{
35 global $langs, $conf, $user;
36 $h = 0;
37 $head = array();
38
39 $head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
40 $head[$h][1] = $langs->trans("ResourceCard");
41 $head[$h][2] = 'resource';
42 $h++;
43
44 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && (!getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_USER') || !getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'))) {
45 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
46 $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
47 $head[$h][1] = $langs->trans('ContactsAddresses');
48 if ($nbContact > 0) {
49 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
50 }
51 $head[$h][2] = 'contact';
52 $h++;
53 }
54
55 // Show more tabs from modules
56 // Entries must be declared in modules descriptor with line
57 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
58 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
59 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'add', 'core');
60
61 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
62 $nbNote = 0;
63 if (!empty($object->note_private)) {
64 $nbNote++;
65 }
66 if (!empty($object->note_public)) {
67 $nbNote++;
68 }
69 $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
70 $head[$h][1] = $langs->trans('Notes');
71 if ($nbNote > 0) {
72 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
73 }
74 $head[$h][2] = 'note';
75 $h++;
76 }
77
78 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
79 $upload_dir = $conf->resource->dir_output."/".dol_sanitizeFileName($object->ref);
80 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
81 $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
82 $head[$h][1] = $langs->trans("Documents");
83 if ($nbFiles > 0) {
84 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbFiles.'</span>';
85 }
86 $head[$h][2] = 'documents';
87 $h++;
88
89 $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id;
90 $head[$h][1] = $langs->trans("Events");
91 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
92 $head[$h][1] .= '/';
93 $head[$h][1] .= $langs->trans("Agenda");
94 }
95 $head[$h][2] = 'agenda';
96 $h++;
97
98 /*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
99 $head[$h][1] = $langs->trans('Info');
100 $head[$h][2] = 'info';
101 $h++;*/
102
103 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'add', 'external');
104
105 complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'remove');
106
107 return $head;
108}
109
116{
117 global $conf, $db, $langs, $user;
118
119 $extrafields = new ExtraFields($db);
120 $extrafields->fetch_name_optionals_label('resource');
121
122 $h = 0;
123 $head = array();
124
125 $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
126 $head[$h][1] = $langs->trans("ResourceSetup");
127 $head[$h][2] = 'general';
128 $h++;
129
130 // Show more tabs from modules
131 // Entries must be declared in modules descriptor with line
132 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
133 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
134 complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin');
135
136 $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
137 $head[$h][1] = $langs->trans("ExtraFields");
138 $nbExtrafields = $extrafields->attributes['resource']['count'];
139 if ($nbExtrafields > 0) {
140 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
141 }
142 $head[$h][2] = 'attributes';
143 $h++;
144
145 complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin', 'remove');
146
147 return $head;
148}
Class to manage standard extra fields.
dol_dir_list($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:62
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 dolibarr global constant string value.
resource_admin_prepare_head()
Prepare head for admin tabs.
resource_prepare_head($object)
Prepare head for tabs.