dolibarr  16.0.5
info.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
4  * Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
5  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31 if (isModEnabled('project')) {
32  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
33  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34 }
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
38 
39 $id = GETPOST('id', 'int');
40 $ref = GETPOST('ref', 'alpha');
41 $action = GETPOST('action', 'aZ09');
42 
43 $label = GETPOST('label', 'alphanohtml');
44 $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
45 
46 // Security check
47 $socid = GETPOST('socid', 'int');
48 if ($user->socid) {
49  $socid = $user->socid;
50 }
51 
52 $object = new Salary($db);
53 $extrafields = new ExtraFields($db);
54 
55 $childids = $user->getAllChildIds(1);
56 
57 // fetch optionals attributes and labels
58 $extrafields->fetch_name_optionals_label($object->table_element);
59 
60 $object = new Salary($db);
61 if ($id > 0 || !empty($ref)) {
62  $object->fetch($id, $ref);
63 
64  // Check current user can read this salary
65  $canread = 0;
66  if (!empty($user->rights->salaries->readall)) {
67  $canread = 1;
68  }
69  if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
70  $canread = 1;
71  }
72  if (!$canread) {
74  }
75 }
76 
77 restrictedArea($user, 'salaries', $object->id, 'salary', '');
78 
79 
80 /*
81  * Actions
82  */
83 
84 // Link to a project
85 if ($action == 'classin' && $user->rights->banque->modifier) {
86  $object->fetch($id);
87  $object->setProject($projectid);
88 }
89 
90 // set label
91 if ($action == 'setlabel' && $user->rights->salaries->write) {
92  $object->fetch($id);
93  $object->label = $label;
94  $object->update($user);
95 }
96 
97 
98 
99 /*
100  * View
101  */
102 
103 if (isModEnabled('project')) $formproject = new FormProjets($db);
104 
105 $title = $langs->trans('Salary')." - ".$langs->trans('Info');
106 $help_url = "";
107 llxHeader("", $title, $help_url);
108 
109 $object = new Salary($db);
110 $object->fetch($id);
111 $object->info($id);
112 
113 $head = salaries_prepare_head($object);
114 
115 print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
116 
117 $linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
118 
119 $morehtmlref = '<div class="refidno">';
120 
121 $userstatic = new User($db);
122 $userstatic->fetch($object->fk_user);
123 
124 
125 // Label
126 if ($action != 'editlabel') {
127  $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
128  $morehtmlref .= $object->label;
129 } else {
130  $morehtmlref .= $langs->trans('Label').' :&nbsp;';
131  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
132  $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
133  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
134  $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
135  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
136  $morehtmlref .= '</form>';
137 }
138 
139 $morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
140 
141 // Project
142 if (isModEnabled('project')) {
143  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
144  if ($user->rights->salaries->write) {
145  if ($action != 'classify') {
146  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
147  }
148  if ($action == 'classify') {
149  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
150  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
151  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
152  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
153  $morehtmlref .= $formproject->select_projects(-1, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
154  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
155  $morehtmlref .= '</form>';
156  } else {
157  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
158  }
159  } else {
160  if (!empty($object->fk_project)) {
161  $proj = new Project($db);
162  $proj->fetch($object->fk_project);
163  $morehtmlref .= ' : '.$proj->getNomUrl(1);
164  if ($proj->title) {
165  $morehtmlref .= ' - '.$proj->title;
166  }
167  } else {
168  $morehtmlref .= '';
169  }
170  }
171 }
172 
173 $morehtmlref .= '</div>';
174 
175 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
176 
177 print '<div class="fichecenter">';
178 print '<div class="underbanner clearboth"></div>';
179 
180 print '<br>';
181 
182 print '<table width="100%"><tr><td>';
183 dol_print_object_info($object);
184 print '</td></tr></table>';
185 
186 print '</div>';
187 
188 print dol_get_fiche_end();
189 
190 // End of page
191 llxFooter();
192 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
dol_print_object_info
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
Definition: functions2.lib.php:205
Salary
Class to manage salary payments.
Definition: salary.class.php:33
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59