dolibarr  16.0.5
salaries.lib.php
1 <?php
29 function salaries_prepare_head($object)
30 {
31  global $db, $langs, $conf;
32 
33  $h = 0;
34  $head = array();
35 
36  $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
37  $head[$h][1] = $langs->trans("Salary");
38  $head[$h][2] = 'card';
39  $h++;
40 
41  // Show more tabs from modules
42  // Entries must be declared in modules descriptor with line
43  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
44  // $this->tabs = array('entity:-tabname); to remove a tab
45  complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
46 
47  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
49  $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
50  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
51  $nbLinks = Link::count($db, $object->element, $object->id);
52  $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
53  $head[$h][1] = $langs->trans('Documents');
54  if (($nbFiles + $nbLinks) > 0) {
55  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
56  }
57  $head[$h][2] = 'documents';
58  $h++;
59 
60  $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
61  $head[$h][1] = $langs->trans("Info");
62  $head[$h][2] = 'info';
63  $h++;
64 
65  complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
66 
67  return $head;
68 }
69 
75 function salaries_admin_prepare_head()
76 {
77  global $langs, $conf, $user;
78 
79  $h = 0;
80  $head = array();
81 
82  $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
83  $head[$h][1] = $langs->trans("Miscellaneous");
84  $head[$h][2] = 'general';
85  $h++;
86 
87  // Show more tabs from modules
88  // Entries must be declared in modules descriptor with line
89  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
90  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
91  complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
92 
93  $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
94  $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
95  $head[$h][2] = 'attributes';
96  $h++;
97 
98  complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
99 
100  return $head;
101 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
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