dolibarr 23.0.3
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-2025 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 $object->update($user);
113}
114
115
116
117/*
118 * View
119 */
120
121$form = new Form($db);
122if (isModEnabled('project')) {
123 $formproject = new FormProjets($db);
124}
125
126$title = $langs->trans('Salary')." - ".$langs->trans('Info');
127$help_url = "";
128llxHeader("", $title, $help_url);
129
130$object->fetch($id);
131$object->info($id);
132
133$head = salaries_prepare_head($object);
134
135print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
136
137$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
138
139$morehtmlref = '<div class="refidno">';
140
141$userstatic = new User($db);
142$userstatic->fetch($object->fk_user);
143
144
145// Label
146if ($action != 'editlabel') {
147 $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $permissiontoadd, 'string', '', 0, 1);
148 $morehtmlref .= $object->label;
149} else {
150 $morehtmlref .= $langs->trans('Label').' :&nbsp;';
151 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
152 $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
153 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
154 $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
155 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
156 $morehtmlref .= '</form>';
157}
158
159$morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
160
161$usercancreate = $permissiontoadd;
162
163// Project
164if (isModEnabled('project')) {
165 $langs->load("projects");
166 $morehtmlref .= '<br>';
167 if ($usercancreate) {
168 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
169 if ($action != 'classify') {
170 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
171 }
172 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
173 } else {
174 if (!empty($object->fk_project)) {
175 $proj = new Project($db);
176 $proj->fetch($object->fk_project);
177 $morehtmlref .= $proj->getNomUrl(1);
178 if ($proj->title) {
179 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
180 }
181 }
182 }
183}
184
185$morehtmlref .= '</div>';
186
187$totalpaid = $object->getSommePaiement();
188
189$object->totalpaid = $totalpaid;
190$object->alreadypaid = $totalpaid; // Same then $totalpaid because there is no amount of credit note or deposits for salary payments.
191
192dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
193
194print '<div class="fichecenter">';
195print '<div class="underbanner clearboth"></div>';
196
197print '<br>';
198
199print '<table class="centpercent"><tr><td>';
200dol_print_object_info($object);
201print '</td></tr></table>';
202
203print '</div>';
204
205print dol_get_fiche_end();
206
207// End of page
208llxFooter();
209$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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.