30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43 $action =
GETPOST(
'action',
'aZ09');
44 $cancel =
GETPOST(
'cancel',
'alpha');
45 $confirm =
GETPOST(
'confirm',
'alpha');
49 $fuserid = (
GETPOST(
'fuserid',
'int') ?
GETPOST(
'fuserid',
'int') : $user->id);
52 $langs->loadLangs(array(
"other",
"holiday",
"mails"));
56 $childids = $user->getAllChildIds(1);
59 if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) $morefilter =
'AND employee = 1';
68 $extrafields->fetch_name_optionals_label($object->table_element);
70 if (($id > 0) || $ref)
72 $object->fetch($id, $ref);
76 if (!empty($user->rights->holiday->readall)) $canread = 1;
77 if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) $canread = 1;
86 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) $cancreate = 1;
87 if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate = 1;
90 if (!empty($user->rights->holiday->delete)) $candelete = 1;
91 if ($object->statut ==
Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete = 1;
94 if ($user->socid) $socid = $user->socid;
95 $result =
restrictedArea($user,
'holiday', $object->id,
'holiday');
102 $parameters = array(
'socid' => $socid);
103 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
110 if (!empty($backtopage))
112 header(
"Location: ".$backtopage);
119 if ($action ==
'add')
139 $starthalfday =
GETPOST(
'starthalfday');
140 $endhalfday =
GETPOST(
'endhalfday');
143 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') $halfday = 2;
144 elseif ($starthalfday ==
'afternoon') $halfday = -1;
145 elseif ($endhalfday == 'morning') $halfday = 1;
147 $valideur =
GETPOST('valideur', '
int');
151 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->holiday->write))
152 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->
id == $fuserid && empty($user->rights->holiday->write))
153 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->
id != $fuserid && empty($user->rights->holiday->writeall_advance))
158 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) {
159 if (!in_array($fuserid, $childids)) {
170 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
176 if (empty($date_debut))
183 if (empty($date_fin))
190 if ($date_debut > $date_fin)
198 $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
207 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
208 if ($nbopenedday < 0.5)
218 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'), null,
'errors');
226 $object->fk_user = $fuserid;
227 $object->description = $description;
228 $object->fk_validator = $valideur;
229 $object->fk_type = $type;
230 $object->date_debut = $date_debut;
231 $object->date_fin = $date_fin;
232 $object->halfday = $halfday;
234 $result = $object->create($user);
247 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
255 if ($action ==
'update' &&
GETPOSTISSET(
'savevalidator') && !empty($user->rights->holiday->approve))
261 $object->fk_validator =
GETPOST(
'valideur',
'int');
263 if ($object->fk_validator != $object->oldcopy->fk_validator)
265 $verif = $object->update($user);
270 $action =
'editvalidator';
272 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
280 if ($action ==
'update' && !
GETPOSTISSET(
'savevalidator'))
286 $starthalfday =
GETPOST(
'starthalfday');
287 $endhalfday =
GETPOST(
'endhalfday');
289 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') $halfday = 2;
290 elseif ($starthalfday ==
'afternoon') $halfday = -1;
291 elseif ($endhalfday == 'morning') $halfday = 1;
294 if (!$user->rights->holiday->write)
297 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?action=create');
309 $valideur =
GETPOST(
'valideur',
'int');
310 $description = trim(
GETPOST(
'description',
'restricthtml'));
313 if (empty($_POST[
'date_debut_'])) {
314 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&error=nodatedebut');
319 if (empty($_POST[
'date_fin_'])) {
320 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&error=nodatefin');
325 if ($date_debut > $date_fin) {
326 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&error=datefin');
332 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&error=Valideur');
337 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
338 if ($nbopenedday < 0.5)
340 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&error=DureeHoliday');
344 $object->description = $description;
345 $object->date_debut = $date_debut;
346 $object->date_fin = $date_fin;
347 $object->fk_validator = $valideur;
348 $object->halfday = $halfday;
351 $verif = $object->update($user);
358 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
372 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $user->rights->holiday->delete)
386 $result = $object->delete($user);
397 header(
'Location: list.php?restore_lastsearch_values=1');
405 if ($action ==
'confirm_send')
416 $verif = $object->validate($user);
422 $destinataire =
new User($db);
423 $destinataire->fetch($object->fk_validator);
424 $emailTo = $destinataire->email;
428 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
429 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
434 $expediteur =
new User($db);
435 $expediteur->fetch($object->fk_user);
437 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
440 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
441 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;
443 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
446 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
449 $message .= $langs->transnoentities(
"HolidaysToValidateBody").
"\n";
451 $delayForRequest = $object->getConfCP(
'delayForRequest');
457 if ($object->getConfCP(
'AlertValidatorDelay'))
459 if ($object->date_debut < $nextMonth)
462 $message .= $langs->transnoentities(
"HolidaysToValidateDelay", $object->getConfCP(
'delayForRequest')).
"\n";
467 if ($object->getConfCP(
'AlertValidatorSolde'))
469 $nbopenedday =
num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
470 if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type))
473 $message .= $langs->transnoentities(
"HolidaysToValidateAlertSolde").
"\n";
478 $message .=
"- ".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
479 $message .=
"- ".$langs->transnoentitiesnoconv(
"Period").
" : ".
dol_print_date($object->date_debut,
'day').
" ".$langs->transnoentitiesnoconv(
"To").
" ".
dol_print_date($object->date_fin,
'day').
"\n";
480 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$object->id.
"\n\n";
483 $trackid =
'leav'.$object->id;
485 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
488 $result = $mail->sendfile();
495 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
505 if ($action ==
'update_extras')
510 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
511 if ($ret < 0) $error++;
516 $result = $object->insertExtraFields(
'HOLIDAY_MODIFY');
525 $action =
'edit_extras';
529 if ($action ==
'confirm_valid')
538 $object->date_valid =
dol_now();
539 $object->fk_user_valid = $user->id;
544 $verif = $object->approve($user);
555 $nbopenedday =
num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
556 $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type);
557 $newSolde = ($soldeActuel - $nbopenedday);
560 $result = $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv(
"Holidays"), $newSolde, $object->fk_type);
568 $result = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type);
579 $destinataire =
new User($db);
580 $destinataire->fetch($object->fk_user);
581 $emailTo = $destinataire->email;
585 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
588 $expediteur =
new User($db);
589 $expediteur->fetch($object->fk_validator);
591 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
594 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
595 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;
597 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
600 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
603 $message .= $langs->transnoentities(
"HolidaysValidatedBody",
dol_print_date($object->date_debut,
'day'),
dol_print_date($object->date_fin,
'day')).
"\n";
605 $message .=
"- ".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
607 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$object->id.
"\n\n";
610 $trackid =
'leav'.$object->id;
612 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
615 $result = $mail->sendfile();
629 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
638 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes')
640 if (!empty($_POST[
'detail_refuse']))
648 $object->fk_user_refuse = $user->id;
650 $object->detail_refuse =
GETPOST(
'detail_refuse',
'alphanohtml');
654 $verif = $object->update($user);
665 $destinataire =
new User($db);
666 $destinataire->fetch($object->fk_user);
667 $emailTo = $destinataire->email;
671 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
674 $expediteur =
new User($db);
675 $expediteur->fetch($object->fk_validator);
677 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
680 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
681 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;
683 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
686 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
689 $message .= $langs->transnoentities(
"HolidaysRefusedBody",
dol_print_date($object->date_debut,
'day'),
dol_print_date($object->date_fin,
'day')).
"\n";
690 $message .=
GETPOST(
'detail_refuse',
'alpha').
"\n\n";
692 $message .=
"- ".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
694 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$object->id.
"\n\n";
697 $trackid =
'leav'.$object->id;
699 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
702 $result = $mail->sendfile();
718 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
726 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")), null,
'errors');
733 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes')
739 $oldstatus = $object->statut;
742 $result = $object->update($user);
746 setEventMessages($langs->trans(
'ErrorBackToDraft').
' '.$object->error, $object->errors,
'errors');
753 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
761 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes')
769 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))))
773 $oldstatus = $object->statut;
774 $object->date_cancel =
dol_now();
775 $object->fk_user_cancel = $user->id;
778 $result = $object->update($user);
783 $nbopenedday =
num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
785 $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type);
786 $newSolde = ($soldeActuel + $nbopenedday);
789 $result1 = $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv(
"HolidaysCancelation"), $newSolde, $object->fk_type);
792 $result2 = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type);
794 if ($result1 < 0 || $result2 < 0)
797 setEventMessages($langs->trans(
'ErrorCantDeleteCP').
' '.$object->error, $object->errors,
'errors');
809 if (!$error && $result > 0)
812 $destinataire =
new User($db);
813 $destinataire->fetch($object->fk_user);
814 $emailTo = $destinataire->email;
818 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
823 $expediteur =
new User($db);
824 $expediteur->fetch($object->fk_user_cancel);
826 $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
829 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
830 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;
832 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
835 $message = $langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",\n";
838 $message .= $langs->transnoentities(
"HolidaysCanceledBody",
dol_print_date($object->date_debut,
'day'),
dol_print_date($object->date_fin,
'day')).
"\n";
839 $message .=
"- ".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"\n";
841 $message .=
"- ".$langs->transnoentitiesnoconv(
"Link").
" : ".$dolibarr_main_url_root.
"/holiday/card.php?id=".$object->id.
"\n\n";
844 $trackid =
'leav'.$object->id;
846 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'',
'', 0, 0,
'',
'', $trackid);
849 $result = $mail->sendfile();
856 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
886 $form =
new Form($db);
889 $listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
891 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
893 if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add')
896 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))))
898 $errors[] = $langs->trans(
'CantCreateCP');
907 $errors[] = $langs->trans(
'ErrorEndDateCP');
910 $errors[] = $langs->trans(
'ErrorSQLCreateCP').
' <b>'.htmlentities($_GET[
'msg']).
'</b>';
913 $errors[] = $langs->trans(
'CantCreateCP');
916 $errors[] = $langs->trans(
'InvalidValidatorCP');
919 $errors[] = $langs->trans(
'NoDateDebut');
922 $errors[] = $langs->trans(
'NoDateFin');
924 case 'DureeHoliday' :
925 $errors[] = $langs->trans(
'ErrorDureeCP');
928 $errors[] = $langs->trans(
'alreadyCPexist');
936 $delayForRequest = $object->getConfCP(
'delayForRequest');
941 print '<script type="text/javascript">
944 if(document.demandeCP.date_debut_.value != "")
946 if(document.demandeCP.date_fin_.value != "")
948 if(document.demandeCP.valideur.value != "-1") {
952 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
958 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
964 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
971 print '<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" onsubmit="return valider()" name="demandeCP">'.
"\n";
972 print '<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
973 print '<input type="hidden" name="action" value="add" />'.
"\n";
975 if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
979 $typeleaves = $object->getTypes(1, 1);
980 foreach ($typeleaves as $key => $val)
982 $nb_type = $object->getCPforUser($user->id, $val[
'rowid']);
983 $nb_holiday += $nb_type;
985 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
988 print $langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
'<br>';
992 } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) {
993 print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).
'<br>';
1000 print '<table class="border centpercent">';
1005 print '<td class="titlefield fieldrequired">'.$langs->trans(
"User").
'</td>';
1008 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance))
1010 print img_picto(
'',
'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id),
'fuserid', 0,
'', 0,
'hierarchyme',
'',
'0,'.$conf->entity, 0, 0, $morefilter, 0,
'',
'minwidth200 maxwidth500');
1013 print img_picto(
'',
'user').$form->select_dolusers(
GETPOST(
'fuserid',
'int') ?
GETPOST(
'fuserid',
'int') : $user->id,
'fuserid', 0,
'', 0,
'',
'',
'0,'.$conf->entity, 0, 0, $morefilter, 0,
'',
'minwidth200 maxwidth500');
1020 print '<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1022 $typeleaves = $object->getTypes(1, -1);
1023 $arraytypeleaves = array();
1024 foreach ($typeleaves as $key => $val)
1026 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1027 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1028 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1030 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'',
true);
1031 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1037 print
'<td class="fieldrequired">';
1038 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1042 if (!
GETPOST(
'date_debut_')) {
1043 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1046 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1048 print
' ';
1049 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1055 print
'<td class="fieldrequired">';
1056 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1060 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1063 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1065 print
' ';
1066 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1072 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1076 $include_users = $object->fetch_users_approver_holiday();
1077 if (empty($include_users)) {
1078 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1080 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1081 if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR;
1082 if (
GETPOST(
'valideur',
'int') > 0) $defaultselectuser =
GETPOST(
'valideur',
'int');
1083 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1084 print
img_picto(
'',
'user').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1093 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1094 print
'<td class="tdtop">';
1095 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1096 print $doleditor->Create(1);
1100 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1107 print
'<div class="center">';
1108 print
'<input type="submit" value="'.$langs->trans(
"SendRequestCP").
'" name="bouton" class="button">';
1109 print
' ';
1110 print
'<input type="button" value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" onclick="history.go(-1)">';
1113 print
'</from>'.
"\n";
1117 print
'<div class="tabBar">';
1119 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1123 if (($id > 0) || $ref)
1125 $result = $object->fetch($id, $ref);
1127 $valideur =
new User($db);
1128 $valideur->fetch($object->fk_validator);
1130 $userRequest =
new User($db);
1131 $userRequest->fetch($object->fk_user);
1141 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1144 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP').
' '.$_GET[
'msg'];
1147 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1150 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1152 case 'nodatedebut' :
1153 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1156 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1158 case 'DureeHoliday' :
1159 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1161 case 'NoMotifRefuse' :
1162 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1165 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend').
"\n".$_GET[
'error_content'];
1177 if (($action ==
'edit' && $object->statut ==
Holiday::STATUS_DRAFT) || ($action ==
'editvalidator'))
1181 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">'.
"\n";
1182 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1183 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1184 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1187 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1189 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1194 print
'<div class="fichecenter">';
1195 print
'<div class="fichehalfleft">';
1196 print
'<div class="underbanner clearboth"></div>';
1198 print
'<table class="border tableforfield centpercent">';
1203 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1205 print $userRequest->getNomUrl(-1,
'leave');
1210 print
'<td>'.$langs->trans(
"Type").
'</td>';
1212 $typeleaves = $object->getTypes(1, -1);
1213 $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']);
1214 print empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
1218 $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ?
'afternoon' :
'morning';
1219 $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ?
'morning' :
'afternoon';
1224 print
'<td class="nowrap">';
1225 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1227 print
'<td>'.dol_print_date($object->date_debut,
'day');
1228 print
' ';
1229 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1234 print
'<td class="nowrap">';
1235 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1238 print $form->selectDate($object->date_debut,
'date_debut_');
1239 print
' ';
1240 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1248 print
'<td class="nowrap">';
1249 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1251 print
'<td>'.dol_print_date($object->date_fin,
'day');
1252 print
' ';
1253 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1258 print
'<td class="nowrap">';
1259 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1262 print $form->selectDate($object->date_fin,
'date_fin_');
1263 print
' ';
1264 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1272 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1273 $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
1274 $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
1275 if ($includesaturday) $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1276 if ($includesunday) $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1277 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1280 print
num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
1287 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1288 print
'<td>'.$object->detail_refuse.
'</td>';
1296 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1297 print
'<td>'.nl2br($object->description).
'</td>';
1301 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1302 print
'<td class="tdtop">';
1303 $doleditor =
new DolEditor(
'description', $object->description,
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1304 print $doleditor->Create(1);
1309 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1312 print
'</table>'.
"\n";
1315 print
'<div class="fichehalfright">';
1316 print
'<div class="ficheaddleft">';
1318 print
'<div class="underbanner clearboth"></div>';
1321 print
'<table class="border tableforfield centpercent">'.
"\n";
1324 if (!empty($object->fk_user_create))
1326 $userCreate =
new User($db);
1327 $userCreate->fetch($object->fk_user_create);
1329 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1330 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1335 if (!$edit && $action !=
'editvalidator') {
1337 print
'<td class="titlefield">';
1339 else print $langs->trans(
'ReviewedByCP');
1341 print
'<td>'.$valideur->getNomUrl(-1);
1342 $include_users = $object->fetch_users_approver_holiday();
1345 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1351 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1353 $include_users = $object->fetch_users_approver_holiday();
1354 if (!in_array($object->fk_validator, $include_users))
1356 $include_users[] = $object->fk_validator;
1358 if (empty($include_users)) print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1360 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1361 $s = $form->select_dolusers($object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1362 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1364 if ($action ==
'editvalidator')
1366 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1367 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1374 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1375 print
'<td>'.dol_print_date($object->date_create,
'dayhour',
'tzuser').
'</td>';
1379 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1380 print
'<td>'.dol_print_date($object->date_valid,
'dayhour',
'tzuser').
'</td>';
1385 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1386 print
'<td>'.dol_print_date($object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1391 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1392 print
'<td>'.dol_print_date($object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1402 print
'<div class="clearboth"></div>';
1408 if ($action ==
'delete')
1410 if ($user->rights->holiday->delete)
1412 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1419 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1423 if ($action ==
'valid')
1425 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1429 if ($action ==
'refuse')
1431 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1432 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1436 if ($action ==
'cancel')
1438 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1442 if ($action ==
'backtodraft')
1444 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1447 if (($action ==
'edit' && $object->statut ==
Holiday::STATUS_DRAFT) || ($action ==
'editvalidator'))
1451 print
'<div class="center">';
1454 print
'<input type="submit" value="'.$langs->trans(
"Save").
'" class="button button-save">';
1466 print
'<div class="tabsAction">';
1470 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1474 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=sendToValidate" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1478 if ($user->id == $object->fk_validator)
1480 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=valid" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1481 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=refuse" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1483 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1484 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1487 if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) && ($object->statut == 2 || $object->statut == 3))
1489 if (($object->date_debut >
dol_now()) || $user->admin) print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=cancel" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1490 else print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1494 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1498 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1504 print
'<div class="tabBar">';
1505 print $langs->trans(
'ErrorUserViewCP');
1506 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1510 print
'<div class="tabBar">';
1511 print $langs->trans(
'ErrorIDFicheCP');
1512 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1518 if (
GETPOST(
'modelselected')) {
1519 $action =
'presend';
1522 if ($action !=
'presend')
1524 print
'<div class="fichecenter"><div class="fichehalfleft">';
1525 print
'<a name="builddoc"></a>';
1527 $includedocgeneration = 0;
1530 if ($includedocgeneration) {
1532 $relativepath = $objref.
'/'.$objref.
'.pdf';
1533 $filedir = $conf->holiday->dir_output.
'/'.$object->element.
'/'.$objref;
1534 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1535 $genallowed = ($user->rights->holiday->read && $object->fk_user == $user->id) || !empty($user->rights->holiday->readall);
1536 $delallowed = ($user->rights->holiday->write && $object->fk_user == $user->id) || !empty($user->rights->holiday->writeall_advance);
1537 print $formfile->showdocuments(
'holiday:Holiday', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1545 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1554 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1556 $somethingshown =
$formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
1558 print
'</div></div></div>';
1566 if (is_object($db)) $db->close();
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.
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...
holiday_prepare_head($object)
Return array head with list of tabs to view object informations.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
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.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
const STATUS_DRAFT
Draft status.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
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 '...
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->sendfile();.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it'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) ...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program 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.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
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 'newtoken'.
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.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.