dolibarr  16.0.5
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3  * Copyright (C) 2012-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
7  * Copyright (C) 2014-2017 Ferran Marcet <fmarcet@2byte.es>
8  * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
9  * Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
10  * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, orwrite
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43 
44 // Get parameters
45 $action = GETPOST('action', 'aZ09');
46 $cancel = GETPOST('cancel', 'alpha');
47 $confirm = GETPOST('confirm', 'alpha');
48 
49 $id = GETPOST('id', 'int');
50 $ref = GETPOST('ref', 'alpha');
51 $fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id);
52 $socid = GETPOST('socid', 'int');
53 
54 // Load translation files required by the page
55 $langs->loadLangs(array("other", "holiday", "mails", "trips"));
56 
57 $error = 0;
58 
59 $now = dol_now();
60 
61 $childids = $user->getAllChildIds(1);
62 
63 $morefilter = '';
64 if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
65  $morefilter = 'AND employee = 1';
66 }
67 
68 $object = new Holiday($db);
69 
70 $extrafields = new ExtraFields($db);
71 
72 // fetch optionals attributes and labels
73 $extrafields->fetch_name_optionals_label($object->table_element);
74 
75 if (($id > 0) || $ref) {
76  $object->fetch($id, $ref);
77 
78  // Check current user can read this leave request
79  $canread = 0;
80  if (!empty($user->rights->holiday->readall)) {
81  $canread = 1;
82  }
83  if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) {
84  $canread = 1;
85  }
86  if (!$canread) {
88  }
89 }
90 
91 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
92 $hookmanager->initHooks(array('holidaycard', 'globalcard'));
93 
94 $cancreate = 0;
95 $cancreateall = 0;
96 if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) {
97  $cancreate = 1;
98 }
99 if (!empty($user->rights->holiday->writeall)) {
100  $cancreate = 1;
101  $cancreateall = 1;
102 }
103 
104 $candelete = 0;
105 if (!empty($user->rights->holiday->delete)) {
106  $candelete = 1;
107 }
108 if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) {
109  $candelete = 1;
110 }
111 
112 // Protection if external user
113 if ($user->socid) {
114  $socid = $user->socid;
115 }
116 $result = restrictedArea($user, 'holiday', $object->id, 'holiday', '', '', 'rowid', $object->statut);
117 
118 
119 /*
120  * Actions
121  */
122 
123 $parameters = array('socid' => $socid);
124 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
125 if ($reshook < 0) {
126  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
127 }
128 
129 if (empty($reshook)) {
130  $backurlforlist = DOL_URL_ROOT.'/holiday/list.php';
131 
132  if (empty($backtopage) || ($cancel && empty($id))) {
133  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
134  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
135  $backtopage = $backurlforlist;
136  } else {
137  $backtopage = DOL_URL_ROOT.'/holiday/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
138  }
139  }
140  }
141 
142  if ($cancel) {
143  if (!empty($backtopageforcancel)) {
144  header("Location: ".$backtopageforcancel);
145  exit;
146  } elseif (!empty($backtopage)) {
147  header("Location: ".$backtopage);
148  exit;
149  }
150  $action = '';
151  }
152 
153  // Add leave request
154  if ($action == 'add') {
155  // If no right to create a request
156  if (!$cancreate) {
157  $error++;
158  setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
159  $action = 'create';
160  }
161 
162  if (!$error) {
163  $object = new Holiday($db);
164 
165  $db->begin();
166 
167  $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
168  $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
169  $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
170  $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
171  $starthalfday = GETPOST('starthalfday');
172  $endhalfday = GETPOST('endhalfday');
173  $type = GETPOST('type');
174  $halfday = 0;
175  if ($starthalfday == 'afternoon' && $endhalfday == 'morning') {
176  $halfday = 2;
177  } elseif ($starthalfday == 'afternoon') {
178  $halfday = -1;
179  } elseif ($endhalfday == 'morning') {
180  $halfday = 1;
181  }
182 
183  $approverid = GETPOST('valideur', 'int');
184  $description = trim(GETPOST('description', 'restricthtml'));
185 
186  // Check that leave is for a user inside the hierarchy or advanced permission for all is set
187  if (!$cancreateall) {
188  if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
189  if (empty($user->rights->holiday->write)) {
190  $error++;
191  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
192  } elseif (!in_array($fuserid, $childids)) {
193  $error++;
194  setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
195  $action = 'create';
196  }
197  } else {
198  if (empty($user->rights->holiday->write) && empty($user->rights->holiday->writeall_advance)) {
199  $error++;
200  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
201  } elseif (empty($user->rights->holiday->writeall_advance) && !in_array($fuserid, $childids)) {
202  $error++;
203  setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
204  $action = 'create';
205  }
206  }
207  }
208 
209  // If no type
210  if ($type <= 0) {
211  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
212  $error++;
213  $action = 'create';
214  }
215 
216  // If no start date
217  if (empty($date_debut)) {
218  setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
219  $error++;
220  $action = 'create';
221  }
222  // If no end date
223  if (empty($date_fin)) {
224  setEventMessages($langs->trans("NoDateFin"), null, 'errors');
225  $error++;
226  $action = 'create';
227  }
228  // If start date after end date
229  if ($date_debut > $date_fin) {
230  setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
231  $error++;
232  $action = 'create';
233  }
234 
235  // Check if there is already holiday for this period
236  $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
237  if (!$verifCP) {
238  setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
239  $error++;
240  $action = 'create';
241  }
242 
243  // If there is no Business Days within request
244  $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
245  if ($nbopenedday < 0.5) {
246  setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day
247  $error++;
248  $action = 'create';
249  }
250 
251  // If no validator designated
252  if ($approverid < 1) {
253  setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
254  $error++;
255  }
256 
257  // Fill array 'array_options' with data from add form
258  $ret = $extrafields->setOptionalsFromPost(null, $object);
259  if ($ret < 0) {
260  $error++;
261  }
262 
263  $result = 0;
264 
265  if (!$error) {
266  $object->fk_user = $fuserid;
267  $object->description = $description;
268  $object->fk_validator = $approverid;
269  $object->fk_type = $type;
270  $object->date_debut = $date_debut;
271  $object->date_fin = $date_fin;
272  $object->halfday = $halfday;
273 
274  $result = $object->create($user);
275  if ($result <= 0) {
276  setEventMessages($object->error, $object->errors, 'errors');
277  $error++;
278  }
279  }
280 
281  // If no SQL error we redirect to the request card
282  if (!$error) {
283  $db->commit();
284 
285  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
286  exit;
287  } else {
288  $db->rollback();
289  }
290  }
291  }
292 
293  // If this is an update and we are an approver, we can update to change the approver
294  if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) {
295  $object->fetch($id);
296 
297  $object->oldcopy = dol_clone($object);
298 
299  $object->fk_validator = GETPOST('valideur', 'int');
300 
301  if ($object->fk_validator != $object->oldcopy->fk_validator) {
302  $verif = $object->update($user);
303 
304  if ($verif <= 0) {
305  setEventMessages($object->error, $object->errors, 'warnings');
306  $action = 'editvalidator';
307  } else {
308  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
309  exit;
310  }
311  }
312 
313  $action = '';
314  }
315 
316  if ($action == 'update' && !GETPOSTISSET('savevalidator')) {
317  $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
318  $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
319  $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
320  $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
321  $starthalfday = GETPOST('starthalfday');
322  $endhalfday = GETPOST('endhalfday');
323  $halfday = 0;
324  if ($starthalfday == 'afternoon' && $endhalfday == 'morning') {
325  $halfday = 2;
326  } elseif ($starthalfday == 'afternoon') {
327  $halfday = -1;
328  } elseif ($endhalfday == 'morning') {
329  $halfday = 1;
330  }
331 
332  // If no right to modify a request
333  if (!$cancreateall) {
334  if ($cancreate) {
335  if (!in_array($fuserid, $childids)) {
336  setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
337  header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
338  exit;
339  }
340  } else {
341  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
342  header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
343  exit;
344  }
345  }
346 
347  $object->fetch($id);
348 
349  // If under validation
350  if ($object->statut == Holiday::STATUS_DRAFT) {
351  // If this is the requestor or has read/write rights
352  if ($cancreate) {
353  $approverid = GETPOST('valideur', 'int');
354  // TODO Check this approver user id has the permission for approval
355 
356  $description = trim(GETPOST('description', 'restricthtml'));
357 
358  // If no start date
359  if (!GETPOST('date_debut_')) {
360  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=nodatedebut');
361  exit;
362  }
363 
364  // If no end date
365  if (!GETPOST('date_fin_')) {
366  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=nodatefin');
367  exit;
368  }
369 
370  // If start date after end date
371  if ($date_debut > $date_fin) {
372  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=datefin');
373  exit;
374  }
375 
376  // If no validator designated
377  if ($approverid < 1) {
378  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=Valideur');
379  exit;
380  }
381 
382  // If there is no Business Days within request
383  $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
384  if ($nbopenedday < 0.5) {
385  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=DureeHoliday');
386  exit;
387  }
388 
389  $object->description = $description;
390  $object->date_debut = $date_debut;
391  $object->date_fin = $date_fin;
392  $object->fk_validator = $approverid;
393  $object->halfday = $halfday;
394 
395  // Update
396  $verif = $object->update($user);
397 
398  if ($verif <= 0) {
399  setEventMessages($object->error, $object->errors, 'warnings');
400  $action = 'edit';
401  } else {
402  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
403  exit;
404  }
405  } else {
406  setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
407  $action = '';
408  }
409  } else {
410  setEventMessages($langs->trans("ErrorBadStatus"), null, 'errors');
411  $action = '';
412  }
413  }
414 
415  // If delete of request
416  if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $candelete) {
417  $error = 0;
418 
419  $db->begin();
420 
421  $object->fetch($id);
422 
423  // If this is a rough draft, approved, canceled or refused
424  if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) {
425  $result = $object->delete($user);
426  } else {
427  $error++;
428  setEventMessages($langs->trans('BadStatusOfObject'), null, 'errors');
429  $action = '';
430  }
431 
432  if (!$error) {
433  $db->commit();
434  header('Location: list.php?restore_lastsearch_values=1');
435  exit;
436  } else {
437  $db->rollback();
438  }
439  }
440 
441  // Action validate (+ send email for approval)
442  if ($action == 'confirm_send') {
443  $object->fetch($id);
444 
445  // If draft and owner of leave
446  if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) {
447  $object->oldcopy = dol_clone($object);
448 
449  $object->statut = Holiday::STATUS_VALIDATED;
450 
451  $verif = $object->validate($user);
452 
453  // If no SQL error, we redirect to the request form
454  if ($verif > 0) {
455  // To
456  $destinataire = new User($db);
457  $destinataire->fetch($object->fk_validator);
458  $emailTo = $destinataire->email;
459 
460  if (!$emailTo) {
461  dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email");
462  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
463  exit;
464  }
465 
466  // From
467  $expediteur = new User($db);
468  $expediteur->fetch($object->fk_user);
469  //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email.
470  $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
471 
472  // Subject
473  $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
474  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
475  $societeName = $conf->global->MAIN_APPLICATION_TITLE;
476  }
477 
478  $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate");
479 
480  // Content
481  $message = "<p>".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",</p>\n";
482 
483  $message .= "<p>".$langs->transnoentities("HolidaysToValidateBody")."</p>\n";
484 
485 
486  // option to warn the validator in case of too short delay
487  if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_TOO_LOW_DELAY)) {
488  $delayForRequest = 0; // TODO Set delay depending of holiday leave type
489  if ($delayForRequest) {
490  $nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd');
491 
492  if ($object->date_debut < $nowplusdelay) {
493  $message = "<p>".$langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."</p>\n";
494  }
495  }
496  }
497 
498  // option to notify the validator if the balance is less than the request
499  if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE)) {
500  $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
501 
502  if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
503  $message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
504  }
505  }
506 
507  $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id;
508 
509  $message .= "<ul>";
510  $message .= "<li>".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."</li>\n";
511  $message .= "<li>".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."</li>\n";
512  $message .= "<li>".$langs->transnoentitiesnoconv("Link").' : <a href="'.$link.'" target="_blank">'.$link."</a></li>\n";
513  $message .= "</ul>\n";
514 
515  $trackid = 'leav'.$object->id;
516 
517  $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid);
518 
519  // Sending the email
520  $result = $mail->sendfile();
521 
522  if (!$result) {
523  setEventMessages($mail->error, $mail->errors, 'warnings');
524  $action = '';
525  } else {
526  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
527  exit;
528  }
529  } else {
530  setEventMessages($object->error, $object->errors, 'errors');
531  $action = '';
532  }
533  }
534  }
535 
536  if ($action == 'update_extras') {
537  $object->oldcopy = dol_clone($object);
538 
539  // Fill array 'array_options' with data from update form
540  $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
541  if ($ret < 0) {
542  $error++;
543  }
544 
545  if (!$error) {
546  // Actions on extra fields
547  $result = $object->insertExtraFields('HOLIDAY_MODIFY');
548  if ($result < 0) {
549  setEventMessages($object->error, $object->errors, 'errors');
550  $error++;
551  }
552  }
553 
554  if ($error) {
555  $action = 'edit_extras';
556  }
557  }
558 
559  // Approve leave request
560  if ($action == 'confirm_valid') {
561  $object->fetch($id);
562 
563  // If status is waiting approval and approver is also user
564  if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) {
565  $object->oldcopy = dol_clone($object);
566 
567  $object->date_valid = dol_now();
568  $object->fk_user_valid = $user->id;
569  $object->statut = Holiday::STATUS_APPROVED;
570 
571  $db->begin();
572 
573  $verif = $object->approve($user);
574  if ($verif <= 0) {
575  setEventMessages($object->error, $object->errors, 'errors');
576  $error++;
577  }
578 
579  // If no SQL error, we redirect to the request form
580  if (!$error) {
581  // Calculcate number of days consumed
582  $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
583  $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type);
584  $newSolde = ($soldeActuel - $nbopenedday);
585  $label = $langs->transnoentitiesnoconv("Holidays").' - '.$object->ref;
586 
587  // The modification is added to the LOG
588  $result = $object->addLogCP($user->id, $object->fk_user, $label, $newSolde, $object->fk_type);
589  if ($result < 0) {
590  $error++;
591  setEventMessages(null, $object->errors, 'errors');
592  }
593 
594  // Update balance
595  $result = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type);
596  if ($result < 0) {
597  $error++;
598  setEventMessages(null, $object->errors, 'errors');
599  }
600  }
601 
602  if (!$error) {
603  // To
604  $destinataire = new User($db);
605  $destinataire->fetch($object->fk_user);
606  $emailTo = $destinataire->email;
607 
608  if (!$emailTo) {
609  dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email");
610  } else {
611  // From
612  $expediteur = new User($db);
613  $expediteur->fetch($object->fk_validator);
614  //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email.
615  $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
616 
617  // Subject
618  $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
619  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
620  $societeName = $conf->global->MAIN_APPLICATION_TITLE;
621  }
622 
623  $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated");
624 
625  // Content
626  $message = "<p>".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",</p>\n";
627 
628  $message .= "<p>".$langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."</p>\n";
629 
630  $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id;
631 
632  $message .= "<ul>\n";
633  $message .= "<li>".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."</li>\n";
634  $message .= "<li>".$langs->transnoentitiesnoconv("Link").' : <a href="'.$link.'" target="_blank">'.$link."</a></li>\n";
635  $message .= "</ul>\n";
636 
637  $trackid = 'leav'.$object->id;
638 
639  $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid);
640 
641  // Sending email
642  $result = $mail->sendfile();
643 
644  if (!$result) {
645  setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1
646  $action = '';
647  }
648  }
649  }
650 
651  if (!$error) {
652  $db->commit();
653 
654  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
655  exit;
656  } else {
657  $db->rollback();
658  $action = '';
659  }
660  }
661  }
662 
663  if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') {
664  if (GETPOST('detail_refuse')) {
665  $object->fetch($id);
666 
667  // If status pending validation and validator = user
668  if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) {
669  $object->date_refuse = dol_print_date('dayhour', dol_now());
670  $object->fk_user_refuse = $user->id;
671  $object->statut = Holiday::STATUS_REFUSED;
672  $object->detail_refuse = GETPOST('detail_refuse', 'alphanohtml');
673 
674  $db->begin();
675 
676  $verif = $object->update($user);
677  if ($verif <= 0) {
678  $error++;
679  setEventMessages($object->error, $object->errors, 'errors');
680  }
681 
682  // If no SQL error, we redirect to the request form
683  if (!$error) {
684  // To
685  $destinataire = new User($db);
686  $destinataire->fetch($object->fk_user);
687  $emailTo = $destinataire->email;
688 
689  if (!$emailTo) {
690  dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email");
691  } else {
692  // From
693  $expediteur = new User($db);
694  $expediteur->fetch($object->fk_validator);
695  //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email.
696  $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
697 
698  // Subject
699  $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
700  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
701  $societeName = $conf->global->MAIN_APPLICATION_TITLE;
702  }
703 
704  $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused");
705 
706  // Content
707  $message = "<p>".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",</p>\n";
708 
709  $message .= "<p>".$langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."<p>\n";
710  $message .= "<p>".GETPOST('detail_refuse', 'alpha')."</p>";
711 
712  $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id;
713 
714  $message .= "<ul>\n";
715  $message .= "<li>".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."</li>\n";
716  $message .= "<li>".$langs->transnoentitiesnoconv("Link").' : <a href="'.$link.'" target="_blank">'.$link."</a></li>\n";
717  $message .= "</ul>";
718 
719  $trackid = 'leav'.$object->id;
720 
721  $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid);
722 
723  // sending email
724  $result = $mail->sendfile();
725 
726  if (!$result) {
727  setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1
728  $action = '';
729  }
730  }
731  } else {
732  $action = '';
733  }
734 
735  if (!$error) {
736  $db->commit();
737 
738  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
739  exit;
740  } else {
741  $db->rollback();
742  $action = '';
743  }
744  }
745  } else {
746  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DetailRefusCP")), null, 'errors');
747  $action = 'refuse';
748  }
749  }
750 
751 
752  // If the request is validated
753  if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') {
754  $error = 0;
755 
756  $object->fetch($id);
757 
758  $oldstatus = $object->statut;
759  $object->statut = Holiday::STATUS_DRAFT;
760 
761  $result = $object->update($user);
762  if ($result < 0) {
763  $error++;
764  setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors');
765  }
766 
767  if (!$error) {
768  $db->commit();
769 
770  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
771  exit;
772  } else {
773  $db->rollback();
774  }
775  }
776 
777  // If confirmation of cancellation
778  if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') {
779  $error = 0;
780 
781  $object->fetch($id);
782 
783  // If status pending validation and validator = validator or user, or rights to do for others
784  if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) &&
785  (!empty($user->admin) || $user->id == $object->fk_validator || $cancreate || $cancreateall)) {
786  $db->begin();
787 
788  $oldstatus = $object->statut;
789  $object->date_cancel = dol_now();
790  $object->fk_user_cancel = $user->id;
791  $object->statut = Holiday::STATUS_CANCELED;
792 
793  $result = $object->update($user);
794 
795  if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) { // holiday was already validated, status 3, so we must increase back the balance
796  // Call trigger
797  $result = $object->call_trigger('HOLIDAY_CANCEL', $user);
798  if ($result < 0) {
799  $error++;
800  }
801 
802  // Calculcate number of days consumed
803  $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
804 
805  $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type);
806  $newSolde = ($soldeActuel + $nbopenedday);
807 
808  // The modification is added to the LOG
809  $result1 = $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $object->fk_type);
810 
811  // Update of the balance
812  $result2 = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type);
813 
814  if ($result1 < 0 || $result2 < 0) {
815  $error++;
816  setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors');
817  }
818  }
819 
820  if (!$error) {
821  $db->commit();
822  } else {
823  $db->rollback();
824  }
825 
826  // If no SQL error, we redirect to the request form
827  if (!$error && $result > 0) {
828  // To
829  $destinataire = new User($db);
830  $destinataire->fetch($object->fk_user);
831  $emailTo = $destinataire->email;
832 
833  if (!$emailTo) {
834  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
835  exit;
836  }
837 
838  // From
839  $expediteur = new User($db);
840  $expediteur->fetch($object->fk_user_cancel);
841  //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email.
842  $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
843 
844  // Subject
845  $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
846  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
847  $societeName = $conf->global->MAIN_APPLICATION_TITLE;
848  }
849 
850  $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled");
851 
852  // Content
853  $message = "<p>".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",</p>\n";
854 
855  $message .= "<p>".$langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."</p>\n";
856 
857  $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id;
858 
859  $message .= "<ul>\n";
860  $message .= "<li>".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."</li>\n";
861  $message .= "<li>".$langs->transnoentitiesnoconv("Link").' : <a href="'.$link.'" target="_blank">'.$link."</a></li>\n";
862  $message .= "</ul>\n";
863 
864  $trackid = 'leav'.$object->id;
865 
866  $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid);
867 
868  // sending email
869  $result = $mail->sendfile();
870 
871  if (!$result) {
872  setEventMessages($mail->error, $mail->errors, 'warnings');
873  $action = '';
874  } else {
875  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
876  exit;
877  }
878  }
879  }
880  }
881 
882  /*
883  // Actions when printing a doc from card
884  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
885 
886  // Actions to send emails
887  $triggersendname = 'HOLIDAY_SENTBYMAIL';
888  $autocopy='MAIN_MAIL_AUTOCOPY_HOLIDAY_TO';
889  $trackid='leav'.$object->id;
890  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
891 
892  // Actions to build doc
893  $upload_dir = $conf->holiday->dir_output;
894  $permissiontoadd = $user->rights->holiday->creer;
895  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
896  */
897 }
898 
899 
900 
901 /*
902  * View
903  */
904 
905 $form = new Form($db);
906 $object = new Holiday($db);
907 
908 $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
909 
910 $title = $langs->trans('Leave');
911 $help_url = 'EN:Module_Holiday';
912 
913 llxHeader('', $title, $help_url);
914 
915 $edit = false;
916 
917 if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
918  // If user has no permission to create a leave
919  if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)))) {
920  $errors[] = $langs->trans('CantCreateCP');
921  } else {
922  // Form to add a leave request
923  print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png');
924 
925  // Error management
926  if (GETPOST('error')) {
927  switch (GETPOST('error')) {
928  case 'datefin':
929  $errors[] = $langs->trans('ErrorEndDateCP');
930  break;
931  case 'SQL_Create':
932  $errors[] = $langs->trans('ErrorSQLCreateCP');
933  break;
934  case 'CantCreate':
935  $errors[] = $langs->trans('CantCreateCP');
936  break;
937  case 'Valideur':
938  $errors[] = $langs->trans('InvalidValidatorCP');
939  break;
940  case 'nodatedebut':
941  $errors[] = $langs->trans('NoDateDebut');
942  break;
943  case 'nodatefin':
944  $errors[] = $langs->trans('NoDateFin');
945  break;
946  case 'DureeHoliday':
947  $errors[] = $langs->trans('ErrorDureeCP');
948  break;
949  case 'alreadyCP':
950  $errors[] = $langs->trans('alreadyCPexist');
951  break;
952  }
953 
954  setEventMessages($errors, null, 'errors');
955  }
956 
957 
958  print '<script type="text/javascript">
959  $( document ).ready(function() {
960  $("input.button-save").click("submit", function(e) {
961  console.log("Call valider()");
962  if (document.demandeCP.date_debut_.value != "")
963  {
964  if(document.demandeCP.date_fin_.value != "")
965  {
966  if(document.demandeCP.valideur.value != "-1") {
967  return true;
968  }
969  else {
970  alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'");
971  return false;
972  }
973  }
974  else
975  {
976  alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'");
977  return false;
978  }
979  }
980  else
981  {
982  alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'");
983  return false;
984  }
985  });
986  });
987  </script>'."\n";
988 
989 
990  // Formulaire de demande
991  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="demandeCP">'."\n";
992  print '<input type="hidden" name="token" value="'.newToken().'" />'."\n";
993  print '<input type="hidden" name="action" value="add" />'."\n";
994 
995  if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
996  print dol_get_fiche_head('', '', '', -1);
997 
998  $out = '';
999  $nb_holiday = 0;
1000  $typeleaves = $object->getTypes(1, 1);
1001  foreach ($typeleaves as $key => $val) {
1002  $nb_type = $object->getCPforUser($user->id, $val['rowid']);
1003  $nb_holiday += $nb_type;
1004 
1005  $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
1006  //$out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>';
1007  }
1008  print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>';
1009  print $out;
1010 
1011  print dol_get_fiche_end();
1012  } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) {
1013  print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
1014  }
1015 
1016  print dol_get_fiche_head();
1017 
1018  //print '<span>'.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'</span><br><br>';
1019 
1020  print '<table class="border centpercent">';
1021  print '<tbody>';
1022 
1023  // User for leave request
1024  print '<tr>';
1025  print '<td class="titlefield fieldrequired">'.$langs->trans("User").'</td>';
1026  print '<td>';
1027  if ($cancreate && !$cancreateall) {
1028  print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500');
1029  //print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
1030  } else {
1031  print img_picto('', 'user').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500');
1032  }
1033  print '</td>';
1034  print '</tr>';
1035 
1036  // Type
1037  print '<tr>';
1038  print '<td class="fieldrequired">'.$langs->trans("Type").'</td>';
1039  print '<td>';
1040  $typeleaves = $object->getTypes(1, -1);
1041  $arraytypeleaves = array();
1042  foreach ($typeleaves as $key => $val) {
1043  $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
1044  $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : '');
1045  $arraytypeleaves[$val['rowid']] = $labeltoshow;
1046  }
1047  print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true);
1048  if ($user->admin) {
1049  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1050  }
1051  print '</td>';
1052  print '</tr>';
1053 
1054  // Date start
1055  print '<tr>';
1056  print '<td class="fieldrequired">';
1057  print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday"));
1058  print '</td>';
1059  print '<td>';
1060  // Si la demande ne vient pas de l'agenda
1061  if (!GETPOST('date_debut_')) {
1062  print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1);
1063  } else {
1064  $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month', 'int'), GETPOST('date_debut_day', 'int'), GETPOST('date_debut_year', 'int'));
1065  print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1);
1066  }
1067  print ' &nbsp; &nbsp; ';
1068  print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday', 'alpha') ?GETPOST('starthalfday', 'alpha') : 'morning'));
1069  print '</td>';
1070  print '</tr>';
1071 
1072  // Date end
1073  print '<tr>';
1074  print '<td class="fieldrequired">';
1075  print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday"));
1076  print '</td>';
1077  print '<td>';
1078  if (!GETPOST('date_fin_')) {
1079  print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1);
1080  } else {
1081  $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month', 'int'), GETPOST('date_fin_day', 'int'), GETPOST('date_fin_year', 'int'));
1082  print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1);
1083  }
1084  print ' &nbsp; &nbsp; ';
1085  print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday', 'alpha') ?GETPOST('endhalfday', 'alpha') : 'afternoon'));
1086  print '</td>';
1087  print '</tr>';
1088 
1089  // Approver
1090  print '<tr>';
1091  print '<td class="fieldrequired">'.$langs->trans("ReviewedByCP").'</td>';
1092  print '<td>';
1093 
1094  $object = new Holiday($db);
1095  $include_users = $object->fetch_users_approver_holiday();
1096  if (empty($include_users)) {
1097  print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
1098  } else {
1099  // Defined default approver (the forced approved of user or the supervisor if no forced value defined)
1100  // Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users
1101  $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1102  if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) {
1103  $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver
1104  }
1105  if (GETPOST('valideur', 'int') > 0) {
1106  $defaultselectuser = GETPOST('valideur', 'int');
1107  }
1108  $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
1109  print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
1110  }
1111 
1112  //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent
1113  print '</td>';
1114  print '</tr>';
1115 
1116  // Description
1117  print '<tr>';
1118  print '<td>'.$langs->trans("DescCP").'</td>';
1119  print '<td class="tdtop">';
1120  $doleditor = new DolEditor('description', GETPOST('description', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%');
1121  print $doleditor->Create(1);
1122  print '</td></tr>';
1123 
1124  // Other attributes
1125  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1126 
1127  print '</tbody>';
1128  print '</table>';
1129 
1130  print dol_get_fiche_end();
1131 
1132  print $form->buttonsSaveCancel("SendRequestCP");
1133 
1134  print '</from>'."\n";
1135  }
1136 } else {
1137  if ($error) {
1138  print '<div class="tabBar">';
1139  print $error;
1140  print '<br><br><input type="button" value="'.$langs->trans("ReturnCP").'" class="button" onclick="history.go(-1)" />';
1141  print '</div>';
1142  } else {
1143  // Affichage de la fiche d'une demande de congés payés
1144  if (($id > 0) || $ref) {
1145  $result = $object->fetch($id, $ref);
1146 
1147  $approverexpected = new User($db);
1148  $approverexpected->fetch($object->fk_validator);
1149 
1150  $userRequest = new User($db);
1151  $userRequest->fetch($object->fk_user);
1152 
1153  //print load_fiche_titre($langs->trans('TitreRequestCP'));
1154 
1155  // Si il y a une erreur
1156  if (GETPOST('error')) {
1157  switch (GETPOST('error')) {
1158  case 'datefin':
1159  $errors[] = $langs->transnoentitiesnoconv('ErrorEndDateCP');
1160  break;
1161  case 'SQL_Create':
1162  $errors[] = $langs->transnoentitiesnoconv('ErrorSQLCreateCP');
1163  break;
1164  case 'CantCreate':
1165  $errors[] = $langs->transnoentitiesnoconv('CantCreateCP');
1166  break;
1167  case 'Valideur':
1168  $errors[] = $langs->transnoentitiesnoconv('InvalidValidatorCP');
1169  break;
1170  case 'nodatedebut':
1171  $errors[] = $langs->transnoentitiesnoconv('NoDateDebut');
1172  break;
1173  case 'nodatefin':
1174  $errors[] = $langs->transnoentitiesnoconv('NoDateFin');
1175  break;
1176  case 'DureeHoliday':
1177  $errors[] = $langs->transnoentitiesnoconv('ErrorDureeCP');
1178  break;
1179  case 'NoMotifRefuse':
1180  $errors[] = $langs->transnoentitiesnoconv('NoMotifRefuseCP');
1181  break;
1182  case 'mail':
1183  $errors[] = $langs->transnoentitiesnoconv('ErrorMailNotSend');
1184  break;
1185  }
1186 
1187  setEventMessages($errors, null, 'errors');
1188  }
1189 
1190  // check if the user has the right to read this request
1191  if ($canread) {
1192  $head = holiday_prepare_head($object);
1193 
1194  if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) {
1195  if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) {
1196  $edit = true;
1197  }
1198 
1199  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'."\n";
1200  print '<input type="hidden" name="token" value="'.newToken().'" />'."\n";
1201  print '<input type="hidden" name="action" value="update"/>'."\n";
1202  print '<input type="hidden" name="id" value="'.$object->id.'" />'."\n";
1203  }
1204 
1205  print dol_get_fiche_head($head, 'card', $langs->trans("CPTitreMenu"), -1, 'holiday');
1206 
1207  $linkback = '<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1208 
1209  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
1210 
1211 
1212  print '<div class="fichecenter">';
1213  print '<div class="fichehalfleft">';
1214  print '<div class="underbanner clearboth"></div>';
1215 
1216  print '<table class="border tableforfield centpercent">';
1217  print '<tbody>';
1218 
1219  // User
1220  print '<tr>';
1221  print '<td class="titlefield">'.$langs->trans("User").'</td>';
1222  print '<td>';
1223  print $userRequest->getNomUrl(-1, 'leave');
1224  print '</td></tr>';
1225 
1226  // Type
1227  print '<tr>';
1228  print '<td>'.$langs->trans("Type").'</td>';
1229  print '<td>';
1230  $typeleaves = $object->getTypes(1, -1);
1231  $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']);
1232  print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
1233  print '</td>';
1234  print '</tr>';
1235 
1236  $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
1237  $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
1238 
1239  if (!$edit) {
1240  print '<tr>';
1241  print '<td class="nowrap">';
1242  print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
1243  print '</td>';
1244  print '<td>'.dol_print_date($object->date_debut, 'day');
1245  print ' &nbsp; &nbsp; ';
1246  print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
1247  print '</td>';
1248  print '</tr>';
1249  } else {
1250  print '<tr>';
1251  print '<td class="nowrap">';
1252  print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
1253  print '</td>';
1254  print '<td>';
1255  print $form->selectDate($object->date_debut, 'date_debut_');
1256  print ' &nbsp; &nbsp; ';
1257  print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday') ?GETPOST('starthalfday') : $starthalfday));
1258  print '</td>';
1259  print '</tr>';
1260  }
1261 
1262  if (!$edit) {
1263  print '<tr>';
1264  print '<td class="nowrap">';
1265  print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
1266  print '</td>';
1267  print '<td>'.dol_print_date($object->date_fin, 'day');
1268  print ' &nbsp; &nbsp; ';
1269  print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
1270  print '</td>';
1271  print '</tr>';
1272  } else {
1273  print '<tr>';
1274  print '<td class="nowrap">';
1275  print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
1276  print '</td>';
1277  print '<td>';
1278  print $form->selectDate($object->date_fin, 'date_fin_');
1279  print ' &nbsp; &nbsp; ';
1280  print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday') ?GETPOST('endhalfday') : $endhalfday));
1281  print '</td>';
1282  print '</tr>';
1283  }
1284 
1285  // Nb of days
1286  print '<tr>';
1287  print '<td>';
1288  $htmlhelp = $langs->trans('NbUseDaysCPHelp');
1289  $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
1290  $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
1291  if ($includesaturday) {
1292  $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
1293  }
1294  if ($includesunday) {
1295  $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
1296  }
1297  print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
1298  print '</td>';
1299  print '<td>';
1300  print num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
1301  print '</td>';
1302  print '</tr>';
1303 
1304  if ($object->statut == Holiday::STATUS_REFUSED) {
1305  print '<tr>';
1306  print '<td>'.$langs->trans('DetailRefusCP').'</td>';
1307  print '<td>'.$object->detail_refuse.'</td>';
1308  print '</tr>';
1309  }
1310 
1311  // Description
1312  if (!$edit) {
1313  print '<tr>';
1314  print '<td>'.$langs->trans('DescCP').'</td>';
1315  print '<td>'.nl2br($object->description).'</td>';
1316  print '</tr>';
1317  } else {
1318  print '<tr>';
1319  print '<td>'.$langs->trans('DescCP').'</td>';
1320  print '<td class="tdtop">';
1321  $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%');
1322  print $doleditor->Create(1);
1323  print '</td></tr>';
1324  }
1325 
1326  // Other attributes
1327  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1328 
1329  print '</tbody>';
1330  print '</table>'."\n";
1331 
1332  print '</div>';
1333  print '<div class="fichehalfright">';
1334 
1335  print '<div class="underbanner clearboth"></div>';
1336 
1337  // Info workflow
1338  print '<table class="border tableforfield centpercent">'."\n";
1339  print '<tbody>';
1340 
1341  if (!empty($object->fk_user_create)) {
1342  $userCreate = new User($db);
1343  $userCreate->fetch($object->fk_user_create);
1344  print '<tr>';
1345  print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
1346  print '<td>'.$userCreate->getNomUrl(-1).'</td>';
1347  print '</tr>';
1348  }
1349 
1350  // Approver
1351  if (!$edit && $action != 'editvalidator') {
1352  print '<tr>';
1353  print '<td class="titlefield">';
1354  if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) {
1355  print $langs->trans('ApprovedBy');
1356  } else {
1357  print $langs->trans('ReviewedByCP');
1358  }
1359  print '</td>';
1360  print '<td>';
1361  if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) {
1362  $approverdone = new User($db);
1363  $approverdone->fetch($object->fk_user_valid);
1364  print $approverdone->getNomUrl(-1);
1365  } else {
1366  print $approverexpected->getNomUrl(-1);
1367  }
1368  $include_users = $object->fetch_users_approver_holiday();
1369  if (is_array($include_users) && in_array($user->id, $include_users) && $object->statut == Holiday::STATUS_VALIDATED) {
1370  print '<a class="editfielda paddingleft" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editvalidator&token='.newToken().'">'.img_edit($langs->trans("Edit")).'</a>';
1371  }
1372  print '</td>';
1373  print '</tr>';
1374  } else {
1375  print '<tr>';
1376  print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
1377  print '<td>';
1378  $include_users = $object->fetch_users_approver_holiday();
1379  if (!in_array($object->fk_validator, $include_users)) { // Add the current validator to the list to not lose it when editing.
1380  $include_users[] = $object->fk_validator;
1381  }
1382  if (empty($include_users)) {
1383  print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
1384  } else {
1385  $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ? '' : array($user->id)); // Nobody if we are admin or if we are not the user of the leave.
1386  $s = $form->select_dolusers($object->fk_validator, "valideur", (($action == 'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1387  print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
1388  }
1389  if ($action == 'editvalidator') {
1390  print '<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans("Save").'">';
1391  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1392  }
1393  print '</td>';
1394  print '</tr>';
1395  }
1396 
1397  print '<tr>';
1398  print '<td>'.$langs->trans('DateCreation').'</td>';
1399  print '<td>'.dol_print_date($object->date_create, 'dayhour', 'tzuser').'</td>';
1400  print '</tr>';
1401  if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) {
1402  print '<tr>';
1403  print '<td>'.$langs->trans('DateValidCP').'</td>';
1404  print '<td>'.dol_print_date($object->date_valid, 'dayhour', 'tzuser').'</td>'; // warning: date_valid is approval date on holiday module
1405  print '</tr>';
1406  }
1407  if ($object->statut == Holiday::STATUS_CANCELED) {
1408  print '<tr>';
1409  print '<td>'.$langs->trans('DateCancelCP').'</td>';
1410  print '<td>'.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').'</td>';
1411  print '</tr>';
1412  }
1413  if ($object->statut == Holiday::STATUS_REFUSED) {
1414  print '<tr>';
1415  print '<td>'.$langs->trans('DateRefusCP').'</td>';
1416  print '<td>'.dol_print_date($object->date_refuse, 'dayhour', 'tzuser').'</td>';
1417  print '</tr>';
1418  }
1419  print '</tbody>';
1420  print '</table>';
1421 
1422  print '</div>';
1423  print '</div>';
1424 
1425  print '<div class="clearboth"></div>';
1426 
1427  print dol_get_fiche_end();
1428 
1429 
1430  // Confirmation messages
1431  if ($action == 'delete') {
1432  if ($candelete) {
1433  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleDeleteCP"), $langs->trans("ConfirmDeleteCP"), "confirm_delete", '', 0, 1);
1434  }
1435  }
1436 
1437  // Si envoi en validation
1438  if ($action == 'sendToValidate' && $object->statut == Holiday::STATUS_DRAFT) {
1439  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleToValidCP"), $langs->trans("ConfirmToValidCP"), "confirm_send", '', 1, 1);
1440  }
1441 
1442  // Si validation de la demande
1443  if ($action == 'valid') {
1444  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleValidCP"), $langs->trans("ConfirmValidCP"), "confirm_valid", '', 1, 1);
1445  }
1446 
1447  // Si refus de la demande
1448  if ($action == 'refuse') {
1449  $array_input = array(array('type'=>"text", 'label'=> $langs->trans('DetailRefusCP'), 'name'=>"detail_refuse", 'size'=>"50", 'value'=>""));
1450  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0);
1451  }
1452 
1453  // Si annulation de la demande
1454  if ($action == 'cancel') {
1455  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleCancelCP"), $langs->trans("ConfirmCancelCP"), "confirm_cancel", '', 1, 1);
1456  }
1457 
1458  // Si back to draft
1459  if ($action == 'backtodraft') {
1460  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleSetToDraft"), $langs->trans("ConfirmSetToDraft"), "confirm_draft", '', 1, 1);
1461  }
1462 
1463  if (($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) {
1464  if ($action == 'edit' && $object->statut == Holiday::STATUS_DRAFT) {
1465  if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) {
1466  print $form->buttonsSaveCancel();
1467  }
1468  }
1469 
1470  print '</form>';
1471  }
1472 
1473  if (!$edit) {
1474  // Buttons for actions
1475 
1476  print '<div class="tabsAction">';
1477 
1478  if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) {
1479  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'" class="butAction">'.$langs->trans("EditCP").'</a>';
1480  }
1481 
1482  if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { // If draft
1483  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=sendToValidate&token='.newToken().'" class="butAction">'.$langs->trans("Validate").'</a>';
1484  }
1485 
1486  if ($object->statut == Holiday::STATUS_VALIDATED) { // If validated
1487  // Button Approve / Refuse
1488  if ($user->id == $object->fk_validator) {
1489  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
1490  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
1491  } else {
1492  print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("Approve").'</a>';
1493  print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>';
1494 
1495  // Button Cancel (because we can't approve)
1496  if ($cancreate || $cancreateall) {
1497  if (($object->date_debut > dol_now()) || !empty($user->admin)) {
1498  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
1499  } else {
1500  print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'-'.$langs->trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'</a>';
1501  }
1502  }
1503  }
1504  }
1505  if ($object->statut == Holiday::STATUS_APPROVED) { // If validated and approved
1506  if ($user->id == $object->fk_validator || $cancreate || $cancreateall) {
1507  if (($object->date_debut > dol_now()) || !empty($user->admin)) {
1508  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
1509  } else {
1510  print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'-'.$langs->trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'</a>';
1511  }
1512  } else { // I have no rights on the user of the holiday.
1513  if (!empty($user->admin)) { // If current approver can't cancel an approved leave, we allow admin user
1514  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
1515  } else {
1516  print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'</a>';
1517  }
1518  }
1519  }
1520 
1521  if (($cancreate || $cancreateall) && $object->statut == Holiday::STATUS_CANCELED) {
1522  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
1523  }
1524  if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) { // If draft or canceled or refused
1525  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
1526  }
1527 
1528  print '</div>';
1529  }
1530  } else {
1531  print '<div class="tabBar">';
1532  print $langs->trans('ErrorUserViewCP');
1533  print '<br><br><input type="button" value="'.$langs->trans("ReturnCP").'" class="button" onclick="history.go(-1)" />';
1534  print '</div>';
1535  }
1536  } else {
1537  print '<div class="tabBar">';
1538  print $langs->trans('ErrorIDFicheCP');
1539  print '<br><br><input type="button" value="'.$langs->trans("ReturnCP").'" class="button" onclick="history.go(-1)" />';
1540  print '</div>';
1541  }
1542 
1543 
1544  // Select mail models is same action as presend
1545  if (GETPOST('modelselected')) {
1546  $action = 'presend';
1547  }
1548 
1549  if ($action != 'presend' && $action != 'edit') {
1550  print '<div class="fichecenter"><div class="fichehalfleft">';
1551  print '<a name="builddoc"></a>'; // ancre
1552 
1553  $includedocgeneration = 0;
1554 
1555  // Documents
1556  if ($includedocgeneration) {
1557  $objref = dol_sanitizeFileName($object->ref);
1558  $relativepath = $objref.'/'.$objref.'.pdf';
1559  $filedir = $conf->holiday->dir_output.'/'.$object->element.'/'.$objref;
1560  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1561  $genallowed = ($user->rights->holiday->read && $object->fk_user == $user->id) || !empty($user->rights->holiday->readall); // If you can read, you can build the PDF to read content
1562  $delallowed = ($user->rights->holiday->write && $object->fk_user == $user->id) || !empty($user->rights->holiday->writeall_advance); // If you can create/edit, you can remove a file on card
1563  print $formfile->showdocuments('holiday:Holiday', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
1564  }
1565 
1566  // Show links to link elements
1567  //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
1568  //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1569 
1570 
1571  print '</div><div class="fichehalfright">';
1572 
1573  $MAXEVENT = 10;
1574  $morehtmlright = '';
1575 
1576  // List of actions on element
1577  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1578  $formactions = new FormActions($db);
1579  $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
1580 
1581  print '</div></div>';
1582  }
1583  }
1584 }
1585 
1586 // End of page
1587 llxFooter();
1588 
1589 if (is_object($db)) {
1590  $db->close();
1591 }
num_open_day
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
Definition: date.lib.php:982
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
CMailFile
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Definition: CMailFile.class.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Holiday\STATUS_APPROVED
const STATUS_APPROVED
Approved.
Definition: holiday.class.php:154
dol_clone
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
Definition: functions.lib.php:1158
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
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.
Definition: functions.lib.php:2046
$help_url
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:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:178
dol_escape_js
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Definition: functions.lib.php:1423
Holiday\STATUS_REFUSED
const STATUS_REFUSED
Refused.
Definition: holiday.class.php:162
Holiday
Class of the module paid holiday.
Definition: holiday.class.php:34
Holiday\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: holiday.class.php:146
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolGetFirstLastname
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
Definition: functions.lib.php:8062
dol_time_plus_duree
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Holiday\STATUS_CANCELED
const STATUS_CANCELED
Canceled.
Definition: holiday.class.php:158
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$parameters
$parameters
Actions.
Definition: card.php:78
Holiday\STATUS_VALIDATED
const STATUS_VALIDATED
Validated status.
Definition: holiday.class.php:150
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
holiday_prepare_head
holiday_prepare_head($object)
Return array head with list of tabs to view object informations.
Definition: holiday.lib.php:30
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30