dolibarr  16.0.5
fichinter.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4  * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
6  * Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
7 
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  * or see https://www.gnu.org/
22  */
23 
36 function fichinter_prepare_head($object)
37 {
38  global $db, $langs, $conf, $user;
39  $langs->load("fichinter");
40 
41  $h = 0;
42  $head = array();
43 
44  $head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id;
45  $head[$h][1] = $langs->trans("Intervention");
46  $head[$h][2] = 'card';
47  $h++;
48 
49  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
50  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
51  $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
52  $head[$h][1] = $langs->trans('InterventionContact');
53  if ($nbContact > 0) {
54  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
55  }
56  $head[$h][2] = 'contact';
57  $h++;
58  }
59 
60  // Show more tabs from modules
61  // Entries must be declared in modules descriptor with line
62  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
63  // $this->tabs = array('entity:-tabname); to remove a tab
64  complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention');
65 
66  // Tab to link resources
67  if (isModEnabled('resource')) {
68  require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
69  $objectres = new Dolresource($db);
70  $linked_resources = $objectres->getElementResources('fichinter', $object->id);
71  $nbResource = (is_array($linked_resources) ?count($linked_resources) : 0);
72  // if (is_array($objectres->available_resources))
73  // {
74  // foreach ($objectres->available_resources as $modresources => $resources)
75  // {
76  // $resources=(array) $resources; // To be sure $resources is an array
77  // foreach($resources as $resource_obj)
78  // {
79  // $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj);
80  // }
81  // }
82  // }
83 
84  $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
85  $head[$h][1] = $langs->trans("Resources");
86  if ($nbResource > 0) {
87  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbResource.'</span>';
88  }
89  $head[$h][2] = 'resource';
90  $h++;
91  }
92 
93  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
94  $nbNote = 0;
95  if (!empty($object->note_private)) {
96  $nbNote++;
97  }
98  if (!empty($object->note_public)) {
99  $nbNote++;
100  }
101  $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
102  $head[$h][1] = $langs->trans('Notes');
103  if ($nbNote > 0) {
104  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
105  }
106  $head[$h][2] = 'note';
107  $h++;
108  }
109 
110  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
111  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
112  $upload_dir = $conf->ficheinter->dir_output."/".dol_sanitizeFileName($object->ref);
113  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
114  $nbLinks = Link::count($db, $object->element, $object->id);
115  $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
116  $head[$h][1] = $langs->trans("Documents");
117  if (($nbFiles + $nbLinks) > 0) {
118  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
119  }
120  $head[$h][2] = 'documents';
121  $h++;
122 
123  $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id;
124  $head[$h][1] = $langs->trans('Info');
125  $head[$h][2] = 'info';
126  $h++;
127 
128  complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove');
129 
130  return $head;
131 }
132 
139 {
140  global $langs, $conf, $user;
141 
142  $h = 0;
143  $head = array();
144 
145  $h = 0;
146 
147  $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
148  $head[$h][1] = $langs->trans("Interventions");
149  $head[$h][2] = 'ficheinter';
150  $h++;
151 
152  // Show more tabs from modules
153  // Entries must be declared in modules descriptor with line
154  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
155  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
156  complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin');
157 
158  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
159  $head[$h][1] = $langs->trans("ExtraFields");
160  $head[$h][2] = 'attributes';
161  $h++;
162 
163  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
164  $head[$h][1] = $langs->trans("ExtraFieldsLines");
165  $head[$h][2] = 'attributesdet';
166  $h++;
167 
168 
169 
170  complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin', 'remove');
171 
172  return $head;
173 }
174 
181 function fichinter_rec_prepare_head($object)
182 {
183  global $langs, $conf; //, $user;
184 
185  $h = 0;
186  $head = array();
187 
188  $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
189  $head[$h][1] = $langs->trans("CardFichinter");
190  $head[$h][2] = 'card';
191  $h++;
192 
193  complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
194 
195  complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec', 'remove');
196 
197 
198  return $head;
199 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
fichinter_rec_prepare_head
fichinter_rec_prepare_head($object)
Prepare array with list of tabs.
Definition: fichinter.lib.php:181
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9038
Dolresource
DAO Resource object.
Definition: dolresource.class.php:30
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
fichinter_prepare_head
fichinter_prepare_head($object)
Prepare array with list of tabs.
Definition: fichinter.lib.php:36
fichinter_admin_prepare_head
fichinter_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: fichinter.lib.php:138