dolibarr 25.0.0-alpha
holiday_agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Manzi Osee <info@sicrwanda.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24// Load Dolibarr environment
25require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array('holiday', 'other'));
42
43// Get parameters
44$id = GETPOSTINT('id');
45$ref = GETPOST('ref', 'alpha');
46
47$action = GETPOST('action', 'aZ09');
48$cancel = GETPOST('cancel', 'alpha');
49$backtopage = GETPOST('backtopage', 'alpha');
50
51if (GETPOST('actioncode', 'array')) {
52 $actioncode = GETPOST('actioncode', 'array', 3);
53 if (!count($actioncode)) {
54 $actioncode = '0';
55 }
56} else {
57 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
58}
59
60$search_rowid = GETPOST('search_rowid');
61$search_agenda_label = GETPOST('search_agenda_label');
62
63// Load variables for pagination
64$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
65$sortfield = GETPOST('sortfield', 'aZ09comma');
66$sortorder = GETPOST('sortorder', 'aZ09comma');
67$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
68if (empty($page) || $page == -1) {
69 $page = 0;
70} // If $page is not defined, or '' or -1
71$offset = $limit * $page;
72$pageprev = $page - 1;
73$pagenext = $page + 1;
74if (!$sortfield) {
75 $sortfield = 'a.datep,a.id';
76}
77if (!$sortorder) {
78 $sortorder = 'DESC';
79}
80
81// Initialize a technical objects
82$object = new Holiday($db);
83$hookmanager->initHooks(array('holidayagenda', 'globalcard')); // Note that conf->hooks_modules contains array
84
85// Fetch optionals attributes and labels
86$extrafields->fetch_name_optionals_label($object->table_element);
87
88$childids = $user->getAllChildIds(1);
89
90// Load object
91$permissiontoapprove = $user->hasRight('holiday', 'approve');
92$canread = 0;
93if (($id > 0) || $ref) {
94 $object->fetch($id, $ref);
95
96 // Check current user can read this leave request (same rules as the card)
97 if ($user->hasRight('holiday', 'readall')) {
98 $canread = 1;
99 }
100 if ($user->hasRight('holiday', 'read') && in_array($object->fk_user, $childids)) {
101 $canread = 1;
102 }
103 if ($permissiontoapprove && $object->fk_validator == $user->id && !getDolGlobalString('HOLIDAY_CAN_APPROVE_ONLY_THE_SUBORDINATES')) {
104 $canread = 1;
105 }
106 if (!$canread) {
108 }
109}
110
111// Security check
112if ($user->socid) {
113 $socid = $user->socid;
114}
115$result = restrictedArea($user, 'holiday', $object->id, 'holiday');
116
117if (!isModEnabled('holiday')) {
119}
120
121
122/*
123 * Actions
124 */
125
126$parameters = array('id' => $id);
127$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
128if ($reshook < 0) {
129 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
130}
131
132if (empty($reshook)) {
133 // Cancel
134 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
135 header("Location: ".$backtopage);
136 exit;
137 }
138
139 // Purge search criteria
140 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
141 $actioncode = '';
142 $search_agenda_label = '';
143 }
144}
145
146
147
148/*
149 * View
150 */
151
152$form = new Form($db);
153
154if ($object->id > 0) {
155 $title = $langs->trans("Leave").' - '.$langs->trans("Agenda");
156 $help_url = 'EN:Module_Holiday';
157 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-holiday page-card_agenda');
158
159 if (isModEnabled('notification')) {
160 $langs->load("mails");
161 }
162
163 $head = holiday_prepare_head($object);
164
165 print dol_get_fiche_head($head, 'agenda', $langs->trans("Holiday"), -1, $object->picto);
166
167 // Object card
168 // ------------------------------------------------------------
169 $linkback = '<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
170
171 $morehtmlref = '<div class="refidno">';
172 if ($object->fk_user > 0) {
173 $employee = new User($db);
174 $employee->fetch($object->fk_user);
175 $morehtmlref .= $langs->trans("User").' : '.$employee->getNomUrl(-1);
176 }
177 $morehtmlref .= '</div>';
178
179 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
180
181 print '<div class="fichecenter">';
182 print '<div class="underbanner clearboth"></div>';
183
184 $object->info($object->id);
185 dol_print_object_info($object, 1);
186
187 print '</div>';
188
189 print dol_get_fiche_end();
190
191
192 // Actions buttons
193
194 $objthirdparty = $object;
195 $objcon = new stdClass();
196
197 $out = '&origin='.urlencode((string) ($object->element)).'&originid='.urlencode((string) ($object->id));
198 $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
199 $out .= '&backtopage='.urlencode($urlbacktopage);
200
201 $morehtmlright = '';
202 if (isModEnabled('agenda')) {
203 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
204 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
205 } else {
206 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0);
207 }
208 }
209
210 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
211 print '<br>';
212
213 $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : '');
214 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
215 $param .= '&contextpage='.urlencode($contextpage);
216 }
217 if ($limit > 0 && $limit != $conf->liste_limit) {
218 $param .= '&limit='.((int) $limit);
219 }
220
221 print_barre_liste($langs->trans("Actions"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
222
223 // List of all actions
224 $filters = array();
225 $filters['search_agenda_label'] = $search_agenda_label;
226 $filters['search_rowid'] = $search_rowid;
227
228 // TODO Replace this with same code than into list.php
229 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
230 }
231}
232
233// End of page
234llxFooter();
235$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 generation of HTML components Only common components must be here.
Class of the module paid holiday.
Class to manage Dolibarr users.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
holiday_prepare_head($object)
Return array head with list of tabs to view object information.
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
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.