dolibarr  7.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 <glgpoirier@gmail.com>
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 <http://www.gnu.org/licenses/>.
18  */
19 
32 function resource_prepare_head($object)
33 {
34  global $langs, $conf, $user;
35  $h = 0;
36  $head = array();
37 
38  $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
39  $head[$h][1] = $langs->trans("ResourceCard");
40  $head[$h][2] = 'resource';
41  $h++;
42 
43  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
44  {
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) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
49  $head[$h][2] = 'contact';
50  $h++;
51  }
52 
53  // Show more tabs from modules
54  // Entries must be declared in modules descriptor with line
55  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
56  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
57  complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
58 
59  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60  {
61  $nbNote = 0;
62  if(!empty($object->note_private)) $nbNote++;
63  if(!empty($object->note_public)) $nbNote++;
64  $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
65  $head[$h][1] = $langs->trans('Notes');
66  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67  $head[$h][2] = 'note';
68  $h++;
69  }
70 
71  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
72  $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
73  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
74  $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
75  $head[$h][1] = $langs->trans("Documents");
76  if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
77  $head[$h][2] = 'documents';
78  $h++;
79 
80  /*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
81  $head[$h][1] = $langs->trans('Info');
82  $head[$h][2] = 'info';
83  $h++;*/
84 
85  complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
86 
87  return $head;
88 }
89 
90 function resource_admin_prepare_head() {
91 
92  global $langs, $conf, $user;
93 
94  $h = 0;
95  $head = array();
96 
97  $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
98  $head[$h][1] = $langs->trans("ResourceSetup");
99  $head[$h][2] = 'general';
100  $h++;
101 
102  // Show more tabs from modules
103  // Entries must be declared in modules descriptor with line
104  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
105  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
106  complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
107 
108  $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
109  $head[$h][1] = $langs->trans("ExtraFields");
110  $head[$h][2] = 'attributes';
111  $h++;
112 
113  complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
114 
115  return $head;
116 
117 }
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
resource_prepare_head($object)
Prepare head for tabs.