29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'holiday';
45 public $table_element =
'holiday';
50 public $fk_element =
'fk_holiday';
55 public $picto =
'holiday';
65 public $date_create =
'';
75 public $date_debut =
'';
80 public $date_fin =
'';
85 public $date_debut_gmt =
'';
90 public $date_fin_gmt =
'';
106 public $fk_validator;
111 public $date_valid = 0;
116 public $fk_user_valid;
121 public $date_approval;
126 public $fk_user_approve;
131 public $date_refuse = 0;
136 public $fk_user_refuse;
141 public $date_cancel = 0;
146 public $fk_user_cancel;
151 public $fk_user_create;
156 public $detail_refuse =
'';
163 public $holiday = array();
164 public $events = array();
165 public $logs = array();
171 public $optName =
'';
175 public $optValue =
'';
179 public $optRowid = 0;
212 $this->ismultientitymanaged = 0;
225 global $langs,
$conf;
226 $langs->load(
"order");
229 $conf->global->HOLIDAY_ADDON =
'mod_holiday_madonna';
239 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
240 foreach ($dirmodels as $reldir) {
244 $mybool = ((bool) @include_once $dir.$file) || $mybool;
252 $obj =
new $classname();
253 '@phan-var-force ModelNumRefHolidays $obj';
254 $numref = $obj->getNextValue($objsoc, $this);
259 $this->error = $obj->error;
264 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_HOLIDAY_ADDON_NotDefined");
288 $this->db->rollback();
300 public function create($user, $notrigger = 0)
308 if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) {
309 $this->error =
"ErrorBadParameterFkUser";
312 if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) {
313 $this->error =
"ErrorBadParameterFkValidator";
316 if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) {
317 $this->error =
"ErrorBadParameterFkType";
322 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday(";
325 $sql .=
"date_create,";
326 $sql .=
"description,";
327 $sql .=
"date_debut,";
331 $sql .=
"fk_validator,";
333 $sql .=
"fk_user_create,";
335 $sql .=
") VALUES (";
337 $sql .=
" ".((int) $this->fk_user).
",";
338 $sql .=
" '".$this->db->idate($now).
"',";
339 $sql .=
" '".$this->db->escape($this->
description).
"',";
340 $sql .=
" '".$this->db->idate($this->date_debut).
"',";
341 $sql .=
" '".$this->db->idate($this->date_fin).
"',";
342 $sql .=
" ".((int) $this->halfday).
",";
344 $sql .=
" ".((int) $this->fk_validator).
",";
345 $sql .=
" ".((int) $this->fk_type).
",";
346 $sql .=
" ".((int) $user->id).
",";
347 $sql .=
" ".((int)
$conf->entity);
352 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
353 $resql = $this->db->query($sql);
356 $this->errors[] =
"Error ".$this->db->lasterror();
360 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"holiday");
364 $initialref =
'(PROV'.$this->id.
')';
365 if (!empty($this->
ref)) {
366 $initialref = $this->ref;
369 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"holiday SET ref='".$this->db->escape($initialref).
"' WHERE rowid=".((int) $this->
id);
370 if ($this->db->query($sql)) {
371 $this->
ref = $initialref;
380 if (!$error && !$notrigger) {
394 foreach ($this->errors as $errmsg) {
395 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
396 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
398 $this->db->rollback();
414 public function fetch($id, $ref =
'')
417 $sql .=
" cp.rowid,";
419 $sql .=
" cp.fk_user,";
420 $sql .=
" cp.date_create,";
421 $sql .=
" cp.description,";
422 $sql .=
" cp.date_debut,";
423 $sql .=
" cp.date_fin,";
424 $sql .=
" cp.halfday,";
425 $sql .=
" cp.statut as status,";
426 $sql .=
" cp.fk_validator,";
427 $sql .=
" cp.date_valid,";
428 $sql .=
" cp.fk_user_valid,";
429 $sql .=
" cp.date_approval,";
430 $sql .=
" cp.fk_user_approve,";
431 $sql .=
" cp.date_refuse,";
432 $sql .=
" cp.fk_user_refuse,";
433 $sql .=
" cp.date_cancel,";
434 $sql .=
" cp.fk_user_cancel,";
435 $sql .=
" cp.detail_refuse,";
436 $sql .=
" cp.note_private,";
437 $sql .=
" cp.note_public,";
438 $sql .=
" cp.fk_user_create,";
439 $sql .=
" cp.fk_type,";
440 $sql .=
" cp.entity";
441 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp";
443 $sql .=
" WHERE cp.rowid = ".((int) $id);
445 $sql .=
" WHERE cp.ref = '".$this->db->escape($ref).
"'";
448 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
449 $resql = $this->db->query($sql);
451 if ($this->db->num_rows($resql)) {
452 $obj = $this->db->fetch_object($resql);
454 $this->
id = $obj->rowid;
455 $this->
ref = ($obj->ref ? $obj->ref : $obj->rowid);
456 $this->fk_user = $obj->fk_user;
457 $this->date_create = $this->db->jdate($obj->date_create);
459 $this->date_debut = $this->db->jdate($obj->date_debut);
460 $this->date_fin = $this->db->jdate($obj->date_fin);
461 $this->date_debut_gmt = $this->db->jdate($obj->date_debut, 1);
462 $this->date_fin_gmt = $this->db->jdate($obj->date_fin, 1);
463 $this->halfday = $obj->halfday;
464 $this->
status = $obj->status;
465 $this->statut = $obj->status;
466 $this->fk_validator = $obj->fk_validator;
467 $this->date_valid = $this->db->jdate($obj->date_valid);
468 $this->fk_user_valid = $obj->fk_user_valid;
469 $this->user_validation_id = $obj->fk_user_valid;
470 $this->date_approval = $this->db->jdate($obj->date_approval);
471 $this->fk_user_approve = $obj->fk_user_approve;
472 $this->date_refuse = $this->db->jdate($obj->date_refuse);
473 $this->fk_user_refuse = $obj->fk_user_refuse;
474 $this->date_cancel = $this->db->jdate($obj->date_cancel);
475 $this->fk_user_cancel = $obj->fk_user_cancel;
476 $this->detail_refuse = $obj->detail_refuse;
477 $this->note_private = $obj->note_private;
478 $this->note_public = $obj->note_public;
479 $this->fk_user_create = $obj->fk_user_create;
480 $this->fk_type = $obj->fk_type;
481 $this->entity = $obj->entity;
489 $this->db->free($resql);
493 $this->error =
"Error ".$this->db->lasterror();
510 $sql .=
" cp.rowid,";
513 $sql .=
" cp.fk_user,";
514 $sql .=
" cp.fk_type,";
515 $sql .=
" cp.date_create,";
516 $sql .=
" cp.description,";
517 $sql .=
" cp.date_debut,";
518 $sql .=
" cp.date_fin,";
519 $sql .=
" cp.halfday,";
520 $sql .=
" cp.statut as status,";
521 $sql .=
" cp.fk_validator,";
522 $sql .=
" cp.date_valid,";
523 $sql .=
" cp.fk_user_valid,";
524 $sql .=
" cp.date_approval,";
525 $sql .=
" cp.fk_user_approve,";
526 $sql .=
" cp.date_refuse,";
527 $sql .=
" cp.fk_user_refuse,";
528 $sql .=
" cp.date_cancel,";
529 $sql .=
" cp.fk_user_cancel,";
530 $sql .=
" cp.detail_refuse,";
532 $sql .=
" uu.lastname as user_lastname,";
533 $sql .=
" uu.firstname as user_firstname,";
534 $sql .=
" uu.login as user_login,";
535 $sql .=
" uu.statut as user_status,";
536 $sql .=
" uu.photo as user_photo,";
538 $sql .=
" ua.lastname as validator_lastname,";
539 $sql .=
" ua.firstname as validator_firstname,";
540 $sql .=
" ua.login as validator_login,";
541 $sql .=
" ua.statut as validator_status,";
542 $sql .=
" ua.photo as validator_photo";
544 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp, ".MAIN_DB_PREFIX.
"user as uu, ".MAIN_DB_PREFIX.
"user as ua";
545 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
546 $sql .=
" AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid";
547 $sql .=
" AND cp.fk_user IN (".$this->db->sanitize($user_id).
")";
550 if (!empty($filter)) {
555 if (!empty($order)) {
559 dol_syslog(get_class($this).
"::fetchByUser", LOG_DEBUG);
560 $resql = $this->db->query($sql);
565 $tab_result = $this->holiday;
566 $num = $this->db->num_rows($resql);
575 $obj = $this->db->fetch_object($resql);
577 $tab_result[$i][
'rowid'] = $obj->rowid;
578 $tab_result[$i][
'id'] = $obj->rowid;
579 $tab_result[$i][
'ref'] = ($obj->ref ? $obj->ref : $obj->rowid);
581 $tab_result[$i][
'fk_user'] = $obj->fk_user;
582 $tab_result[$i][
'fk_type'] = $obj->fk_type;
583 $tab_result[$i][
'date_create'] = $this->db->jdate($obj->date_create);
584 $tab_result[$i][
'description'] = $obj->description;
585 $tab_result[$i][
'date_debut'] = $this->db->jdate($obj->date_debut);
586 $tab_result[$i][
'date_fin'] = $this->db->jdate($obj->date_fin);
587 $tab_result[$i][
'date_debut_gmt'] = $this->db->jdate($obj->date_debut, 1);
588 $tab_result[$i][
'date_fin_gmt'] = $this->db->jdate($obj->date_fin, 1);
589 $tab_result[$i][
'halfday'] = $obj->halfday;
590 $tab_result[$i][
'statut'] = $obj->status;
591 $tab_result[$i][
'status'] = $obj->status;
592 $tab_result[$i][
'fk_validator'] = $obj->fk_validator;
593 $tab_result[$i][
'date_valid'] = $this->db->jdate($obj->date_valid);
594 $tab_result[$i][
'fk_user_valid'] = $obj->fk_user_valid;
595 $tab_result[$i][
'date_approval'] = $this->db->jdate($obj->date_approval);
596 $tab_result[$i][
'fk_user_approve'] = $obj->fk_user_approve;
597 $tab_result[$i][
'date_refuse'] = $this->db->jdate($obj->date_refuse);
598 $tab_result[$i][
'fk_user_refuse'] = $obj->fk_user_refuse;
599 $tab_result[$i][
'date_cancel'] = $this->db->jdate($obj->date_cancel);
600 $tab_result[$i][
'fk_user_cancel'] = $obj->fk_user_cancel;
601 $tab_result[$i][
'detail_refuse'] = $obj->detail_refuse;
603 $tab_result[$i][
'user_firstname'] = $obj->user_firstname;
604 $tab_result[$i][
'user_lastname'] = $obj->user_lastname;
605 $tab_result[$i][
'user_login'] = $obj->user_login;
606 $tab_result[$i][
'user_statut'] = $obj->user_status;
607 $tab_result[$i][
'user_status'] = $obj->user_status;
608 $tab_result[$i][
'user_photo'] = $obj->user_photo;
610 $tab_result[$i][
'validator_firstname'] = $obj->validator_firstname;
611 $tab_result[$i][
'validator_lastname'] = $obj->validator_lastname;
612 $tab_result[$i][
'validator_login'] = $obj->validator_login;
613 $tab_result[$i][
'validator_statut'] = $obj->validator_status;
614 $tab_result[$i][
'validator_status'] = $obj->validator_status;
615 $tab_result[$i][
'validator_photo'] = $obj->validator_photo;
621 $this->holiday = $tab_result;
625 $this->error =
"Error ".$this->db->lasterror();
640 $sql .=
" cp.rowid,";
642 $sql .=
" cp.fk_user,";
643 $sql .=
" cp.fk_type,";
644 $sql .=
" cp.date_create,";
645 $sql .=
" cp.tms as date_modification,";
646 $sql .=
" cp.description,";
647 $sql .=
" cp.date_debut,";
648 $sql .=
" cp.date_fin,";
649 $sql .=
" cp.halfday,";
650 $sql .=
" cp.statut as status,";
651 $sql .=
" cp.fk_validator,";
652 $sql .=
" cp.date_valid,";
653 $sql .=
" cp.fk_user_valid,";
654 $sql .=
" cp.date_approval,";
655 $sql .=
" cp.fk_user_approve,";
656 $sql .=
" cp.date_refuse,";
657 $sql .=
" cp.fk_user_refuse,";
658 $sql .=
" cp.date_cancel,";
659 $sql .=
" cp.fk_user_cancel,";
660 $sql .=
" cp.detail_refuse,";
662 $sql .=
" uu.lastname as user_lastname,";
663 $sql .=
" uu.firstname as user_firstname,";
664 $sql .=
" uu.login as user_login,";
665 $sql .=
" uu.statut as user_status,";
666 $sql .=
" uu.photo as user_photo,";
668 $sql .=
" ua.lastname as validator_lastname,";
669 $sql .=
" ua.firstname as validator_firstname,";
670 $sql .=
" ua.login as validator_login,";
671 $sql .=
" ua.statut as validator_status,";
672 $sql .=
" ua.photo as validator_photo";
674 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp, ".MAIN_DB_PREFIX.
"user as uu, ".MAIN_DB_PREFIX.
"user as ua";
675 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
676 $sql .=
" AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid ";
679 if (!empty($filter)) {
684 if (!empty($order)) {
688 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
689 $resql = $this->db->query($sql);
694 $tab_result = $this->holiday;
695 $num = $this->db->num_rows($resql);
704 $obj = $this->db->fetch_object($resql);
706 $tab_result[$i][
'rowid'] = $obj->rowid;
707 $tab_result[$i][
'id'] = $obj->rowid;
708 $tab_result[$i][
'ref'] = ($obj->ref ? $obj->ref : $obj->rowid);
710 $tab_result[$i][
'fk_user'] = $obj->fk_user;
711 $tab_result[$i][
'fk_type'] = $obj->fk_type;
712 $tab_result[$i][
'date_create'] = $this->db->jdate($obj->date_create);
713 $tab_result[$i][
'date_modification'] = $this->db->jdate($obj->date_modification);
714 $tab_result[$i][
'description'] = $obj->description;
715 $tab_result[$i][
'date_debut'] = $this->db->jdate($obj->date_debut);
716 $tab_result[$i][
'date_fin'] = $this->db->jdate($obj->date_fin);
717 $tab_result[$i][
'date_debut_gmt'] = $this->db->jdate($obj->date_debut, 1);
718 $tab_result[$i][
'date_fin_gmt'] = $this->db->jdate($obj->date_fin, 1);
719 $tab_result[$i][
'halfday'] = $obj->halfday;
720 $tab_result[$i][
'statut'] = $obj->status;
721 $tab_result[$i][
'status'] = $obj->status;
722 $tab_result[$i][
'fk_validator'] = $obj->fk_validator;
723 $tab_result[$i][
'date_valid'] = $this->db->jdate($obj->date_valid);
724 $tab_result[$i][
'fk_user_valid'] = $obj->fk_user_valid;
725 $tab_result[$i][
'date_approval'] = $this->db->jdate($obj->date_approval);
726 $tab_result[$i][
'fk_user_approve'] = $obj->fk_user_approve;
727 $tab_result[$i][
'date_refuse'] = $obj->date_refuse;
728 $tab_result[$i][
'fk_user_refuse'] = $obj->fk_user_refuse;
729 $tab_result[$i][
'date_cancel'] = $obj->date_cancel;
730 $tab_result[$i][
'fk_user_cancel'] = $obj->fk_user_cancel;
731 $tab_result[$i][
'detail_refuse'] = $obj->detail_refuse;
733 $tab_result[$i][
'user_firstname'] = $obj->user_firstname;
734 $tab_result[$i][
'user_lastname'] = $obj->user_lastname;
735 $tab_result[$i][
'user_login'] = $obj->user_login;
736 $tab_result[$i][
'user_statut'] = $obj->user_status;
737 $tab_result[$i][
'user_status'] = $obj->user_status;
738 $tab_result[$i][
'user_photo'] = $obj->user_photo;
740 $tab_result[$i][
'validator_firstname'] = $obj->validator_firstname;
741 $tab_result[$i][
'validator_lastname'] = $obj->validator_lastname;
742 $tab_result[$i][
'validator_login'] = $obj->validator_login;
743 $tab_result[$i][
'validator_statut'] = $obj->validator_status;
744 $tab_result[$i][
'validator_status'] = $obj->validator_status;
745 $tab_result[$i][
'validator_photo'] = $obj->validator_photo;
750 $this->holiday = $tab_result;
754 $this->error =
"Error ".$this->db->lasterror();
767 public function validate($user =
null, $notrigger = 0)
769 global
$conf, $langs;
770 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
774 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
776 if ($checkBalance > 0) {
777 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
781 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
782 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
783 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1);
785 if (($balance - $daysAsked) < 0) {
786 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
792 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref) || $this->
ref == $this->
id)) {
800 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
801 $sql .=
" fk_user_valid = ".((int) $user->id).
",";
802 $sql .=
" date_valid = '".$this->db->idate(
dol_now()).
"',";
803 if (!empty($this->
status) && is_numeric($this->
status)) {
804 $sql .=
" statut = ".((int) $this->
status).
",";
806 $this->error =
'Property status must be a numeric value';
809 $sql .=
" ref = '".$this->db->escape($num).
"'";
810 $sql .=
" WHERE rowid = ".((int) $this->
id);
814 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
815 $resql = $this->db->query($sql);
818 $this->errors[] =
"Error ".$this->db->lasterror();
824 $result = $this->
call_trigger(
'HOLIDAY_VALIDATE', $user);
833 $this->oldref = $this->ref;
836 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
838 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
"ecm_files set filename = CONCAT('" . $this->db->escape($this->newref) .
"', SUBSTR(filename, " . (strlen($this->
ref) + 1) .
")), filepath = 'holiday/" . $this->db->escape($this->newref) .
"'";
839 $sql .=
" WHERE filename LIKE '" . $this->db->escape($this->
ref) .
"%' AND filepath = 'holiday/" . $this->db->escape($this->
ref) .
"' and entity = " . ((int)
$conf->entity);
840 $resql = $this->db->query($sql);
843 $this->error = $this->db->lasterror();
845 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'holiday/".$this->db->escape($this->newref).
"'";
846 $sql .=
" WHERE filepath = 'holiday/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
847 $resql = $this->db->query($sql);
850 $this->error = $this->db->lasterror();
856 $dirsource =
$conf->holiday->multidir_output[$this->entity] .
'/' . $oldref;
857 $dirdest =
$conf->holiday->multidir_output[$this->entity] .
'/' . $newref;
858 if (!$error && file_exists($dirsource)) {
859 dol_syslog(get_class($this) .
"::validate rename dir " . $dirsource .
" into " . $dirdest);
860 if (@rename($dirsource, $dirdest)) {
863 $listoffiles =
dol_dir_list($dirdest,
'files', 1,
'^' . preg_quote($oldref,
'/'));
864 foreach ($listoffiles as $fileentry) {
865 $dirsource = $fileentry[
'name'];
866 $dirdest = preg_replace(
'/^' . preg_quote($oldref,
'/') .
'/', $newref, $dirsource);
867 $dirsource = $fileentry[
'path'] .
'/' . $dirsource;
868 $dirdest = $fileentry[
'path'] .
'/' . $dirdest;
869 @rename($dirsource, $dirdest);
879 foreach ($this->errors as $errmsg) {
880 dol_syslog(get_class($this).
"::validate ".$errmsg, LOG_ERR);
881 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
883 $this->db->rollback();
899 public function approve($user =
null, $notrigger = 0)
903 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
905 if ($checkBalance > 0) {
906 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
910 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
911 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
912 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1);
914 if (($balance - $daysAsked) < 0) {
915 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
921 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
922 $sql .=
" description= '".$this->db->escape($this->
description).
"',";
923 if (!empty($this->date_debut)) {
924 $sql .=
" date_debut = '".$this->db->idate($this->date_debut).
"',";
928 if (!empty($this->date_fin)) {
929 $sql .=
" date_fin = '".$this->db->idate($this->date_fin).
"',";
933 $sql .=
" halfday = ".((int) $this->halfday).
",";
934 if (!empty($this->
status) && is_numeric($this->
status)) {
935 $sql .=
" statut = ".((int) $this->
status).
",";
939 if (!empty($this->fk_validator)) {
940 $sql .=
" fk_validator = ".((int) $this->fk_validator).
",";
944 if (!empty($this->date_valid)) {
945 $sql .=
" date_valid = '".$this->db->idate($this->date_valid).
"',";
947 $sql .=
" date_valid = NULL,";
949 if (!empty($this->fk_user_valid)) {
950 $sql .=
" fk_user_valid = ".((int) $this->fk_user_valid).
",";
952 $sql .=
" fk_user_valid = NULL,";
954 if (!empty($this->date_approval)) {
955 $sql .=
" date_approval = '".$this->db->idate($this->date_approval).
"',";
957 $sql .=
" date_approval = NULL,";
959 if (!empty($this->fk_user_approve)) {
960 $sql .=
" fk_user_approve = ".((int) $this->fk_user_approve).
",";
962 $sql .=
" fk_user_approve = NULL,";
964 if (!empty($this->date_refuse)) {
965 $sql .=
" date_refuse = '".$this->db->idate($this->date_refuse).
"',";
967 $sql .=
" date_refuse = NULL,";
969 if (!empty($this->fk_user_refuse)) {
970 $sql .=
" fk_user_refuse = ".((int) $this->fk_user_refuse).
",";
972 $sql .=
" fk_user_refuse = NULL,";
974 if (!empty($this->date_cancel)) {
975 $sql .=
" date_cancel = '".$this->db->idate($this->date_cancel).
"',";
977 $sql .=
" date_cancel = NULL,";
979 if (!empty($this->fk_user_cancel)) {
980 $sql .=
" fk_user_cancel = ".((int) $this->fk_user_cancel).
",";
982 $sql .=
" fk_user_cancel = NULL,";
984 if (!empty($this->detail_refuse)) {
985 $sql .=
" detail_refuse = '".$this->db->escape($this->detail_refuse).
"'";
987 $sql .=
" detail_refuse = NULL";
989 $sql .=
" WHERE rowid = ".((int) $this->
id);
993 dol_syslog(get_class($this).
"::approve", LOG_DEBUG);
994 $resql = $this->db->query($sql);
997 $this->errors[] =
"Error ".$this->db->lasterror();
1003 $result = $this->
call_trigger(
'HOLIDAY_APPROVE', $user);
1013 foreach ($this->errors as $errmsg) {
1014 dol_syslog(get_class($this).
"::approve ".$errmsg, LOG_ERR);
1015 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1017 $this->db->rollback();
1020 $this->db->commit();
1032 public function update($user =
null, $notrigger = 0)
1034 global
$conf, $langs;
1037 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
1039 if ($checkBalance > 0 && $this->statut != self::STATUS_DRAFT && $this->statut != self::STATUS_CANCELED) {
1040 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
1044 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
1045 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
1046 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1);
1048 if (($balance - $daysAsked) < 0) {
1049 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
1055 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
1057 $sql .=
" description= '".$this->db->escape($this->
description).
"',";
1059 if (!empty($this->date_debut)) {
1060 $sql .=
" date_debut = '".$this->db->idate($this->date_debut).
"',";
1064 if (!empty($this->date_fin)) {
1065 $sql .=
" date_fin = '".$this->db->idate($this->date_fin).
"',";
1069 $sql .=
" halfday = ".((int) $this->halfday).
",";
1070 if (!empty($this->
status) && is_numeric($this->
status)) {
1071 $sql .=
" statut = ".((int) $this->
status).
",";
1075 if (!empty($this->fk_validator)) {
1076 $sql .=
" fk_validator = ".((int) $this->fk_validator).
",";
1080 if (!empty($this->date_valid)) {
1081 $sql .=
" date_valid = '".$this->db->idate($this->date_valid).
"',";
1083 $sql .=
" date_valid = NULL,";
1085 if (!empty($this->fk_user_valid)) {
1086 $sql .=
" fk_user_valid = ".((int) $this->fk_user_valid).
",";
1088 $sql .=
" fk_user_valid = NULL,";
1090 if (!empty($this->date_approval)) {
1091 $sql .=
" date_approval = '".$this->db->idate($this->date_approval).
"',";
1093 $sql .=
" date_approval = NULL,";
1095 if (!empty($this->fk_user_approve)) {
1096 $sql .=
" fk_user_approve = ".((int) $this->fk_user_approve).
",";
1098 $sql .=
" fk_user_approve = NULL,";
1100 if (!empty($this->date_refuse)) {
1101 $sql .=
" date_refuse = '".$this->db->idate($this->date_refuse).
"',";
1103 $sql .=
" date_refuse = NULL,";
1105 if (!empty($this->fk_user_refuse)) {
1106 $sql .=
" fk_user_refuse = ".((int) $this->fk_user_refuse).
",";
1108 $sql .=
" fk_user_refuse = NULL,";
1110 if (!empty($this->date_cancel)) {
1111 $sql .=
" date_cancel = '".$this->db->idate($this->date_cancel).
"',";
1113 $sql .=
" date_cancel = NULL,";
1115 if (!empty($this->fk_user_cancel)) {
1116 $sql .=
" fk_user_cancel = ".((int) $this->fk_user_cancel).
",";
1118 $sql .=
" fk_user_cancel = NULL,";
1120 if (!empty($this->detail_refuse)) {
1121 $sql .=
" detail_refuse = '".$this->db->escape($this->detail_refuse).
"'";
1123 $sql .=
" detail_refuse = NULL";
1126 $sql .=
" WHERE rowid = ".((int) $this->
id);
1130 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1131 $resql = $this->db->query($sql);
1134 $this->errors[] =
"Error ".$this->db->lasterror();
1145 if (!$notrigger && $user !==
null) {
1147 $result = $this->
call_trigger(
'HOLIDAY_MODIFY', $user);
1157 foreach ($this->errors as $errmsg) {
1158 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1159 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1161 $this->db->rollback();
1164 $this->db->commit();
1177 public function delete($user, $notrigger = 0)
1179 global
$conf, $langs;
1182 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"holiday";
1183 $sql .=
" WHERE rowid=".((int) $this->
id);
1187 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1188 $resql = $this->db->query($sql);
1191 $this->errors[] =
"Error ".$this->db->lasterror();
1197 $result = $this->
call_trigger(
'HOLIDAY_DELETE', $user);
1207 foreach ($this->errors as $errmsg) {
1208 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1209 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1211 $this->db->rollback();
1214 $this->db->commit();
1236 foreach ($this->holiday as $infos_CP) {
1247 if ($halfday == 0) {
1248 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1251 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1254 } elseif ($halfday == -1) {
1256 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1257 if ($dateStart < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1261 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1262 if ($dateStart < $dateEnd) {
1265 if ($dateEnd < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1269 } elseif ($halfday == 1) {
1271 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1272 if ($dateStart < $dateEnd) {
1275 if ($dateStart > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1279 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1280 if ($dateEnd > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1284 } elseif ($halfday == 2) {
1286 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1287 if ($dateStart < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1291 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1292 if ($dateEnd > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1297 dol_print_error(
null,
'Bad value of parameter halfday when calling function verifDateHolidayCP');
1316 $isavailablemorning =
true;
1317 $isavailableafternoon =
true;
1320 $sql =
"SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut as status";
1321 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp";
1322 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
1323 $sql .=
" AND cp.fk_user = ".(int) $fk_user;
1324 $sql .=
" AND cp.date_debut <= '".$this->db->idate($timestamp).
"' AND cp.date_fin >= '".$this->db->idate($timestamp).
"'";
1325 if ($status !=
'-1') {
1326 $sql .=
" AND cp.statut IN (".$this->db->sanitize($status).
")";
1329 $resql = $this->db->query($sql);
1331 $num_rows = $this->db->num_rows($resql);
1332 if ($num_rows > 0) {
1333 $arrayofrecord = array();
1335 while ($i < $num_rows) {
1336 $obj = $this->db->fetch_object($resql);
1339 $arrayofrecord[$obj->rowid] = array(
'date_start' => $this->db->jdate($obj->date_start),
'date_end' => $this->db->jdate($obj->date_end),
'halfday' => $obj->halfday,
'status' => $obj->status);
1344 $isavailablemorning =
true;
1345 foreach ($arrayofrecord as $record) {
1346 if ($timestamp == $record[
'date_start'] && $record[
'halfday'] == 2) {
1349 if ($timestamp == $record[
'date_start'] && $record[
'halfday'] == -1) {
1352 $isavailablemorning =
false;
1355 $isavailableafternoon =
true;
1356 foreach ($arrayofrecord as $record) {
1357 if ($timestamp == $record[
'date_end'] && $record[
'halfday'] == 2) {
1360 if ($timestamp == $record[
'date_end'] && $record[
'halfday'] == 1) {
1363 $isavailableafternoon =
false;
1371 $result = array(
'morning' => (
int) $isavailablemorning,
'afternoon' => (
int) $isavailableafternoon);
1372 if (!$isavailablemorning) {
1373 $result[
'morning_reason'] =
'leave_request';
1375 if (!$isavailableafternoon) {
1376 $result[
'afternoon_reason'] =
'leave_request';
1391 $langs->load(
'holiday');
1392 $nofetch = !empty($params[
'nofetch']);
1395 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Holiday").
'</u>';
1396 if (isset($this->
status)) {
1397 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1399 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1401 if (!$nofetch && !empty($this->fk_type)) {
1402 $typeleaves = $this->
getTypes(1, -1);
1403 if (empty($typeleaves[$this->fk_type])) {
1404 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved", $this->fk_type);
1406 $labeltoshow = (($typeleaves[$this->fk_type][
'code'] && $langs->trans($typeleaves[$this->fk_type][
'code']) != $typeleaves[$this->fk_type][
'code']) ? $langs->trans($typeleaves[$this->fk_type][
'code']) : $typeleaves[$this->fk_type][
'label']);
1408 $datas[
'type'] =
'<br><b>'.$langs->trans(
"Type") .
':</b> ' . $labeltoshow;
1410 if (isset($this->halfday) && !empty($this->date_debut) && !empty($this->date_fin)) {
1411 $listhalfday = array(
1412 'morning' => $langs->trans(
"Morning"),
1413 "afternoon" => $langs->trans(
"Afternoon")
1415 $starthalfday = ($this->halfday == -1 || $this->halfday == 2) ?
'afternoon' :
'morning';
1416 $endhalfday = ($this->halfday == 1 || $this->halfday == 2) ?
'morning' :
'afternoon';
1417 $datas[
'date_start'] =
'<br><b>'.$langs->trans(
'DateDebCP') .
'</b>: '.
dol_print_date($this->date_debut,
'day') .
' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1418 $datas[
'date_end'] =
'<br><b>'.$langs->trans(
'DateFinCP') .
'</b>: '.
dol_print_date($this->date_fin,
'day') .
' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1434 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1436 global
$conf, $langs, $hookmanager;
1438 if (!empty(
$conf->dol_no_mouse_hover)) {
1445 'objecttype' => $this->element,
1448 $classfortooltip =
'classfortooltip';
1451 $classfortooltip =
'classforajaxtooltip';
1452 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1458 $url = DOL_URL_ROOT.
'/holiday/card.php?id='.$this->id;
1463 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1464 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1465 $add_save_lastsearch_values = 1;
1467 if ($add_save_lastsearch_values) {
1468 $url .=
'&save_lastsearch_values=1';
1473 if (empty($notooltip)) {
1475 $label = $langs->trans(
"ShowMyObject");
1476 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1478 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1479 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1481 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1484 $linkstart =
'<a href="'.$url.
'"';
1485 $linkstart .= $linkclose.
'>';
1488 $result .= $linkstart;
1491 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1493 if ($withpicto != 2) {
1494 $result .= $this->ref;
1496 $result .= $linkend;
1499 $hookmanager->initHooks(array($this->element .
'dao'));
1500 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1501 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1503 $result = $hookmanager->resPrint;
1505 $result .= $hookmanager->resPrint;
1531 public function LibStatut($status, $mode = 0, $startdate =
'')
1536 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1544 $this->labelStatusShort[
self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'DraftCP');
1552 $statusType =
'status6';
1553 if (!empty($startdate) && $startdate >=
dol_now()) {
1554 $statusType =
'status4';
1555 $params = array(
'tooltip' => $this->labelStatus[$status].
' - '.$langs->trans(
"Forthcoming"));
1557 if ($status == self::STATUS_DRAFT) {
1558 $statusType =
'status0';
1560 if ($status == self::STATUS_VALIDATED) {
1561 $statusType =
'status1';
1563 if ($status == self::STATUS_CANCELED) {
1564 $statusType =
'status9';
1566 if ($status == self::STATUS_REFUSED) {
1567 $statusType =
'status9';
1570 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode,
'', $params);
1582 public function selectStatutCP($selected = 0, $htmlname =
'select_statut', $morecss =
'minwidth125')
1587 $name = array(
'DraftCP',
'ToReviewCP',
'ApprovedCP',
'CancelCP',
'RefuseCP');
1588 $nb = count($name) + 1;
1591 $out =
'<select name="'.$htmlname.
'" id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'">'.
"\n";
1592 $out .=
'<option value="-1"> </option>'.
"\n";
1595 for ($i = 1; $i < $nb; $i++) {
1596 if ($i == $selected) {
1597 $out .=
'<option value="'.$i.
'" selected>'.$langs->trans($name[$i - 1]).
'</option>'.
"\n";
1599 $out .=
'<option value="'.$i.
'">'.$langs->trans($name[$i - 1]).
'</option>'.
"\n";
1603 $out .=
"</select>\n";
1606 $out .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($showempty < 0 ? (
string) $showempty :
'-1'), $morecss);
1620 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_config SET";
1621 $sql .=
" value = '".$this->db->escape($value).
"'";
1622 $sql .=
" WHERE name = '".$this->db->escape($name).
"'";
1624 dol_syslog(get_class($this).
'::updateConfCP name='.$name, LOG_DEBUG);
1625 $result = $this->db->query($sql);
1643 $sql =
"SELECT value";
1644 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_config";
1645 $sql .=
" WHERE name = '".$this->db->escape($name).
"'";
1647 dol_syslog(get_class($this).
'::getConfCP name='.$name.
' createifnotfound='.$createifnotfound, LOG_DEBUG);
1648 $result = $this->db->query($sql);
1651 $obj = $this->db->fetch_object($result);
1654 if ($createifnotfound) {
1655 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_config(name, value)";
1656 $sql .=
" VALUES('".$this->db->escape($name).
"', '".$this->db->escape($createifnotfound).
"')";
1657 $result = $this->db->query($sql);
1659 return $createifnotfound;
1661 $this->error = $this->db->lasterror();
1672 $this->error = $this->db->lasterror();
1687 global $user, $langs;
1691 if (empty($userID) && empty($nbHoliday) && empty($fk_type)) {
1692 $langs->load(
"holiday");
1704 if (empty($stringInDBForLastUpdate)) {
1708 if ($stringInDBForLastUpdate <
'20000101000000') {
1709 $stringInDBForLastUpdate =
'20000101000000';
1720 while ($yearMonthLastUpdate < $yearMonthNow) {
1726 $users = $this->
fetchUsers(
false,
false,
' AND u.statut > 0');
1727 $nbUser = count($users);
1729 $typeleaves = $this->
getTypes(1, 1);
1732 foreach ($users as $userCounter) {
1733 $nbDaysToAdd = (isset($typeleaves[$userCounter[
'type']][
'newbymonth']) ? $typeleaves[$userCounter[
'type']][
'newbymonth'] : 0);
1734 if (empty($nbDaysToAdd)) {
1738 dol_syslog(
"We update leave type id ".$userCounter[
'type'].
" for user id ".$userCounter[
'rowid'], LOG_DEBUG);
1740 $nowHoliday = (float) $userCounter[
'nb_holiday'];
1741 $newSolde = $nowHoliday + $nbDaysToAdd;
1744 $this->
addLogCP($user->id, $userCounter[
'rowid'], $langs->trans(
'HolidayMonthlyCredit'), $newSolde, $userCounter[
'type']);
1746 $result = $this->
updateSoldeCP($userCounter[
'rowid'], $newSolde, $userCounter[
'type']);
1749 $this->db->rollback();
1753 if (empty($decrease)) {
1758 $filter =
" AND cp.statut = ".((int) self::STATUS_APPROVED);
1761 $filter .=
" AND cp.fk_type = ".((int) $userCounter[
'type']);
1762 $this->
fetchByUser($userCounter[
'id'],
'', $filter);
1764 if (empty($this->holiday)) {
1768 $startOfMonth =
dol_mktime(0, 0, 0, (
int) $month, 1, (
int) $year, 1);
1771 foreach ($this->holiday as $obj) {
1772 $startDate = $obj[
'date_debut_gmt'];
1773 $endDate = $obj[
'date_fin_gmt'];
1775 if ($startDate <= $endOfMonth && $startDate < $startOfMonth) {
1776 $startDate = $startOfMonth;
1779 if ($startOfMonth <= $endDate && $endDate > $endOfMonth) {
1780 $endDate = $endOfMonth;
1783 $nbDaysToDeduct = (int)
num_open_day($startDate, $endDate, 0, 1, $obj[
'halfday']);
1785 if ($nbDaysToDeduct <= 0) {
1789 $newSolde -= $nbDaysToDeduct;
1792 $this->
addLogCP($user->id, $userCounter[
'rowid'], $obj[
'ref'].
' - '.$langs->trans(
'HolidayConsumption'), $newSolde, $userCounter[
'type']);
1794 $result = $this->
updateSoldeCP($userCounter[
'rowid'], $newSolde, $userCounter[
'type']);
1797 $this->db->rollback();
1805 $lastUpdate =
dol_mktime(0, 0, 0, (
int) $newMonth[
'month'], 1, (
int) $newMonth[
'year']);
1807 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_config SET";
1808 $sql .=
" value = '".$this->db->escape(
dol_print_date($lastUpdate,
'%Y%m%d%H%M%S')).
"'";
1809 $sql .=
" WHERE name = 'lastUpdate'";
1810 $result = $this->db->query($sql);
1813 $this->db->rollback();
1817 $this->db->commit();
1831 $sql =
"SELECT nb_holiday FROM ".MAIN_DB_PREFIX.
"holiday_users";
1832 $sql .=
" WHERE fk_user = ".(int) $userID.
" AND fk_type = ".(
int) $fk_type;
1833 $resql = $this->db->query($sql);
1835 $num = $this->db->num_rows($resql);
1839 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_users SET";
1840 $sql .=
" nb_holiday = ".((float) $nbHoliday);
1841 $sql .=
" WHERE fk_user = ".(int) $userID.
" AND fk_type = ".(
int) $fk_type;
1842 $result = $this->db->query($sql);
1845 $this->errors[] = $this->db->lasterror();
1849 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users(nb_holiday, fk_user, fk_type) VALUES (";
1850 $sql .= ((float) $nbHoliday);
1851 $sql .=
", ".(int) $userID.
", ".(
int) $fk_type.
")";
1852 $result = $this->db->query($sql);
1855 $this->errors[] = $this->db->lasterror();
1859 $this->errors[] = $this->db->lasterror();
1882 dol_syslog(get_class($this).
'::createCPusers');
1883 $arrayofusers = $this->
fetchUsers(
false,
true);
1885 foreach ($arrayofusers as $users) {
1886 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users";
1887 $sql .=
" (fk_user, nb_holiday)";
1888 $sql .=
" VALUES (".((int) $users[
'rowid']).
"', '0')";
1890 $resql = $this->db->query($sql);
1896 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users";
1897 $sql .=
" (fk_user, nb_holiday)";
1898 $sql .=
" VALUES (".((int) $userid).
"', '0')";
1900 $resql = $this->db->query($sql);
1916 $sql =
"SELECT nb_holiday";
1917 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users";
1918 $sql .=
" WHERE fk_user = ".(int) $user_id;
1920 $sql .=
" AND fk_type = ".(int) $fk_type;
1923 dol_syslog(get_class($this).
'::getCPforUser user_id='.$user_id.
' type_id='.$fk_type, LOG_DEBUG);
1924 $result = $this->db->query($sql);
1926 $obj = $this->db->fetch_object($result);
1929 return $obj->nb_holiday;
1946 public function fetchUsers($stringlist =
true, $type =
true, $filters =
'')
1950 dol_syslog(get_class($this).
"::fetchUsers", LOG_DEBUG);
1956 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
1957 $sql .=
" DISTINCT";
1960 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1962 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
1963 $sql .=
", ".MAIN_DB_PREFIX.
"usergroup_user as ug";
1964 $sql .=
" WHERE ((ug.fk_user = u.rowid";
1965 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
1966 $sql .=
" OR u.entity = 0)";
1968 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1970 $sql .=
" AND u.statut > 0";
1971 $sql .=
" AND u.employee = 1";
1976 $resql = $this->db->query($sql);
1981 $num = $this->db->num_rows($resql);
1986 $obj = $this->db->fetch_object($resql);
1989 $stringlist .= $obj->rowid;
1991 $stringlist .=
', '.$obj->rowid;
2000 $this->error =
"Error ".$this->db->lasterror();
2005 $sql =
"SELECT DISTINCT cpu.fk_user";
2006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users as cpu, ".MAIN_DB_PREFIX.
"user as u";
2007 $sql .=
" WHERE cpu.fk_user = u.rowid";
2012 $resql = $this->db->query($sql);
2017 $num = $this->db->num_rows($resql);
2022 $obj = $this->db->fetch_object($resql);
2025 $stringlist .= $obj->fk_user;
2027 $stringlist .=
', '.$obj->fk_user;
2036 $this->error =
"Error ".$this->db->lasterror();
2046 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
2047 $sql .=
" DISTINCT";
2049 $sql .=
" u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut as status, u.fk_user";
2050 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
2052 if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
2053 $sql .=
", ".MAIN_DB_PREFIX.
"usergroup_user as ug";
2054 $sql .=
" WHERE ((ug.fk_user = u.rowid";
2055 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
2056 $sql .=
" OR u.entity = 0)";
2058 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
2061 $sql .=
" AND u.statut > 0";
2062 $sql .=
" AND u.employee = 1";
2067 $resql = $this->db->query($sql);
2072 $tab_result = $this->holiday;
2073 $num = $this->db->num_rows($resql);
2077 $obj = $this->db->fetch_object($resql);
2079 $tab_result[$i][
'rowid'] = (int) $obj->rowid;
2080 $tab_result[$i][
'id'] = (int) $obj->rowid;
2081 $tab_result[$i][
'name'] = $obj->lastname;
2082 $tab_result[$i][
'lastname'] = $obj->lastname;
2083 $tab_result[$i][
'firstname'] = $obj->firstname;
2084 $tab_result[$i][
'gender'] = $obj->gender;
2085 $tab_result[$i][
'status'] = (int) $obj->status;
2086 $tab_result[$i][
'employee'] = (int) $obj->employee;
2087 $tab_result[$i][
'photo'] = $obj->photo;
2088 $tab_result[$i][
'fk_user'] = (int) $obj->fk_user;
2098 $this->errors[] =
"Error ".$this->db->lasterror();
2103 $sql =
"SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut as status, u.fk_user";
2104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users as cpu, ".MAIN_DB_PREFIX.
"user as u";
2105 $sql .=
" WHERE cpu.fk_user = u.rowid";
2110 $resql = $this->db->query($sql);
2115 $tab_result = $this->holiday;
2116 $num = $this->db->num_rows($resql);
2120 $obj = $this->db->fetch_object($resql);
2122 $tab_result[$i][
'rowid'] = $obj->rowid;
2123 $tab_result[$i][
'id'] = $obj->rowid;
2124 $tab_result[$i][
'name'] = $obj->lastname;
2125 $tab_result[$i][
'lastname'] = $obj->lastname;
2126 $tab_result[$i][
'firstname'] = $obj->firstname;
2127 $tab_result[$i][
'gender'] = $obj->gender;
2128 $tab_result[$i][
'status'] = $obj->status;
2129 $tab_result[$i][
'employee'] = $obj->employee;
2130 $tab_result[$i][
'photo'] = $obj->photo;
2131 $tab_result[$i][
'fk_user'] = $obj->fk_user;
2133 $tab_result[$i][
'type'] = $obj->fk_type;
2134 $tab_result[$i][
'nb_holiday'] = $obj->nb_holiday;
2142 $this->error =
"Error ".$this->db->lasterror();
2160 $users_validator = array();
2162 $sql =
"SELECT DISTINCT ur.fk_user";
2163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_rights as ur, ".MAIN_DB_PREFIX.
"rights_def as rd";
2164 $sql .=
" WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'";
2166 $sql .=
" SELECT DISTINCT ugu.fk_user";
2167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup_user as ugu, ".MAIN_DB_PREFIX.
"usergroup_rights as ur, ".MAIN_DB_PREFIX.
"rights_def as rd";
2168 $sql .=
" WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'";
2171 dol_syslog(get_class($this).
"::fetch_users_approver_holiday sql=".$sql);
2172 $result = $this->db->query($sql);
2174 $num_rows = $this->db->num_rows($result);
2176 while ($i < $num_rows) {
2177 $objp = $this->db->fetch_object($result);
2178 array_push($users_validator, $objp->fk_user);
2181 return $users_validator;
2183 $this->error = $this->db->lasterror();
2184 dol_syslog(get_class($this).
"::fetch_users_approver_holiday Error ".$this->error, LOG_ERR);
2197 $sql =
"SELECT count(u.rowid) as compteur";
2198 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
2199 $sql .=
" WHERE u.statut > 0";
2201 $result = $this->db->query($sql);
2202 $object = $this->db->fetch_object($result);
2213 $sql =
"SELECT count(u.rowid) as compteur";
2214 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u LEFT JOIN ".MAIN_DB_PREFIX.
"holiday_users hu ON (hu.fk_user=u.rowid)";
2215 $sql .=
" WHERE u.statut > 0 AND hu.fk_user IS NULL";
2217 $result = $this->db->query($sql);
2218 $object = $this->db->fetch_object($result);
2232 if (empty($userCP)) {
2235 dol_syslog(get_class($this).
'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.
' userCP='.$userCP);
2250 public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type)
2252 global
$conf, $langs;
2260 if ($prev_solde == $new_solde) {
2267 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_logs (";
2268 $sql .=
"date_action,";
2269 $sql .=
"fk_user_action,";
2270 $sql .=
"fk_user_update,";
2271 $sql .=
"type_action,";
2272 $sql .=
"prev_solde,";
2273 $sql .=
"new_solde,";
2275 $sql .=
") VALUES (";
2276 $sql .=
" '".$this->db->idate(
dol_now()).
"',";
2277 $sql .=
" ".((int) $fk_user_action).
",";
2278 $sql .=
" ".((int) $fk_user_update).
",";
2279 $sql .=
" '".$this->db->escape($label).
"',";
2280 $sql .=
" ".((float) $prev_solde).
",";
2281 $sql .=
" ".((float) $new_solde).
",";
2282 $sql .=
" ".((int) $fk_type);
2285 $resql = $this->db->query($sql);
2288 $this->errors[] =
"Error ".$this->db->lasterror();
2292 $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"holiday_logs");
2297 foreach ($this->errors as $errmsg) {
2298 dol_syslog(get_class($this).
"::addLogCP ".$errmsg, LOG_ERR);
2299 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2301 $this->db->rollback();
2304 $this->db->commit();
2305 return $this->optRowid;
2319 $sql .=
" cpl.rowid,";
2320 $sql .=
" cpl.date_action,";
2321 $sql .=
" cpl.fk_user_action,";
2322 $sql .=
" cpl.fk_user_update,";
2323 $sql .=
" cpl.type_action,";
2324 $sql .=
" cpl.prev_solde,";
2325 $sql .=
" cpl.new_solde,";
2326 $sql .=
" cpl.fk_type";
2327 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_logs as cpl";
2328 $sql .=
" WHERE cpl.rowid > 0";
2331 if (!empty($sqlwhere)) {
2332 $sql .=
" ".$sqlwhere;
2336 if (!empty($sqlorder)) {
2337 $sql .=
" ".$sqlorder;
2340 dol_syslog(get_class($this).
"::fetchLog", LOG_DEBUG);
2341 $resql = $this->db->query($sql);
2346 $tab_result = $this->logs;
2347 $num = $this->db->num_rows($resql);
2356 $obj = $this->db->fetch_object($resql);
2358 $tab_result[$i][
'rowid'] = $obj->rowid;
2359 $tab_result[$i][
'id'] = $obj->rowid;
2360 $tab_result[$i][
'date_action'] = $obj->date_action;
2361 $tab_result[$i][
'fk_user_action'] = $obj->fk_user_action;
2362 $tab_result[$i][
'fk_user_update'] = $obj->fk_user_update;
2363 $tab_result[$i][
'type_action'] = $obj->type_action;
2364 $tab_result[$i][
'prev_solde'] = $obj->prev_solde;
2365 $tab_result[$i][
'new_solde'] = $obj->new_solde;
2366 $tab_result[$i][
'fk_type'] = $obj->fk_type;
2371 $this->logs = $tab_result;
2375 $this->error =
"Error ".$this->db->lasterror();
2392 $sql =
"SELECT rowid, code, label, affect, delay, newbymonth";
2393 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_holiday_types";
2394 $sql .=
" WHERE (fk_country IS NULL OR fk_country = ".((int) $mysoc->country_id).
')';
2395 $sql .=
" AND entity IN (0, ".getEntity(
'c_holiday_types').
")";
2397 $sql .=
" AND active = ".((int) $active);
2400 $sql .=
" AND affect = ".((int) $affect);
2402 $sql .=
" ORDER BY sortorder";
2404 $result = $this->db->query($sql);
2406 $num = $this->db->num_rows($result);
2409 while ($obj = $this->db->fetch_object($result)) {
2410 $types[$obj->rowid] = array(
'id' => $obj->rowid,
'rowid' => $obj->rowid,
'code' => $obj->code,
'label' => $obj->label,
'affect' => $obj->affect,
'delay' => $obj->delay,
'newbymonth' => $obj->newbymonth);
2433 $sql =
"SELECT f.rowid, f.statut as status,";
2434 $sql .=
" f.date_create as datec,";
2435 $sql .=
" f.tms as date_modification,";
2436 $sql .=
" f.date_valid as datev,";
2437 $sql .=
" f.date_approval as datea,";
2438 $sql .=
" f.date_refuse as dater,";
2439 $sql .=
" f.fk_user_create as fk_user_creation,";
2440 $sql .=
" f.fk_user_modif as fk_user_modification,";
2441 $sql .=
" f.fk_user_valid as fk_user_validation,";
2442 $sql .=
" f.fk_user_approve as fk_user_approval_done,";
2443 $sql .=
" f.fk_validator as fk_user_approval_expected,";
2444 $sql .=
" f.fk_user_refuse as fk_user_refuse";
2445 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as f";
2446 $sql .=
" WHERE f.rowid = ".((int) $id);
2447 $sql .=
" AND f.entity = ".$conf->entity;
2449 $resql = $this->db->query($sql);
2451 if ($this->db->num_rows($resql)) {
2452 $obj = $this->db->fetch_object($resql);
2454 $this->
id = $obj->rowid;
2456 $this->date_creation = $this->db->jdate($obj->datec);
2457 $this->date_modification = $this->db->jdate($obj->date_modification);
2458 $this->date_validation = $this->db->jdate($obj->datev);
2459 $this->date_approval = $this->db->jdate($obj->datea);
2461 $this->user_creation_id = $obj->fk_user_creation;
2462 $this->user_validation_id = $obj->fk_user_validation;
2463 $this->user_modification_id = $obj->fk_user_modification;
2466 if ($obj->fk_user_approval_done) {
2467 $this->fk_user_approve = $obj->fk_user_approval_done;
2471 $this->db->free($resql);
2487 global $user, $langs;
2491 $this->specimen = 1;
2493 $this->fk_user = $user->id;
2495 $this->date_debut =
dol_now();
2496 $this->date_fin =
dol_now() + (24 * 3600);
2497 $this->date_valid =
dol_now();
2498 $this->fk_validator = $user->id;
2515 $this->nb = array();
2517 $sql =
"SELECT count(h.rowid) as nb";
2518 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as h";
2519 $sql .=
" WHERE h.statut > 1";
2520 $sql .=
" AND h.entity IN (".getEntity(
'holiday').
")";
2521 if (!$user->hasRight(
'holiday',
'readall')) {
2522 $userchildids = $user->getAllChildIds(1);
2523 $sql .=
" AND (h.fk_user IN (".$this->db->sanitize(implode(
',', $userchildids)).
")";
2524 $sql .=
" OR h.fk_validator IN (".$this->db->sanitize(implode(
',', $userchildids)).
"))";
2527 $resql = $this->db->query($sql);
2529 while ($obj = $this->db->fetch_object($resql)) {
2530 $this->nb[
"holidays"] = $obj->nb;
2532 $this->db->free($resql);
2536 $this->error = $this->db->error();
2551 global
$conf, $langs;
2559 $sql =
"SELECT h.rowid, h.date_debut";
2560 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as h";
2561 $sql .=
" WHERE h.statut = 2";
2562 $sql .=
" AND h.entity IN (".getEntity(
'holiday').
")";
2563 if (!$user->hasRight(
'holiday',
'read_all')) {
2564 $userchildids = $user->getAllChildIds(1);
2565 $sql .=
" AND (h.fk_user IN (".$this->db->sanitize(implode(
',', $userchildids)).
")";
2566 $sql .=
" OR h.fk_validator IN (".$this->db->sanitize(implode(
',', $userchildids)).
"))";
2569 $resql = $this->db->query($sql);
2571 $langs->load(
"members");
2574 $response->warning_delay =
$conf->holiday->approve->warning_delay / 60 / 60 / 24;
2575 $response->label = $langs->trans(
"HolidaysToApprove");
2576 $response->labelShort = $langs->trans(
"ToApprove");
2577 $response->url = DOL_URL_ROOT.
'/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday';
2580 while ($obj = $this->db->fetch_object($resql)) {
2581 $response->nbtodo++;
2583 if ($this->db->jdate($obj->date_debut) < ($now -
$conf->holiday->approve->warning_delay)) {
2584 $response->nbtodolate++;
2591 $this->error = $this->db->error();
2606 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2608 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2609 $return .=
'<div class="info-box info-box-sm">';
2610 $return .=
'<span class="info-box-icon bg-infobox-action">';
2612 $return .=
'</span>';
2613 $return .=
'<div class="info-box-content">';
2614 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl().
'</span>';
2615 if ($selected >= 0) {
2616 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2618 if (property_exists($this,
'fk_type')) {
2621 $return .=
'<div class="info_box-label tdoverflowmax100" title="'.dol_escape_htmltag($arraydata[
'labeltype']).
'">'.
dol_escape_htmltag($arraydata[
'labeltype']).
'</div>';
2623 if (property_exists($this,
'date_debut') && property_exists($this,
'date_fin')) {
2624 $return .=
'<span class="info-box-label small">'.dol_print_date($this->date_debut,
'day').
'</span>';
2625 $return .=
' <span class="opacitymedium small">'.$langs->trans(
"To").
'</span> ';
2626 $return .=
'<span class="info-box-label small">'.dol_print_date($this->date_fin,
'day').
'</span>';
2627 if (!empty($arraydata[
'nbopenedday'])) {
2628 $return .=
' ('.$arraydata[
'nbopenedday'].
')';
2631 if (method_exists($this,
'getLibStatut')) {
2632 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2634 $return .=
'</div>';
2635 $return .=
'</div>';
2636 $return .=
'</div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class of the module paid holiday.
getTypes($active=-1, $affect=-1)
Return array with list of types.
getNomUrl($withpicto=0, $save_lastsearch_value=-1, $notooltip=0, $morecss='')
Return clickable name (with picto eventually)
verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday=0)
Check if a user is on holiday (partially or completely) into a period.
validate($user=null, $notrigger=0)
Validate leave request.
info($id)
Load information on object.
updateBalance()
Update balance of vacations and check table of users for holidays is complete.
updateConfCP($name, $value)
Met à jour une option du module Holiday Payés.
const STATUS_VALIDATED
Validated status.
const STATUS_DRAFT
Draft status.
fetch($id, $ref='')
Load object in memory from database.
addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type)
addLogCP
verifNbUsers($userDolibarrWithoutCP, $userCP)
Compare le nombre d'utilisateur actif de Dolibarr à celui des utilisateurs des congés payés.
verifDateHolidayForTimestamp($fk_user, $timestamp, $status='-1')
Check that a user is not on holiday for a particular timestamp.
approve($user=null, $notrigger=0)
Approve leave request.
getNextNumRef($objsoc)
Returns the reference to the following non used Order depending on the active numbering module define...
const STATUS_REFUSED
Refused.
getConfCP($name, $createifnotfound='')
Return value of a conf parameter for leave module TODO Move this into llx_const table.
load_board($user)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
initAsSpecimen()
Initialise an instance with random values.
create($user, $notrigger=0)
Créer un congés payés dans la base de données.
selectStatutCP($selected=0, $htmlname='select_statut', $morecss='minwidth125')
Show select with list of leave status.
countActiveUsersWithoutCP()
Compte le nombre d'utilisateur actifs dans Dolibarr sans CP.
updateSoldeCP($userID=0, $nbHoliday=0, $fk_type=0)
Met à jour le timestamp de la dernière mise à jour du solde des CP.
update($user=null, $notrigger=0)
Update database.
getCPforUser($user_id, $fk_type=0)
Return the balance of annual leave of a user.
fetch_users_approver_holiday()
Return list of people with permission to validate leave requests.
__construct($db)
Constructor.
loadStateBoard()
Load this->nb for dashboard.
getLibStatut($mode=0)
Returns the label status.
createCPusers($single=false, $userid=0)
Create entries for each user at setup step.
fetchAll($order, $filter)
List all holidays of all users.
const STATUS_CANCELED
Canceled.
fetchLog($sqlorder, $sqlwhere)
List log of leaves.
countActiveUsers()
Compte le nombre d'utilisateur actifs dans Dolibarr.
fetchByUser($user_id, $order='', $filter='')
List holidays for a particular user or list of users.
const STATUS_APPROVED
Approved.
getTooltipContentArray($params)
getTooltipContentArray
fetchUsers($stringlist=true, $type=true, $filters='')
Get list of Users or list of vacation balance.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
LibStatut($status, $mode=0, $startdate='')
Returns the label of a status.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_next_month($month, $year)
Return next month.
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_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...