dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
21  * or see http://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("Card");
46  $head[$h][2] = 'card';
47  $h++;
48 
49  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
50  {
51  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
52  $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
53  $head[$h][1] = $langs->trans('InterventionContact');
54  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
55  $head[$h][2] = 'contact';
56  $h++;
57  }
58 
59  // Show more tabs from modules
60  // Entries must be declared in modules descriptor with line
61  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
62  // $this->tabs = array('entity:-tabname); to remove a tab
63  complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
64 
65  // Tab to link resources
66  if ($conf->resource->enabled)
67  {
68  require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
69  $nbResource = 0;
70  $objectres=new Dolresource($db);
71  if (is_array($objectres->available_resources))
72  {
73  foreach ($objectres->available_resources as $modresources => $resources)
74  {
75  $resources=(array) $resources; // To be sure $resources is an array
76  foreach($resources as $resource_obj)
77  {
78  $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
79  }
80  }
81  }
82 
83  $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
84  $head[$h][1] = $langs->trans("Resources");
85  if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
86  $head[$h][2] = 'resource';
87  $h++;
88  }
89 
90  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
91  {
92  $nbNote = 0;
93  if(!empty($object->note_private)) $nbNote++;
94  if(!empty($object->note_public)) $nbNote++;
95  $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
96  $head[$h][1] = $langs->trans('Notes');
97  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
98  $head[$h][2] = 'note';
99  $h++;
100  }
101 
102  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
103  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
104  $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
105  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
106  $nbLinks=Link::count($db, $object->element, $object->id);
107  $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
108  $head[$h][1] = $langs->trans("Documents");
109  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
110  $head[$h][2] = 'documents';
111  $h++;
112 
113  $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id;
114  $head[$h][1] = $langs->trans('Info');
115  $head[$h][2] = 'info';
116  $h++;
117 
118  complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
119 
120  return $head;
121 }
122 
129 {
130  global $langs, $conf, $user;
131 
132  $h = 0;
133  $head = array();
134 
135  $h = 0;
136 
137  $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
138  $head[$h][1] = $langs->trans("Interventions");
139  $head[$h][2] = 'ficheinter';
140  $h++;
141 
142  // Show more tabs from modules
143  // Entries must be declared in modules descriptor with line
144  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
145  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
146  complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
147 
148  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
149  $head[$h][1] = $langs->trans("ExtraFields");
150  $head[$h][2] = 'attributes';
151  $h++;
152 
153  $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
154  $head[$h][1] = $langs->trans("ExtraFieldsLines");
155  $head[$h][2] = 'attributesdet';
156  $h++;
157 
158 
159 
160  complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
161 
162  return $head;
163 }
164 
171 function fichinter_rec_prepare_head($object)
172 {
173  global $langs, $conf; //, $user;
174 
175  $h = 0;
176  $head = array();
177 
178  $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
179  $head[$h][1] = $langs->trans("CardFichinter");
180  $head[$h][2] = 'card';
181  $h++;
182 
183  complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
184 
185  complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
186 
187 
188  return $head;
189 }
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.
fichinter_rec_prepare_head($object)
Prepare array with list of tabs.
fichinter_prepare_head($object)
Prepare array with list of tabs.
fichinter_admin_prepare_head()
Return array head with list of tabs to view object informations.
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:59
DAO Resource object.