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