dolibarr  7.0.0-beta
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@capnetworks.com>
5  * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
6 
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 <http://www.gnu.org/licenses/>.
20  * or see http://www.gnu.org/
21  */
22 
35 function fichinter_prepare_head($object)
36 {
37  global $db, $langs, $conf, $user;
38  $langs->load("fichinter");
39 
40  $h = 0;
41  $head = array();
42 
43  $head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id;
44  $head[$h][1] = $langs->trans("Card");
45  $head[$h][2] = 'card';
46  $h++;
47 
48  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
49  {
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) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
54  $head[$h][2] = 'contact';
55  $h++;
56  }
57 
58  // Show more tabs from modules
59  // Entries must be declared in modules descriptor with line
60  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
61  // $this->tabs = array('entity:-tabname); to remove a tab
62  complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
63 
64  // Tab to link resources
65  if ($conf->resource->enabled)
66  {
67  require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
68  $nbResource = 0;
69  $objectres=new Dolresource($db);
70  if (is_array($objectres->available_resources))
71  {
72  foreach ($objectres->available_resources as $modresources => $resources)
73  {
74  $resources=(array) $resources; // To be sure $resources is an array
75  foreach($resources as $resource_obj)
76  {
77  $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
78 
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 
165 
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_prepare_head($object)
Prepare array with list of tabs.
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
fichinter_admin_prepare_head()
Return array head with list of tabs to view object informations.
DAO Resource object.