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);
88if (($id > 0) || $ref) {
93 if ($user->hasRight(
'holiday',
'readall')) {
96 if ($user->hasRight(
'holiday',
'read') && in_array(
$object->fk_user, $childids)) {
105$hookmanager->initHooks(array(
'holidaycard',
'globalcard'));
108$permissiontoaddall = 0;
109if ($user->hasRight(
'holiday',
'write') && in_array($fuserid, $childids)) {
110 $permissiontoadd = 1;
112if ($user->hasRight(
'holiday',
'writeall')) {
113 $permissiontoadd = 1;
114 $permissiontoaddall = 1;
118if ($user->hasRight(
'holiday',
'delete')) {
127 $socid = $user->socid;
136$parameters = array(
'socid' => $socid);
137$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
142if (empty($reshook)) {
143 $backurlforlist = DOL_URL_ROOT.
'/holiday/list.php';
145 if (empty($backtopage) || ($cancel && empty($id))) {
146 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
147 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
148 $backtopage = $backurlforlist;
150 $backtopage = DOL_URL_ROOT.
'/holiday/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
156 if (!empty($backtopageforcancel)) {
157 header(
"Location: ".$backtopageforcancel);
159 } elseif (!empty($backtopage)) {
160 header(
"Location: ".$backtopage);
167 if ($action ==
'add' && $permissiontoadd) {
176 $starthalfday =
GETPOST(
'starthalfday');
177 $endhalfday =
GETPOST(
'endhalfday');
180 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
182 } elseif ($starthalfday ==
'afternoon') {
184 } elseif ($endhalfday ==
'morning') {
189 $description = trim(
GETPOST(
'description',
'restricthtml'));
192 if (!$permissiontoaddall) {
194 if (!$user->hasRight(
'holiday',
'write')) {
197 } elseif (!in_array($fuserid, $childids)) {
203 if (!$user->hasRight(
'holiday',
'write') && !$user->hasRight(
'holiday',
'writeall_advance')) {
206 } elseif (!$user->hasRight(
'holiday',
'writeall_advance') && !in_array($fuserid, $childids)) {
216 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
222 if (empty($date_debut)) {
228 if (empty($date_fin)) {
234 if ($date_debut > $date_fin) {
241 $verifCP =
$object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
249 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
250 if ($nbopenedday < 0.5) {
257 if ($approverid < 1) {
258 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'),
null,
'errors');
262 $approverslist =
$object->fetch_users_approver_holiday();
263 if (!in_array($approverid, $approverslist)) {
264 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidator'),
null,
'errors');
269 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
278 $object->description = $description;
279 $object->fk_validator = $approverid;
281 $object->date_debut = $date_debut;
286 $result =
$object->create($user);
297 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
305 if ($action ==
'update' && GETPOSTISSET(
'savevalidator') && $user->hasRight(
'holiday',
'approve')) {
313 $verif =
$object->update($user);
317 $action =
'editvalidator';
319 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
327 if ($action ==
'update' && !GETPOSTISSET(
'savevalidator')) {
332 $starthalfday =
GETPOST(
'starthalfday');
333 $endhalfday =
GETPOST(
'endhalfday');
335 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
337 } elseif ($starthalfday ==
'afternoon') {
339 } elseif ($endhalfday ==
'morning') {
344 if (!$permissiontoaddall) {
345 if ($permissiontoadd) {
346 if (!in_array($fuserid, $childids)) {
348 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
353 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
363 if ($permissiontoadd) {
367 $description = trim(
GETPOST(
'description',
'restricthtml'));
377 if ($date_debut > $date_fin) {
384 if ($approverid < 1) {
391 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
392 if ($nbopenedday < 0.5) {
401 $object->description = $description;
402 $object->date_debut = $date_debut;
404 $object->fk_validator = $approverid;
408 $verif =
$object->update($user);
420 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
436 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $candelete) {
445 $result =
$object->delete($user);
454 header(
'Location: list.php?restore_lastsearch_values=1');
462 if ($action ==
'confirm_send') {
471 $verif =
$object->validate($user);
476 $destinataire =
new User($db);
477 $destinataire->fetch(
$object->fk_validator);
478 $emailTo = $destinataire->email;
481 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
482 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
487 $expediteur =
new User($db);
488 $expediteur->fetch(
$object->fk_user);
498 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
501 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
503 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateBody").
"</p>\n";
508 $delayForRequest = 0;
509 if ($delayForRequest) {
512 if (
$object->date_debut < $nowplusdelay) {
513 $message =
"<p>".$langs->transnoentities(
"HolidaysToValidateDelay", $delayForRequest).
"</p>\n";
523 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateAlertSolde").
"</p>\n";
527 $typeleaves =
$object->getTypes(1, -1);
528 if (empty($typeleaves[
$object->fk_type])) {
529 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
531 $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']);
534 $starthalfdaykey =
"Afternoon";
535 $endhalfdaykey =
"Morning";
536 } elseif (
$object->halfday == -1) {
537 $starthalfdaykey =
"Afternoon";
538 $endhalfdaykey =
"Afternoon";
539 } elseif (
$object->halfday == 1) {
540 $starthalfdaykey =
"Morning";
541 $endhalfdaykey =
"Morning";
543 $starthalfdaykey =
"Morning";
544 $endhalfdaykey =
"Afternoon";
547 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
550 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
551 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
552 $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";
553 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
554 $message .=
"</ul>\n";
556 $trackid =
'leav'.$object->id;
560 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
563 $result = $mail->sendfile();
569 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
579 if ($action ==
'update_extras') {
583 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
590 $result =
$object->insertExtraFields(
'HOLIDAY_MODIFY');
598 $action =
'edit_extras';
603 if ($action ==
'confirm_valid') {
611 $object->fk_user_approve = $user->id;
619 $verif =
$object->approve($user);
626 if (!$error && empty($decrease)) {
630 $newSolde = ($soldeActuel - $nbopenedday);
631 $label =
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayConsumption");
650 $destinataire =
new User($db);
651 $destinataire->fetch(
$object->fk_user);
652 $emailTo = $destinataire->email;
655 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
658 $expediteur =
new User($db);
659 $expediteur->fetch(
$object->fk_validator);
669 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
672 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
678 $message .=
"<ul>\n";
679 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
680 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
681 $message .=
"</ul>\n";
683 $trackid =
'leav'.$object->id;
687 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
690 $result = $mail->sendfile();
702 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
711 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
712 if (
GETPOST(
'detail_refuse')) {
718 $object->fk_user_refuse = $user->id;
725 $verif =
$object->update($user);
734 $destinataire =
new User($db);
735 $destinataire->fetch(
$object->fk_user);
736 $emailTo = $destinataire->email;
739 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
742 $expediteur =
new User($db);
743 $expediteur->fetch(
$object->fk_validator);
753 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
756 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
759 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
763 $message .=
"<ul>\n";
764 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
765 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
768 $trackid =
'leav'.$object->id;
772 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
775 $result = $mail->sendfile();
789 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
797 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
804 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes') {
813 $result =
$object->update($user);
822 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
830 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
837 (!empty($user->admin) || $user->id ==
$object->fk_validator || $permissiontoadd || $permissiontoaddall)) {
842 $object->fk_user_cancel = $user->id;
848 $result =
$object->update($user);
852 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
857 $startDate =
$object->date_debut_gmt;
858 $endDate =
$object->date_fin_gmt;
860 if (!empty($decrease)) {
862 $date = strtotime(
'-1 month', $lastUpdate);
863 $endOfMonthBeforeLastUpdate =
dol_mktime(0, 0, 0, (
int) date(
'm', $date), (
int) date(
't', $date), (
int) date(
'Y', $date), 1);
864 if (
$object->date_debut_gmt < $endOfMonthBeforeLastUpdate &&
$object->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
865 $endDate = $endOfMonthBeforeLastUpdate;
866 } elseif (
$object->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
867 $endDate = $startDate;
875 $newSolde = ($soldeActuel + $nbopenedday);
878 $result1 =
$object->addLogCP($user->id,
$object->fk_user,
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayCreditAfterCancellation"), $newSolde,
$object->fk_type);
883 if ($result1 < 0 || $result2 < 0) {
896 if (!$error && $result > 0) {
898 $destinataire =
new User($db);
899 $destinataire->fetch(
$object->fk_user);
900 $emailTo = $destinataire->email;
903 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
908 $expediteur =
new User($db);
909 $expediteur->fetch(
$object->fk_user_cancel);
919 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
922 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
928 $message .=
"<ul>\n";
929 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
930 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
931 $message .=
"</ul>\n";
933 $trackid =
'leav'.$object->id;
937 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
940 $result = $mail->sendfile();
946 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
976$form =
new Form($db);
980$listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
982$title = $langs->trans(
'Leave');
983$help_url =
'EN:Module_Holiday';
985llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-card');
989if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
991 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'))))) {
992 $errors[] = $langs->trans(
'CantCreateCP');
1001 $errors[] = $langs->trans(
'ErrorEndDateCP');
1004 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
1007 $errors[] = $langs->trans(
'CantCreateCP');
1010 $errors[] = $langs->trans(
'InvalidValidatorCP');
1013 $errors[] = $langs->trans(
'NoDateDebut');
1016 $errors[] = $langs->trans(
'NoDateFin');
1018 case 'DureeHoliday':
1019 $errors[] = $langs->trans(
'ErrorDureeCP');
1022 $errors[] = $langs->trans(
'alreadyCPexist');
1030 print
'<script type="text/javascript">
1031 $( document ).ready(function() {
1032 $("input.button-save").click("submit", function(e) {
1033 console.log("Call valider()");
1034 if (document.demandeCP.date_debut_.value != "")
1036 if(document.demandeCP.date_fin_.value != "")
1038 if(document.demandeCP.valideur.value != "-1") {
1042 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
1048 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
1054 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
1063 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="demandeCP">'.
"\n";
1064 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1065 print
'<input type="hidden" name="action" value="add" />'.
"\n";
1071 print
'<table class="border centpercent">';
1076 print
'<td class="titlefield fieldrequired tdtop">'.$langs->trans(
"User").
'</td>';
1077 print
'<td><div class="inline-block">';
1078 if ($permissiontoadd && !$permissiontoaddall) {
1079 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');
1082 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');
1087 print
'<div class="leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">';
1091 $typeleaves =
$object->getTypes(1, 1);
1092 foreach ($typeleaves as $key => $val) {
1093 $nb_type =
$object->getCPforUser(($fuserid ? $fuserid : $user->id), $val[
'rowid']);
1094 $nb_holiday += $nb_type;
1096 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
1099 print
' ';
1101 $htmltooltip = $langs->trans(
"Detail").
'<br>';
1102 $htmltooltip .= $out;
1104 print $form->textwithtooltip($langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
' '.
img_picto(
'',
'help'), $htmltooltip);
1107 if (!empty(
$conf->use_javascript_ajax)) {
1109 print
'$( document ).ready(function() {
1110 jQuery("#fuserid").change(function() {
1111 console.log("We change to user id "+jQuery("#fuserid").val());
1112 if (jQuery("#fuserid").val() == '.((int) $user->id).
') {
1113 jQuery(".leaveuserbalance").show();
1115 jQuery(".leaveuserbalance").hide();
1122 print
'<div class="leaveuserbalance paddingtop">';
1132 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1134 $typeleaves =
$object->getTypes(1, -1);
1135 $arraytypeleaves = array();
1136 foreach ($typeleaves as $key => $val) {
1137 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1138 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1139 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1141 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'', true);
1143 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1150 print
'<td class="fieldrequired">';
1151 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1153 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1154 if (!
GETPOST(
'date_debut_')) {
1155 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1158 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1160 print
' ';
1161 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1167 print
'<td class="fieldrequired">';
1168 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1170 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1172 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1175 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1177 print
' ';
1178 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1184 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1188 $include_users =
$object->fetch_users_approver_holiday();
1189 if (empty($include_users)) {
1190 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1194 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1201 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.
$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1202 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1211 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1212 print
'<td class="tdtop">';
1213 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1214 print $doleditor->Create(1);
1218 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1225 print $form->buttonsSaveCancel(
"SendRequestCP");
1227 print
'</from>'.
"\n";
1230 if ($error && $action !=
'edit') {
1231 print
'<div class="tabBar">';
1233 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1237 if (($id > 0) || $ref) {
1238 $result =
$object->fetch($id, $ref);
1240 $approverexpected =
new User($db);
1241 $approverexpected->fetch(
$object->fk_validator);
1243 $userRequest =
new User($db);
1244 $userRequest->fetch(
$object->fk_user);
1252 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1255 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP');
1258 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1261 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1264 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1267 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1269 case 'DureeHoliday':
1270 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1272 case 'NoMotifRefuse':
1273 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1276 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend');
1292 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">'.
"\n";
1293 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1294 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1295 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1298 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1300 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1302 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref');
1305 print
'<div class="fichecenter">';
1306 print
'<div class="fichehalfleft">';
1307 print
'<div class="underbanner clearboth"></div>';
1309 print
'<table class="border tableforfield centpercent">';
1314 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1316 print $userRequest->getNomUrl(-1,
'leave');
1321 print
'<td>'.$langs->trans(
"Type").
'</td>';
1323 $typeleaves =
$object->getTypes(1, -1);
1324 if (empty($typeleaves[
$object->fk_type])) {
1325 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
1327 $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']);
1333 $starthalfday = (
$object->halfday == -1 ||
$object->halfday == 2) ?
'afternoon' :
'morning';
1334 $endhalfday = (
$object->halfday == 1 ||
$object->halfday == 2) ?
'morning' :
'afternoon';
1338 print
'<td class="nowrap">';
1339 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1341 print
'<td>'.dol_print_date(
$object->date_debut,
'day');
1342 print
' ';
1343 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1348 print
'<td class="nowrap">';
1349 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1353 print $form->selectDate($tmpdate ? $tmpdate :
$object->date_debut,
'date_debut_');
1354 print
' ';
1355 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1362 print
'<td class="nowrap">';
1363 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1365 print
'<td>'.dol_print_date(
$object->date_fin,
'day');
1366 print
' ';
1367 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1372 print
'<td class="nowrap">';
1373 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1376 print $form->selectDate(
$object->date_fin,
'date_fin_');
1377 print
' ';
1378 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1386 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1387 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
1388 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
1389 if ($includesaturday) {
1390 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1392 if ($includesunday) {
1393 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1395 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1404 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1405 print
'<td>'.$object->detail_refuse.
'</td>';
1412 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1413 print
'<td>'.nl2br(
$object->description).
'</td>';
1417 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1418 print
'<td class="tdtop">';
1419 $doleditor =
new DolEditor(
'description',
$object->description,
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1420 print $doleditor->Create(1);
1425 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1428 print
'</table>'.
"\n";
1431 print
'<div class="fichehalfright">';
1433 print
'<div class="underbanner clearboth"></div>';
1436 print
'<table class="border tableforfield centpercent">'.
"\n";
1439 if (!empty(
$object->fk_user_create)) {
1440 $userCreate =
new User($db);
1441 $userCreate->fetch(
$object->fk_user_create);
1443 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1444 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1449 if (!$edit && $action !=
'editvalidator') {
1451 print
'<td class="titlefield">';
1453 print $langs->trans(
'ApprovedBy');
1455 print $langs->trans(
'ReviewedByCP');
1460 if (
$object->fk_user_approve > 0) {
1461 $approverdone =
new User($db);
1462 $approverdone->fetch(
$object->fk_user_approve);
1463 print $approverdone->getNomUrl(-1);
1466 print $approverexpected->getNomUrl(-1);
1468 $include_users =
$object->fetch_users_approver_holiday();
1470 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1476 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1478 $include_users =
$object->fetch_users_approver_holiday();
1479 if (!in_array(
$object->fk_validator, $include_users)) {
1480 $include_users[] =
$object->fk_validator;
1482 if (empty($include_users)) {
1483 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1485 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1486 $s = $form->select_dolusers(
$object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1487 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1489 if ($action ==
'editvalidator') {
1490 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1491 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1498 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1499 print
'<td>'.dol_print_date(
$object->date_create,
'dayhour',
'tzuser').
'</td>';
1503 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1504 print
'<td>'.dol_print_date(
$object->date_approval,
'dayhour',
'tzuser').
'</td>';
1509 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1510 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1515 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1516 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1525 print
'<div class="clearboth"></div>';
1531 if ($action ==
'delete') {
1533 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1539 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1543 if ($action ==
'valid') {
1544 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1548 if ($action ==
'refuse') {
1549 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1550 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1554 if ($action ==
'cancel') {
1555 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1559 if ($action ==
'backtodraft') {
1560 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1566 print $form->buttonsSaveCancel();
1576 print
'<div class="tabsAction">';
1579 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1583 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=sendToValidate&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1588 if (($user->id ==
$object->fk_validator || $permissiontoaddall) && $user->hasRight(
'holiday',
'approve')) {
1589 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1590 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=refuse&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1592 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1593 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1596 if ($permissiontoadd || $permissiontoaddall) {
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>';
1606 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $permissiontoadd || $permissiontoaddall) {
1607 if ((
$object->date_fin >
dol_now()) || !empty($user->admin) || $user->id ==
$object->fk_user_approve) {
1608 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1610 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1613 if (!empty($user->admin)) {
1614 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1616 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1622 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1625 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1631 print
'<div class="tabBar">';
1632 print $langs->trans(
'ErrorUserViewCP');
1633 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1637 print
'<div class="tabBar">';
1638 print $langs->trans(
'ErrorIDFicheCP');
1639 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1645 if (
GETPOST(
'modelselected')) {
1646 $action =
'presend';
1649 if ($action !=
'presend' && $action !=
'edit') {
1650 print
'<div class="fichecenter"><div class="fichehalfleft">';
1651 print
'<a name="builddoc"></a>';
1653 $includedocgeneration = 0;
1656 if ($includedocgeneration) {
1658 $relativepath = $objref.
'/'.$objref.
'.pdf';
1659 $filedir =
$conf->holiday->dir_output.
'/'.
$object->element.
'/'.$objref;
1660 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1661 $genallowed = ($user->hasRight(
'holiday',
'read') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'readall');
1662 $delallowed = ($user->hasRight(
'holiday',
'write') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'writeall_advance');
1663 print $formfile->showdocuments(
'holiday:Holiday',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1671 print
'</div><div class="fichehalfright">';
1674 $morehtmlright =
'';
1677 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1679 $somethingshown = $formactions->showactions(
$object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
1681 print
'</div></div>';
1689if (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'.
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 =...
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.
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.