36require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
56$action =
GETPOST(
'action',
'aZ09');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$confirm =
GETPOST(
'confirm',
'alpha');
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
64$fuserid = (
GETPOSTINT(
'fuserid') ?
GETPOSTINT(
'fuserid') : ($action ==
'create' ? $user->id : 0));
68$langs->loadLangs(array(
"other",
"holiday",
"mails",
"trips"));
75$childids = $user->getAllChildIds(1);
79 $morefilter =
'AND employee = 1';
85$extrafields->fetch_name_optionals_label(
$object->table_element);
88$hookmanager->initHooks(array(
'holidaycard',
'globalcard'));
90$permissiontoapprove = $user->hasRight(
'holiday',
'approve');
93if (($id > 0) || $ref) {
97 if ($user->hasRight(
'holiday',
'readall')) {
100 if ($user->hasRight(
'holiday',
'read') && in_array(
$object->fk_user, $childids)) {
103 if ($permissiontoapprove &&
$object->fk_validator == $user->id && !
getDolGlobalString(
'HOLIDAY_CAN_APPROVE_ONLY_THE_SUBORDINATES')) {
115$permissiontoaddall = 0;
116if ($user->hasRight(
'holiday',
'write') && in_array($fuserid, $childids)) {
117 $permissiontoadd = 1;
119if ($user->hasRight(
'holiday',
'writeall')) {
120 $permissiontoadd = 1;
121 $permissiontoaddall = 1;
123$permissiontoeditextra = $permissiontoadd;
124if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
126 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
130if ($user->hasRight(
'holiday',
'delete')) {
139 $socid = $user->socid;
148$parameters = array(
'socid' => $socid);
149$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
151 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
154if (empty($reshook)) {
155 $backurlforlist = DOL_URL_ROOT.
'/holiday/list.php';
157 if (empty($backtopage) || ($cancel && empty($id))) {
158 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
159 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
160 $backtopage = $backurlforlist;
162 $backtopage = DOL_URL_ROOT.
'/holiday/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
168 if (!empty($backtopageforcancel)) {
169 header(
"Location: ".$backtopageforcancel);
171 } elseif (!empty($backtopage)) {
172 header(
"Location: ".$backtopage);
179 if ($action ==
'add' && $permissiontoadd) {
184 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
186 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
187 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
188 $starthalfday =
GETPOST(
'starthalfday');
189 $endhalfday =
GETPOST(
'endhalfday');
192 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
194 } elseif ($starthalfday ==
'afternoon') {
196 } elseif ($endhalfday ==
'morning') {
201 $description = trim(
GETPOST(
'description',
'restricthtml'));
204 if (!$permissiontoaddall) {
206 if (!$user->hasRight(
'holiday',
'write')) {
208 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
209 } elseif (!in_array($fuserid, $childids)) {
211 setEventMessages($langs->trans(
"UserNotInHierachy"),
null,
'errors');
215 if (!$user->hasRight(
'holiday',
'write') && !$user->hasRight(
'holiday',
'writeall')) {
217 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
218 } elseif (!$user->hasRight(
'holiday',
'writeall') && !in_array($fuserid, $childids)) {
220 setEventMessages($langs->trans(
"UserNotInHierachy"),
null,
'errors');
228 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
234 if (empty($date_debut)) {
235 setEventMessages($langs->trans(
"NoDateDebut"),
null,
'errors');
240 if (empty($date_fin)) {
241 setEventMessages($langs->trans(
"NoDateFin"),
null,
'errors');
246 if ($date_debut > $date_fin) {
247 setEventMessages($langs->trans(
"ErrorEndDateCP"),
null,
'errors');
253 $verifCP =
$object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
255 setEventMessages($langs->trans(
"alreadyCPexist"),
null,
'errors');
260 $tmpUser =
new User($db);
261 $tmpUser->fetch($fuserid);
264 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday, $tmpUser->country_id, $tmpUser->id);
265 if ($nbopenedday < 0.5) {
266 setEventMessages($langs->trans(
"ErrorDureeCP"),
null,
'errors');
272 if ($approverid < 1) {
273 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidatorCP'),
null,
'errors');
277 $approverslist =
$object->fetch_users_approver_holiday();
278 if (!in_array($approverid, $approverslist)) {
279 setEventMessages($langs->transnoentitiesnoconv(
'InvalidValidator'),
null,
'errors');
284 $ret = $extrafields->setOptionalsFromPost(
null, $object);
293 $object->description = $description;
294 $object->fk_validator = $approverid;
296 $object->date_debut = $date_debut;
301 $result =
$object->create($user);
312 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
320 if ($action ==
'update' &&
GETPOSTISSET(
'savevalidator') && $permissiontoapprove) {
328 $verif =
$object->update($user);
332 $action =
'editvalidator';
334 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
342 if ($action ==
'update' && !
GETPOSTISSET(
'savevalidator')) {
343 $date_debut =
GETPOSTDATE(
'date_debut_',
'00:00:00');
345 $date_debut_gmt =
GETPOSTDATE(
'date_debut_',
'00:00:00', 1);
346 $date_fin_gmt =
GETPOSTDATE(
'date_fin_',
'00:00:00', 1);
347 $starthalfday =
GETPOST(
'starthalfday');
348 $endhalfday =
GETPOST(
'endhalfday');
350 if ($starthalfday ==
'afternoon' && $endhalfday ==
'morning') {
352 } elseif ($starthalfday ==
'afternoon') {
354 } elseif ($endhalfday ==
'morning') {
359 if (!$permissiontoaddall) {
360 if ($permissiontoadd) {
361 if (!in_array($fuserid, $childids)) {
362 setEventMessages($langs->trans(
"UserNotInHierachy"),
null,
'errors');
363 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
367 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
368 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?action=create');
378 if ($permissiontoadd) {
382 $description = trim(
GETPOST(
'description',
'restricthtml'));
386 setEventMessages($langs->trans(
'NoDateFin'),
null,
'warnings');
392 if ($date_debut > $date_fin) {
393 setEventMessages($langs->trans(
'ErrorEndDateCP'),
null,
'warnings');
399 if ($approverid < 1) {
400 setEventMessages($langs->trans(
'InvalidValidatorCP'),
null,
'warnings');
405 $tmpUser =
new User($db);
406 $tmpUser->fetch($fuserid);
409 $nbopenedday =
num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday, $tmpUser->country_id, $tmpUser->id);
410 if ($nbopenedday < 0.5) {
411 setEventMessages($langs->trans(
'ErrorDureeCP'),
null,
'warnings');
419 $object->description = $description;
420 $object->date_debut = $date_debut;
422 $object->fk_validator = $approverid;
426 $verif =
$object->update($user);
438 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
444 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
448 setEventMessages($langs->trans(
"ErrorBadStatus"),
null,
'errors');
454 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm') ==
'yes' && $candelete) {
464 $result =
$object->delete($user);
472 setEventMessages($langs->trans(
'BadStatusOfObject'),
null,
'errors');
478 header(
'Location: list.php?restore_lastsearch_values=1');
486 if ($action ==
'confirm_send') {
495 $verif =
$object->validate($user);
500 $destinataire =
new User($db);
501 $destinataire->fetch(
$object->fk_validator);
502 $emailTo = $destinataire->email;
505 dol_syslog(
"Expected validator has no email, so we redirect directly to finished page without sending email");
506 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
511 $expediteur =
new User($db);
512 $expediteur->fetch(
$object->fk_user);
524 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysToValidate");
527 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
529 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateBody").
"</p>\n";
535 if ($delayForRequest) {
538 if (
$object->date_debut < $nowplusdelay) {
539 $message =
"<p>".$langs->transnoentities(
"HolidaysToValidateDelay", (
string) $delayForRequest).
"</p>\n";
548 $affectingtypes =
$object->getTypes(1, 1);
549 if (!empty($affectingtypes[
$object->fk_type])) {
550 $tmpUser =
new User($db);
551 $tmpUser->fetch(
$object->fk_user);
556 $message .=
"<p>".$langs->transnoentities(
"HolidaysToValidateAlertSolde").
"</p>\n";
561 $typeleaves =
$object->getTypes(1, -1);
562 if (empty($typeleaves[
$object->fk_type])) {
563 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type);
565 $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']);
568 $starthalfdaykey =
"Afternoon";
569 $endhalfdaykey =
"Morning";
570 } elseif (
$object->halfday == -1) {
571 $starthalfdaykey =
"Afternoon";
572 $endhalfdaykey =
"Afternoon";
573 } elseif (
$object->halfday == 1) {
574 $starthalfdaykey =
"Morning";
575 $endhalfdaykey =
"Morning";
577 $starthalfdaykey =
"Morning";
578 $endhalfdaykey =
"Afternoon";
580 $starthalfdaykey =
"";
584 $link =
dol_buildpath(
"/holiday/card.php", 3) .
'?id='.$object->id;
587 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Name").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
588 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Type").
" : ".(empty($labeltoshow) ? $langs->trans(
"TypeWasDisabledOrRemoved",
$object->fk_type) : $labeltoshow).
"</li>\n";
589 $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";
590 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
591 $message .=
"</ul>\n";
593 $trackid =
'leav'.$object->id;
597 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
600 $result = $mail->sendfile();
603 setEventMessages($mail->error, $mail->errors,
'warnings');
606 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
616 if ($action ==
'update_extras' && $permissiontoeditextra) {
619 $attribute_name =
GETPOST(
'attribute',
'aZ09');
622 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
628 $result =
$object->updateExtraField($attribute_name,
'HOLIDAY_MODIFY');
636 $action =
'edit_extras';
641 if ($action ==
'confirm_valid' && $permissiontoapprove) {
649 $object->fk_user_approve = $user->id;
657 $verif =
$object->approve($user);
664 if (!$error && empty($decrease)) {
665 $tmpUser =
new User($db);
666 $tmpUser->fetch(
$object->fk_user);
671 $newSolde = ($soldeActuel - $nbopenedday);
672 $label =
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayConsumption");
678 setEventMessages(
null,
$object->errors,
'errors');
685 setEventMessages(
null,
$object->errors,
'errors');
691 $destinataire =
new User($db);
692 $destinataire->fetch(
$object->fk_user);
693 $emailTo = $destinataire->email;
696 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
699 $expediteur =
new User($db);
700 $expediteur->fetch(
$object->fk_validator);
710 $subject =
'['.$societeName.
"] ".$langs->transnoentitiesnoconv(
"HolidaysValidated");
713 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
719 $message .=
"<ul>\n";
720 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ValidatedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
721 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
722 $message .=
"</ul>\n";
724 $trackid =
'leav'.$object->id;
728 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
731 $result = $mail->sendfile();
734 setEventMessages($mail->error, $mail->errors,
'warnings');
747 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
752 if ($action ==
'confirm_refuse' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoapprove) {
753 if (
GETPOST(
'detail_refuse')) {
759 $object->fk_user_refuse = $user->id;
766 $verif =
$object->update($user);
775 $destinataire =
new User($db);
776 $destinataire->fetch(
$object->fk_user);
777 $emailTo = $destinataire->email;
780 dol_syslog(
"User that request leave has no email, so we redirect directly to finished page without sending email");
783 $expediteur =
new User($db);
784 $expediteur->fetch(
$object->fk_validator);
794 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysRefused");
797 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
800 $message .=
"<p>".GETPOST(
'detail_refuse',
'alpha').
"</p>";
804 $message .=
"<ul>\n";
805 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
806 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
809 $trackid =
'leav'.$object->id;
813 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
816 $result = $mail->sendfile();
819 setEventMessages($mail->error, $mail->errors,
'warnings');
830 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
838 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DetailRefusCP")),
null,
'errors');
844 if ($action ==
'confirm_draft' &&
GETPOST(
'confirm') ==
'yes' && $permissiontoadd) {
853 $result =
$object->update($user);
856 setEventMessages($langs->trans(
'ErrorBackToDraft').
' '.
$object->error,
$object->errors,
'errors');
862 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
870 if ($action ==
'confirm_cancel' &&
GETPOST(
'confirm') ==
'yes') {
877 ($user->id ==
$object->fk_validator || $permissiontoadd || $permissiontoaddall || $permissiontoapprove)) {
882 $object->fk_user_cancel = $user->id;
888 $result =
$object->update($user);
892 $result =
$object->call_trigger(
'HOLIDAY_CANCEL', $user);
897 $startDate =
$object->date_debut_gmt;
898 $endDate =
$object->date_fin_gmt;
900 if (!empty($decrease)) {
902 $date = strtotime(
'-1 month', $lastUpdate);
903 $endOfMonthBeforeLastUpdate =
dol_mktime(0, 0, 0, (
int)
date(
'm', $date), (
int)
date(
't', $date), (
int)
date(
'Y', $date), 1);
904 if (
$object->date_debut_gmt < $endOfMonthBeforeLastUpdate &&
$object->date_fin_gmt > $endOfMonthBeforeLastUpdate) {
905 $endDate = $endOfMonthBeforeLastUpdate;
906 } elseif (
$object->date_debut_gmt > $endOfMonthBeforeLastUpdate) {
907 $endDate = $startDate;
911 $tmpUser =
new User($db);
912 $tmpUser->fetch(
$object->fk_user);
918 $newSolde = ($soldeActuel + $nbopenedday);
921 $result1 =
$object->addLogCP($user->id,
$object->fk_user,
$object->ref.
' - '.$langs->transnoentitiesnoconv(
"HolidayCreditAfterCancellation"), $newSolde,
$object->fk_type);
926 if ($result1 < 0 || $result2 < 0) {
928 setEventMessages($langs->trans(
'ErrorCantDeleteCP').
' '.
$object->error,
$object->errors,
'errors');
939 if (!$error && $result > 0) {
941 $destinataire =
new User($db);
942 $destinataire->fetch(
$object->fk_user);
943 $emailTo = $destinataire->email;
946 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
951 $expediteur =
new User($db);
952 $expediteur->fetch(
$object->fk_user_cancel);
962 $subject = $societeName.
" - ".$langs->transnoentitiesnoconv(
"HolidaysCanceled");
965 $message =
"<p>".$langs->transnoentitiesnoconv(
"Hello").
" ".$destinataire->firstname.
",</p>\n";
971 $message .=
"<ul>\n";
972 $message .=
"<li>".$langs->transnoentitiesnoconv(
"ModifiedBy").
" : ".
dolGetFirstLastname($expediteur->firstname, $expediteur->lastname).
"</li>\n";
973 $message .=
"<li>".$langs->transnoentitiesnoconv(
"Link").
' : <a href="'.$link.
'" target="_blank">'.$link.
"</a></li>\n";
974 $message .=
"</ul>\n";
976 $trackid =
'leav'.$object->id;
980 $mail =
new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(),
'', $sendtobcc, 0, 1,
'',
'', $trackid);
983 $result = $mail->sendfile();
986 setEventMessages($mail->error, $mail->errors,
'warnings');
989 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1019$form =
new Form($db);
1023$listhalfday = array(
'morning' => $langs->trans(
"Morning"),
"afternoon" => $langs->trans(
"Afternoon"));
1025$title = $langs->trans(
'Leave');
1026$help_url =
'EN:Module_Holiday';
1028llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-card');
1032if ((empty($id) && empty($ref)) || $action ==
'create' || $action ==
'add') {
1034 if ((in_array($fuserid, $childids) && !$user->hasRight(
'holiday',
'write')) || (!in_array($fuserid, $childids) && ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'holiday',
'writeall') || !$user->hasRight(
'holiday',
'writeall'))))) {
1035 $errors[] = $langs->trans(
'CantCreateCP');
1044 $errors[] = $langs->trans(
'ErrorEndDateCP');
1047 $errors[] = $langs->trans(
'ErrorSQLCreateCP');
1050 $errors[] = $langs->trans(
'CantCreateCP');
1053 $errors[] = $langs->trans(
'InvalidValidatorCP');
1056 $errors[] = $langs->trans(
'NoDateDebut');
1059 $errors[] = $langs->trans(
'NoDateFin');
1061 case 'DureeHoliday':
1062 $errors[] = $langs->trans(
'ErrorDureeCP');
1065 $errors[] = $langs->trans(
'alreadyCPexist');
1069 setEventMessages(
null, $errors,
'errors');
1073 print
'<script type="text/javascript">
1074 $( document ).ready(function() {
1075 $("input.button-save").click("submit", function(e) {
1076 console.log("Call valider()");
1077 if (document.demandeCP.date_debut_.value != "")
1079 if(document.demandeCP.date_fin_.value != "")
1081 if(document.demandeCP.valideur.value != "-1") {
1085 alert(\''.dol_escape_js($langs->transnoentities(
'InvalidValidatorCP')).
'\');
1091 alert(\
''.
dol_escape_js($langs->transnoentities(
'NoDateFin')).
'\');
1097 alert(\
''.
dol_escape_js($langs->transnoentities(
'NoDateDebut')).
'\');
1105 // Leave request form
1106 print '<form method=
"POST" action=
"'.$_SERVER['PHP_SELF'].'" name=
"demandeCP">
'."\n";
1107 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'" />
'."\n";
1108 print '<input
type=
"hidden" name=
"action" value=
"add" />
'."\n";
1110 print dol_get_fiche_head();
1112 //print '<span>
'.$langs->trans('DelayToRequestCP
',$object->getConfCP('delayForRequest
')).'</span><br><br>
';
1114 print '<
table class=
"border centpercent">
';
1117 // User for leave request
1119 print '<td
class=
"titlefield fieldrequired tdtop">
'.$langs->trans("User").'</td>
';
1120 print '<td><div
class=
"inline-block">
';
1121 if ($permissiontoadd && !$permissiontoaddall) {
1122 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid
', 0, null, 0, 'hierarchyme
', '', '0,
'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500
inline-block
');
1123 //print '<input
type=
"hidden" name=
"fuserid" value=
"'.($fuserid?$fuserid:$user->id).'">
';
1125 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid
', 0, null, 0, '', '', '0,
'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500
inline-block
');
1129 if (!getDolGlobalString('HOLIDAY_HIDE_BALANCE
')) {
1130 print '<div
class=
"leaveuserbalance paddingtop inline-block floatright badge badge-status0 badge-status margintoponsmartphone">
';
1134 $typeleaves = $object->getTypes(1, 1);
1135 foreach ($typeleaves as $key => $val) {
1136 $nb_type = $object->getCPforUser(($fuserid ? $fuserid : $user->id), $val['rowid
']);
1137 $nb_holiday += $nb_type;
1139 $out .= ' -
'.($langs->trans($val['code
']) != $val['code
'] ? $langs->trans($val['code
']) : $val['label
']).': <strong>
'.($nb_type ? price2num($nb_type) : 0).'</strong>
';
1140 if ($val['newbymonth
'] > 0) {
1141 $out .= ' <span
class=
"opacitymedium">+
'.$val['newbymonth
'].' /
'.$langs->trans("Month").'</span>
';
1146 print '
';
1148 $htmltooltip = $langs->trans("Detail").'<br>
';
1149 $htmltooltip .= $out;
1151 print $form->textwithtooltip($langs->trans('SoldeCPUser
', (string) round($nb_holiday, 5)).' '.img_picto('', 'help
'), $htmltooltip);
1154 if (!empty($conf->use_javascript_ajax)) {
1156 print '$( document ).ready(
function() {
1157 jQuery(
"#fuserid").change(
function() {
1158 console.log(
"We change to user id "+jQuery(
"#fuserid").val());
1159 if (jQuery(
"#fuserid").val() ==
'.((int) $user->id).') {
1160 jQuery(
".leaveuserbalance").show();
1162 jQuery(
".leaveuserbalance").hide();
1168 } elseif (!is_numeric(getDolGlobalString('HOLIDAY_HIDE_BALANCE
'))) {
1169 print '<div
class=
"leaveuserbalance paddingtop">
';
1170 print $langs->trans(getDolGlobalString('HOLIDAY_HIDE_BALANCE
'));
1179 print '<td
class=
"fieldrequired">
'.$langs->trans("Type").'</td>
';
1181 $typeleaves = $object->getTypes(1, -1);
1182 $arraytypeleaves = array();
1183 foreach ($typeleaves as $key => $val) {
1184 $labeltoshow = ($langs->trans($val['code
']) != $val['code
'] ? $langs->trans($val['code
']) : $val['label
']);
1185 $labeltoshow .= ($val['delay
'] > 0 ? ' (
'.$langs->trans("NoticePeriod").':
'.$val['delay
'].' '.$langs->trans("days").')
' : '');
1186 $arraytypeleaves[$val['rowid
']] = $labeltoshow;
1188 if (empty($typeleaves)) {
1189 print $langs->trans("PleaseDefineSomeTypeOfHolidayFirst");
1191 print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha
') ? GETPOST('type', 'alpha
') : ''), 1, 0, 0, '', 0, 0, 0, '', '', 1);
1193 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1201 print '<td
class=
"fieldrequired">
';
1202 print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday"));
1204 print '<td>
'.img_picto('', 'action
', 'class=
"pictofixedwidth"');
1205 if (!GETPOST('date_debut_
')) { // If visitor does not come from agenda
1206 print $form->selectDate(-1, 'date_debut_
', 0, 0, 0, '', 1, 1);
1208 $tmpdate = GETPOSTDATE('date_debut_
', '00:00:00
');
1209 print $form->selectDate($tmpdate, 'date_debut_
', 0, 0, 0, '', 1, 1);
1211 print '
';
1212 print $form->selectarray('starthalfday
', $listhalfday, (GETPOST('starthalfday
', 'alpha
') ? GETPOST('starthalfday
', 'alpha
') : 'morning
'));
1218 print '<td
class=
"fieldrequired">
';
1219 print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday"));
1221 print '<td>
'.img_picto('', 'action
', 'class=
"pictofixedwidth"');
1222 if (!GETPOST('date_fin_
')) {
1223 print $form->selectDate(-1, 'date_fin_
', 0, 0, 0, '', 1, 1);
1225 $tmpdate = GETPOSTDATE('date_fin_
', '00:00:00
');
1226 print $form->selectDate($tmpdate, 'date_fin_
', 0, 0, 0, '', 1, 1);
1228 print '
';
1229 print $form->selectarray('endhalfday
', $listhalfday, (GETPOST('endhalfday
', 'alpha
') ? GETPOST('endhalfday
', 'alpha
') : 'afternoon
'));
1235 print '<td
class=
"fieldrequired">
'.$langs->trans("ReviewedByCP").'</td>
';
1238 $object = new Holiday($db);
1239 $include_users = $object->fetch_users_approver_holiday();
1240 if (empty($include_users)) {
1241 print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
1243 // Defined default approver (the forced approver of edited user or the supervisor of user if no forced value defined)
1244 // Note: This user will be set only if the defined approver has permission to approve so is inside include_users
1245 $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
1246 if ($fuserid != $user->id) {
1247 $fuser = new User($db);
1248 $fuser->fetch($fuserid);
1249 $defaultselectuser = (empty($fuser->fk_user_holiday_validator) ? $fuser->fk_user : $fuser->fk_user_holiday_validator);
1252 if (getDolGlobalString('HOLIDAY_DEFAULT_VALIDATOR
')) {
1253 $defaultselectuser = getDolGlobalString('HOLIDAY_DEFAULT_VALIDATOR
'); // Can force default approver
1255 if (GETPOSTINT('valideur
') > 0) {
1256 $defaultselectuser = GETPOSTINT('valideur
');
1258 $s = $form->select_dolusers($defaultselectuser, "valideur", 1, null, 0, $include_users, '', '0,
'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500
');
1259 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
1262 //print $form->select_dolusers((GETPOST('valideur
','int')>0?GETPOST('valideur
','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent
1268 print '<td>
'.$langs->trans("DescCP").'</td>
';
1269 print '<td
class=
"tdtop">
';
1270 $doleditor = new DolEditor('description', GETPOST('description', 'restricthtml
'), '', 80, 'dolibarr_notes
', 'In
', false, false, isModEnabled('fckeditor
'), ROWS_3, '90%
');
1271 print $doleditor->Create(1);
1275 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php
';
1280 print dol_get_fiche_end();
1282 print $form->buttonsSaveCancel("SendRequestCP");
1284 print '</from>
'."\n";
1287 if ($error && $action != 'edit
') {
1288 print '<div
class=
"tabBar">
';
1289 print '<br><br><input
type=
"button" value=
"'.$langs->trans("ReturnCP
").'" class=
"button" onclick=
"history.go(-1)" />
';
1292 // Show page in view or edit mode
1293 if (($id > 0) || $ref) {
1294 $result = $object->fetch($id, $ref);
1296 $approverexpected = new User($db);
1297 $approverexpected->fetch($object->fk_validator); // Use that should be the approver
1299 $userRequest = new User($db);
1300 $userRequest->fetch($object->fk_user);
1302 //print load_fiche_titre($langs->trans('TitreRequestCP
'));
1304 // Si il y a une erreur
1305 if (GETPOST('error
')) {
1306 switch (GETPOST('error
')) {
1308 $errors[] = $langs->transnoentitiesnoconv('ErrorEndDateCP
');
1311 $errors[] = $langs->transnoentitiesnoconv('ErrorSQLCreateCP
');
1314 $errors[] = $langs->transnoentitiesnoconv('CantCreateCP
');
1317 $errors[] = $langs->transnoentitiesnoconv('InvalidValidatorCP
');
1320 $errors[] = $langs->transnoentitiesnoconv('NoDateDebut
');
1323 $errors[] = $langs->transnoentitiesnoconv('NoDateFin
');
1325 case 'DureeHoliday
':
1326 $errors[] = $langs->transnoentitiesnoconv('ErrorDureeCP
');
1328 case 'NoMotifRefuse
':
1329 $errors[] = $langs->transnoentitiesnoconv('NoMotifRefuseCP
');
1332 $errors[] = $langs->transnoentitiesnoconv('ErrorMailNotSend
');
1336 setEventMessages(null, $errors, 'errors
');
1339 // check if the user has the right to read this request
1341 $head = holiday_prepare_head($object);
1343 $editmode = (($action == 'edit
' && $object->status == Holiday::STATUS_DRAFT) || ($action == 'editvalidator
'));
1346 if ($action == 'edit
' && $object->status == Holiday::STATUS_DRAFT) {
1350 print '<form method=
"post" action=
"'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">
'."\n";
1351 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'" />
'."\n";
1352 print '<input
type=
"hidden" name=
"action" value=
"update"/>
'."\n";
1353 print '<input
type=
"hidden" name=
"id" value=
"'.$object->id.'" />
'."\n";
1356 // No drop area in edit mode: these tabs are printed inside the edit form, and dropping a file
1357 // reloads the page, which would discard what the user is typing.
1358 print dol_get_fiche_head($head, 'card
', $langs->trans("CPTitreMenu"), -1, 'holiday
', 0, '', '', 0, '', ($editmode ? 0 : 1));
1360 $linkback = '<a href=
"'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1">
'.$langs->trans("BackToList").'</a>
';
1362 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
1365 print '<div
class=
"fichecenter">
';
1366 print '<div
class=
"fichehalfleft">
';
1367 print '<div
class=
"underbanner clearboth"></div>
';
1369 print '<
table class=
"border tableforfield centpercent">
';
1374 print '<td
class=
"titlefield">
'.$langs->trans("User").'</td>
';
1376 print $userRequest->getNomUrl(-1, 'leave
');
1381 print '<td>
'.$langs->trans("Type").'</td>
';
1383 $typeleaves = $object->getTypes(1, -1);
1384 if (empty($typeleaves[$object->fk_type])) {
1385 $labeltoshow = $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type);
1387 $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
']);
1393 $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon
' : 'morning
';
1394 $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning
' : 'afternoon
';
1398 print '<td
class=
"nowrap">
';
1399 print $form->textwithpicto($langs->trans('DateDebCP
'), $langs->trans("FirstDayOfHoliday"));
1401 print '<td>
'.dol_print_date($object->date_debut, 'day
');
1402 print '
';
1403 print '<span
class=
"opacitymedium">
'.$langs->trans($listhalfday[$starthalfday]).'</span>
';
1408 print '<td
class=
"nowrap">
';
1409 print $form->textwithpicto($langs->trans('DateDebCP
'), $langs->trans("FirstDayOfHoliday"));
1412 $tmpdate = GETPOSTDATE('date_debut_
', '00:00:00
');
1413 print $form->selectDate($tmpdate ? $tmpdate : $object->date_debut, 'date_debut_
');
1414 print '
';
1415 print $form->selectarray('starthalfday
', $listhalfday, (GETPOST('starthalfday
') ? GETPOST('starthalfday
') : $starthalfday));
1422 print '<td
class=
"nowrap">
';
1423 print $form->textwithpicto($langs->trans('DateFinCP
'), $langs->trans("LastDayOfHoliday"));
1425 print '<td>
'.dol_print_date($object->date_fin, 'day
');
1426 print '
';
1427 print '<span
class=
"opacitymedium">
'.$langs->trans($listhalfday[$endhalfday]).'</span>
';
1432 print '<td
class=
"nowrap">
';
1433 print $form->textwithpicto($langs->trans('DateFinCP
'), $langs->trans("LastDayOfHoliday"));
1436 print $form->selectDate($object->date_fin, 'date_fin_
');
1437 print '
';
1438 print $form->selectarray('endhalfday
', $listhalfday, (GETPOST('endhalfday
') ? GETPOST('endhalfday
') : $endhalfday));
1446 $htmlhelp = $langs->trans('NbUseDaysCPHelp
');
1447 $includesaturday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY
', 1);
1448 $includesunday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY
', 1);
1449 if ($includesaturday) {
1450 $htmlhelp .= '<br>
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
1452 if ($includesunday) {
1453 $htmlhelp .= '<br>
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
1455 print $form->textwithpicto($langs->trans('NbUseDaysCP
'), $htmlhelp);
1458 print num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, (int) $object->halfday, $userRequest->country_id, $object->fk_user);
1462 if ($object->status == Holiday::STATUS_REFUSED) {
1464 print '<td>
'.$langs->trans('DetailRefusCP
').'</td>
';
1465 print '<td>
'.$object->detail_refuse.'</td>
';
1472 print '<td>
'.$langs->trans('DescCP
').'</td>
';
1473 print '<td>
'.nl2br($object->description).'</td>
';
1477 print '<td>
'.$langs->trans('DescCP
').'</td>
';
1478 print '<td
class=
"tdtop">
';
1479 $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_notes
', 'In
', false, false, isModEnabled('fckeditor
'), ROWS_3, '90%
');
1480 print $doleditor->Create(1);
1485 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
1488 print '</
table>
'."\n";
1491 print '<div
class=
"fichehalfright">
';
1493 print '<div
class=
"underbanner clearboth"></div>
';
1496 print '<
table class=
"border tableforfield centpercent">
'."\n";
1499 if (!empty($object->fk_user_create)) {
1500 $userCreate = new User($db);
1501 $userCreate->fetch($object->fk_user_create);
1503 print '<td
class=
"titlefield">
'.$langs->trans('RequestByCP
').'</td>
';
1504 print '<td>
'.$userCreate->getNomUrl(-1).'</td>
';
1509 if (!$edit && $action != 'editvalidator
') {
1511 print '<td
class=
"titlefield">
';
1512 if ($object->status == Holiday::STATUS_APPROVED || $object->status == Holiday::STATUS_CANCELED) {
1513 print $langs->trans('ApprovedBy
');
1515 print $langs->trans('ReviewedByCP
');
1519 if ($object->status == Holiday::STATUS_APPROVED || $object->status == Holiday::STATUS_CANCELED) {
1520 if ($object->fk_user_approve > 0) {
1521 $approverdone = new User($db);
1522 $approverdone->fetch($object->fk_user_approve);
1523 print $approverdone->getNomUrl(-1);
1526 print $approverexpected->getNomUrl(-1);
1528 $include_users = $object->fetch_users_approver_holiday();
1529 if (is_array($include_users) && in_array($user->id, $include_users) && $object->status == Holiday::STATUS_VALIDATED) {
1530 print '<a
class=
"editfielda paddingleft" href=
"'.$_SERVER["PHP_SELF
"].'?id='.$object->id.'&action=editvalidator">
'.img_edit($langs->trans("Edit")).'</a>
';
1536 print '<td
class=
"titlefield">
'.$langs->trans('ReviewedByCP
').'</td>
'; // Will be approved by
1538 $include_users = $object->fetch_users_approver_holiday();
1539 if (!in_array($object->fk_validator, $include_users)) { // Add the current validator to the list to not lose it when editing.
1540 $include_users[] = $object->fk_validator;
1542 if (empty($include_users)) {
1543 print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
1545 $arrayofvalidatorstoexclude = (($user->admin || ($user->id != $userRequest->id)) ? '' : array($user->id)); // We exclude ourself from validator list. Not if we are admin or if we are on the leave of someone else
1546 $s = $form->select_dolusers($object->fk_validator, "valideur", (($action == 'editvalidator
') ? 0 : 1), $arrayofvalidatorstoexclude, 0, $include_users);
1547 print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
1549 if ($action == 'editvalidator
') {
1550 print '<input
type=
"submit" class=
"button button-save" name=
"savevalidator" value=
"'.$langs->trans("Save
").'">
';
1551 print '<input
type=
"submit" class=
"button button-cancel" name=
"cancel" value=
"'.$langs->trans("Cancel
").'">
';
1558 print '<td>
'.$langs->trans('DateCreation
').'</td>
';
1559 print '<td>
'.dol_print_date($object->date_create, 'dayhour
', 'tzuser
').'</td>
';
1561 if ($object->status == Holiday::STATUS_APPROVED || $object->status == Holiday::STATUS_CANCELED) {
1563 print '<td>
'.$langs->trans('DateValidCP
').'</td>
';
1564 print '<td>
'.dol_print_date($object->date_approval, 'dayhour
', 'tzuser
').'</td>
'; // warning: date_valid is approval date on holiday module
1567 if ($object->status == Holiday::STATUS_CANCELED) {
1569 print '<td>
'.$langs->trans('DateCancelCP
').'</td>
';
1570 print '<td>
'.dol_print_date($object->date_cancel, 'dayhour
', 'tzuser
').'</td>
';
1573 if ($object->status == Holiday::STATUS_REFUSED) {
1575 print '<td>
'.$langs->trans('DateRefusCP
').'</td>
';
1576 print '<td>
'.dol_print_date($object->date_refuse, 'dayhour
', 'tzuser
').'</td>
';
1585 print '<div
class=
"clearboth"></div>
';
1587 print dol_get_fiche_end();
1590 // Confirmation messages
1591 if ($action == 'delete') {
1593 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleDeleteCP"), $langs->trans("ConfirmDeleteCP"), "confirm_delete", '', 0, 1);
1597 // Si envoi en validation
1598 if ($action == 'sendToValidate
' && $object->status == Holiday::STATUS_DRAFT) {
1599 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleToValidCP"), $langs->trans("ConfirmToValidCP"), "confirm_send", '', 1, 1);
1602 // If validating the request
1603 if ($action == 'valid
') {
1604 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleValidCP"), $langs->trans("ConfirmValidCP"), "confirm_valid", '', 1, 1);
1607 // If refusing the request
1608 if ($action == 'refuse
') {
1609 $array_input = array(array('type' => "text", 'label
' => $langs->trans('DetailRefusCP
'), 'name' => "detail_refuse", 'size
' => "50", 'value
' => ""));
1610 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP
'), "confirm_refuse", $array_input, 1, 0);
1613 // If cancelling the request
1614 if ($action == 'cancel
') {
1615 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleCancelCP"), $langs->trans("ConfirmCancelCP"), "confirm_cancel", '', 1, 1);
1619 if ($action == 'backtodraft
') {
1620 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleSetToDraft"), $langs->trans("ConfirmSetToDraft"), "confirm_draft", '', 1, 1);
1623 if (($action == 'edit
' && $object->status == Holiday::STATUS_DRAFT) || ($action == 'editvalidator
')) {
1624 if ($action == 'edit
' && $object->status == Holiday::STATUS_DRAFT) {
1625 if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) {
1626 print $form->buttonsSaveCancel();
1634 // Buttons for actions
1636 print '<div
class=
"tabsAction">
';
1638 if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) {
1639 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?id='.$object->id.'&action=edit&token='.newToken().'" class=
"butAction">
'.$langs->trans("EditCP").'</a>
';
1642 if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) { // If draft
1643 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?id='.$object->id.'&action=sendToValidate&token='.newToken().'" class=
"butAction">
'.$langs->trans("Validate").'</a>
';
1646 if ($object->status == Holiday::STATUS_VALIDATED) { // If validated
1647 // Button Approve / Refuse
1648 if (($user->id == $object->fk_validator || $permissiontoaddall) && $permissiontoapprove) {
1649 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?id='.$object->id.'&action=valid&token='.newToken().'" class=
"butAction">
'.$langs->trans("Approve").'</a>
';
1650 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?id='.$object->id.'&action=refuse&token='.newToken().'" class=
"butAction">
'.$langs->trans("ActionRefuseCP").'</a>
';
1652 print '<a href=
"#" class=
"butActionRefused classfortooltip" title=
"'.$langs->trans("NotTheAssignedApprover
").'">
'.$langs->trans("Approve").'</a>
';
1653 print '<a href=
"#" class=
"butActionRefused classfortooltip" title=
"'.$langs->trans("NotTheAssignedApprover
").'">
'.$langs->trans("ActionRefuseCP").'</a>
';
1655 // Button Cancel (because we can't approve)
1656 if ($permissiontoadd || $permissiontoaddall) {
1658 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1660 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
' - '.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1666 if ($user->id ==
$object->fk_validator || $user->id ==
$object->fk_user_approve || $permissiontoadd || $permissiontoaddall || $permissiontoapprove) {
1667 if (((
$object->date_fin >
dol_now()) && $permissiontoapprove) || $user->id ==
$object->fk_user_approve) {
1668 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1671 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'" class="butAction">'.$langs->trans(
"ActionCancelCP").
'</a>';
1673 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"HolidayStarted").
' - '.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1677 print
'<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ActionCancelCP").
'</a>';
1682 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=backtodraft" class="butAction">'.$langs->trans(
"SetToDraft").
'</a>';
1685 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$langs->trans(
"DeleteCP").
'</a>';
1691 print
'<div class="tabBar">';
1692 print $langs->trans(
'ErrorUserViewCP');
1693 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1697 print
'<div class="tabBar">';
1698 print $langs->trans(
'ErrorIDFicheCP');
1699 print
'<br><br><input type="button" value="'.$langs->trans(
"ReturnCP").
'" class="button" onclick="history.go(-1)" />';
1705 if (
GETPOST(
'modelselected')) {
1706 $action =
'presend';
1709 if ($action !=
'presend' && $action !=
'edit') {
1710 print
'<div class="fichecenter"><div class="fichehalfleft">';
1711 print
'<a name="builddoc"></a>';
1730 print
'</div><div class="fichehalfright">';
1734 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/holiday/holiday_agenda.php?id='.
$object->id);
1737 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1739 $somethingshown = $formactions->showactions($object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1741 print
'</div></div>';
1749if (is_object($db)) {
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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 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, $countryCodeOrId='', $user_id=0)
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.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='gmt')
Return date for now.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
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...
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
treeview li table
No Email.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
$conf db user
Active Directory does not allow anonymous connections.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.