dolibarr  7.0.0-beta
holiday.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
30 function holiday_prepare_head($object)
31 {
32  global $db, $langs, $conf, $user;
33 
34  $h = 0;
35  $head = array();
36 
37  $head[$h][0] = DOL_URL_ROOT.'/holiday/card.php?id='.$object->id;
38  $head[$h][1] = $langs->trans("Card");
39  $head[$h][2] = 'card';
40  $h++;
41 
42  // Attachments
43  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
44  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
45  $upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
46  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
47  $nbLinks=Link::count($db, $object->element, $object->id);
48  $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id;
49  $head[$h][1] = $langs->trans('Documents');
50  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
51  $head[$h][2] = 'documents';
52  $h++;
53 
54  // Show more tabs from modules
55  // Entries must be declared in modules descriptor with line
56  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
57  // $this->tabs = array('entity:-tabname); to remove a tab
58  complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday');
59 
60  complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove');
61 
62  return $head;
63 }
holiday_prepare_head($object)
Return array head with list of tabs to view object informations.
Definition: holiday.lib.php:30
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_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