dolibarr 18.0.6
salaries.lib.php
1<?php
30function salaries_prepare_head($object)
31{
32 global $db, $langs, $conf;
33
34 $h = 0;
35 $head = array();
36
37 $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
38 $head[$h][1] = $langs->trans("Salary");
39 $head[$h][2] = 'card';
40 $h++;
41
42 // Show more tabs from modules
43 // Entries must be declared in modules descriptor with line
44 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
45 // $this->tabs = array('entity:-tabname); to remove a tab
46 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'add', 'core');
47
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
49 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
50 $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
51 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
52 $nbLinks = Link::count($db, $object->element, $object->id);
53 $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
54 $head[$h][1] = $langs->trans('Documents');
55 if (($nbFiles + $nbLinks) > 0) {
56 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
57 }
58 $head[$h][2] = 'documents';
59 $h++;
60
61 $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
62 $head[$h][1] = $langs->trans("Info");
63 $head[$h][2] = 'info';
64 $h++;
65
66 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'add', 'external');
67
68 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
69
70 return $head;
71}
72
78function salaries_admin_prepare_head()
79{
80 global $conf, $db, $langs, $user;
81
82 $extrafields = new ExtraFields($db);
83 $extrafields->fetch_name_optionals_label('salary');
84
85 $h = 0;
86 $head = array();
87
88 $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
89 $head[$h][1] = $langs->trans("Miscellaneous");
90 $head[$h][2] = 'general';
91 $h++;
92
93 // Show more tabs from modules
94 // Entries must be declared in modules descriptor with line
95 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
96 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
97 complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
98
99 $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
100 $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
101 $nbExtrafields = $extrafields->attributes['salary']['count'];
102 if ($nbExtrafields > 0) {
103 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
104 }
105 $head[$h][2] = 'attributes';
106 $h++;
107
108 complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
109
110 return $head;
111}
Class to manage standard extra fields.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).