dolibarr  17.0.4
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 // 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 = GETPOST('id', 'int');
41 $ref = GETPOST('ref', 'alpha');
42 $action = GETPOST('action', 'aZ09');
43 
44 $label = GETPOST('label', 'alphanohtml');
45 $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
46 
47 // Security check
48 $socid = GETPOST('socid', 'int');
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 (!empty($user->rights->salaries->readall)) {
71  $canread = 1;
72  }
73  if (!empty($user->rights->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->rights->salaries->read;
84 $permissiontoadd = $user->rights->salaries->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
85 $permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
86 
87 
88 /*
89  * Actions
90  */
91 
92 // Link to a project
93 if ($action == 'classin' && $user->rights->banque->modifier) {
94  $object->fetch($id);
95  $object->setProject($projectid);
96 }
97 
98 // set label
99 if ($action == 'setlabel' && $user->rights->salaries->write) {
100  $object->fetch($id);
101  $object->label = $label;
102  $object->update($user);
103 }
104 
105 
106 
107 /*
108  * View
109  */
110 
111 if (isModEnabled('project')) $formproject = new FormProjets($db);
112 
113 $title = $langs->trans('Salary')." - ".$langs->trans('Info');
114 $help_url = "";
115 llxHeader("", $title, $help_url);
116 
117 $object->fetch($id);
118 $object->info($id);
119 
120 $head = salaries_prepare_head($object);
121 
122 print dol_get_fiche_head($head, 'info', $langs->trans("SalaryPayment"), -1, 'salary');
123 
124 $linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
125 
126 $morehtmlref = '<div class="refidno">';
127 
128 $userstatic = new User($db);
129 $userstatic->fetch($object->fk_user);
130 
131 
132 // Label
133 if ($action != 'editlabel') {
134  $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
135  $morehtmlref .= $object->label;
136 } else {
137  $morehtmlref .= $langs->trans('Label').' :&nbsp;';
138  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
139  $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
140  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
141  $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
142  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
143  $morehtmlref .= '</form>';
144 }
145 
146 $morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
147 
148 $usercancreate = $permissiontoadd;
149 
150 // Project
151 if (isModEnabled('project')) {
152  $langs->load("projects");
153  $morehtmlref .= '<br>';
154  if ($usercancreate) {
155  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
156  if ($action != 'classify') {
157  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
158  }
159  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
160  } else {
161  if (!empty($object->fk_project)) {
162  $proj = new Project($db);
163  $proj->fetch($object->fk_project);
164  $morehtmlref .= $proj->getNomUrl(1);
165  if ($proj->title) {
166  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
167  }
168  }
169  }
170 }
171 
172 $morehtmlref .= '</div>';
173 
174 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
175 
176 print '<div class="fichecenter">';
177 print '<div class="underbanner clearboth"></div>';
178 
179 print '<br>';
180 
181 print '<table class="centpercent"><tr><td>';
182 dol_print_object_info($object);
183 print '</td></tr></table>';
184 
185 print '</div>';
186 
187 print dol_get_fiche_end();
188 
189 // End of page
190 llxFooter();
191 $db->close();
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:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage standard extra fields.
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:47
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 editer/modifier 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.