29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'holiday';
46 public $TRIGGER_PREFIX =
'HOLIDAY';
51 public $table_element =
'holiday';
56 public $fk_element =
'fk_holiday';
61 public $picto =
'holiday';
71 public $date_create =
'';
81 public $date_debut =
'';
86 public $date_fin =
'';
91 public $date_debut_gmt =
'';
96 public $date_fin_gmt =
'';
101 public $halfday =
'';
112 public $fk_validator;
117 public $date_valid = 0;
122 public $fk_user_valid;
127 public $date_approval;
132 public $fk_user_approve;
137 public $user_approve_id;
142 public $date_refuse = 0;
147 public $fk_user_refuse;
152 public $date_cancel = 0;
157 public $fk_user_cancel;
162 public $fk_user_create;
167 public $detail_refuse =
'';
174 public $holiday = array();
175 public $events = array();
180 public $logs = array();
214 $this->ismultientitymanaged = 0;
227 global $langs, $conf;
228 $langs->load(
"order");
231 $conf->global->HOLIDAY_ADDON =
'mod_holiday_madonna';
241 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
242 foreach ($dirmodels as $reldir) {
246 $mybool = ((bool) @include_once $dir.$file) || $mybool;
254 $obj =
new $classname();
255 '@phan-var-force ModelNumRefHolidays $obj';
256 $numref = $obj->getNextValue($objsoc, $this);
261 $this->error = $obj->error;
266 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_HOLIDAY_ADDON_NotDefined");
290 $this->db->rollback();
302 public function create($user, $notrigger = 0)
310 if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) {
311 $this->error =
"ErrorBadParameterFkUser";
314 if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) {
315 $this->error =
"ErrorBadParameterFkValidator";
318 if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) {
319 $this->error =
"ErrorBadParameterFkType";
324 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday(";
327 $sql .=
"date_create,";
328 $sql .=
"description,";
329 $sql .=
"date_debut,";
333 $sql .=
"fk_validator,";
335 $sql .=
"fk_user_create,";
337 $sql .=
") VALUES (";
339 $sql .=
" ".((int) $this->fk_user).
",";
340 $sql .=
" '".$this->db->idate($now).
"',";
341 $sql .=
" '".$this->db->escape($this->
description).
"',";
342 $sql .=
" '".$this->db->idate($this->date_debut).
"',";
343 $sql .=
" '".$this->db->idate($this->date_fin).
"',";
344 $sql .=
" ".((int) $this->halfday).
",";
346 $sql .=
" ".((int) $this->fk_validator).
",";
347 $sql .=
" ".((int) $this->fk_type).
",";
348 $sql .=
" ".((int) $user->id).
",";
349 $sql .=
" ".((int) $conf->entity);
354 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
355 $resql = $this->db->query($sql);
358 $this->errors[] =
"Error ".$this->db->lasterror();
362 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"holiday");
366 $initialref =
'(PROV'.$this->id.
')';
367 if (!empty($this->
ref)) {
368 $initialref = $this->ref;
371 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"holiday SET ref='".$this->db->escape($initialref).
"' WHERE rowid=".((int) $this->
id);
372 if ($this->db->query($sql)) {
373 $this->
ref = $initialref;
382 if (!$error && !$notrigger) {
384 $result = $this->call_trigger(
'HOLIDAY_CREATE', $user);
396 foreach ($this->errors as $errmsg) {
397 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
398 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
400 $this->db->rollback();
416 public function fetch($id, $ref =
'')
419 $sql .=
" cp.rowid,";
421 $sql .=
" cp.fk_user,";
422 $sql .=
" cp.date_create,";
423 $sql .=
" cp.description,";
424 $sql .=
" cp.date_debut,";
425 $sql .=
" cp.date_fin,";
426 $sql .=
" cp.halfday,";
427 $sql .=
" cp.statut as status,";
428 $sql .=
" cp.fk_validator,";
429 $sql .=
" cp.date_valid,";
430 $sql .=
" cp.fk_user_valid,";
431 $sql .=
" cp.date_approval,";
432 $sql .=
" cp.fk_user_approve,";
433 $sql .=
" cp.date_refuse,";
434 $sql .=
" cp.fk_user_refuse,";
435 $sql .=
" cp.date_cancel,";
436 $sql .=
" cp.fk_user_cancel,";
437 $sql .=
" cp.detail_refuse,";
438 $sql .=
" cp.note_private,";
439 $sql .=
" cp.note_public,";
440 $sql .=
" cp.fk_user_create,";
441 $sql .=
" cp.fk_type,";
442 $sql .=
" cp.entity";
443 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp";
445 $sql .=
" WHERE cp.rowid = ".((int) $id);
447 $sql .=
" WHERE cp.ref = '".$this->db->escape($ref).
"'";
450 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
451 $resql = $this->db->query($sql);
453 if ($this->db->num_rows($resql)) {
454 $obj = $this->db->fetch_object($resql);
456 $this->
id = $obj->rowid;
457 $this->
ref = ($obj->ref ? $obj->ref : $obj->rowid);
458 $this->fk_user = $obj->fk_user;
459 $this->date_create = $this->db->jdate($obj->date_create);
461 $this->date_debut = $this->db->jdate($obj->date_debut);
462 $this->date_fin = $this->db->jdate($obj->date_fin);
463 $this->date_debut_gmt = $this->db->jdate($obj->date_debut, 1);
464 $this->date_fin_gmt = $this->db->jdate($obj->date_fin, 1);
465 $this->halfday = $obj->halfday;
466 $this->
status = $obj->status;
467 $this->statut = $obj->status;
468 $this->fk_validator = $obj->fk_validator;
469 $this->date_valid = $this->db->jdate($obj->date_valid);
470 $this->fk_user_valid = $obj->fk_user_valid;
471 $this->user_validation_id = $obj->fk_user_valid;
472 $this->date_approval = $this->db->jdate($obj->date_approval);
473 $this->fk_user_approve = $obj->fk_user_approve;
474 $this->date_refuse = $this->db->jdate($obj->date_refuse);
475 $this->fk_user_refuse = $obj->fk_user_refuse;
476 $this->date_cancel = $this->db->jdate($obj->date_cancel);
477 $this->fk_user_cancel = $obj->fk_user_cancel;
478 $this->detail_refuse = $obj->detail_refuse;
479 $this->note_private = $obj->note_private;
480 $this->note_public = $obj->note_public;
481 $this->fk_user_create = $obj->fk_user_create;
482 $this->fk_type = $obj->fk_type;
483 $this->entity = $obj->entity;
491 $this->db->free($resql);
495 $this->error =
"Error ".$this->db->lasterror();
512 $sql .=
" cp.rowid,";
515 $sql .=
" cp.fk_user,";
516 $sql .=
" cp.fk_type,";
517 $sql .=
" cp.date_create,";
518 $sql .=
" cp.description,";
519 $sql .=
" cp.date_debut,";
520 $sql .=
" cp.date_fin,";
521 $sql .=
" cp.halfday,";
522 $sql .=
" cp.statut as status,";
523 $sql .=
" cp.fk_validator,";
524 $sql .=
" cp.date_valid,";
525 $sql .=
" cp.fk_user_valid,";
526 $sql .=
" cp.date_approval,";
527 $sql .=
" cp.fk_user_approve,";
528 $sql .=
" cp.date_refuse,";
529 $sql .=
" cp.fk_user_refuse,";
530 $sql .=
" cp.date_cancel,";
531 $sql .=
" cp.fk_user_cancel,";
532 $sql .=
" cp.detail_refuse,";
534 $sql .=
" uu.lastname as user_lastname,";
535 $sql .=
" uu.firstname as user_firstname,";
536 $sql .=
" uu.login as user_login,";
537 $sql .=
" uu.statut as user_status,";
538 $sql .=
" uu.photo as user_photo,";
539 $sql .=
" uu.fk_country as country_id,";
541 $sql .=
" ua.lastname as validator_lastname,";
542 $sql .=
" ua.firstname as validator_firstname,";
543 $sql .=
" ua.login as validator_login,";
544 $sql .=
" ua.statut as validator_status,";
545 $sql .=
" ua.photo as validator_photo";
547 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp, ".MAIN_DB_PREFIX.
"user as uu, ".MAIN_DB_PREFIX.
"user as ua";
548 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
549 $sql .=
" AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid";
550 $sql .=
" AND cp.fk_user IN (".$this->db->sanitize($user_id).
")";
553 if (!empty($filter)) {
558 if (!empty($order)) {
562 dol_syslog(get_class($this).
"::fetchByUser", LOG_DEBUG);
563 $resql = $this->db->query($sql);
568 $tab_result = $this->holiday;
569 $num = $this->db->num_rows($resql);
578 $obj = $this->db->fetch_object($resql);
580 $tab_result[$i][
'rowid'] = $obj->rowid;
581 $tab_result[$i][
'id'] = $obj->rowid;
582 $tab_result[$i][
'ref'] = ($obj->ref ? $obj->ref : $obj->rowid);
584 $tab_result[$i][
'fk_user'] = $obj->fk_user;
585 $tab_result[$i][
'fk_type'] = $obj->fk_type;
586 $tab_result[$i][
'date_create'] = $this->db->jdate($obj->date_create);
587 $tab_result[$i][
'description'] = $obj->description;
588 $tab_result[$i][
'date_debut'] = $this->db->jdate($obj->date_debut);
589 $tab_result[$i][
'date_fin'] = $this->db->jdate($obj->date_fin);
590 $tab_result[$i][
'date_debut_gmt'] = $this->db->jdate($obj->date_debut, 1);
591 $tab_result[$i][
'date_fin_gmt'] = $this->db->jdate($obj->date_fin, 1);
592 $tab_result[$i][
'halfday'] = $obj->halfday;
593 $tab_result[$i][
'statut'] = $obj->status;
594 $tab_result[$i][
'status'] = $obj->status;
595 $tab_result[$i][
'fk_validator'] = $obj->fk_validator;
596 $tab_result[$i][
'date_valid'] = $this->db->jdate($obj->date_valid);
597 $tab_result[$i][
'fk_user_valid'] = $obj->fk_user_valid;
598 $tab_result[$i][
'date_approval'] = $this->db->jdate($obj->date_approval);
599 $tab_result[$i][
'fk_user_approve'] = $obj->fk_user_approve;
600 $tab_result[$i][
'date_refuse'] = $this->db->jdate($obj->date_refuse);
601 $tab_result[$i][
'fk_user_refuse'] = $obj->fk_user_refuse;
602 $tab_result[$i][
'date_cancel'] = $this->db->jdate($obj->date_cancel);
603 $tab_result[$i][
'fk_user_cancel'] = $obj->fk_user_cancel;
604 $tab_result[$i][
'detail_refuse'] = $obj->detail_refuse;
606 $tab_result[$i][
'user_firstname'] = $obj->user_firstname;
607 $tab_result[$i][
'user_lastname'] = $obj->user_lastname;
608 $tab_result[$i][
'user_login'] = $obj->user_login;
609 $tab_result[$i][
'user_statut'] = $obj->user_status;
610 $tab_result[$i][
'user_status'] = $obj->user_status;
611 $tab_result[$i][
'user_photo'] = $obj->user_photo;
613 $tab_result[$i][
'validator_firstname'] = $obj->validator_firstname;
614 $tab_result[$i][
'validator_lastname'] = $obj->validator_lastname;
615 $tab_result[$i][
'validator_login'] = $obj->validator_login;
616 $tab_result[$i][
'validator_statut'] = $obj->validator_status;
617 $tab_result[$i][
'validator_status'] = $obj->validator_status;
618 $tab_result[$i][
'validator_photo'] = $obj->validator_photo;
620 $tab_result[$i][
'country_id'] = (int) $obj->country_id;
626 $this->holiday = $tab_result;
630 $this->error =
"Error ".$this->db->lasterror();
645 $sql .=
" cp.rowid,";
647 $sql .=
" cp.fk_user,";
648 $sql .=
" cp.fk_type,";
649 $sql .=
" cp.date_create,";
650 $sql .=
" cp.tms as date_modification,";
651 $sql .=
" cp.description,";
652 $sql .=
" cp.date_debut,";
653 $sql .=
" cp.date_fin,";
654 $sql .=
" cp.halfday,";
655 $sql .=
" cp.statut as status,";
656 $sql .=
" cp.fk_validator,";
657 $sql .=
" cp.date_valid,";
658 $sql .=
" cp.fk_user_valid,";
659 $sql .=
" cp.date_approval,";
660 $sql .=
" cp.fk_user_approve,";
661 $sql .=
" cp.date_refuse,";
662 $sql .=
" cp.fk_user_refuse,";
663 $sql .=
" cp.date_cancel,";
664 $sql .=
" cp.fk_user_cancel,";
665 $sql .=
" cp.detail_refuse,";
667 $sql .=
" uu.lastname as user_lastname,";
668 $sql .=
" uu.firstname as user_firstname,";
669 $sql .=
" uu.login as user_login,";
670 $sql .=
" uu.statut as user_status,";
671 $sql .=
" uu.photo as user_photo,";
673 $sql .=
" ua.lastname as validator_lastname,";
674 $sql .=
" ua.firstname as validator_firstname,";
675 $sql .=
" ua.login as validator_login,";
676 $sql .=
" ua.statut as validator_status,";
677 $sql .=
" ua.photo as validator_photo";
679 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp, ".MAIN_DB_PREFIX.
"user as uu, ".MAIN_DB_PREFIX.
"user as ua";
680 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
681 $sql .=
" AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid ";
684 if (!empty($filter)) {
689 if (!empty($order)) {
693 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
694 $resql = $this->db->query($sql);
699 $tab_result = $this->holiday;
700 $num = $this->db->num_rows($resql);
709 $obj = $this->db->fetch_object($resql);
711 $tab_result[$i][
'rowid'] = $obj->rowid;
712 $tab_result[$i][
'id'] = $obj->rowid;
713 $tab_result[$i][
'ref'] = ($obj->ref ? $obj->ref : $obj->rowid);
715 $tab_result[$i][
'fk_user'] = $obj->fk_user;
716 $tab_result[$i][
'fk_type'] = $obj->fk_type;
717 $tab_result[$i][
'date_create'] = $this->db->jdate($obj->date_create);
718 $tab_result[$i][
'date_modification'] = $this->db->jdate($obj->date_modification);
719 $tab_result[$i][
'description'] = $obj->description;
720 $tab_result[$i][
'date_debut'] = $this->db->jdate($obj->date_debut);
721 $tab_result[$i][
'date_fin'] = $this->db->jdate($obj->date_fin);
722 $tab_result[$i][
'date_debut_gmt'] = $this->db->jdate($obj->date_debut, 1);
723 $tab_result[$i][
'date_fin_gmt'] = $this->db->jdate($obj->date_fin, 1);
724 $tab_result[$i][
'halfday'] = $obj->halfday;
725 $tab_result[$i][
'statut'] = $obj->status;
726 $tab_result[$i][
'status'] = $obj->status;
727 $tab_result[$i][
'fk_validator'] = $obj->fk_validator;
728 $tab_result[$i][
'date_valid'] = $this->db->jdate($obj->date_valid);
729 $tab_result[$i][
'fk_user_valid'] = $obj->fk_user_valid;
730 $tab_result[$i][
'date_approval'] = $this->db->jdate($obj->date_approval);
731 $tab_result[$i][
'fk_user_approve'] = $obj->fk_user_approve;
732 $tab_result[$i][
'date_refuse'] = $obj->date_refuse;
733 $tab_result[$i][
'fk_user_refuse'] = $obj->fk_user_refuse;
734 $tab_result[$i][
'date_cancel'] = $obj->date_cancel;
735 $tab_result[$i][
'fk_user_cancel'] = $obj->fk_user_cancel;
736 $tab_result[$i][
'detail_refuse'] = $obj->detail_refuse;
738 $tab_result[$i][
'user_firstname'] = $obj->user_firstname;
739 $tab_result[$i][
'user_lastname'] = $obj->user_lastname;
740 $tab_result[$i][
'user_login'] = $obj->user_login;
741 $tab_result[$i][
'user_statut'] = $obj->user_status;
742 $tab_result[$i][
'user_status'] = $obj->user_status;
743 $tab_result[$i][
'user_photo'] = $obj->user_photo;
745 $tab_result[$i][
'validator_firstname'] = $obj->validator_firstname;
746 $tab_result[$i][
'validator_lastname'] = $obj->validator_lastname;
747 $tab_result[$i][
'validator_login'] = $obj->validator_login;
748 $tab_result[$i][
'validator_statut'] = $obj->validator_status;
749 $tab_result[$i][
'validator_status'] = $obj->validator_status;
750 $tab_result[$i][
'validator_photo'] = $obj->validator_photo;
755 $this->holiday = $tab_result;
759 $this->error =
"Error ".$this->db->lasterror();
772 public function validate($user =
null, $notrigger = 0)
774 global $conf, $langs;
775 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
779 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
781 if ($checkBalance > 0) {
782 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
786 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
787 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
788 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1, (
int) $this->halfday);
790 if (($balance - $daysAsked) < 0) {
791 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
797 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref) || $this->
ref == $this->
id) {
800 $num = (string) $this->
ref;
805 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
806 $sql .=
" fk_user_valid = ".((int) $user->id).
",";
807 $sql .=
" date_valid = '".$this->db->idate(
dol_now()).
"',";
808 if (!empty($this->
status) && is_numeric($this->
status)) {
809 $sql .=
" statut = ".((int) $this->
status).
",";
811 $this->error =
'Property status must be a numeric value';
814 $sql .=
" ref = '".$this->db->escape($num).
"'";
815 $sql .=
" WHERE rowid = ".((int) $this->
id);
819 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
820 $resql = $this->db->query($sql);
823 $this->errors[] =
"Error ".$this->db->lasterror();
829 $result = $this->call_trigger(
'HOLIDAY_VALIDATE', $user);
838 $this->oldref = $this->ref;
841 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
843 $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) .
"'";
844 $sql .=
" WHERE filename LIKE '" . $this->db->escape($this->
ref) .
"%' AND filepath = 'holiday/" . $this->db->escape($this->
ref) .
"' and entity = " . ((int) $conf->entity);
845 $resql = $this->db->query($sql);
848 $this->error = $this->db->lasterror();
850 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'holiday/".$this->db->escape($this->newref).
"'";
851 $sql .=
" WHERE filepath = 'holiday/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
852 $resql = $this->db->query($sql);
855 $this->error = $this->db->lasterror();
861 $dirsource = $conf->holiday->multidir_output[$this->entity] .
'/' . $oldref;
862 $dirdest = $conf->holiday->multidir_output[$this->entity] .
'/' . $newref;
863 if (!$error && file_exists($dirsource)) {
864 dol_syslog(get_class($this) .
"::validate rename dir " . $dirsource .
" into " . $dirdest);
865 if (@rename($dirsource, $dirdest)) {
868 $listoffiles =
dol_dir_list($dirdest,
'files', 1,
'^' . preg_quote($oldref,
'/'));
869 foreach ($listoffiles as $fileentry) {
870 $dirsource = $fileentry[
'name'];
871 $dirdest = preg_replace(
'/^' . preg_quote($oldref,
'/') .
'/', $newref, $dirsource);
872 $dirsource = $fileentry[
'path'] .
'/' . $dirsource;
873 $dirdest = $fileentry[
'path'] .
'/' . $dirdest;
874 @rename($dirsource, $dirdest);
884 foreach ($this->errors as $errmsg) {
885 dol_syslog(get_class($this).
"::validate ".$errmsg, LOG_ERR);
886 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
888 $this->db->rollback();
904 public function approve($user =
null, $notrigger = 0)
908 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
910 if ($checkBalance > 0) {
911 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
915 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
916 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
917 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1, (
int) $this->halfday);
919 if (($balance - $daysAsked) < 0) {
920 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
926 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
927 $sql .=
" description= '".$this->db->escape($this->
description).
"',";
928 if (!empty($this->date_debut)) {
929 $sql .=
" date_debut = '".$this->db->idate($this->date_debut).
"',";
933 if (!empty($this->date_fin)) {
934 $sql .=
" date_fin = '".$this->db->idate($this->date_fin).
"',";
938 $sql .=
" halfday = ".((int) $this->halfday).
",";
939 if (!empty($this->
status) && is_numeric($this->
status)) {
940 $sql .=
" statut = ".((int) $this->
status).
",";
944 if (!empty($this->fk_validator)) {
945 $sql .=
" fk_validator = ".((int) $this->fk_validator).
",";
949 if (!empty($this->date_valid)) {
950 $sql .=
" date_valid = '".$this->db->idate($this->date_valid).
"',";
952 $sql .=
" date_valid = NULL,";
954 if (!empty($this->fk_user_valid)) {
955 $sql .=
" fk_user_valid = ".((int) $this->fk_user_valid).
",";
957 $sql .=
" fk_user_valid = NULL,";
959 if (!empty($this->date_approval)) {
960 $sql .=
" date_approval = '".$this->db->idate($this->date_approval).
"',";
962 $sql .=
" date_approval = NULL,";
964 if (!empty($this->fk_user_approve)) {
965 $sql .=
" fk_user_approve = ".((int) $this->fk_user_approve).
",";
967 $sql .=
" fk_user_approve = NULL,";
969 if (!empty($this->date_refuse)) {
970 $sql .=
" date_refuse = '".$this->db->idate($this->date_refuse).
"',";
972 $sql .=
" date_refuse = NULL,";
974 if (!empty($this->fk_user_refuse)) {
975 $sql .=
" fk_user_refuse = ".((int) $this->fk_user_refuse).
",";
977 $sql .=
" fk_user_refuse = NULL,";
979 if (!empty($this->date_cancel)) {
980 $sql .=
" date_cancel = '".$this->db->idate($this->date_cancel).
"',";
982 $sql .=
" date_cancel = NULL,";
984 if (!empty($this->fk_user_cancel)) {
985 $sql .=
" fk_user_cancel = ".((int) $this->fk_user_cancel).
",";
987 $sql .=
" fk_user_cancel = NULL,";
989 if (!empty($this->detail_refuse)) {
990 $sql .=
" detail_refuse = '".$this->db->escape($this->detail_refuse).
"'";
992 $sql .=
" detail_refuse = NULL";
994 $sql .=
" WHERE rowid = ".((int) $this->
id);
998 dol_syslog(get_class($this).
"::approve", LOG_DEBUG);
999 $resql = $this->db->query($sql);
1002 $this->errors[] =
"Error ".$this->db->lasterror();
1008 $result = $this->call_trigger(
'HOLIDAY_APPROVE', $user);
1018 foreach ($this->errors as $errmsg) {
1019 dol_syslog(get_class($this).
"::approve ".$errmsg, LOG_ERR);
1020 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1022 $this->db->rollback();
1025 $this->db->commit();
1037 public function update($user =
null, $notrigger = 0)
1039 global $conf, $langs;
1042 $checkBalance =
getDictionaryValue(
'c_holiday_types',
'block_if_negative', $this->fk_type,
true);
1043 if ($this->
status == self::STATUS_REFUSED || $this->
status == self::STATUS_APPROVED) {
1047 if ($checkBalance > 0 && $this->statut != self::STATUS_DRAFT && $this->statut != self::STATUS_CANCELED) {
1048 $balance = $this->
getCPforUser($this->fk_user, $this->fk_type);
1052 $datedebutforcount = !empty($this->date_debut_gmt) ? $this->date_debut_gmt : $this->date_debut;
1053 $datefinforcount = !empty($this->date_fin_gmt) ? $this->date_fin_gmt : $this->date_fin;
1054 $daysAsked =
num_open_day($datedebutforcount, $datefinforcount, 0, 1, (
int) $this->halfday);
1056 if (($balance - $daysAsked) < 0) {
1057 $this->error =
'LeaveRequestCreationBlockedBecauseBalanceIsNegative';
1063 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday SET";
1065 $sql .=
" description= '".$this->db->escape($this->
description).
"',";
1067 if (!empty($this->date_debut)) {
1068 $sql .=
" date_debut = '".$this->db->idate($this->date_debut).
"',";
1072 if (!empty($this->date_fin)) {
1073 $sql .=
" date_fin = '".$this->db->idate($this->date_fin).
"',";
1077 $sql .=
" halfday = ".((int) $this->halfday).
",";
1078 if (!empty($this->
status) && is_numeric($this->
status)) {
1079 $sql .=
" statut = ".((int) $this->
status).
",";
1083 if (!empty($this->fk_validator)) {
1084 $sql .=
" fk_validator = ".((int) $this->fk_validator).
",";
1088 if (!empty($this->date_valid)) {
1089 $sql .=
" date_valid = '".$this->db->idate($this->date_valid).
"',";
1091 $sql .=
" date_valid = NULL,";
1093 if (!empty($this->fk_user_valid)) {
1094 $sql .=
" fk_user_valid = ".((int) $this->fk_user_valid).
",";
1096 $sql .=
" fk_user_valid = NULL,";
1098 if (!empty($this->date_approval)) {
1099 $sql .=
" date_approval = '".$this->db->idate($this->date_approval).
"',";
1101 $sql .=
" date_approval = NULL,";
1103 if (!empty($this->fk_user_approve)) {
1104 $sql .=
" fk_user_approve = ".((int) $this->fk_user_approve).
",";
1106 $sql .=
" fk_user_approve = NULL,";
1108 if (!empty($this->date_refuse)) {
1109 $sql .=
" date_refuse = '".$this->db->idate($this->date_refuse).
"',";
1111 $sql .=
" date_refuse = NULL,";
1113 if (!empty($this->fk_user_refuse)) {
1114 $sql .=
" fk_user_refuse = ".((int) $this->fk_user_refuse).
",";
1116 $sql .=
" fk_user_refuse = NULL,";
1118 if (!empty($this->date_cancel)) {
1119 $sql .=
" date_cancel = '".$this->db->idate($this->date_cancel).
"',";
1121 $sql .=
" date_cancel = NULL,";
1123 if (!empty($this->fk_user_cancel)) {
1124 $sql .=
" fk_user_cancel = ".((int) $this->fk_user_cancel).
",";
1126 $sql .=
" fk_user_cancel = NULL,";
1128 if (!empty($this->detail_refuse)) {
1129 $sql .=
" detail_refuse = '".$this->db->escape($this->detail_refuse).
"'";
1131 $sql .=
" detail_refuse = NULL";
1134 $sql .=
" WHERE rowid = ".((int) $this->
id);
1138 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1139 $resql = $this->db->query($sql);
1142 $this->errors[] =
"Error ".$this->db->lasterror();
1153 if (!$notrigger && $user !==
null) {
1155 $result = $this->call_trigger(
'HOLIDAY_MODIFY', $user);
1165 foreach ($this->errors as $errmsg) {
1166 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1167 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1169 $this->db->rollback();
1172 $this->db->commit();
1185 public function delete($user, $notrigger = 0)
1187 global $conf, $langs;
1190 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"holiday";
1191 $sql .=
" WHERE rowid=".((int) $this->
id);
1202 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1203 $resql = $this->db->query($sql);
1206 $this->errors[] =
"Error ".$this->db->lasterror();
1213 $result = $this->call_trigger(
'HOLIDAY_DELETE', $user);
1223 foreach ($this->errors as $errmsg) {
1224 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1225 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1227 $this->db->rollback();
1230 $this->db->commit();
1252 foreach ($this->holiday as $infos_CP) {
1263 if ($halfday == 0) {
1264 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1267 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1270 } elseif ($halfday == -1) {
1272 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1273 if ($dateStart < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1277 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1278 if ($dateStart < $dateEnd) {
1281 if ($dateEnd < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1285 } elseif ($halfday == 1) {
1287 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1288 if ($dateStart < $dateEnd) {
1291 if ($dateStart > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1295 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1296 if ($dateEnd > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1300 } elseif ($halfday == 2) {
1302 if ($dateStart >= $infos_CP[
'date_debut'] && $dateStart <= $infos_CP[
'date_fin']) {
1303 if ($dateStart < $infos_CP[
'date_fin'] || in_array($infos_CP[
'halfday'], array(0, -1))) {
1307 if ($dateEnd <= $infos_CP[
'date_fin'] && $dateEnd >= $infos_CP[
'date_debut']) {
1308 if ($dateEnd > $infos_CP[
'date_debut'] || in_array($infos_CP[
'halfday'], array(0, 1))) {
1313 dol_print_error(
null,
'Bad value of parameter halfday when calling function verifDateHolidayCP');
1332 $isavailablemorning =
true;
1333 $isavailableafternoon =
true;
1336 $sql =
"SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut as status";
1337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp";
1338 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
1339 $sql .=
" AND cp.fk_user = ".(int) $fk_user;
1340 $sql .=
" AND cp.date_debut <= '".$this->db->idate($timestamp).
"' AND cp.date_fin >= '".$this->db->idate($timestamp).
"'";
1341 if ($status !=
'-1') {
1342 $sql .=
" AND cp.statut IN (".$this->db->sanitize($status).
")";
1345 $resql = $this->db->query($sql);
1347 $num_rows = $this->db->num_rows($resql);
1348 if ($num_rows > 0) {
1349 $arrayofrecord = array();
1351 while ($i < $num_rows) {
1352 $obj = $this->db->fetch_object($resql);
1355 $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);
1360 $isavailablemorning =
true;
1361 foreach ($arrayofrecord as $record) {
1362 if ($timestamp == $record[
'date_start'] && $record[
'halfday'] == 2) {
1365 if ($timestamp == $record[
'date_start'] && $record[
'halfday'] == -1) {
1368 $isavailablemorning =
false;
1371 $isavailableafternoon =
true;
1372 foreach ($arrayofrecord as $record) {
1373 if ($timestamp == $record[
'date_end'] && $record[
'halfday'] == 2) {
1376 if ($timestamp == $record[
'date_end'] && $record[
'halfday'] == 1) {
1379 $isavailableafternoon =
false;
1387 $result = array(
'morning' => (
int) $isavailablemorning,
'afternoon' => (
int) $isavailableafternoon);
1388 if (!$isavailablemorning) {
1389 $result[
'morning_reason'] =
'leave_request';
1391 if (!$isavailableafternoon) {
1392 $result[
'afternoon_reason'] =
'leave_request';
1407 $langs->load(
'holiday');
1408 $nofetch = !empty($params[
'nofetch']);
1411 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Holiday").
'</u>';
1412 if (isset($this->
status)) {
1413 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1415 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1417 if (!$nofetch && !empty($this->fk_type)) {
1418 $typeleaves = $this->
getTypes(1, -1);
1419 if (empty($typeleaves[$this->fk_type])) {
1420 $labeltoshow = $langs->trans(
"TypeWasDisabledOrRemoved", $this->fk_type);
1422 $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']);
1424 $datas[
'type'] =
'<br><b>'.$langs->trans(
"Type") .
':</b> ' . $labeltoshow;
1426 if (isset($this->halfday) && !empty($this->date_debut) && !empty($this->date_fin)) {
1427 $listhalfday = array(
1428 'morning' => $langs->trans(
"Morning"),
1429 "afternoon" => $langs->trans(
"Afternoon")
1431 $starthalfday = ($this->halfday == -1 || $this->halfday == 2) ?
'afternoon' :
'morning';
1432 $endhalfday = ($this->halfday == 1 || $this->halfday == 2) ?
'morning' :
'afternoon';
1433 $datas[
'date_start'] =
'<br><b>'.$langs->trans(
'DateDebCP') .
'</b>: '.
dol_print_date($this->date_debut,
'day') .
' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).
'</span>';
1434 $datas[
'date_end'] =
'<br><b>'.$langs->trans(
'DateFinCP') .
'</b>: '.
dol_print_date($this->date_fin,
'day') .
' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).
'</span>';
1450 public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
1452 global $conf, $langs, $hookmanager;
1454 if (!empty($conf->dol_no_mouse_hover)) {
1461 'objecttype' => $this->element,
1464 $classfortooltip =
'classfortooltip';
1467 $classfortooltip =
'classforajaxtooltip';
1468 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1474 $url = DOL_URL_ROOT.
'/holiday/card.php?id='.$this->id;
1479 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1480 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1481 $add_save_lastsearch_values = 1;
1483 if ($add_save_lastsearch_values) {
1484 $url .=
'&save_lastsearch_values=1';
1489 if (empty($notooltip)) {
1491 $label = $langs->trans(
"ShowMyObject");
1492 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1494 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1495 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1497 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1500 $linkstart =
'<a href="'.$url.
'"';
1501 $linkstart .= $linkclose.
'>';
1504 $result .= $linkstart;
1507 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1509 if ($withpicto != 2) {
1510 $result .= $this->ref;
1512 $result .= $linkend;
1515 $hookmanager->initHooks(array($this->element .
'dao'));
1516 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1517 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1519 $result = $hookmanager->resPrint;
1521 $result .= $hookmanager->resPrint;
1547 public function LibStatut($status, $mode = 0, $startdate =
'')
1552 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1560 $this->labelStatusShort[
self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'DraftCP');
1568 $statusType =
'status6';
1569 if (!empty($startdate) && $startdate >=
dol_now()) {
1570 $statusType =
'status4';
1571 $params = array(
'tooltip' => $this->labelStatus[$status].
' - '.$langs->trans(
"Forthcoming"));
1573 if ($status == self::STATUS_DRAFT) {
1574 $statusType =
'status0';
1576 if ($status == self::STATUS_VALIDATED) {
1577 $statusType =
'status1';
1579 if ($status == self::STATUS_CANCELED) {
1580 $statusType =
'status9';
1582 if ($status == self::STATUS_REFUSED) {
1583 $statusType =
'status9';
1586 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode,
'', $params);
1598 public function selectStatutCP($selected = 0, $htmlname =
'select_statut', $morecss =
'minwidth125')
1603 $name = array(
'DraftCP',
'ToReviewCP',
'ApprovedCP',
'CancelCP',
'RefuseCP');
1604 $nb = count($name) + 1;
1607 $out =
'<select name="'.$htmlname.
'" id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'">'.
"\n";
1608 $out .=
'<option value="-1"> </option>'.
"\n";
1611 for ($i = 1; $i < $nb; $i++) {
1612 if ($i == $selected) {
1613 $out .=
'<option value="'.$i.
'" selected>'.$langs->trans($name[$i - 1]).
'</option>'.
"\n";
1615 $out .=
'<option value="'.$i.
'">'.$langs->trans($name[$i - 1]).
'</option>'.
"\n";
1619 $out .=
"</select>\n";
1622 $out .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($showempty < 0 ? (
string) $showempty :
'-1'), $morecss);
1636 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_config SET";
1637 $sql .=
" value = '".$this->db->escape($value).
"'";
1638 $sql .=
" WHERE name = '".$this->db->escape($name).
"'";
1640 dol_syslog(get_class($this).
'::updateConfCP name='.$name, LOG_DEBUG);
1641 $result = $this->db->query($sql);
1659 $sql =
"SELECT value";
1660 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_config";
1661 $sql .=
" WHERE name = '".$this->db->escape($name).
"'";
1663 dol_syslog(get_class($this).
'::getConfCP name='.$name.
' createifnotfound='.$createifnotfound, LOG_DEBUG);
1664 $result = $this->db->query($sql);
1667 $obj = $this->db->fetch_object($result);
1670 if ($createifnotfound) {
1671 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_config(name, value)";
1672 $sql .=
" VALUES('".$this->db->escape($name).
"', '".$this->db->escape($createifnotfound).
"')";
1673 $result = $this->db->query($sql);
1675 return $createifnotfound;
1677 $this->error = $this->db->lasterror();
1688 $this->error = $this->db->lasterror();
1703 global $user, $langs;
1707 if (empty($userID) && empty($nbHoliday) && empty($fk_type)) {
1708 $langs->load(
"holiday");
1721 if (empty($stringInDBForLastUpdate)) {
1724 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_config SET";
1725 $sql .=
" value = '".$this->db->escape($stringInDBForLastUpdate).
"'";
1726 $sql .=
" WHERE name = 'lastUpdate'";
1727 $result = $this->db->query($sql);
1729 $this->error = $this->db->lasterror();
1734 if ($stringInDBForLastUpdate <
'20000101000000') {
1735 $stringInDBForLastUpdate =
'20000101000000';
1746 while ($yearMonthLastUpdate < $yearMonthNow) {
1752 $users = $this->
fetchUsers(
false,
false,
' AND u.statut > 0');
1753 $nbUser = count($users);
1755 $typeleaves = $this->
getTypes(1, 1);
1758 foreach ($users as $userCounter) {
1759 $nbDaysToAdd = (isset($typeleaves[$userCounter[
'type']][
'newbymonth']) ? $typeleaves[$userCounter[
'type']][
'newbymonth'] : 0);
1760 if (empty($nbDaysToAdd)) {
1764 dol_syslog(
"We update leave type id ".$userCounter[
'type'].
" for user id ".$userCounter[
'rowid'], LOG_DEBUG);
1766 $nowHoliday = (float) $userCounter[
'nb_holiday'];
1767 $newSolde = $nowHoliday + $nbDaysToAdd;
1770 $this->
addLogCP($user->id, $userCounter[
'rowid'], $langs->trans(
'HolidayMonthlyCredit'), $newSolde, $userCounter[
'type']);
1772 $result = $this->
updateSoldeCP($userCounter[
'rowid'], $newSolde, $userCounter[
'type']);
1775 $this->db->rollback();
1779 if (empty($decrease)) {
1784 $filter =
" AND cp.statut = ".((int) self::STATUS_APPROVED);
1787 $filter .=
" AND cp.fk_type = ".((int) $userCounter[
'type']);
1788 $this->
fetchByUser($userCounter[
'id'],
'', $filter);
1790 if (empty($this->holiday)) {
1794 $startOfMonth =
dol_mktime(0, 0, 0, (
int) $month, 1, (
int) $year, 1);
1797 foreach ($this->holiday as $obj) {
1798 $startDate = $obj[
'date_debut_gmt'];
1799 $endDate = $obj[
'date_fin_gmt'];
1801 if ($startDate <= $endOfMonth && $startDate < $startOfMonth) {
1802 $startDate = $startOfMonth;
1805 if ($startOfMonth <= $endDate && $endDate > $endOfMonth) {
1806 $endDate = $endOfMonth;
1809 $nbDaysToDeduct = (float)
num_open_day($startDate, $endDate, 0, 1, $obj[
'halfday'], $obj[
'country_id']);
1811 if ($nbDaysToDeduct <= 0) {
1815 $newSolde -= $nbDaysToDeduct;
1818 $this->
addLogCP($user->id, $userCounter[
'rowid'], $obj[
'ref'].
' - '.$langs->trans(
'HolidayConsumption'), $newSolde, $userCounter[
'type']);
1820 $result = $this->
updateSoldeCP($userCounter[
'rowid'], $newSolde, $userCounter[
'type']);
1823 $this->db->rollback();
1831 $lastUpdate =
dol_mktime(0, 0, 0, (
int) $newMonth[
'month'], 1, (
int) $newMonth[
'year']);
1833 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_config SET";
1834 $sql .=
" value = '".$this->db->escape(
dol_print_date($lastUpdate,
'%Y%m%d%H%M%S')).
"'";
1835 $sql .=
" WHERE name = 'lastUpdate'";
1836 $result = $this->db->query($sql);
1839 $this->db->rollback();
1843 $this->db->commit();
1857 $sql =
"SELECT nb_holiday FROM ".MAIN_DB_PREFIX.
"holiday_users";
1858 $sql .=
" WHERE fk_user = ".(int) $userID.
" AND fk_type = ".(
int) $fk_type;
1859 $resql = $this->db->query($sql);
1861 $num = $this->db->num_rows($resql);
1865 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"holiday_users SET";
1866 $sql .=
" nb_holiday = ".((float) $nbHoliday);
1867 $sql .=
" WHERE fk_user = ".(int) $userID.
" AND fk_type = ".(
int) $fk_type;
1868 $result = $this->db->query($sql);
1871 $this->errors[] = $this->db->lasterror();
1875 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users(nb_holiday, fk_user, fk_type) VALUES (";
1876 $sql .= ((float) $nbHoliday);
1877 $sql .=
", ".(int) $userID.
", ".(
int) $fk_type.
")";
1878 $result = $this->db->query($sql);
1881 $this->errors[] = $this->db->lasterror();
1885 $this->errors[] = $this->db->lasterror();
1908 dol_syslog(get_class($this).
'::createCPusers');
1909 $arrayofusers = $this->
fetchUsers(
false,
true);
1911 foreach ($arrayofusers as $users) {
1912 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users";
1913 $sql .=
" (fk_user, nb_holiday)";
1914 $sql .=
" VALUES (".((int) $users[
'rowid']).
"', '0')";
1916 $resql = $this->db->query($sql);
1922 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_users";
1923 $sql .=
" (fk_user, nb_holiday)";
1924 $sql .=
" VALUES (".((int) $userid).
"', '0')";
1926 $resql = $this->db->query($sql);
1942 $sql =
"SELECT nb_holiday";
1943 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users";
1944 $sql .=
" WHERE fk_user = ".(int) $user_id;
1946 $sql .=
" AND fk_type = ".(int) $fk_type;
1949 dol_syslog(get_class($this).
'::getCPforUser user_id='.$user_id.
' type_id='.$fk_type, LOG_DEBUG);
1950 $result = $this->db->query($sql);
1952 $obj = $this->db->fetch_object($result);
1955 return $obj->nb_holiday;
1972 public function fetchUsers($stringlist =
true, $type =
true, $filters =
'')
1974 dol_syslog(get_class($this).
"::fetchUsers", LOG_DEBUG);
1981 $sql .=
" DISTINCT";
1984 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1987 $sql .=
", ".MAIN_DB_PREFIX.
"usergroup_user as ug";
1988 $sql .=
" WHERE ((ug.fk_user = u.rowid";
1989 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
1990 $sql .=
" OR u.entity = 0)";
1992 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
1994 $sql .=
" AND u.statut > 0";
1995 $sql .=
" AND u.employee = 1";
2000 $resql = $this->db->query($sql);
2005 $num = $this->db->num_rows($resql);
2010 $obj = $this->db->fetch_object($resql);
2013 $stringlist .= $obj->rowid;
2015 $stringlist .=
', '.$obj->rowid;
2024 $this->error =
"Error ".$this->db->lasterror();
2029 $sql =
"SELECT DISTINCT cpu.fk_user";
2030 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users as cpu, ".MAIN_DB_PREFIX.
"user as u";
2031 $sql .=
" WHERE cpu.fk_user = u.rowid";
2036 $resql = $this->db->query($sql);
2041 $num = $this->db->num_rows($resql);
2046 $obj = $this->db->fetch_object($resql);
2049 $stringlist .= $obj->fk_user;
2051 $stringlist .=
', '.$obj->fk_user;
2060 $this->error =
"Error ".$this->db->lasterror();
2071 $sql .=
" DISTINCT";
2073 $sql .=
" u.rowid, u.lastname, u.firstname, u.gender, u.fk_country as country_id, u.photo, u.employee, u.statut as status, u.fk_user";
2074 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
2077 $sql .=
", ".MAIN_DB_PREFIX.
"usergroup_user as ug";
2078 $sql .=
" WHERE ((ug.fk_user = u.rowid";
2079 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
2080 $sql .=
" OR u.entity = 0)";
2082 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
2085 $sql .=
" AND u.statut > 0";
2086 $sql .=
" AND u.employee = 1";
2091 $resql = $this->db->query($sql);
2096 $tab_result = $this->holiday;
2097 $num = $this->db->num_rows($resql);
2101 $obj = $this->db->fetch_object($resql);
2103 $tab_result[$i][
'rowid'] = (int) $obj->rowid;
2104 $tab_result[$i][
'id'] = (int) $obj->rowid;
2105 $tab_result[$i][
'name'] = $obj->lastname;
2106 $tab_result[$i][
'lastname'] = $obj->lastname;
2107 $tab_result[$i][
'firstname'] = $obj->firstname;
2108 $tab_result[$i][
'gender'] = $obj->gender;
2109 $tab_result[$i][
'status'] = (int) $obj->status;
2110 $tab_result[$i][
'employee'] = (int) $obj->employee;
2111 $tab_result[$i][
'photo'] = $obj->photo;
2112 $tab_result[$i][
'fk_user'] = (int) $obj->fk_user;
2113 $tab_result[$i][
'country_id'] = (int) $obj->country_id;
2123 $this->errors[] =
"Error ".$this->db->lasterror();
2128 $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";
2129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_users as cpu, ".MAIN_DB_PREFIX.
"user as u";
2130 $sql .=
" WHERE cpu.fk_user = u.rowid";
2135 $resql = $this->db->query($sql);
2140 $tab_result = $this->holiday;
2141 $num = $this->db->num_rows($resql);
2145 $obj = $this->db->fetch_object($resql);
2147 $tab_result[$i][
'rowid'] = $obj->rowid;
2148 $tab_result[$i][
'id'] = $obj->rowid;
2149 $tab_result[$i][
'name'] = $obj->lastname;
2150 $tab_result[$i][
'lastname'] = $obj->lastname;
2151 $tab_result[$i][
'firstname'] = $obj->firstname;
2152 $tab_result[$i][
'gender'] = $obj->gender;
2153 $tab_result[$i][
'status'] = $obj->status;
2154 $tab_result[$i][
'employee'] = $obj->employee;
2155 $tab_result[$i][
'photo'] = $obj->photo;
2156 $tab_result[$i][
'fk_user'] = $obj->fk_user;
2158 $tab_result[$i][
'type'] = $obj->fk_type;
2159 $tab_result[$i][
'nb_holiday'] = $obj->nb_holiday;
2167 $this->error =
"Error ".$this->db->lasterror();
2185 $users_validator = array();
2187 $sql =
"SELECT DISTINCT ur.fk_user";
2188 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_rights as ur, ".MAIN_DB_PREFIX.
"rights_def as rd";
2189 $sql .=
" WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'";
2191 $sql .=
" SELECT DISTINCT ugu.fk_user";
2192 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup_user as ugu, ".MAIN_DB_PREFIX.
"usergroup_rights as ur, ".MAIN_DB_PREFIX.
"rights_def as rd";
2193 $sql .=
" WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'";
2196 dol_syslog(get_class($this).
"::fetch_users_approver_holiday sql=".$sql);
2197 $result = $this->db->query($sql);
2199 $num_rows = $this->db->num_rows($result);
2201 while ($i < $num_rows) {
2202 $objp = $this->db->fetch_object($result);
2203 array_push($users_validator, $objp->fk_user);
2206 return $users_validator;
2208 $this->error = $this->db->lasterror();
2209 dol_syslog(get_class($this).
"::fetch_users_approver_holiday Error ".$this->error, LOG_ERR);
2222 $sql =
"SELECT count(u.rowid) as compteur";
2223 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
2224 $sql .=
" WHERE u.statut > 0";
2226 $result = $this->db->query($sql);
2227 $object = $this->db->fetch_object($result);
2238 $sql =
"SELECT count(u.rowid) as compteur";
2239 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u LEFT JOIN ".MAIN_DB_PREFIX.
"holiday_users hu ON (hu.fk_user=u.rowid)";
2240 $sql .=
" WHERE u.statut > 0 AND hu.fk_user IS NULL";
2242 $result = $this->db->query($sql);
2243 $object = $this->db->fetch_object($result);
2257 if (empty($userCP)) {
2260 dol_syslog(get_class($this).
'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.
' userCP='.$userCP);
2275 public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type)
2283 if ($prev_solde == $new_solde) {
2290 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"holiday_logs (";
2291 $sql .=
"date_action,";
2292 $sql .=
"fk_user_action,";
2293 $sql .=
"fk_user_update,";
2294 $sql .=
"type_action,";
2295 $sql .=
"prev_solde,";
2296 $sql .=
"new_solde,";
2298 $sql .=
") VALUES (";
2299 $sql .=
" '".$this->db->idate(
dol_now()).
"',";
2300 $sql .=
" ".((int) $fk_user_action).
",";
2301 $sql .=
" ".((int) $fk_user_update).
",";
2302 $sql .=
" '".$this->db->escape($label).
"',";
2303 $sql .=
" ".((float) $prev_solde).
",";
2304 $sql .=
" ".((float) $new_solde).
",";
2305 $sql .=
" ".((int) $fk_type);
2308 $resql = $this->db->query($sql);
2311 $this->errors[] =
"Error ".$this->db->lasterror();
2316 $optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"holiday_logs");
2321 foreach ($this->errors as $errmsg) {
2322 dol_syslog(get_class($this).
"::addLogCP ".$errmsg, LOG_ERR);
2323 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2325 $this->db->rollback();
2328 $this->db->commit();
2343 $sql .=
" cpl.rowid,";
2344 $sql .=
" cpl.date_action,";
2345 $sql .=
" cpl.fk_user_action,";
2346 $sql .=
" cpl.fk_user_update,";
2347 $sql .=
" cpl.type_action,";
2348 $sql .=
" cpl.prev_solde,";
2349 $sql .=
" cpl.new_solde,";
2350 $sql .=
" cpl.fk_type";
2351 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday_logs as cpl";
2352 $sql .=
" WHERE cpl.rowid > 0";
2355 if (!empty($sqlwhere)) {
2356 $sql .=
" ".$sqlwhere;
2360 if (!empty($sqlorder)) {
2361 $sql .=
" ".$sqlorder;
2364 dol_syslog(get_class($this).
"::fetchLog", LOG_DEBUG);
2365 $resql = $this->db->query($sql);
2370 $tab_result = $this->logs;
2371 $num = $this->db->num_rows($resql);
2380 $obj = $this->db->fetch_object($resql);
2382 $tab_result[$i][
'rowid'] = (int) $obj->rowid;
2383 $tab_result[$i][
'id'] = (int) $obj->rowid;
2384 $tab_result[$i][
'date_action'] = (string) $obj->date_action;
2385 $tab_result[$i][
'fk_user_action'] = (int) $obj->fk_user_action;
2386 $tab_result[$i][
'fk_user_update'] = (int) $obj->fk_user_update;
2387 $tab_result[$i][
'type_action'] = (string) $obj->type_action;
2388 $tab_result[$i][
'prev_solde'] = (float) $obj->prev_solde;
2389 $tab_result[$i][
'new_solde'] = (float) $obj->new_solde;
2390 $tab_result[$i][
'fk_type'] = (int) $obj->fk_type;
2395 $this->logs = $tab_result;
2399 $this->error =
"Error ".$this->db->lasterror();
2416 $sql =
"SELECT rowid, code, label, affect, delay, newbymonth";
2417 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_holiday_types";
2418 $sql .=
" WHERE (fk_country IS NULL OR fk_country = ".((int)
$mysoc->country_id).
')';
2419 $sql .=
" AND entity IN (0, ".getEntity(
'c_holiday_types').
")";
2421 $sql .=
" AND active = ".((int) $active);
2424 $sql .=
" AND affect = ".((int) $affect);
2426 $sql .=
" ORDER BY sortorder";
2428 $result = $this->db->query($sql);
2430 $num = $this->db->num_rows($result);
2433 while ($obj = $this->db->fetch_object($result)) {
2434 $types[$obj->rowid] = array(
2435 'id' => $obj->rowid,
2436 'rowid' => $obj->rowid,
2437 'code' => $obj->code,
2438 'label' => $obj->label,
2439 'affect' => $obj->affect,
2440 'delay' => $obj->delay,
2441 'newbymonth' => $obj->newbymonth
2465 $sql =
"SELECT f.rowid, f.statut as status,";
2466 $sql .=
" f.date_create as datec,";
2467 $sql .=
" f.tms as date_modification,";
2468 $sql .=
" f.date_valid as datev,";
2469 $sql .=
" f.date_approval as datea,";
2470 $sql .=
" f.date_refuse as dater,";
2471 $sql .=
" f.fk_user_create as fk_user_creation,";
2472 $sql .=
" f.fk_user_modif as fk_user_modification,";
2473 $sql .=
" f.fk_user_valid as fk_user_validation,";
2474 $sql .=
" f.fk_user_approve as fk_user_approval_done,";
2475 $sql .=
" f.fk_validator as fk_user_approval_expected,";
2476 $sql .=
" f.fk_user_refuse as fk_user_refuse";
2477 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as f";
2478 $sql .=
" WHERE f.rowid = ".((int) $id);
2479 $sql .=
" AND f.entity = ".$conf->entity;
2481 $resql = $this->db->query($sql);
2483 if ($this->db->num_rows($resql)) {
2484 $obj = $this->db->fetch_object($resql);
2486 $this->
id = $obj->rowid;
2488 $this->date_creation = $this->db->jdate($obj->datec);
2489 $this->date_modification = $this->db->jdate($obj->date_modification);
2490 $this->date_validation = $this->db->jdate($obj->datev);
2491 $this->date_approval = $this->db->jdate($obj->datea);
2493 $this->user_creation_id = $obj->fk_user_creation;
2494 $this->user_validation_id = $obj->fk_user_validation;
2495 $this->user_modification_id = $obj->fk_user_modification;
2498 if ($obj->fk_user_approval_done) {
2499 $this->fk_user_approve = $obj->fk_user_approval_done;
2500 $this->user_approve_id = $obj->fk_user_approval_done;
2504 $this->db->free($resql);
2520 global $user, $langs;
2524 $this->specimen = 1;
2526 $this->fk_user = $user->id;
2528 $this->date_debut =
dol_now();
2529 $this->date_fin =
dol_now() + (24 * 3600);
2530 $this->date_valid =
dol_now();
2531 $this->fk_validator = $user->id;
2548 $this->nb = array();
2550 $sql =
"SELECT count(h.rowid) as nb";
2551 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as h";
2552 $sql .=
" WHERE h.statut > 1";
2553 $sql .=
" AND h.entity IN (".getEntity(
'holiday').
")";
2554 if (!$user->hasRight(
'holiday',
'readall')) {
2555 $userchildids = $user->getAllChildIds(1);
2556 $sql .=
" AND (h.fk_user IN (".$this->db->sanitize(implode(
',', $userchildids)).
")";
2557 $sql .=
" OR h.fk_validator IN (".$this->db->sanitize(implode(
',', $userchildids)).
"))";
2560 $resql = $this->db->query($sql);
2562 while ($obj = $this->db->fetch_object($resql)) {
2563 $this->nb[
"holidays"] = $obj->nb;
2565 $this->db->free($resql);
2569 $this->error = $this->db->error();
2584 global $conf, $langs;
2592 $sql =
"SELECT h.rowid, h.date_debut";
2593 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as h";
2594 $sql .=
" WHERE h.statut = 2";
2595 $sql .=
" AND h.entity IN (".getEntity(
'holiday').
")";
2596 if (!$user->hasRight(
'holiday',
'read_all')) {
2597 $userchildids = $user->getAllChildIds(1);
2598 $sql .=
" AND (h.fk_user IN (".$this->db->sanitize(implode(
',', $userchildids)).
")";
2599 $sql .=
" OR h.fk_validator IN (".$this->db->sanitize(implode(
',', $userchildids)).
"))";
2602 $resql = $this->db->query($sql);
2604 $langs->load(
"members");
2607 $response->warning_delay = $conf->holiday->approve->warning_delay / 60 / 60 / 24;
2608 $response->label = $langs->trans(
"HolidaysToApprove");
2609 $response->labelShort = $langs->trans(
"ToApprove");
2610 $response->url = DOL_URL_ROOT.
'/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday';
2613 while ($obj = $this->db->fetch_object($resql)) {
2614 $response->nbtodo++;
2616 if ($this->db->jdate($obj->date_debut) < ($now - $conf->holiday->approve->warning_delay)) {
2617 $response->nbtodolate++;
2624 $this->error = $this->db->error();
2639 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
2641 $return =
'<div class="box-flex-item box-flex-grow-zero">';
2642 $return .=
'<div class="info-box info-box-sm">';
2643 $return .=
'<span class="info-box-icon bg-infobox-action">';
2645 $return .=
'</span>';
2646 $return .=
'<div class="info-box-content">';
2647 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl().
'</span>';
2648 if ($selected >= 0) {
2649 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2651 if (property_exists($this,
'fk_type')) {
2654 $return .=
'<div class="info_box-label tdoverflowmax100" title="'.dol_escape_htmltag($arraydata[
'labeltype']).
'">'.
dol_escape_htmltag($arraydata[
'labeltype']).
'</div>';
2656 if (property_exists($this,
'date_debut') && property_exists($this,
'date_fin')) {
2657 $return .=
'<span class="info-box-label small">'.dol_print_date($this->date_debut,
'day').
'</span>';
2658 $return .=
' <span class="opacitymedium small">'.$langs->trans(
"To").
'</span> ';
2659 $return .=
'<span class="info-box-label small">'.dol_print_date($this->date_fin,
'day').
'</span>';
2660 if (!empty($arraydata[
'nbopenedday'])) {
2661 $return .=
' ('.$arraydata[
'nbopenedday'].
')';
2664 if (method_exists($this,
'getLibStatut')) {
2665 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2667 $return .=
'</div>';
2668 $return .=
'</div>';
2669 $return .=
'</div>';
if(! $sortfield) if(! $sortorder) $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...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
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, $countryCodeOrId='')
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_now($mode='gmt')
Return date for now.
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...