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