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);
89if (($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) {
172 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
174 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
175 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
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')) {
328 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
330 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
331 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
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";
546 $starthalfdaykey =
"";
550 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
553 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
554 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
555 $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";
556 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
557 $message .=
"</ul>\n";
559 $trackid =
'leav'.$object->id;
563 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
566 $result = $mail->sendfile();
572 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
582 if ($action ==
'update_extras') {
586 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
593 $result =
$object->insertExtraFields(
'HOLIDAY_MODIFY');
601 $action =
'edit_extras';
606 if ($action ==
'confirm_valid') {
614 $object->fk_user_approve = $user->id;
622 $verif =
$object->approve($user);
629 if (!$error && empty($decrease)) {
633 $newSolde = ($soldeActuel - $nbopenedday);
634 $label =
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayConsumption");
653 $destinataire =
new User($db);
654 $destinataire->fetch(
$object->fk_user);
655 $emailTo = $destinataire->email;
658 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
661 $expediteur =
new User($db);
662 $expediteur->fetch(
$object->fk_validator);
672 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
675 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
681 $message .=
"<ul>\n";
682 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
683 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
684 $message .=
"</ul>\n";
686 $trackid =
'leav'.$object->id;
690 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
693 $result = $mail->sendfile();
705 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
714 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
715 if (
GETPOST(
'detail_refuse')) {
721 $object->fk_user_refuse = $user->id;
728 $verif =
$object->update($user);
737 $destinataire =
new User($db);
738 $destinataire->fetch(
$object->fk_user);
739 $emailTo = $destinataire->email;
742 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
745 $expediteur =
new User($db);
746 $expediteur->fetch(
$object->fk_validator);
756 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
759 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
762 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
766 $message .=
"<ul>\n";
767 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
768 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
771 $trackid =
'leav'.$object->id;
775 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
778 $result = $mail->sendfile();
792 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
800 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
807 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes') {
816 $result =
$object->update($user);
825 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
833 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
840 (!empty($user->admin) || $user->id ==
$object->fk_validator || $permissiontoadd || $permissiontoaddall)) {
845 $object->fk_user_cancel = $user->id;
851 $result =
$object->update($user);
855 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
860 $startDate =
$object->date_debut_gmt;
861 $endDate =
$object->date_fin_gmt;
863 if (!empty($decrease)) {
865 $date = strtotime(
'-1 month', $lastUpdate);
866 $endOfMonthBeforeLastUpdate =
dol_mktime(0, 0, 0, (
int) date(
'm', $date), (
int) date(
't', $date), (
int) date(
'Y', $date), 1);
867 if (
$object->date_debut_gmt < $endOfMonthBeforeLastUpdate &&
$object->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
868 $endDate = $endOfMonthBeforeLastUpdate;
869 } elseif (
$object->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
870 $endDate = $startDate;
878 $newSolde = ($soldeActuel + $nbopenedday);
881 $result1 =
$object->addLogCP($user->id,
$object->fk_user,
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayCreditAfterCancellation"), $newSolde,
$object->fk_type);
886 if ($result1 < 0 || $result2 < 0) {
899 if (!$error && $result > 0) {
901 $destinataire =
new User($db);
902 $destinataire->fetch(
$object->fk_user);
903 $emailTo = $destinataire->email;
906 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
911 $expediteur =
new User($db);
912 $expediteur->fetch(
$object->fk_user_cancel);
922 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
925 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
931 $message .=
"<ul>\n";
932 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
933 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
934 $message .=
"</ul>\n";
936 $trackid =
'leav'.$object->id;
940 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
943 $result = $mail->sendfile();
949 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
979$form =
new Form($db);
983$listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
985$title = $langs->trans(
'Leave');
986$help_url =
'EN:Module_Holiday';
988llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-card');
992if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
994 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'))))) {
995 $errors[] = $langs->trans(
'CantCreateCP');
1004 $errors[] = $langs->trans(
'ErrorEndDateCP');
1007 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
1010 $errors[] = $langs->trans(
'CantCreateCP');
1013 $errors[] = $langs->trans(
'InvalidValidatorCP');
1016 $errors[] = $langs->trans(
'NoDateDebut');
1019 $errors[] = $langs->trans(
'NoDateFin');
1021 case 'DureeHoliday':
1022 $errors[] = $langs->trans(
'ErrorDureeCP');
1025 $errors[] = $langs->trans(
'alreadyCPexist');
1033 print
'<script type="text/javascript">
1034 $( document ).ready(function() {
1035 $("input.button-save").click("submit", function(e) {
1036 console.log("Call valider()");
1037 if (document.demandeCP.date_debut_.value != "")
1039 if(document.demandeCP.date_fin_.value != "")
1041 if(document.demandeCP.valideur.value != "-1") {
1045 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
1051 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
1057 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
1066 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="demandeCP">'.
"\n";
1067 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1068 print
'<input type="hidden" name="action" value="add" />'.
"\n";
1074 print
'<table class="border centpercent">';
1079 print
'<td class="titlefield fieldrequired tdtop">'.$langs->trans(
"User").
'</td>';
1080 print
'<td><div class="inline-block">';
1081 if ($permissiontoadd && !$permissiontoaddall) {
1082 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');
1085 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');
1090 print
'<div class="leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">';
1094 $typeleaves =
$object->getTypes(1, 1);
1095 foreach ($typeleaves as $key => $val) {
1096 $nb_type =
$object->getCPforUser(($fuserid ? $fuserid : $user->id), $val[
'rowid']);
1097 $nb_holiday += $nb_type;
1099 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
1102 print
' ';
1104 $htmltooltip = $langs->trans(
"Detail").
'<br>';
1105 $htmltooltip .= $out;
1107 print $form->textwithtooltip($langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
' '.
img_picto(
'',
'help'), $htmltooltip);
1110 if (!empty(
$conf->use_javascript_ajax)) {
1112 print
'$( document ).ready(function() {
1113 jQuery("#fuserid").change(function() {
1114 console.log("We change to user id "+jQuery("#fuserid").val());
1115 if (jQuery("#fuserid").val() == '.((int) $user->id).
') {
1116 jQuery(".leaveuserbalance").show();
1118 jQuery(".leaveuserbalance").hide();
1125 print
'<div class="leaveuserbalance paddingtop">';
1135 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1137 $typeleaves =
$object->getTypes(1, -1);
1138 $arraytypeleaves = array();
1139 foreach ($typeleaves as $key => $val) {
1140 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1141 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1142 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1144 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'', true);
1146 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1153 print
'<td class="fieldrequired">';
1154 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1156 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1157 if (!
GETPOST(
'date_debut_')) {
1158 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1160 $tmpdate =
GETPOSTDATE(
'date_debut_',
'00:00:00');
1161 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1163 print
' ';
1164 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1170 print
'<td class="fieldrequired">';
1171 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1173 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1175 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1178 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1180 print
' ';
1181 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1187 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1191 $include_users =
$object->fetch_users_approver_holiday();
1192 if (empty($include_users)) {
1193 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1197 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1204 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.
$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1205 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1214 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1215 print
'<td class="tdtop">';
1216 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1217 print $doleditor->Create(1);
1221 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1228 print $form->buttonsSaveCancel(
"SendRequestCP");
1230 print
'</from>'.
"\n";
1233 if ($error && $action !=
'edit') {
1234 print
'<div class="tabBar">';
1236 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1240 if (($id > 0) || $ref) {
1241 $result =
$object->fetch($id, $ref);
1243 $approverexpected =
new User($db);
1244 $approverexpected->fetch(
$object->fk_validator);
1246 $userRequest =
new User($db);
1247 $userRequest->fetch(
$object->fk_user);
1255 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1258 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP');
1261 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1264 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1267 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1270 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1272 case 'DureeHoliday':
1273 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1275 case 'NoMotifRefuse':
1276 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1279 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend');
1295 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">'.
"\n";
1296 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1297 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1298 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1301 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1303 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1305 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref');
1308 print
'<div class="fichecenter">';
1309 print
'<div class="fichehalfleft">';
1310 print
'<div class="underbanner clearboth"></div>';
1312 print
'<table class="border tableforfield centpercent">';
1317 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1319 print $userRequest->getNomUrl(-1,
'leave');
1324 print
'<td>'.$langs->trans(
"Type").
'</td>';
1326 $typeleaves =
$object->getTypes(1, -1);
1327 if (empty($typeleaves[
$object->fk_type])) {
1328 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
1330 $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']);
1336 $starthalfday = (
$object->halfday == -1 ||
$object->halfday == 2) ?
'afternoon' :
'morning';
1337 $endhalfday = (
$object->halfday == 1 ||
$object->halfday == 2) ?
'morning' :
'afternoon';
1341 print
'<td class="nowrap">';
1342 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1344 print
'<td>'.dol_print_date(
$object->date_debut,
'day');
1345 print
' ';
1346 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1351 print
'<td class="nowrap">';
1352 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1355 $tmpdate =
GETPOSTDATE(
'date_debut_',
'00:00:00');
1356 print $form->selectDate($tmpdate ? $tmpdate :
$object->date_debut,
'date_debut_');
1357 print
' ';
1358 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1365 print
'<td class="nowrap">';
1366 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1368 print
'<td>'.dol_print_date(
$object->date_fin,
'day');
1369 print
' ';
1370 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1375 print
'<td class="nowrap">';
1376 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1379 print $form->selectDate(
$object->date_fin,
'date_fin_');
1380 print
' ';
1381 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1389 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1390 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
1391 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
1392 if ($includesaturday) {
1393 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1395 if ($includesunday) {
1396 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1398 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1407 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1408 print
'<td>'.$object->detail_refuse.
'</td>';
1415 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1416 print
'<td>'.nl2br(
$object->description).
'</td>';
1420 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1421 print
'<td class="tdtop">';
1422 $doleditor =
new DolEditor(
'description',
$object->description,
'', 80,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1423 print $doleditor->Create(1);
1428 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1431 print
'</table>'.
"\n";
1434 print
'<div class="fichehalfright">';
1436 print
'<div class="underbanner clearboth"></div>';
1439 print
'<table class="border tableforfield centpercent">'.
"\n";
1442 if (!empty(
$object->fk_user_create)) {
1443 $userCreate =
new User($db);
1444 $userCreate->fetch(
$object->fk_user_create);
1446 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1447 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1452 if (!$edit && $action !=
'editvalidator') {
1454 print
'<td class="titlefield">';
1456 print $langs->trans(
'ApprovedBy');
1458 print $langs->trans(
'ReviewedByCP');
1463 if (
$object->fk_user_approve > 0) {
1464 $approverdone =
new User($db);
1465 $approverdone->fetch(
$object->fk_user_approve);
1466 print $approverdone->getNomUrl(-1);
1469 print $approverexpected->getNomUrl(-1);
1471 $include_users =
$object->fetch_users_approver_holiday();
1473 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1479 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1481 $include_users =
$object->fetch_users_approver_holiday();
1482 if (!in_array(
$object->fk_validator, $include_users)) {
1483 $include_users[] =
$object->fk_validator;
1485 if (empty($include_users)) {
1486 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1488 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1489 $s = $form->select_dolusers(
$object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1490 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1492 if ($action ==
'editvalidator') {
1493 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1494 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1501 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1502 print
'<td>'.dol_print_date(
$object->date_create,
'dayhour',
'tzuser').
'</td>';
1506 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1507 print
'<td>'.dol_print_date(
$object->date_approval,
'dayhour',
'tzuser').
'</td>';
1512 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1513 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1518 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1519 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1528 print
'<div class="clearboth"></div>';
1534 if ($action ==
'delete') {
1536 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1542 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1546 if ($action ==
'valid') {
1547 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1551 if ($action ==
'refuse') {
1552 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1553 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1557 if ($action ==
'cancel') {
1558 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1562 if ($action ==
'backtodraft') {
1563 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1569 print $form->buttonsSaveCancel();
1579 print
'<div class="tabsAction">';
1582 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1586 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=sendToValidate&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1591 if (($user->id ==
$object->fk_validator || $permissiontoaddall) && $user->hasRight(
'holiday',
'approve')) {
1592 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1593 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=refuse&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1595 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1596 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1599 if ($permissiontoadd || $permissiontoaddall) {
1601 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1603 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1609 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $permissiontoadd || $permissiontoaddall) {
1610 if ((
$object->date_fin >
dol_now()) || !empty($user->admin) || $user->id ==
$object->fk_user_approve) {
1611 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1613 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1616 if (!empty($user->admin)) {
1617 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1619 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1625 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1628 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1634 print
'<div class="tabBar">';
1635 print $langs->trans(
'ErrorUserViewCP');
1636 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1640 print
'<div class="tabBar">';
1641 print $langs->trans(
'ErrorIDFicheCP');
1642 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1648 if (
GETPOST(
'modelselected')) {
1649 $action =
'presend';
1652 if ($action !=
'presend' && $action !=
'edit') {
1653 print
'<div class="fichecenter"><div class="fichehalfleft">';
1654 print
'<a name="builddoc"></a>';
1673 print
'</div><div class="fichehalfright">';
1676 $morehtmlright =
'';
1679 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1681 $somethingshown = $formactions->showactions(
$object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
1683 print
'</div></div>';
1691if (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_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.
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.