dolibarr  20.0.0-beta
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-2023 Alexandre Spangaro <aspangaro@easya.solutions>
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 // Load Dolibarr environment
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
32 if (isModEnabled('project')) {
33  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
35 }
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
39 
40 $id = GETPOSTINT('id');
41 $ref = GETPOST('ref', 'alpha');
42 $action = GETPOST('action', 'aZ09');
43 
44 $label = GETPOST('label', 'alphanohtml');
45 $projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project'));
46 
47 // Security check
48 $socid = GETPOSTINT('socid');
49 if ($user->socid) {
50  $socid = $user->socid;
51 }
52 
53 $object = new Salary($db);
54 $extrafields = new ExtraFields($db);
55 
56 $childids = $user->getAllChildIds(1);
57 
58 // fetch optionals attributes and labels
59 $extrafields->fetch_name_optionals_label($object->table_element);
60 
61 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
62 $hookmanager->initHooks(array('salaryinfo', 'globalcard'));
63 
64 $object = new Salary($db);
65 if ($id > 0 || !empty($ref)) {
66  $object->fetch($id, $ref);
67 
68  // Check current user can read this salary
69  $canread = 0;
70  if ($user->hasRight('salaries', 'readall')) {
71  $canread = 1;
72  }
73  if ($user->hasRight('salaries', 'read') && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
74  $canread = 1;
75  }
76  if (!$canread) {
78  }
79 }
80 
81 restrictedArea($user, 'salaries', $object->id, 'salary', '');
82 
83 $permissiontoread = $user->hasRight('salaries', 'read');
84 $permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
85 $permissiontodelete = $user->hasRight('salaries', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID);
86 
87 
88 /*
89  * Actions
90  */
91 
92 // Link to a project
93 if ($action == 'classin' && $permissiontoadd) {
94  $object->fetch($id);
95  $object->setProject($projectid);
96 }
97 
98 // set label
99 if ($action == 'setlabel' && $permissiontoadd) {
100  $object->fetch($id);
101  $object->label = $label;
102  $object->update($user);
103 }
104 
105 
106 
107 /*
108  * View
109  */
110 
111 $form = new Form($db);
112 if (isModEnabled('project')) {
113  $formproject = new FormProjets($db);
114 }
115 
116 $title = $langs->trans('Salary')." - ".$langs->trans('Info');
117 $help_url = "";
118 llxHeader("", $title, $help_url);
119 
120 $object->fetch($id);
121 $object->info($id);
122 
123 $head = salaries_prepare_head($object);
124 
125 print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
126 
127 $linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
128 
129 $morehtmlref = '<div class="refidno">';
130 
131 $userstatic = new User($db);
132 $userstatic->fetch($object->fk_user);
133 
134 
135 // Label
136 if ($action != 'editlabel') {
137  $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $permissiontoadd, 'string', '', 0, 1);
138  $morehtmlref .= $object->label;
139 } else {
140  $morehtmlref .= $langs->trans('Label').' :&nbsp;';
141  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
142  $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
143  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
144  $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
145  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
146  $morehtmlref .= '</form>';
147 }
148 
149 $morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
150 
151 $usercancreate = $permissiontoadd;
152 
153 // Project
154 if (isModEnabled('project')) {
155  $langs->load("projects");
156  $morehtmlref .= '<br>';
157  if ($usercancreate) {
158  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
159  if ($action != 'classify') {
160  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
161  }
162  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
163  } else {
164  if (!empty($object->fk_project)) {
165  $proj = new Project($db);
166  $proj->fetch($object->fk_project);
167  $morehtmlref .= $proj->getNomUrl(1);
168  if ($proj->title) {
169  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
170  }
171  }
172  }
173 }
174 
175 $morehtmlref .= '</div>';
176 
177 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
178 
179 print '<div class="fichecenter">';
180 print '<div class="underbanner clearboth"></div>';
181 
182 print '<br>';
183 
184 print '<table class="centpercent"><tr><td>';
186 print '</td></tr></table>';
187 
188 print '</div>';
189 
190 print dol_get_fiche_end();
191 
192 // End of page
193 llxFooter();
194 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
Definition: user.class.php:50
dol_print_object_info($object, $usetable=0)
Show information on an object TODO Move this into html.formother.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
restrictedArea(User $user, $features, $object=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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.