dolibarr  7.0.0-beta
loan.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
3  * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
32 function loan_prepare_head($object)
33 {
34  global $db, $langs, $conf;
35 
36  $tab = 0;
37  $head = array();
38 
39  $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
40  $head[$tab][1] = $langs->trans('Card');
41  $head[$tab][2] = 'card';
42  $tab++;
43 
44  // Show more tabs from modules
45  // Entries must be declared in modules descriptor with line
46  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47  // $this->tabs = array('entity:-tabname); to remove a tab
48  complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan');
49 
50  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
51  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
52  $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
53  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
54  $nbLinks=Link::count($db, $object->element, $object->id);
55  $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
56  $head[$tab][1] = $langs->trans("Documents");
57  if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
58  $head[$tab][2] = 'documents';
59  $tab++;
60 
61  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
62  {
63  $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
64  $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
65  $head[$tab][1] = $langs->trans("Notes");
66  if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
67  $head[$tab][2] = 'note';
68  $tab++;
69  }
70 
71  $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
72  $head[$tab][1] = $langs->trans("Info");
73  $head[$tab][2] = 'info';
74  $tab++;
75 
76  complete_head_from_modules($conf,$langs,$object,$head,$tab,'loan','remove');
77 
78  return $head;
79 }
loan_prepare_head($object)
Prepare array with list of tabs.
Definition: loan.lib.php:32
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