dolibarr 25.0.0-alpha
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-2026 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34if (isModEnabled('project')) {
35 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37}
38
47// Load translation files required by the page
48$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
49
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$action = GETPOST('action', 'aZ09');
53
54$label = GETPOST('label', 'alphanohtml');
55$projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project'));
56
57// Security check
58$socid = GETPOSTINT('socid');
59if ($user->socid) {
60 $socid = $user->socid;
61}
62
63$object = new Salary($db);
64$extrafields = new ExtraFields($db);
65
66$childids = $user->getAllChildIds(1);
67
68// fetch optionals attributes and labels
69$extrafields->fetch_name_optionals_label($object->table_element);
70
71// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
72$hookmanager->initHooks(array('salaryinfo', 'globalcard'));
73
74$object = new Salary($db);
75if ($id > 0) {
76 $object->fetch($id);
77
78 // Check current user can read this salary
79 $canread = 0;
80 if ($user->hasRight('salaries', 'readall')) {
81 $canread = 1;
82 }
83 if ($user->hasRight('salaries', 'read') && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
84 $canread = 1;
85 }
86 if (!$canread) {
88 }
89}
90
91restrictedArea($user, 'salaries', $object->id, 'salary', '');
92
93$permissiontoread = $user->hasRight('salaries', 'read');
94$permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
95$permissiontodelete = $user->hasRight('salaries', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID);
96
97
98/*
99 * Actions
100 */
101
102// Link to a project
103if ($action == 'classin' && $permissiontoadd) {
104 $object->fetch($id);
105 $object->setProject($projectid);
106}
107
108// set label
109if ($action == 'setlabel' && $permissiontoadd) {
110 $object->fetch($id);
111 $object->label = $label;
112 $result = $object->update($user);
113 if ($result < 0) {
114 setEventMessages($object->error, $object->errors, 'errors');
115 }
116}
117
118
119
120/*
121 * View
122 */
123
124$form = new Form($db);
125if (isModEnabled('project')) {
126 $formproject = new FormProjets($db);
127}
128
129$title = $langs->trans('Salary')." - ".$langs->trans('Info');
130$help_url = "";
131llxHeader("", $title, $help_url);
132
133$object->fetch($id);
134$object->info($id);
135
136$head = salaries_prepare_head($object);
137
138print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
139
140$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
141
142$morehtmlref = '<div class="refidno">';
143
144$userstatic = new User($db);
145$userstatic->fetch($object->fk_user);
146
147
148// Label
149if ($action != 'editlabel') {
150 $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $permissiontoadd, 'string', '', 0, 1);
151 $morehtmlref .= $object->label;
152} else {
153 $morehtmlref .= $langs->trans('Label').' :&nbsp;';
154 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
155 $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
156 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
157 $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
158 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
159 $morehtmlref .= '</form>';
160}
161
162$morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
163
164$usercancreate = $permissiontoadd;
165
166// Project
167if (isModEnabled('project')) {
168 $langs->load("projects");
169 $morehtmlref .= '<br>';
170 if ($usercancreate) {
171 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
172 if ($action != 'classify') {
173 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
174 }
175 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
176 } else {
177 if (!empty($object->fk_project)) {
178 $proj = new Project($db);
179 $proj->fetch($object->fk_project);
180 $morehtmlref .= $proj->getNomUrl(1);
181 if ($proj->title) {
182 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
183 }
184 }
185 }
186}
187
188$morehtmlref .= '</div>';
189
190$totalpaid = $object->getSommePaiement();
191
192$object->totalpaid = $totalpaid;
193$object->alreadypaid = $totalpaid; // Same then $totalpaid because there is no amount of credit note or deposits for salary payments.
194
195dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
196
197print '<div class="fichecenter">';
198print '<div class="underbanner clearboth"></div>';
199
200print '<br>';
201
202print '<table class="centpercent"><tr><td>';
203dol_print_object_info($object);
204print '</td></tr></table>';
205
206print '</div>';
207
208print dol_get_fiche_end();
209
210// End of page
211llxFooter();
212$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
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.
dol_print_object_info($object, $usetable=0)
Show information on an object TODO Move this into html.formother.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.