34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47$action =
GETPOST(
'action',
'aZ09');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
59$langs->loadLangs(array(
"other",
"holiday",
"mails",
"trips"));
65$childids = $user->getAllChildIds(1);
69 $morefilter =
'AND employee = 1';
77$extrafields->fetch_name_optionals_label(
$object->table_element);
79if (($id > 0) || $ref) {
84 if ($user->hasRight(
'holiday',
'readall')) {
87 if ($user->hasRight(
'holiday',
'read') && in_array(
$object->fk_user, $childids)) {
96$hookmanager->initHooks(array(
'holidaycard',
'globalcard'));
99$permissiontoaddall = 0;
100if ($user->hasRight(
'holiday',
'write') && in_array($fuserid, $childids)) {
101 $permissiontoadd = 1;
103if ($user->hasRight(
'holiday',
'writeall')) {
104 $permissiontoadd = 1;
105 $permissiontoaddall = 1;
109if ($user->hasRight(
'holiday',
'delete')) {
118 $socid = $user->socid;
127$parameters = array(
'socid' => $socid);
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
133if (empty($reshook)) {
134 $backurlforlist = DOL_URL_ROOT.
'/holiday/list.php';
136 if (empty($backtopage) || ($cancel && empty($id))) {
137 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
138 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
139 $backtopage = $backurlforlist;
141 $backtopage = DOL_URL_ROOT.
'/holiday/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
147 if (!empty($backtopageforcancel)) {
148 header(
"Location: ".$backtopageforcancel);
150 } elseif (!empty($backtopage)) {
151 header(
"Location: ".$backtopage);
158 if ($action ==
'add' && $permissiontoadd) {
167 $starthalfday =
GETPOST(
'starthalfday');
168 $endhalfday =
GETPOST(
'endhalfday');
171 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
173 } elseif ($starthalfday ==
'afternoon') {
175 } elseif ($endhalfday ==
'morning') {
180 $description = trim(
GETPOST(
'description',
'restricthtml'));
183 if (!$permissiontoaddall) {
185 if (!$user->hasRight(
'holiday',
'write')) {
188 } elseif (!in_array($fuserid, $childids)) {
194 if (!$user->hasRight(
'holiday',
'write') && !$user->hasRight(
'holiday',
'writeall_advance')) {
197 } elseif (!$user->hasRight(
'holiday',
'writeall_advance') && !in_array($fuserid, $childids)) {
207 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
213 if (empty($date_debut)) {
219 if (empty($date_fin)) {
225 if ($date_debut > $date_fin) {
232 $verifCP =
$object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
240 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
241 if ($nbopenedday < 0.5) {
248 if ($approverid < 1) {
249 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'),
null,
'errors');
253 $approverslist =
$object->fetch_users_approver_holiday();
254 if (!in_array($approverid, $approverslist)) {
255 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidator'),
null,
'errors');
260 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
269 $object->description = $description;
270 $object->fk_validator = $approverid;
272 $object->date_debut = $date_debut;
275 $object->entity = $conf->entity;
277 $result =
$object->create($user);
288 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
296 if ($action ==
'update' && GETPOSTISSET(
'savevalidator') && $user->hasRight(
'holiday',
'approve')) {
304 $verif =
$object->update($user);
308 $action =
'editvalidator';
310 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
318 if ($action ==
'update' && !GETPOSTISSET(
'savevalidator')) {
323 $starthalfday =
GETPOST(
'starthalfday');
324 $endhalfday =
GETPOST(
'endhalfday');
326 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
328 } elseif ($starthalfday ==
'afternoon') {
330 } elseif ($endhalfday ==
'morning') {
335 if (!$permissiontoaddall) {
336 if ($permissiontoadd) {
337 if (!in_array($fuserid, $childids)) {
339 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
344 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
354 if ($permissiontoadd) {
358 $description = trim(
GETPOST(
'description',
'restricthtml'));
368 if ($date_debut > $date_fin) {
375 if ($approverid < 1) {
382 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
383 if ($nbopenedday < 0.5) {
392 $object->description = $description;
393 $object->date_debut = $date_debut;
395 $object->fk_validator = $approverid;
399 $verif =
$object->update($user);
411 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
427 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $candelete) {
436 $result =
$object->delete($user);
445 header(
'Location: list.php?restore_lastsearch_values=1');
453 if ($action ==
'confirm_send') {
462 $verif =
$object->validate($user);
467 $destinataire =
new User($db);
468 $destinataire->fetch(
$object->fk_validator);
469 $emailTo = $destinataire->email;
472 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
473 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
478 $expediteur =
new User($db);
479 $expediteur->fetch(
$object->fk_user);
489 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
492 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
494 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateBody").
"</p>\n";
499 $delayForRequest = 0;
500 if ($delayForRequest) {
503 if (
$object->date_debut < $nowplusdelay) {
504 $message =
"<p>".$langs->transnoentities(
"HolidaysToValidateDelay", $delayForRequest).
"</p>\n";
514 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateAlertSolde").
"</p>\n";
518 $typeleaves =
$object->getTypes(1, -1);
519 if (empty($typeleaves[
$object->fk_type])) {
520 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
522 $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']);
525 $starthalfdaykey =
"Afternoon";
526 $endhalfdaykey =
"Morning";
527 } elseif (
$object->halfday == -1) {
528 $starthalfdaykey =
"Afternoon";
529 $endhalfdaykey =
"Afternoon";
530 } elseif (
$object->halfday == 1) {
531 $starthalfdaykey =
"Morning";
532 $endhalfdaykey =
"Morning";
534 $starthalfdaykey =
"Morning";
535 $endhalfdaykey =
"Afternoon";
538 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
541 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
542 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
543 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Period").
" : ".
dol_print_date(
$object->date_debut,
'day').
" ".$langs->transnoentitiesnoconv($starthalfdaykey).
" ".$langs->transnoentitiesnoconv(
"To").
" ".
dol_print_date(
$object->date_fin,
'day').
" ".$langs->transnoentitiesnoconv($endhalfdaykey).
"</li>\n";
544 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
545 $message .=
"</ul>\n";
547 $trackid =
'leav'.$object->id;
551 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
554 $result = $mail->sendfile();
560 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
570 if ($action ==
'update_extras') {
574 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
581 $result =
$object->insertExtraFields(
'HOLIDAY_MODIFY');
589 $action =
'edit_extras';
594 if ($action ==
'confirm_valid') {
602 $object->fk_user_approve = $user->id;
610 $verif =
$object->approve($user);
617 if (!$error && empty($decrease)) {
621 $newSolde = ($soldeActuel - $nbopenedday);
622 $label =
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayConsumption");
641 $destinataire =
new User($db);
642 $destinataire->fetch(
$object->fk_user);
643 $emailTo = $destinataire->email;
646 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
649 $expediteur =
new User($db);
650 $expediteur->fetch(
$object->fk_validator);
660 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
663 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
669 $message .=
"<ul>\n";
670 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
671 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
672 $message .=
"</ul>\n";
674 $trackid =
'leav'.$object->id;
678 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
681 $result = $mail->sendfile();
693 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
702 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
703 if (
GETPOST(
'detail_refuse')) {
709 $object->fk_user_refuse = $user->id;
716 $verif =
$object->update($user);
725 $destinataire =
new User($db);
726 $destinataire->fetch(
$object->fk_user);
727 $emailTo = $destinataire->email;
730 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
733 $expediteur =
new User($db);
734 $expediteur->fetch(
$object->fk_validator);
744 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
747 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
750 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
754 $message .=
"<ul>\n";
755 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
756 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
759 $trackid =
'leav'.$object->id;
763 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
766 $result = $mail->sendfile();
780 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
788 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
795 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes') {
804 $result =
$object->update($user);
813 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
821 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
828 (!empty($user->admin) || $user->id ==
$object->fk_validator || $permissiontoadd || $permissiontoaddall)) {
833 $object->fk_user_cancel = $user->id;
839 $result =
$object->update($user);
843 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
848 $startDate =
$object->date_debut_gmt;
849 $endDate =
$object->date_fin_gmt;
851 if (!empty($decrease)) {
853 $date = strtotime(
'-1 month', $lastUpdate);
854 $endOfMonthBeforeLastUpdate =
dol_mktime(0, 0, 0, (
int) date(
'm', $date), (
int) date(
't', $date), (
int) date(
'Y', $date), 1);
855 if (
$object->date_debut_gmt < $endOfMonthBeforeLastUpdate &&
$object->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
856 $endDate = $endOfMonthBeforeLastUpdate;
857 } elseif (
$object->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
858 $endDate = $startDate;
866 $newSolde = ($soldeActuel + $nbopenedday);
869 $result1 =
$object->addLogCP($user->id,
$object->fk_user,
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayCreditAfterCancellation"), $newSolde,
$object->fk_type);
874 if ($result1 < 0 || $result2 < 0) {
887 if (!$error && $result > 0) {
889 $destinataire =
new User($db);
890 $destinataire->fetch(
$object->fk_user);
891 $emailTo = $destinataire->email;
894 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
899 $expediteur =
new User($db);
900 $expediteur->fetch(
$object->fk_user_cancel);
910 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
913 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
919 $message .=
"<ul>\n";
920 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
921 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
922 $message .=
"</ul>\n";
924 $trackid =
'leav'.$object->id;
928 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
931 $result = $mail->sendfile();
937 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
967$form =
new Form($db);
970$listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
972$title = $langs->trans(
'Leave');
973$help_url =
'EN:Module_Holiday';
975llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-card');
979if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
981 if ((in_array($fuserid, $childids) && !$user->hasRight(
'holiday',
'write')) || (!in_array($fuserid, $childids) && ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'holiday',
'writeall_advance') || !$user->hasRight(
'holiday',
'writeall'))))) {
982 $errors[] = $langs->trans(
'CantCreateCP');
991 $errors[] = $langs->trans(
'ErrorEndDateCP');
994 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
997 $errors[] = $langs->trans(
'CantCreateCP');
1000 $errors[] = $langs->trans(
'InvalidValidatorCP');
1003 $errors[] = $langs->trans(
'NoDateDebut');
1006 $errors[] = $langs->trans(
'NoDateFin');
1008 case 'DureeHoliday':
1009 $errors[] = $langs->trans(
'ErrorDureeCP');
1012 $errors[] = $langs->trans(
'alreadyCPexist');
1020 print
'<script type="text/javascript">
1021 $( document ).ready(function() {
1022 $("input.button-save").click("submit", function(e) {
1023 console.log("Call valider()");
1024 if (document.demandeCP.date_debut_.value != "")
1026 if(document.demandeCP.date_fin_.value != "")
1028 if(document.demandeCP.valideur.value != "-1") {
1032 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
1038 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
1044 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
1053 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="demandeCP">'.
"\n";
1054 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1055 print
'<input type="hidden" name="action" value="add" />'.
"\n";
1061 print
'<table class="border centpercent">';
1066 print
'<td class="titlefield fieldrequired tdtop">'.$langs->trans(
"User").
'</td>';
1067 print
'<td><div class="inline-block">';
1068 if ($permissiontoadd && !$permissiontoaddall) {
1069 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(($fuserid ? $fuserid : $user->id),
'fuserid', 0,
'', 0,
'hierarchyme',
'',
'0,'.$conf->entity, 0, 0, $morefilter, 0,
'',
'minwidth200 maxwidth500 inline-block');
1072 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($fuserid ? $fuserid : $user->id,
'fuserid', 0,
'', 0,
'',
'',
'0,'.$conf->entity, 0, 0, $morefilter, 0,
'',
'minwidth200 maxwidth500 inline-block');
1077 print
'<div class="leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">';
1081 $typeleaves =
$object->getTypes(1, 1);
1082 foreach ($typeleaves as $key => $val) {
1083 $nb_type =
$object->getCPforUser(($fuserid ? $fuserid : $user->id), $val[
'rowid']);
1084 $nb_holiday += $nb_type;
1086 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
1089 print
' ';
1091 $htmltooltip = $langs->trans(
"Detail").
'<br>';
1092 $htmltooltip .= $out;
1094 print $form->textwithtooltip($langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
' '.
img_picto(
'',
'help'), $htmltooltip);
1097 if (!empty($conf->use_javascript_ajax)) {
1099 print
'$( document ).ready(function() {
1100 jQuery("#fuserid").change(function() {
1101 console.log("We change to user id "+jQuery("#fuserid").val());
1102 if (jQuery("#fuserid").val() == '.((int) $user->id).
') {
1103 jQuery(".leaveuserbalance").show();
1105 jQuery(".leaveuserbalance").hide();
1112 print
'<div class="leaveuserbalance paddingtop">';
1122 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1124 $typeleaves =
$object->getTypes(1, -1);
1125 $arraytypeleaves = array();
1126 foreach ($typeleaves as $key => $val) {
1127 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1128 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1129 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1131 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'', true);
1133 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1140 print
'<td class="fieldrequired">';
1141 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1143 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1144 if (!
GETPOST(
'date_debut_')) {
1145 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1148 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1150 print
' ';
1151 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1157 print
'<td class="fieldrequired">';
1158 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1160 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1162 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1165 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1167 print
' ';
1168 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1174 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1178 $include_users =
$object->fetch_users_approver_holiday();
1179 if (empty($include_users)) {
1180 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1184 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1191 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1192 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1201 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1202 print
'<td class="tdtop">';
1203 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1204 print $doleditor->Create(1);
1208 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1215 print $form->buttonsSaveCancel(
"SendRequestCP");
1217 print
'</from>'.
"\n";
1220 if ($error && $action !=
'edit') {
1221 print
'<div class="tabBar">';
1223 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1227 if (($id > 0) || $ref) {
1228 $result =
$object->fetch($id, $ref);
1230 $approverexpected =
new User($db);
1231 $approverexpected->fetch(
$object->fk_validator);
1233 $userRequest =
new User($db);
1234 $userRequest->fetch(
$object->fk_user);
1242 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1245 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP');
1248 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1251 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1254 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1257 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1259 case 'DureeHoliday':
1260 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1262 case 'NoMotifRefuse':
1263 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1266 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend');
1282 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">'.
"\n";
1283 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1284 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1285 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1288 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1290 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1292 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref');
1295 print
'<div class="fichecenter">';
1296 print
'<div class="fichehalfleft">';
1297 print
'<div class="underbanner clearboth"></div>';
1299 print
'<table class="border tableforfield centpercent">';
1304 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1306 print $userRequest->getNomUrl(-1,
'leave');
1311 print
'<td>'.$langs->trans(
"Type").
'</td>';
1313 $typeleaves =
$object->getTypes(1, -1);
1314 if (empty($typeleaves[
$object->fk_type])) {
1315 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
1317 $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']);
1323 $starthalfday = (
$object->halfday == -1 ||
$object->halfday == 2) ?
'afternoon' :
'morning';
1324 $endhalfday = (
$object->halfday == 1 ||
$object->halfday == 2) ?
'morning' :
'afternoon';
1328 print
'<td class="nowrap">';
1329 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1331 print
'<td>'.dol_print_date(
$object->date_debut,
'day');
1332 print
' ';
1333 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1338 print
'<td class="nowrap">';
1339 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1343 print $form->selectDate($tmpdate ? $tmpdate :
$object->date_debut,
'date_debut_');
1344 print
' ';
1345 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1352 print
'<td class="nowrap">';
1353 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1355 print
'<td>'.dol_print_date(
$object->date_fin,
'day');
1356 print
' ';
1357 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1362 print
'<td class="nowrap">';
1363 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1366 print $form->selectDate(
$object->date_fin,
'date_fin_');
1367 print
' ';
1368 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1376 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1377 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
1378 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
1379 if ($includesaturday) {
1380 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1382 if ($includesunday) {
1383 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1385 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1394 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1395 print
'<td>'.$object->detail_refuse.
'</td>';
1402 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1403 print
'<td>'.nl2br(
$object->description).
'</td>';
1407 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1408 print
'<td class="tdtop">';
1409 $doleditor =
new DolEditor(
'description',
$object->description,
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1410 print $doleditor->Create(1);
1415 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1418 print
'</table>'.
"\n";
1421 print
'<div class="fichehalfright">';
1423 print
'<div class="underbanner clearboth"></div>';
1426 print
'<table class="border tableforfield centpercent">'.
"\n";
1429 if (!empty(
$object->fk_user_create)) {
1430 $userCreate =
new User($db);
1431 $userCreate->fetch(
$object->fk_user_create);
1433 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1434 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1439 if (!$edit && $action !=
'editvalidator') {
1441 print
'<td class="titlefield">';
1443 print $langs->trans(
'ApprovedBy');
1445 print $langs->trans(
'ReviewedByCP');
1450 if (
$object->fk_user_approve > 0) {
1451 $approverdone =
new User($db);
1452 $approverdone->fetch(
$object->fk_user_approve);
1453 print $approverdone->getNomUrl(-1);
1456 print $approverexpected->getNomUrl(-1);
1458 $include_users =
$object->fetch_users_approver_holiday();
1460 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1466 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1468 $include_users =
$object->fetch_users_approver_holiday();
1469 if (!in_array(
$object->fk_validator, $include_users)) {
1470 $include_users[] =
$object->fk_validator;
1472 if (empty($include_users)) {
1473 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1475 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1476 $s = $form->select_dolusers(
$object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1477 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1479 if ($action ==
'editvalidator') {
1480 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1481 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1488 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1489 print
'<td>'.dol_print_date(
$object->date_create,
'dayhour',
'tzuser').
'</td>';
1493 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1494 print
'<td>'.dol_print_date(
$object->date_approval,
'dayhour',
'tzuser').
'</td>';
1499 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1500 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1505 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1506 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1515 print
'<div class="clearboth"></div>';
1521 if ($action ==
'delete') {
1523 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1529 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1533 if ($action ==
'valid') {
1534 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1538 if ($action ==
'refuse') {
1539 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1540 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1544 if ($action ==
'cancel') {
1545 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1549 if ($action ==
'backtodraft') {
1550 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1556 print $form->buttonsSaveCancel();
1566 print
'<div class="tabsAction">';
1569 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1573 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=sendToValidate&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1578 if (($user->id ==
$object->fk_validator || $permissiontoaddall) && $user->hasRight(
'holiday',
'approve')) {
1579 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1580 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=refuse&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1582 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1583 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1586 if ($permissiontoadd || $permissiontoaddall) {
1588 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1590 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1596 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $permissiontoadd || $permissiontoaddall) {
1597 if ((
$object->date_fin >
dol_now()) || !empty($user->admin) || $user->id ==
$object->fk_user_approve) {
1598 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1600 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1603 if (!empty($user->admin)) {
1604 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1606 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1612 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1615 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1621 print
'<div class="tabBar">';
1622 print $langs->trans(
'ErrorUserViewCP');
1623 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1627 print
'<div class="tabBar">';
1628 print $langs->trans(
'ErrorIDFicheCP');
1629 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1635 if (
GETPOST(
'modelselected')) {
1636 $action =
'presend';
1639 if ($action !=
'presend' && $action !=
'edit') {
1640 print
'<div class="fichecenter"><div class="fichehalfleft">';
1641 print
'<a name="builddoc"></a>';
1643 $includedocgeneration = 0;
1646 if ($includedocgeneration) {
1648 $relativepath = $objref.
'/'.$objref.
'.pdf';
1649 $filedir = $conf->holiday->dir_output.
'/'.
$object->element.
'/'.$objref;
1650 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1651 $genallowed = ($user->hasRight(
'holiday',
'read') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'readall');
1652 $delallowed = ($user->hasRight(
'holiday',
'write') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'writeall_advance');
1653 print $formfile->showdocuments(
'holiday:Holiday',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1661 print
'</div><div class="fichehalfright">';
1664 $morehtmlright =
'';
1667 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1669 $somethingshown = $formactions->showactions(
$object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
1671 print
'</div></div>';
1679if (is_object($db)) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class of the module paid holiday.
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
const STATUS_REFUSED
Refused.
const STATUS_CANCELED
Canceled.
const STATUS_APPROVED
Approved.
Class to manage Dolibarr users.
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)
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
holiday_prepare_head($object)
Return array head with list of tabs to view object information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.