dolibarr 21.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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33if (isModEnabled('project')) {
34 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
36}
37
46// Load translation files required by the page
47$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
48
49$id = GETPOSTINT('id');
50$ref = GETPOST('ref', 'alpha');
51$action = GETPOST('action', 'aZ09');
52
53$label = GETPOST('label', 'alphanohtml');
54$projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project'));
55
56// Security check
57$socid = GETPOSTINT('socid');
58if ($user->socid) {
59 $socid = $user->socid;
60}
61
62$object = new Salary($db);
63$extrafields = new ExtraFields($db);
64
65$childids = $user->getAllChildIds(1);
66
67// fetch optionals attributes and labels
68$extrafields->fetch_name_optionals_label($object->table_element);
69
70// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
71$hookmanager->initHooks(array('salaryinfo', 'globalcard'));
72
73$object = new Salary($db);
74if ($id > 0 || !empty($ref)) {
75 $object->fetch($id, $ref);
76
77 // Check current user can read this salary
78 $canread = 0;
79 if ($user->hasRight('salaries', 'readall')) {
80 $canread = 1;
81 }
82 if ($user->hasRight('salaries', 'read') && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
83 $canread = 1;
84 }
85 if (!$canread) {
87 }
88}
89
90restrictedArea($user, 'salaries', $object->id, 'salary', '');
91
92$permissiontoread = $user->hasRight('salaries', 'read');
93$permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
94$permissiontodelete = $user->hasRight('salaries', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID);
95
96
97/*
98 * Actions
99 */
100
101// Link to a project
102if ($action == 'classin' && $permissiontoadd) {
103 $object->fetch($id);
104 $object->setProject($projectid);
105}
106
107// set label
108if ($action == 'setlabel' && $permissiontoadd) {
109 $object->fetch($id);
110 $object->label = $label;
111 $object->update($user);
112}
113
114
115
116/*
117 * View
118 */
119
120$form = new Form($db);
121if (isModEnabled('project')) {
122 $formproject = new FormProjets($db);
123}
124
125$title = $langs->trans('Salary')." - ".$langs->trans('Info');
126$help_url = "";
127llxHeader("", $title, $help_url);
128
129$object->fetch($id);
130$object->info($id);
131
132$head = salaries_prepare_head($object);
133
134print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
135
136$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
137
138$morehtmlref = '<div class="refidno">';
139
140$userstatic = new User($db);
141$userstatic->fetch($object->fk_user);
142
143
144// Label
145if ($action != 'editlabel') {
146 $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $permissiontoadd, 'string', '', 0, 1);
147 $morehtmlref .= $object->label;
148} else {
149 $morehtmlref .= $langs->trans('Label').' :&nbsp;';
150 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
151 $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
152 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
153 $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
154 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
155 $morehtmlref .= '</form>';
156}
157
158$morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
159
160$usercancreate = $permissiontoadd;
161
162// Project
163if (isModEnabled('project')) {
164 $langs->load("projects");
165 $morehtmlref .= '<br>';
166 if ($usercancreate) {
167 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
168 if ($action != 'classify') {
169 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
170 }
171 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
172 } else {
173 if (!empty($object->fk_project)) {
174 $proj = new Project($db);
175 $proj->fetch($object->fk_project);
176 $morehtmlref .= $proj->getNomUrl(1);
177 if ($proj->title) {
178 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
179 }
180 }
181 }
182}
183
184$morehtmlref .= '</div>';
185
186dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
187
188print '<div class="fichecenter">';
189print '<div class="underbanner clearboth"></div>';
190
191print '<br>';
192
193print '<table class="centpercent"><tr><td>';
194dol_print_object_info($object);
195print '</td></tr></table>';
196
197print '</div>';
198
199print dol_get_fiche_end();
200
201// End of page
202llxFooter();
203$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
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.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.