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';
55$action =
GETPOST(
'action',
'aZ09');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$confirm =
GETPOST(
'confirm',
'alpha');
58$backtopage =
GETPOST(
'backtopage',
'alpha');
59$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
67$langs->loadLangs(array(
"other",
"holiday",
"mails",
"trips"));
74$childids = $user->getAllChildIds(1);
78 $morefilter =
'AND employee = 1';
86$extrafields->fetch_name_optionals_label(
$object->table_element);
89$hookmanager->initHooks(array(
'holidaycard',
'globalcard'));
91$permissiontoapprove = $user->hasRight(
'holiday',
'approve');
94if (($id > 0) || $ref) {
98 if ($user->hasRight(
'holiday',
'readall')) {
101 if ($user->hasRight(
'holiday',
'read') && in_array(
$object->fk_user, $childids)) {
104 if ($permissiontoapprove &&
$object->fk_validator == $user->id && !
getDolGlobalString(
'HOLIDAY_CAN_APPROVE_ONLY_THE_SUBORDINATES')) {
113$permissiontoaddall = 0;
114if ($user->hasRight(
'holiday',
'write') && in_array($fuserid, $childids)) {
115 $permissiontoadd = 1;
117if ($user->hasRight(
'holiday',
'writeall')) {
118 $permissiontoadd = 1;
119 $permissiontoaddall = 1;
123if ($user->hasRight(
'holiday',
'delete')) {
132 $socid = $user->socid;
141$parameters = array(
'socid' => $socid);
142$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
147if (empty($reshook)) {
148 $backurlforlist = DOL_URL_ROOT.
'/holiday/list.php';
150 if (empty($backtopage) || ($cancel && empty($id))) {
151 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
152 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
153 $backtopage = $backurlforlist;
155 $backtopage = DOL_URL_ROOT.
'/holiday/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
161 if (!empty($backtopageforcancel)) {
162 header(
"Location: ".$backtopageforcancel);
164 } elseif (!empty($backtopage)) {
165 header(
"Location: ".$backtopage);
172 if ($action ==
'add' && $permissiontoadd) {
177 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
179 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
180 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
181 $starthalfday =
GETPOST(
'starthalfday');
182 $endhalfday =
GETPOST(
'endhalfday');
185 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
187 } elseif ($starthalfday ==
'afternoon') {
189 } elseif ($endhalfday ==
'morning') {
194 $description = trim(
GETPOST(
'description',
'restricthtml'));
197 if (!$permissiontoaddall) {
199 if (!$user->hasRight(
'holiday',
'write')) {
202 } elseif (!in_array($fuserid, $childids)) {
208 if (!$user->hasRight(
'holiday',
'write') && !$user->hasRight(
'holiday',
'writeall_advance')) {
211 } elseif (!$user->hasRight(
'holiday',
'writeall_advance') && !in_array($fuserid, $childids)) {
221 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
227 if (empty($date_debut)) {
233 if (empty($date_fin)) {
239 if ($date_debut > $date_fin) {
246 $verifCP =
$object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
254 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
255 if ($nbopenedday < 0.5) {
262 if ($approverid < 1) {
263 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'),
null,
'errors');
267 $approverslist =
$object->fetch_users_approver_holiday();
268 if (!in_array($approverid, $approverslist)) {
269 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidator'),
null,
'errors');
274 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
283 $object->description = $description;
284 $object->fk_validator = $approverid;
286 $object->date_debut = $date_debut;
291 $result =
$object->create($user);
302 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
310 if ($action ==
'update' && GETPOSTISSET(
'savevalidator') && $permissiontoapprove) {
318 $verif =
$object->update($user);
322 $action =
'editvalidator';
324 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
332 if ($action ==
'update' && !GETPOSTISSET(
'savevalidator')) {
333 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
335 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
336 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
337 $starthalfday =
GETPOST(
'starthalfday');
338 $endhalfday =
GETPOST(
'endhalfday');
340 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
342 } elseif ($starthalfday ==
'afternoon') {
344 } elseif ($endhalfday ==
'morning') {
349 if (!$permissiontoaddall) {
350 if ($permissiontoadd) {
351 if (!in_array($fuserid, $childids)) {
353 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
358 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
368 if ($permissiontoadd) {
372 $description = trim(
GETPOST(
'description',
'restricthtml'));
382 if ($date_debut > $date_fin) {
389 if ($approverid < 1) {
396 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
397 if ($nbopenedday < 0.5) {
406 $object->description = $description;
407 $object->date_debut = $date_debut;
409 $object->fk_validator = $approverid;
413 $verif =
$object->update($user);
425 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
441 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $candelete) {
450 $result =
$object->delete($user);
459 header(
'Location: list.php?restore_lastsearch_values=1');
467 if ($action ==
'confirm_send') {
476 $verif =
$object->validate($user);
481 $destinataire =
new User($db);
482 $destinataire->fetch(
$object->fk_validator);
483 $emailTo = $destinataire->email;
486 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
487 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
492 $expediteur =
new User($db);
493 $expediteur->fetch(
$object->fk_user);
503 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
506 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
508 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateBody").
"</p>\n";
513 $delayForRequest = 0;
514 if ($delayForRequest) {
517 if (
$object->date_debut < $nowplusdelay) {
518 $message =
"<p>".$langs->transnoentities(
"HolidaysToValidateDelay", $delayForRequest).
"</p>\n";
528 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateAlertSolde").
"</p>\n";
532 $typeleaves =
$object->getTypes(1, -1);
533 if (empty($typeleaves[
$object->fk_type])) {
534 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
536 $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']);
539 $starthalfdaykey =
"Afternoon";
540 $endhalfdaykey =
"Morning";
541 } elseif (
$object->halfday == -1) {
542 $starthalfdaykey =
"Afternoon";
543 $endhalfdaykey =
"Afternoon";
544 } elseif (
$object->halfday == 1) {
545 $starthalfdaykey =
"Morning";
546 $endhalfdaykey =
"Morning";
548 $starthalfdaykey =
"Morning";
549 $endhalfdaykey =
"Afternoon";
551 $starthalfdaykey =
"";
555 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
558 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
559 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
560 $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";
561 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
562 $message .=
"</ul>\n";
564 $trackid =
'leav'.$object->id;
568 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
571 $result = $mail->sendfile();
577 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
587 if ($action ==
'update_extras') {
591 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
598 $result =
$object->insertExtraFields(
'HOLIDAY_MODIFY');
606 $action =
'edit_extras';
611 if ($action ==
'confirm_valid') {
619 $object->fk_user_approve = $user->id;
627 $verif =
$object->approve($user);
634 if (!$error && empty($decrease)) {
638 $newSolde = ($soldeActuel - $nbopenedday);
639 $label =
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayConsumption");
658 $destinataire =
new User($db);
659 $destinataire->fetch(
$object->fk_user);
660 $emailTo = $destinataire->email;
663 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
666 $expediteur =
new User($db);
667 $expediteur->fetch(
$object->fk_validator);
677 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
680 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
686 $message .=
"<ul>\n";
687 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
688 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
689 $message .=
"</ul>\n";
691 $trackid =
'leav'.$object->id;
695 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
698 $result = $mail->sendfile();
710 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
719 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
720 if (
GETPOST(
'detail_refuse')) {
726 $object->fk_user_refuse = $user->id;
733 $verif =
$object->update($user);
742 $destinataire =
new User($db);
743 $destinataire->fetch(
$object->fk_user);
744 $emailTo = $destinataire->email;
747 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
750 $expediteur =
new User($db);
751 $expediteur->fetch(
$object->fk_validator);
761 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
764 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
767 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
771 $message .=
"<ul>\n";
772 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
773 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
776 $trackid =
'leav'.$object->id;
780 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
783 $result = $mail->sendfile();
797 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
805 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
812 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes') {
821 $result =
$object->update($user);
830 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
838 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
845 (!empty($user->admin) || $user->id ==
$object->fk_validator || $permissiontoadd || $permissiontoaddall)) {
850 $object->fk_user_cancel = $user->id;
856 $result =
$object->update($user);
860 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
865 $startDate =
$object->date_debut_gmt;
866 $endDate =
$object->date_fin_gmt;
868 if (!empty($decrease)) {
870 $date = strtotime(
'-1 month', $lastUpdate);
871 $endOfMonthBeforeLastUpdate =
dol_mktime(0, 0, 0, (
int) date(
'm', $date), (
int) date(
't', $date), (
int) date(
'Y', $date), 1);
872 if (
$object->date_debut_gmt < $endOfMonthBeforeLastUpdate &&
$object->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
873 $endDate = $endOfMonthBeforeLastUpdate;
874 } elseif (
$object->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
875 $endDate = $startDate;
883 $newSolde = ($soldeActuel + $nbopenedday);
886 $result1 =
$object->addLogCP($user->id,
$object->fk_user,
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayCreditAfterCancellation"), $newSolde,
$object->fk_type);
891 if ($result1 < 0 || $result2 < 0) {
904 if (!$error && $result > 0) {
906 $destinataire =
new User($db);
907 $destinataire->fetch(
$object->fk_user);
908 $emailTo = $destinataire->email;
911 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
916 $expediteur =
new User($db);
917 $expediteur->fetch(
$object->fk_user_cancel);
927 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
930 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
936 $message .=
"<ul>\n";
937 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
938 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
939 $message .=
"</ul>\n";
941 $trackid =
'leav'.$object->id;
945 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
948 $result = $mail->sendfile();
954 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
984$form =
new Form($db);
988$listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
990$title = $langs->trans(
'Leave');
991$help_url =
'EN:Module_Holiday';
993llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-card');
997if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
999 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'))))) {
1000 $errors[] = $langs->trans(
'CantCreateCP');
1009 $errors[] = $langs->trans(
'ErrorEndDateCP');
1012 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
1015 $errors[] = $langs->trans(
'CantCreateCP');
1018 $errors[] = $langs->trans(
'InvalidValidatorCP');
1021 $errors[] = $langs->trans(
'NoDateDebut');
1024 $errors[] = $langs->trans(
'NoDateFin');
1026 case 'DureeHoliday':
1027 $errors[] = $langs->trans(
'ErrorDureeCP');
1030 $errors[] = $langs->trans(
'alreadyCPexist');
1038 print
'<script type="text/javascript">
1039 $( document ).ready(function() {
1040 $("input.button-save").click("submit", function(e) {
1041 console.log("Call valider()");
1042 if (document.demandeCP.date_debut_.value != "")
1044 if(document.demandeCP.date_fin_.value != "")
1046 if(document.demandeCP.valideur.value != "-1") {
1050 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
1056 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
1062 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
1071 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="demandeCP">'.
"\n";
1072 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1073 print
'<input type="hidden" name="action" value="add" />'.
"\n";
1079 print
'<table class="border centpercent">';
1084 print
'<td class="titlefield fieldrequired tdtop">'.$langs->trans(
"User").
'</td>';
1085 print
'<td><div class="inline-block">';
1086 if ($permissiontoadd && !$permissiontoaddall) {
1087 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');
1090 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');
1095 print
'<div class="leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">';
1099 $typeleaves =
$object->getTypes(1, 1);
1100 foreach ($typeleaves as $key => $val) {
1101 $nb_type =
$object->getCPforUser(($fuserid ? $fuserid : $user->id), $val[
'rowid']);
1102 $nb_holiday += $nb_type;
1104 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
1107 print
' ';
1109 $htmltooltip = $langs->trans(
"Detail").
'<br>';
1110 $htmltooltip .= $out;
1112 print $form->textwithtooltip($langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
' '.
img_picto(
'',
'help'), $htmltooltip);
1115 if (!empty(
$conf->use_javascript_ajax)) {
1117 print
'$( document ).ready(function() {
1118 jQuery("#fuserid").change(function() {
1119 console.log("We change to user id "+jQuery("#fuserid").val());
1120 if (jQuery("#fuserid").val() == '.((int) $user->id).
') {
1121 jQuery(".leaveuserbalance").show();
1123 jQuery(".leaveuserbalance").hide();
1130 print
'<div class="leaveuserbalance paddingtop">';
1140 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1142 $typeleaves =
$object->getTypes(1, -1);
1143 $arraytypeleaves = array();
1144 foreach ($typeleaves as $key => $val) {
1145 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1146 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1147 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1149 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'', true);
1151 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1158 print
'<td class="fieldrequired">';
1159 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1161 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1162 if (!
GETPOST(
'date_debut_')) {
1163 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1165 $tmpdate =
GETPOSTDATE(
'date_debut_',
'00:00:00');
1166 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1168 print
' ';
1169 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1175 print
'<td class="fieldrequired">';
1176 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1178 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1180 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1183 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1185 print
' ';
1186 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1192 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1196 $include_users =
$object->fetch_users_approver_holiday();
1197 if (empty($include_users)) {
1198 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1202 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1209 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.
$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1210 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1219 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1220 print
'<td class="tdtop">';
1221 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1222 print $doleditor->Create(1);
1226 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1233 print $form->buttonsSaveCancel(
"SendRequestCP");
1235 print
'</from>'.
"\n";
1238 if ($error && $action !=
'edit') {
1239 print
'<div class="tabBar">';
1241 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1245 if (($id > 0) || $ref) {
1246 $result =
$object->fetch($id, $ref);
1248 $approverexpected =
new User($db);
1249 $approverexpected->fetch(
$object->fk_validator);
1251 $userRequest =
new User($db);
1252 $userRequest->fetch(
$object->fk_user);
1260 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1263 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP');
1266 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1269 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1272 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1275 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1277 case 'DureeHoliday':
1278 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1280 case 'NoMotifRefuse':
1281 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1284 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend');
1300 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">'.
"\n";
1301 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1302 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1303 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1306 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1308 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1310 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref');
1313 print
'<div class="fichecenter">';
1314 print
'<div class="fichehalfleft">';
1315 print
'<div class="underbanner clearboth"></div>';
1317 print
'<table class="border tableforfield centpercent">';
1322 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1324 print $userRequest->getNomUrl(-1,
'leave');
1329 print
'<td>'.$langs->trans(
"Type").
'</td>';
1331 $typeleaves =
$object->getTypes(1, -1);
1332 if (empty($typeleaves[
$object->fk_type])) {
1333 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
1335 $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']);
1341 $starthalfday = (
$object->halfday == -1 ||
$object->halfday == 2) ?
'afternoon' :
'morning';
1342 $endhalfday = (
$object->halfday == 1 ||
$object->halfday == 2) ?
'morning' :
'afternoon';
1346 print
'<td class="nowrap">';
1347 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1349 print
'<td>'.dol_print_date(
$object->date_debut,
'day');
1350 print
' ';
1351 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1356 print
'<td class="nowrap">';
1357 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1360 $tmpdate =
GETPOSTDATE(
'date_debut_',
'00:00:00');
1361 print $form->selectDate($tmpdate ? $tmpdate :
$object->date_debut,
'date_debut_');
1362 print
' ';
1363 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1370 print
'<td class="nowrap">';
1371 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1373 print
'<td>'.dol_print_date(
$object->date_fin,
'day');
1374 print
' ';
1375 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1380 print
'<td class="nowrap">';
1381 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1384 print $form->selectDate(
$object->date_fin,
'date_fin_');
1385 print
' ';
1386 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1394 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1395 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
1396 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
1397 if ($includesaturday) {
1398 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1400 if ($includesunday) {
1401 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1403 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1412 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1413 print
'<td>'.$object->detail_refuse.
'</td>';
1420 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1421 print
'<td>'.nl2br(
$object->description).
'</td>';
1425 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1426 print
'<td class="tdtop">';
1427 $doleditor =
new DolEditor(
'description',
$object->description,
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1428 print $doleditor->Create(1);
1433 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1436 print
'</table>'.
"\n";
1439 print
'<div class="fichehalfright">';
1441 print
'<div class="underbanner clearboth"></div>';
1444 print
'<table class="border tableforfield centpercent">'.
"\n";
1447 if (!empty(
$object->fk_user_create)) {
1448 $userCreate =
new User($db);
1449 $userCreate->fetch(
$object->fk_user_create);
1451 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1452 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1457 if (!$edit && $action !=
'editvalidator') {
1459 print
'<td class="titlefield">';
1461 print $langs->trans(
'ApprovedBy');
1463 print $langs->trans(
'ReviewedByCP');
1468 if (
$object->fk_user_approve > 0) {
1469 $approverdone =
new User($db);
1470 $approverdone->fetch(
$object->fk_user_approve);
1471 print $approverdone->getNomUrl(-1);
1474 print $approverexpected->getNomUrl(-1);
1476 $include_users =
$object->fetch_users_approver_holiday();
1478 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1484 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1486 $include_users =
$object->fetch_users_approver_holiday();
1487 if (!in_array(
$object->fk_validator, $include_users)) {
1488 $include_users[] =
$object->fk_validator;
1490 if (empty($include_users)) {
1491 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1493 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1494 $s = $form->select_dolusers(
$object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1495 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1497 if ($action ==
'editvalidator') {
1498 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1499 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1506 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1507 print
'<td>'.dol_print_date(
$object->date_create,
'dayhour',
'tzuser').
'</td>';
1511 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1512 print
'<td>'.dol_print_date(
$object->date_approval,
'dayhour',
'tzuser').
'</td>';
1517 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1518 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1523 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1524 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1533 print
'<div class="clearboth"></div>';
1539 if ($action ==
'delete') {
1541 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1547 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1551 if ($action ==
'valid') {
1552 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1556 if ($action ==
'refuse') {
1557 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1558 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1562 if ($action ==
'cancel') {
1563 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1567 if ($action ==
'backtodraft') {
1568 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1574 print $form->buttonsSaveCancel();
1584 print
'<div class="tabsAction">';
1587 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1591 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=sendToValidate&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1596 if (($user->id ==
$object->fk_validator || $permissiontoaddall) && $user->hasRight(
'holiday',
'approve')) {
1597 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1598 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=refuse&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1600 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1601 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1604 if ($permissiontoadd || $permissiontoaddall) {
1606 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1608 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1614 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $permissiontoadd || $permissiontoaddall) {
1615 if ((
$object->date_fin >
dol_now()) || !empty($user->admin) || $user->id ==
$object->fk_user_approve) {
1616 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1618 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1621 if (!empty($user->admin)) {
1622 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1624 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1630 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1633 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1639 print
'<div class="tabBar">';
1640 print $langs->trans(
'ErrorUserViewCP');
1641 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1645 print
'<div class="tabBar">';
1646 print $langs->trans(
'ErrorIDFicheCP');
1647 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1653 if (
GETPOST(
'modelselected')) {
1654 $action =
'presend';
1657 if ($action !=
'presend' && $action !=
'edit') {
1658 print
'<div class="fichecenter"><div class="fichehalfleft">';
1659 print
'<a name="builddoc"></a>';
1678 print
'</div><div class="fichehalfright">';
1684 $morehtmlcenter =
'';
1687 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1689 $somethingshown = $formactions->showactions(
$object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1691 print
'</div></div>';
1699if (is_object($db)) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
GETPOSTDATE($prefix, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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'.
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.