34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47$action =
GETPOST(
'action',
'aZ09');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
59$langs->loadLangs(array(
"other",
"holiday",
"mails",
"trips"));
65$childids = $user->getAllChildIds(1);
69 $morefilter =
'AND employee = 1';
77$extrafields->fetch_name_optionals_label(
$object->table_element);
79if (($id > 0) || $ref) {
84 if ($user->hasRight(
'holiday',
'readall')) {
87 if ($user->hasRight(
'holiday',
'read') && in_array(
$object->fk_user, $childids)) {
96$hookmanager->initHooks(array(
'holidaycard',
'globalcard'));
100if ($user->hasRight(
'holiday',
'write') && in_array($fuserid, $childids)) {
103if ($user->hasRight(
'holiday',
'writeall')) {
109if ($user->hasRight(
'holiday',
'delete')) {
118 $socid = $user->socid;
127$parameters = array(
'socid' => $socid);
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
133if (empty($reshook)) {
134 $backurlforlist = DOL_URL_ROOT.
'/holiday/list.php';
136 if (empty($backtopage) || ($cancel && empty($id))) {
137 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
138 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
139 $backtopage = $backurlforlist;
141 $backtopage = DOL_URL_ROOT.
'/holiday/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
147 if (!empty($backtopageforcancel)) {
148 header(
"Location: ".$backtopageforcancel);
150 } elseif (!empty($backtopage)) {
151 header(
"Location: ".$backtopage);
158 if ($action ==
'add' && $cancreate) {
167 $starthalfday =
GETPOST(
'starthalfday');
168 $endhalfday =
GETPOST(
'endhalfday');
171 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
173 } elseif ($starthalfday ==
'afternoon') {
175 } elseif ($endhalfday ==
'morning') {
180 $description = trim(
GETPOST(
'description',
'restricthtml'));
183 if (!$cancreateall) {
185 if (!$user->hasRight(
'holiday',
'write')) {
188 } elseif (!in_array($fuserid, $childids)) {
194 if (!$user->hasRight(
'holiday',
'write') && !$user->hasRight(
'holiday',
'writeall_advance')) {
197 } elseif (!$user->hasRight(
'holiday',
'writeall_advance') && !in_array($fuserid, $childids)) {
207 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
213 if (empty($date_debut)) {
219 if (empty($date_fin)) {
225 if ($date_debut > $date_fin) {
232 $verifCP =
$object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
240 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
241 if ($nbopenedday < 0.5) {
248 if ($approverid < 1) {
249 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'),
null,
'errors');
253 $approverslist =
$object->fetch_users_approver_holiday();
254 if (!in_array($approverid, $approverslist)) {
255 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidator'),
null,
'errors');
260 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
269 $object->description = $description;
270 $object->fk_validator = $approverid;
272 $object->date_debut = $date_debut;
275 $object->entity = $conf->entity;
277 $result =
$object->create($user);
288 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
296 if ($action ==
'update' && GETPOSTISSET(
'savevalidator') && $user->hasRight(
'holiday',
'approve')) {
304 $verif =
$object->update($user);
308 $action =
'editvalidator';
310 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
318 if ($action ==
'update' && !GETPOSTISSET(
'savevalidator')) {
323 $starthalfday =
GETPOST(
'starthalfday');
324 $endhalfday =
GETPOST(
'endhalfday');
326 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
328 } elseif ($starthalfday ==
'afternoon') {
330 } elseif ($endhalfday ==
'morning') {
335 if (!$cancreateall) {
337 if (!in_array($fuserid, $childids)) {
339 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
344 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
358 $description = trim(
GETPOST(
'description',
'restricthtml'));
368 if ($date_debut > $date_fin) {
375 if ($approverid < 1) {
382 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
383 if ($nbopenedday < 0.5) {
392 $object->description = $description;
393 $object->date_debut = $date_debut;
395 $object->fk_validator = $approverid;
399 $verif =
$object->update($user);
411 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
427 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $candelete) {
436 $result =
$object->delete($user);
445 header(
'Location: list.php?restore_lastsearch_values=1');
453 if ($action ==
'confirm_send') {
462 $verif =
$object->validate($user);
467 $destinataire =
new User($db);
468 $destinataire->fetch(
$object->fk_validator);
469 $emailTo = $destinataire->email;
472 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
473 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
478 $expediteur =
new User($db);
479 $expediteur->fetch(
$object->fk_user);
489 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
492 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
494 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateBody").
"</p>\n";
499 $delayForRequest = 0;
500 if ($delayForRequest) {
503 if (
$object->date_debut < $nowplusdelay) {
504 $message =
"<p>".$langs->transnoentities(
"HolidaysToValidateDelay", $delayForRequest).
"</p>\n";
514 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateAlertSolde").
"</p>\n";
518 $typeleaves =
$object->getTypes(1, -1);
519 if (empty($typeleaves[
$object->fk_type])) {
520 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
522 $labeltoshow = (($typeleaves[
$object->fk_type][
'code'] && $langs->trans($typeleaves[
$object->fk_type][
'code']) != $typeleaves[
$object->fk_type][
'code']) ? $langs->trans($typeleaves[
$object->fk_type][
'code']) : $typeleaves[
$object->fk_type][
'label']);
525 $starthalfdaykey =
"Afternoon";
526 $endhalfdaykey =
"Morning";
527 } elseif (
$object->halfday == -1) {
528 $starthalfdaykey =
"Afternoon";
529 $endhalfdaykey =
"Afternoon";
530 } elseif (
$object->halfday == 1) {
531 $starthalfdaykey =
"Morning";
532 $endhalfdaykey =
"Morning";
534 $starthalfdaykey =
"Morning";
535 $endhalfdaykey =
"Afternoon";
538 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
541 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
542 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
543 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Period").
" : ".
dol_print_date(
$object->date_debut,
'day').
" ".$langs->transnoentitiesnoconv($starthalfdaykey).
" ".$langs->transnoentitiesnoconv(
"To").
" ".
dol_print_date(
$object->date_fin,
'day').
" ".$langs->transnoentitiesnoconv($endhalfdaykey).
"</li>\n";
544 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
545 $message .=
"</ul>\n";
547 $trackid =
'leav'.$object->id;
551 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
554 $result = $mail->sendfile();
560 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
570 if ($action ==
'update_extras') {
574 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
581 $result =
$object->insertExtraFields(
'HOLIDAY_MODIFY');
589 $action =
'edit_extras';
594 if ($action ==
'confirm_valid') {
602 $object->fk_user_approve = $user->id;
608 $verif =
$object->approve($user);
619 $newSolde = ($soldeActuel - $nbopenedday);
620 $label = $langs->transnoentitiesnoconv(
"Holidays").
' - '.
$object->ref;
639 $destinataire =
new User($db);
640 $destinataire->fetch(
$object->fk_user);
641 $emailTo = $destinataire->email;
644 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
647 $expediteur =
new User($db);
648 $expediteur->fetch(
$object->fk_validator);
658 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
661 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
667 $message .=
"<ul>\n";
668 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
669 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
670 $message .=
"</ul>\n";
672 $trackid =
'leav'.$object->id;
676 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
679 $result = $mail->sendfile();
691 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
700 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
701 if (
GETPOST(
'detail_refuse')) {
707 $object->fk_user_refuse = $user->id;
714 $verif =
$object->update($user);
723 $destinataire =
new User($db);
724 $destinataire->fetch(
$object->fk_user);
725 $emailTo = $destinataire->email;
728 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
731 $expediteur =
new User($db);
732 $expediteur->fetch(
$object->fk_validator);
742 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
745 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
748 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
752 $message .=
"<ul>\n";
753 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
754 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
757 $trackid =
'leav'.$object->id;
761 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
764 $result = $mail->sendfile();
778 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
786 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
793 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes') {
802 $result =
$object->update($user);
811 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
819 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
826 (!empty($user->admin) || $user->id ==
$object->fk_validator || $cancreate || $cancreateall)) {
831 $object->fk_user_cancel = $user->id;
835 $result =
$object->update($user);
839 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
848 $newSolde = ($soldeActuel + $nbopenedday);
851 $result1 =
$object->addLogCP($user->id,
$object->fk_user, $langs->transnoentitiesnoconv(
"HolidaysCancelation"), $newSolde,
$object->fk_type);
856 if ($result1 < 0 || $result2 < 0) {
869 if (!$error && $result > 0) {
871 $destinataire =
new User($db);
872 $destinataire->fetch(
$object->fk_user);
873 $emailTo = $destinataire->email;
876 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
881 $expediteur =
new User($db);
882 $expediteur->fetch(
$object->fk_user_cancel);
892 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
895 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
901 $message .=
"<ul>\n";
902 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
903 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
904 $message .=
"</ul>\n";
906 $trackid =
'leav'.$object->id;
910 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
913 $result = $mail->sendfile();
919 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
949$form =
new Form($db);
952$listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
954$title = $langs->trans(
'Leave');
955$help_url =
'EN:Module_Holiday';
961if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
963 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'))))) {
964 $errors[] = $langs->trans(
'CantCreateCP');
973 $errors[] = $langs->trans(
'ErrorEndDateCP');
976 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
979 $errors[] = $langs->trans(
'CantCreateCP');
982 $errors[] = $langs->trans(
'InvalidValidatorCP');
985 $errors[] = $langs->trans(
'NoDateDebut');
988 $errors[] = $langs->trans(
'NoDateFin');
991 $errors[] = $langs->trans(
'ErrorDureeCP');
994 $errors[] = $langs->trans(
'alreadyCPexist');
1002 print
'<script type="text/javascript">
1003 $( document ).ready(function() {
1004 $("input.button-save").click("submit", function(e) {
1005 console.log("Call valider()");
1006 if (document.demandeCP.date_debut_.value != "")
1008 if(document.demandeCP.date_fin_.value != "")
1010 if(document.demandeCP.valideur.value != "-1") {
1014 alert("'.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'");
1020 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'");
1026 alert("'.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'");
1035 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="demandeCP">'.
"\n";
1036 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1037 print
'<input type="hidden" name="action" value="add" />'.
"\n";
1043 print
'<table class="border centpercent">';
1048 print
'<td class="titlefield fieldrequired tdtop">'.$langs->trans(
"User").
'</td>';
1049 print
'<td><div class="inline-block">';
1050 if ($cancreate && !$cancreateall) {
1051 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');
1054 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');
1059 print
'<div class="leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">';
1063 $typeleaves =
$object->getTypes(1, 1);
1064 foreach ($typeleaves as $key => $val) {
1065 $nb_type =
$object->getCPforUser(($fuserid ? $fuserid : $user->id), $val[
'rowid']);
1066 $nb_holiday += $nb_type;
1068 $out .=
' - '.($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']).
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
1071 print
' ';
1073 $htmltooltip = $langs->trans(
"Detail").
'<br>';
1074 $htmltooltip .= $out;
1076 print $form->textwithtooltip($langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
' '.
img_picto(
'',
'help'), $htmltooltip);
1079 if (!empty($conf->use_javascript_ajax)) {
1081 print
'$( document ).ready(function() {
1082 jQuery("#fuserid").change(function() {
1083 console.log("We change to user id "+jQuery("#fuserid").val());
1084 if (jQuery("#fuserid").val() == '.((int) $user->id).
') {
1085 jQuery(".leaveuserbalance").show();
1087 jQuery(".leaveuserbalance").hide();
1094 print
'<div class="leaveuserbalance paddingtop">';
1104 print
'<td class="fieldrequired">'.$langs->trans(
"Type").
'</td>';
1106 $typeleaves =
$object->getTypes(1, -1);
1107 $arraytypeleaves = array();
1108 foreach ($typeleaves as $key => $val) {
1109 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
1110 $labeltoshow .= ($val[
'delay'] > 0 ?
' ('.$langs->trans(
"NoticePeriod").
': '.$val[
'delay'].
' '.$langs->trans(
"days").
')' :
'');
1111 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
1113 print $form->selectarray(
'type', $arraytypeleaves, (
GETPOST(
'type',
'alpha') ?
GETPOST(
'type',
'alpha') :
''), 1, 0, 0,
'', 0, 0, 0,
'',
'', true);
1115 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1122 print
'<td class="fieldrequired">';
1123 print $form->textwithpicto($langs->trans(
"DateDebCP"), $langs->trans(
"FirstDayOfHoliday"));
1125 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1126 if (!
GETPOST(
'date_debut_')) {
1127 print $form->selectDate(-1,
'date_debut_', 0, 0, 0,
'', 1, 1);
1130 print $form->selectDate($tmpdate,
'date_debut_', 0, 0, 0,
'', 1, 1);
1132 print
' ';
1133 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday',
'alpha') ?
GETPOST(
'starthalfday',
'alpha') :
'morning'));
1139 print
'<td class="fieldrequired">';
1140 print $form->textwithpicto($langs->trans(
"DateFinCP"), $langs->trans(
"LastDayOfHoliday"));
1142 print
'<td>'.img_picto(
'',
'action',
'class="pictofixedwidth"');
1144 print $form->selectDate(-1,
'date_fin_', 0, 0, 0,
'', 1, 1);
1147 print $form->selectDate($tmpdate,
'date_fin_', 0, 0, 0,
'', 1, 1);
1149 print
' ';
1150 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday',
'alpha') ?
GETPOST(
'endhalfday',
'alpha') :
'afternoon'));
1156 print
'<td class="fieldrequired">'.$langs->trans(
"ReviewedByCP").
'</td>';
1160 $include_users =
$object->fetch_users_approver_holiday();
1161 if (empty($include_users)) {
1162 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1166 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1173 $s = $form->select_dolusers($defaultselectuser,
"valideur", 1,
'', 0, $include_users,
'',
'0,'.$conf->entity, 0, 0,
'', 0,
'',
'minwidth200 maxwidth500');
1174 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1183 print
'<td>'.$langs->trans(
"DescCP").
'</td>';
1184 print
'<td class="tdtop">';
1185 $doleditor =
new DolEditor(
'description',
GETPOST(
'description',
'restricthtml'),
'', 80,
'dolibarr_notes',
'In', 0,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1186 print $doleditor->Create(1);
1190 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1197 print $form->buttonsSaveCancel(
"SendRequestCP");
1199 print
'</from>'.
"\n";
1202 if ($error && $action !=
'edit') {
1203 print
'<div class="tabBar">';
1205 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1209 if (($id > 0) || $ref) {
1210 $result =
$object->fetch($id, $ref);
1212 $approverexpected =
new User($db);
1213 $approverexpected->fetch(
$object->fk_validator);
1215 $userRequest =
new User($db);
1216 $userRequest->fetch(
$object->fk_user);
1224 $errors[] = $langs->transnoentitiesnoconv(
'ErrorEndDateCP');
1227 $errors[] = $langs->transnoentitiesnoconv(
'ErrorSQLCreateCP');
1230 $errors[] = $langs->transnoentitiesnoconv(
'CantCreateCP');
1233 $errors[] = $langs->transnoentitiesnoconv(
'InvalidValidatorCP');
1236 $errors[] = $langs->transnoentitiesnoconv(
'NoDateDebut');
1239 $errors[] = $langs->transnoentitiesnoconv(
'NoDateFin');
1241 case 'DureeHoliday':
1242 $errors[] = $langs->transnoentitiesnoconv(
'ErrorDureeCP');
1244 case 'NoMotifRefuse':
1245 $errors[] = $langs->transnoentitiesnoconv(
'NoMotifRefuseCP');
1248 $errors[] = $langs->transnoentitiesnoconv(
'ErrorMailNotSend');
1264 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">'.
"\n";
1265 print
'<input type="hidden" name="token" value="'.newToken().
'" />'.
"\n";
1266 print
'<input type="hidden" name="action" value="update"/>'.
"\n";
1267 print
'<input type="hidden" name="id" value="'.$object->id.
'" />'.
"\n";
1270 print
dol_get_fiche_head($head,
'card', $langs->trans(
"CPTitreMenu"), -1,
'holiday');
1272 $linkback =
'<a href="'.DOL_URL_ROOT.
'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1274 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref');
1277 print
'<div class="fichecenter">';
1278 print
'<div class="fichehalfleft">';
1279 print
'<div class="underbanner clearboth"></div>';
1281 print
'<table class="border tableforfield centpercent">';
1286 print
'<td class="titlefield">'.$langs->trans(
"User").
'</td>';
1288 print $userRequest->getNomUrl(-1,
'leave');
1293 print
'<td>'.$langs->trans(
"Type").
'</td>';
1295 $typeleaves =
$object->getTypes(1, -1);
1296 if (empty($typeleaves[
$object->fk_type])) {
1297 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
1299 $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']);
1305 $starthalfday = (
$object->halfday == -1 ||
$object->halfday == 2) ?
'afternoon' :
'morning';
1306 $endhalfday = (
$object->halfday == 1 ||
$object->halfday == 2) ?
'morning' :
'afternoon';
1310 print
'<td class="nowrap">';
1311 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1313 print
'<td>'.dol_print_date(
$object->date_debut,
'day');
1314 print
' ';
1315 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1320 print
'<td class="nowrap">';
1321 print $form->textwithpicto($langs->trans(
'DateDebCP'), $langs->trans(
"FirstDayOfHoliday"));
1325 print $form->selectDate($tmpdate ? $tmpdate :
$object->date_debut,
'date_debut_');
1326 print
' ';
1327 print $form->selectarray(
'starthalfday', $listhalfday, (
GETPOST(
'starthalfday') ?
GETPOST(
'starthalfday') : $starthalfday));
1334 print
'<td class="nowrap">';
1335 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1337 print
'<td>'.dol_print_date(
$object->date_fin,
'day');
1338 print
' ';
1339 print
'<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1344 print
'<td class="nowrap">';
1345 print $form->textwithpicto($langs->trans(
'DateFinCP'), $langs->trans(
"LastDayOfHoliday"));
1348 print $form->selectDate(
$object->date_fin,
'date_fin_');
1349 print
' ';
1350 print $form->selectarray(
'endhalfday', $listhalfday, (
GETPOST(
'endhalfday') ?
GETPOST(
'endhalfday') : $endhalfday));
1358 $htmlhelp = $langs->trans(
'NbUseDaysCPHelp');
1359 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
1360 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
1361 if ($includesaturday) {
1362 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Saturday"));
1364 if ($includesunday) {
1365 $htmlhelp .=
'<br>'.$langs->trans(
"DayIsANonWorkingDay", $langs->trans(
"Sunday"));
1367 print $form->textwithpicto($langs->trans(
'NbUseDaysCP'), $htmlhelp);
1376 print
'<td>'.$langs->trans(
'DetailRefusCP').
'</td>';
1377 print
'<td>'.$object->detail_refuse.
'</td>';
1384 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1385 print
'<td>'.nl2br(
$object->description).
'</td>';
1389 print
'<td>'.$langs->trans(
'DescCP').
'</td>';
1390 print
'<td class="tdtop">';
1391 $doleditor =
new DolEditor(
'description',
$object->description,
'', 80,
'dolibarr_notes',
'In', 0,
false, isModEnabled(
'fckeditor'), ROWS_3,
'90%');
1392 print $doleditor->Create(1);
1397 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1400 print
'</table>'.
"\n";
1403 print
'<div class="fichehalfright">';
1405 print
'<div class="underbanner clearboth"></div>';
1408 print
'<table class="border tableforfield centpercent">'.
"\n";
1411 if (!empty(
$object->fk_user_create)) {
1412 $userCreate =
new User($db);
1413 $userCreate->fetch(
$object->fk_user_create);
1415 print
'<td class="titlefield">'.$langs->trans(
'RequestByCP').
'</td>';
1416 print
'<td>'.$userCreate->getNomUrl(-1).
'</td>';
1421 if (!$edit && $action !=
'editvalidator') {
1423 print
'<td class="titlefield">';
1425 print $langs->trans(
'ApprovedBy');
1427 print $langs->trans(
'ReviewedByCP');
1432 if (
$object->fk_user_approve > 0) {
1433 $approverdone =
new User($db);
1434 $approverdone->fetch(
$object->fk_user_approve);
1435 print $approverdone->getNomUrl(-1);
1438 print $approverexpected->getNomUrl(-1);
1440 $include_users =
$object->fetch_users_approver_holiday();
1442 print
'<a class="editfielda paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editvalidator">'.
img_edit($langs->trans(
"Edit")).
'</a>';
1448 print
'<td class="titlefield">'.$langs->trans(
'ReviewedByCP').
'</td>';
1450 $include_users =
$object->fetch_users_approver_holiday();
1451 if (!in_array(
$object->fk_validator, $include_users)) {
1452 $include_users[] =
$object->fk_validator;
1454 if (empty($include_users)) {
1455 print
img_warning().
' '.$langs->trans(
"NobodyHasPermissionToValidateHolidays");
1457 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ?
'' : array($user->id));
1458 $s = $form->select_dolusers(
$object->fk_validator,
"valideur", (($action ==
'editvalidator') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1459 print $form->textwithpicto($s, $langs->trans(
"AnyOtherInThisListCanValidate"));
1461 if ($action ==
'editvalidator') {
1462 print
'<input type="submit" class="button button-save" name="savevalidator" value="'.$langs->trans(
"Save").
'">';
1463 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1470 print
'<td>'.$langs->trans(
'DateCreation').
'</td>';
1471 print
'<td>'.dol_print_date(
$object->date_create,
'dayhour',
'tzuser').
'</td>';
1475 print
'<td>'.$langs->trans(
'DateValidCP').
'</td>';
1476 print
'<td>'.dol_print_date(
$object->date_approval,
'dayhour',
'tzuser').
'</td>';
1481 print
'<td>'.$langs->trans(
'DateCancelCP').
'</td>';
1482 print
'<td>'.dol_print_date(
$object->date_cancel,
'dayhour',
'tzuser').
'</td>';
1487 print
'<td>'.$langs->trans(
'DateRefusCP').
'</td>';
1488 print
'<td>'.dol_print_date(
$object->date_refuse,
'dayhour',
'tzuser').
'</td>';
1497 print
'<div class="clearboth"></div>';
1503 if ($action ==
'delete') {
1505 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleDeleteCP"), $langs->trans(
"ConfirmDeleteCP"),
"confirm_delete",
'', 0, 1);
1511 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleToValidCP"), $langs->trans(
"ConfirmToValidCP"),
"confirm_send",
'', 1, 1);
1515 if ($action ==
'valid') {
1516 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleValidCP"), $langs->trans(
"ConfirmValidCP"),
"confirm_valid",
'', 1, 1);
1520 if ($action ==
'refuse') {
1521 $array_input = array(array(
'type'=>
"text",
'label'=> $langs->trans(
'DetailRefusCP'),
'name'=>
"detail_refuse",
'size'=>
"50",
'value'=>
""));
1522 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&action=confirm_refuse", $langs->trans(
"TitleRefuseCP"), $langs->trans(
'ConfirmRefuseCP'),
"confirm_refuse", $array_input, 1, 0);
1526 if ($action ==
'cancel') {
1527 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleCancelCP"), $langs->trans(
"ConfirmCancelCP"),
"confirm_cancel",
'', 1, 1);
1531 if ($action ==
'backtodraft') {
1532 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"TitleSetToDraft"), $langs->trans(
"ConfirmSetToDraft"),
"confirm_draft",
'', 1, 1);
1538 print $form->buttonsSaveCancel();
1548 print
'<div class="tabsAction">';
1551 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
"EditCP").
'</a>';
1555 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=sendToValidate&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Validate").
'</a>';
1560 if (($user->id ==
$object->fk_validator || $cancreateall) && $user->hasRight(
'holiday',
'approve')) {
1561 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'" class="butAction">'.$langs->trans(
"Approve").
'</a>';
1562 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=refuse&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1564 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"Approve").
'</a>';
1565 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotTheAssignedApprover").
'">'.$langs->trans(
"ActionRefuseCP").
'</a>';
1568 if ($cancreate || $cancreateall) {
1570 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1572 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1578 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $cancreate || $cancreateall) {
1579 if ((
$object->date_fin >
dol_now()) || !empty($user->admin) || $user->id ==
$object->fk_user_approve) {
1580 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1582 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
'-'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1585 if (!empty($user->admin)) {
1586 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1588 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1594 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1597 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1603 print
'<div class="tabBar">';
1604 print $langs->trans(
'ErrorUserViewCP');
1605 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1609 print
'<div class="tabBar">';
1610 print $langs->trans(
'ErrorIDFicheCP');
1611 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1617 if (
GETPOST(
'modelselected')) {
1618 $action =
'presend';
1621 if ($action !=
'presend' && $action !=
'edit') {
1622 print
'<div class="fichecenter"><div class="fichehalfleft">';
1623 print
'<a name="builddoc"></a>';
1625 $includedocgeneration = 0;
1628 if ($includedocgeneration) {
1630 $relativepath = $objref.
'/'.$objref.
'.pdf';
1631 $filedir = $conf->holiday->dir_output.
'/'.
$object->element.
'/'.$objref;
1632 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1633 $genallowed = ($user->hasRight(
'holiday',
'read') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'readall');
1634 $delallowed = ($user->hasRight(
'holiday',
'write') &&
$object->fk_user == $user->id) || $user->hasRight(
'holiday',
'writeall_advance');
1635 print $formfile->showdocuments(
'holiday:Holiday',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1643 print
'</div><div class="fichehalfright">';
1646 $morehtmlright =
'';
1649 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1651 $somethingshown = $formactions->showactions(
$object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlright);
1653 print
'</div></div>';
1661if (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()
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
holiday_prepare_head($object)
Return array head with list of tabs to view object information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.