dolibarr 20.0.0
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 if (isModEnabled('paymentbybanktransfer')) {
43 $nbStandingOrders = 0;
44 $sql = "SELECT COUNT(pfd.rowid) as nb";
45 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
46 $sql .= " WHERE pfd.fk_salary = ".((int) $object->id);
47 $sql .= " AND type = 'ban'";
48 $resql = $db->query($sql);
49 if ($resql) {
50 $obj = $db->fetch_object($resql);
51 if ($obj) {
52 $nbStandingOrders = $obj->nb;
53 }
54 } else {
55 dol_print_error($db);
56 }
57 $langs->load("banks");
58 $head[$h][0] = DOL_URL_ROOT.'/salaries/virement_request.php?id='.$object->id.'&type=bank-transfer';
59 $head[$h][1] = $langs->trans('BankTransfer');
60 if ($nbStandingOrders > 0) {
61 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>';
62 }
63 $head[$h][2] = 'request_virement';
64 $h++;
65 }
66
67 // Show more tabs from modules
68 // Entries must be declared in modules descriptor with line
69 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
70 // $this->tabs = array('entity:-tabname); to remove a tab
71 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'add', 'core');
72
73 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
74 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
75 $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
76 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
77 $nbLinks = Link::count($db, $object->element, $object->id);
78 $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
79 $head[$h][1] = $langs->trans('Documents');
80 if (($nbFiles + $nbLinks) > 0) {
81 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
82 }
83 $head[$h][2] = 'documents';
84 $h++;
85
86 $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
87 $head[$h][1] = $langs->trans("Info");
88 $head[$h][2] = 'info';
89 $h++;
90
91 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'add', 'external');
92
93 complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
94
95 return $head;
96}
97
103function salaries_admin_prepare_head()
104{
105 global $conf, $db, $langs, $user;
106
107 $extrafields = new ExtraFields($db);
108 $extrafields->fetch_name_optionals_label('salary');
109
110 $h = 0;
111 $head = array();
112
113 $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
114 $head[$h][1] = $langs->trans("Miscellaneous");
115 $head[$h][2] = 'general';
116 $h++;
117
118 // Show more tabs from modules
119 // Entries must be declared in modules descriptor with line
120 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
121 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
122 complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
123
124 $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
125 $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
126 $nbExtrafields = $extrafields->attributes['salary']['count'];
127 if ($nbExtrafields > 0) {
128 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
129 }
130 $head[$h][2] = 'attributes';
131 $h++;
132
133 complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
134
135 return $head;
136}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage standard extra fields.
dol_dir_list($utf8_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:63
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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).