35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
55$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
58$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
59$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
60$usergroup =
GETPOST(
"search_usergroup",
"intcomma", 3) ?
GETPOST(
"search_usergroup",
"intcomma", 3) :
GETPOST(
"usergroup",
"intcomma", 3);
61$showbirthday = empty(
$conf->use_javascript_ajax) ?
GETPOSTINT(
"showbirthday") : 1;
62$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma', 3) ?
GETPOST(
"search_categ_cus",
'intcomma', 3) : 0;
66 $filtert = (string) $user->id;
71$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
72$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
74if (empty($page) || $page == -1) {
78$offset = $limit * $page;
83 $sortfield =
"a.datec";
89 $socid = $user->socid;
96if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
99if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
102if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
103 $filtert = (string) $user->id;
106$action =
GETPOST(
'action',
'aZ09');
108$mode =
GETPOST(
'mode',
'aZ09');
109if (empty($mode) && preg_match(
'/show_/', $action)) {
112$resourceid =
GETPOST(
"search_resourceid",
'int');
117$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
118$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
119$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
121$optioncss =
GETPOST(
'optioncss',
'aZ');
124if ($dateselect > 0) {
131if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
132 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
133 if (!count($actioncode)) {
137 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' :
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE')));
139if (is_scalar($actioncode) && $actioncode ==
'-1') {
143if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
149if (empty($mode) && !GETPOSTISSET(
'mode')) {
150 $mode = $defaultview;
152if ($mode ==
'default') {
153 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
156 $mode =
'show_month';
161 $week = ($week ? $week : date(
"W"));
162 $day = ($day ? $day : date(
"d"));
166 $day = ($day ? $day : date(
"d"));
172$langs->loadLangs(array(
'agenda',
'other',
'commercial'));
175$hookmanager->initHooks(array(
'agenda'));
177$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
178if ($user->socid && $socid) {
187if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
189 if (is_array($_POST)) {
190 foreach ($_POST as $key => $val) {
191 if ($key ==
'token') {
194 $param .=
'&'.$key.
'='.urlencode($val);
197 if (!preg_match(
'/action=/', $param)) {
198 $param .= ($param ?
'&' :
'').
'mode=show_list';
201 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
205if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
207 if (is_array($_POST)) {
208 foreach ($_POST as $key => $val) {
209 if ($key ==
'token') {
212 $param .=
'&'.$key.
'='.urlencode($val);
216 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
232 'maxprint' => $maxprint,
234 'filtert' => $filtert,
235 'showbirthday' => $showbirthday,
236 'canedit' => $canedit,
237 'optioncss' => $optioncss,
238 'actioncode' => $actioncode,
240 'resourceid' => $resourceid,
241 'usergroup' => $usergroup,
243$reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
248$form =
new Form($db);
249$companystatic =
new Societe($db);
250$contactstatic =
new Contact($db);
251$userstatic =
new User($db);
253$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
254llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
258$nowyear = $nowarray[
'year'];
259$nowmonth = $nowarray[
'mon'];
260$nowday = $nowarray[
'mday'];
262$listofextcals = array();
267 while ($i < $MAXAGENDA) {
269 $source =
'AGENDA_EXT_SRC'.$i;
270 $name =
'AGENDA_EXT_NAME'.$i;
271 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
272 $color =
'AGENDA_EXT_COLOR'.$i;
273 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
274 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
277 $listofextcals[] = array(
278 'type' =>
'globalsetup',
294 while ($i < $MAXAGENDA) {
296 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
297 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
298 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
299 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
300 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
301 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
302 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
306 $listofextcals[] = array(
307 'type' =>
'usersetup',
310 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
320$max_day_in_month = 0;
331$max_day_in_prev_month = 0;
335if (empty($mode) || $mode ==
'show_month') {
337 $prev_year = $prev[
'year'];
338 $prev_month = $prev[
'month'];
340 $next_year = $next[
'year'];
341 $next_month = $next[
'month'];
343 $max_day_in_prev_month = (int) date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
344 $max_day_in_month = (int) date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
346 $tmpday = - (int) date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
347 $tmpday += ((isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1) - 1);
352 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
353 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
357 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
359if ($mode ==
'show_week') {
361 $prev_year = $prev[
'prev_year'];
362 $prev_month = $prev[
'prev_month'];
363 $prev_day = $prev[
'prev_day'];
364 $first_day = $prev[
'first_day'];
365 $first_month = $prev[
'first_month'];
366 $first_year = $prev[
'first_year'];
368 $week = $prev[
'week'];
372 $next_year = $next[
'year'];
373 $next_month = $next[
'month'];
374 $next_day = $next[
'day'];
377 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
380 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
382 $tmpday = $first_day;
384if ($mode ==
'show_day') {
386 $prev_year = $prev[
'year'];
387 $prev_month = $prev[
'month'];
388 $prev_day = $prev[
'day'];
390 $next_year = $next[
'year'];
391 $next_month = $next[
'month'];
392 $next_day = $next[
'day'];
394 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
395 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
411if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
412 if (is_array($actioncode)) {
413 foreach ($actioncode as $str_action) {
414 $param .=
"&search_actioncode[]=".urlencode($str_action);
417 $param .=
"&search_actioncode=".urlencode($actioncode);
420if ($resourceid > 0) {
421 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
423if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
424 $param .=
"&search_status=".urlencode($status);
427 $param .=
"&search_filter=".urlencode((
string) $filter);
430 $param .=
"&search_filtert=".urlencode((
string) $filtert);
433 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
436 $param .=
"&search_socid=".urlencode((
string) ($socid));
439 $param .=
"&search_showbirthday=1";
442 $param .=
"&search_projectid=".urlencode((
string) ($pid));
445 $param .=
"&search_type=".urlencode($type);
447$param .=
"&maxprint=".urlencode((
string) ($maxprint));
448if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
449 $param .=
'&mode='.urlencode($mode);
451if ($search_categ_cus != 0) {
452 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
457$nav .=
'<div class="navselectiondate inline-block nowraponall">';
458if (empty($mode) || $mode ==
'show_month') {
459 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
460 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
461 $nav .=
" </span>\n";
462 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
465if ($mode ==
'show_week') {
466 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\" title=\"".
dol_escape_htmltag($langs->trans(
"Previous")).
"\"></i></a> \n";
467 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
468 $nav .=
" </span>\n";
469 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\" title=\"".
dol_escape_htmltag($langs->trans(
"Next")).
"\"></i></a>\n";
470 $picto =
'calendarweek';
472if ($mode ==
'show_day') {
473 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
474 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
475 $nav .=
" </span>\n";
476 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
477 $picto =
'calendarday';
479if (empty(
$conf->dol_optimize_smallscreen)) {
480 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
484$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
486$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
489$paramnodate = $param;
490$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
505$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
506$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
510print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
511if ($optioncss !=
'') {
512 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
514print
'<input type="hidden" name="token" value="'.newToken().
'">';
515print
'<input type="hidden" name="mode" value="'.$mode.
'">';
518$viewmode =
'<div class="navmode inline-block">';
520$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
522$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
524$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
526$viewmode .=
'<a class="btnTitle'.($mode ==
'show_month' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
528$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
530$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
532$viewmode .=
'<a class="btnTitle'.($mode ==
'show_week' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
534$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
536$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
538$viewmode .=
'<a class="btnTitle'.($mode ==
'show_day' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
540$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
542$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
544$viewmode .=
'<a class="btnTitle'.($mode ==
'show_peruser' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%Y') : $year).
'&month='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%m') : $month).
'&day='.(isset(
$object->datep) ?
dol_print_date(
$object->datep,
'%d') : $day).$paramnoactionodate.
'">';
546$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
548$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
551$parameters = array();
553$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
554if (empty($reshook)) {
555 $viewmode .= $hookmanager->resPrint;
556} elseif ($reshook > 1) {
557 $viewmode = $hookmanager->resPrint;
560$viewmode .=
'</div>';
562$viewmode .=
'<span class="marginrightonly"></span>';
567if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
570 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
575 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
576 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
577 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
579 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
586$showextcals = $listofextcals;
587$bookcalcalendars = array();
590if (isModEnabled(
"bookcal")) {
591 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
592 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
593 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
594 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
595 $sql .=
" WHERE bc.status = 1";
596 $sql .=
" AND ba.status = 1";
597 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
598 if (!empty($filtert) && $filtert !=
'-1') {
599 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
601 $resql = $db->query($sql);
603 $num = $db->num_rows($resql);
606 $objp = $db->fetch_object($resql);
607 $label = !empty($objp->label) ? $objp->label : $objp->ref;
608 $bookcalcalendars[
"calendars"][$objp->id_cal] = array(
"id" => $objp->id_cal,
"label" => $label);
609 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
617if (!empty(
$conf->use_javascript_ajax)) {
618 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
620 $s .=
'<script type="text/javascript">'.
"\n";
621 $s .=
'jQuery(document).ready(function () {'.
"\n";
622 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle class .family_birthday"); jQuery(".family_birthday").toggle(); });'.
"\n";
623 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); });'.
"\n";
624 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
625 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
626 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
629 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
631 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
633 $s .=
'console.log("submit form to record new event");'.
"\n";
635 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
636 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
637 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
638 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
639 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
640 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
644 $s .=
'</script>'.
"\n";
647 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled><label class="labelcalendar"><span class="check_holiday_text"> '.$langs->trans(
"LocalAgenda").
' </span></label></div>';
650 if ($user->hasRight(
"holiday",
"read")) {
652 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
653 ?
' checked' :
'') .
'>
654 <label for="check_holiday" class="labelcalendar">
655 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
661 if (is_array($showextcals) && count($showextcals) > 0) {
662 $s .=
'<script type="text/javascript">'.
"\n";
663 $s .=
'jQuery(document).ready(function () {
664 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
665 var name = jQuery(elem).attr("name");
666 if (jQuery(elem).is(":checked")) {
667 jQuery(".family_ext" + name.replace("check_ext", "")).show();
669 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
673 jQuery("div input[name^=\"check_ext\"]").click(function() {
674 var name = $(this).attr("name");
675 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
678 $s .=
'</script>'.
"\n";
680 foreach ($showextcals as $val) {
681 $htmlname = md5($val[
'name']);
683 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
684 $default =
"checked";
689 $tooltip = $langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn';
691 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" value="1" '.$default.
'><label for="check_ext'.$htmlname.
'" title="'.
dol_escape_htmltag($tooltip).
'" class="labelcalendar">'.
dol_escape_htmltag($val[
'name']).
'</label> </div>';
696 $s .=
'<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"><label for="check_birthday" class="labelcalendar"> <span class="check_birthday_text">'.$langs->trans(
"AgendaShowBirthdayEvents").
'</span></label> </div>';
699 if (isModEnabled(
"bookcal")) {
700 if (!empty($bookcalcalendars[
"calendars"])) {
701 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
702 $label = $value[
'label'];
703 $s .=
'<div class="nowrap inline-block minheight30">';
704 $s .=
'<input '.(GETPOST(
'check_bookcal_calendar_'.$value[
'id']) ?
"checked" :
"").
' type="checkbox" id="check_bookcal_calendar_'.$value[
'id'].
'" name="check_bookcal_calendar_'.$value[
'id'].
'" class="check_bookcal_calendar_'.$value[
'id'].
'">';
705 $s .=
'<label for="check_bookcal_calendar_'.$value[
'id'].
'" class="labelcalendar">';
706 $s .=
'<span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span>';
707 $s .=
'</label> </div>';
713 $parameters = array();
714 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
715 if (empty($reshook)) {
716 $s .= $hookmanager->resPrint;
717 } elseif ($reshook > 1) {
718 $s = $hookmanager->resPrint;
721 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
724 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
725 if (!preg_match(
'/showbirthday=/i', $newparam)) {
726 $newparam .=
'&showbirthday=1';
730 if (empty($showbirthday)) {
731 $s .= $langs->trans(
"AgendaShowBirthdayEvents");
733 $s .= $langs->trans(
"AgendaHideBirthdayEvents");
740$eventarray = array();
748$sql .=
' a.id, a.label,';
751$sql .=
' a.percent,';
752$sql .=
' a.fk_user_author,a.fk_user_action,';
753$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
754$sql .=
' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,';
755$sql .=
' a.fk_element, a.elementtype,';
756$sql .=
' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto';
758$parameters = array();
759$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
760$sql .= $hookmanager->resPrint;
762$sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
765if ($filtert > 0 || $usergroup > 0) {
766 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
767 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
769 $sql .=
" AND ar.fk_element = ".((int) $filtert);
771 if ($usergroup > 0) {
772 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
776if ($resourceid > 0) {
777 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
779$sql .=
' WHERE a.fk_action = ca.id';
780$sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
782if (!empty($actioncode)) {
784 if ($actioncode ==
'AC_NON_AUTO') {
785 $sql .=
" AND ca.type != 'systemauto'";
786 } elseif ($actioncode ==
'AC_ALL_AUTO') {
787 $sql .=
" AND ca.type = 'systemauto'";
789 if ($actioncode ==
'AC_OTH') {
790 $sql .=
" AND ca.type != 'systemauto'";
792 if ($actioncode ==
'AC_OTH_AUTO') {
793 $sql .=
" AND ca.type = 'systemauto'";
797 if ($actioncode ==
'AC_NON_AUTO') {
798 $sql .=
" AND ca.type != 'systemauto'";
799 } elseif ($actioncode ==
'AC_ALL_AUTO') {
800 $sql .=
" AND ca.type = 'systemauto'";
801 } elseif ( $actioncode !==
'-1') {
802 if (is_array($actioncode)) {
803 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
805 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
810if ($resourceid > 0) {
811 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
814 $sql .=
" AND a.fk_project=".((int) $pid);
818if (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
819 $search_sale = $user->id;
822if ($search_sale && $search_sale !=
'-1') {
823 if ($search_sale == -2) {
824 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
825 } elseif ($search_sale > 0) {
826 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
831 $sql .=
" AND a.fk_soc = ".((int) $socid);
834if ($mode ==
'show_day') {
836 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
837 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
839 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
840 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
842 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
843 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
848 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
849 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
851 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
852 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
854 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
855 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
859 $sql .=
" AND ca.id = ".((int) $type);
863 $sql .=
" AND a.percent = 0";
865if ($status ===
'na') {
867 $sql .=
" AND a.percent = -1";
869if ($status ==
'50') {
871 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
873if ($status ==
'done' || $status ==
'100') {
874 $sql .=
" AND (a.percent = 100)";
876if ($status ==
'todo') {
877 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
880if ($filtert > 0 || $usergroup > 0) {
883 $sql .=
"ar.fk_element = ".((int) $filtert);
885 if ($usergroup > 0) {
886 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
892if ($search_categ_cus != -1) {
893 if ($search_categ_cus == -2) {
894 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
895 } elseif ($search_categ_cus > 0) {
896 $sql .=
" AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".$db->sanitize($search_categ_cus).
"))";
901$sql .= $db->order(
"datep");
904dol_syslog(
"comm/action/index.php", LOG_DEBUG);
905$resql = $db->query($sql);
907 $num = $db->num_rows($resql);
909 $MAXONSAMEPAGE = 10000;
911 while ($i < $num && $i < $MAXONSAMEPAGE) {
912 $obj = $db->fetch_object($resql);
915 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
923 $event->id = $obj->id;
924 $event->ref = $event->id;
926 $event->fulldayevent = $obj->fulldayevent;
929 if ($event->fulldayevent) {
931 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
932 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
935 $event->datep = $db->jdate($obj->datep,
'tzserver');
936 $event->datef = $db->jdate($obj->datep2,
'tzserver');
942 $event->type_code = $obj->type_code;
943 $event->type_label = $obj->type_label;
944 $event->type_color = $obj->type_color;
945 $event->type = $obj->type_type;
946 $event->type_picto = $obj->type_picto;
948 $event->label = $obj->label;
949 $event->percentage = $obj->percent;
951 $event->authorid = $obj->fk_user_author;
952 $event->userownerid = $obj->fk_user_action;
953 $event->fetch_userassigned();
955 $event->priority = $obj->priority;
956 $event->location = $obj->location;
957 $event->transparency = $obj->transparency;
958 $event->fk_element = $obj->fk_element;
959 $event->elementid = $obj->fk_element;
960 $event->elementtype = $obj->elementtype;
962 $event->fk_project = $obj->fk_project;
964 $event->socid = $obj->fk_soc;
965 $event->contact_id = $obj->fk_contact;
966 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
967 if (!empty($event->fk_bookcal_calendar)) {
968 $event->type =
"bookcal_calendar";
973 $event->date_start_in_calendar = $event->datep;
974 if ($event->datef !=
'' && $event->datef >= $event->datep) {
975 $event->date_end_in_calendar = $event->datef;
977 $event->date_end_in_calendar = $event->datep;
981 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
984 if ($event->date_start_in_calendar < $firstdaytoshow) {
985 $event->date_start_in_calendar = $firstdaytoshow;
987 if ($event->date_end_in_calendar >= $lastdaytoshow) {
988 $event->date_end_in_calendar = ($lastdaytoshow - 1);
992 $daycursor = $event->date_start_in_calendar;
997 $daycursorend = $event->date_end_in_calendar;
998 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
999 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1000 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1009 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1010 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
1024 $eventarray[$daykey][] = $event;
1027 $daykey += 60 * 60 * 24;
1029 if ($daykey > $daykeyend) {
1038 $parameters[
'obj'] = $obj;
1039 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
1040 $event = $hookmanager->resPrint;
1057 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1058 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
1059 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
1060 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1061 if ($mode ==
'show_day') {
1062 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1063 $sql .=
' AND DAY(birthday) = '.((int) $day);
1065 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1067 $sql .=
' ORDER BY birthday';
1069 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1070 $resql = $db->query($sql);
1072 $num = $db->num_rows($resql);
1075 $obj = $db->fetch_object($resql);
1079 $event->id = $obj->rowid;
1080 $event->ref = $event->id;
1085 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1086 $event->datef = $event->datep;
1088 $event->type_code =
'BIRTHDAY';
1089 $event->type_label =
'';
1090 $event->type_color =
'';
1091 $event->type =
'birthdate';
1092 $event->type_picto =
'birthdate';
1094 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1095 $event->percentage = 100;
1096 $event->fulldayevent = 1;
1098 $event->contact_id = $obj->rowid;
1100 $event->date_start_in_calendar = $db->jdate($event->datep);
1101 $event->date_end_in_calendar = $db->jdate($event->datef);
1104 $daycursor = $event->datep;
1109 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1111 $eventarray[$daykey][] = $event;
1129if ($user->hasRight(
"holiday",
"read")) {
1130 $sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status";
1131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1132 $sql .=
" WHERE u.rowid = x.fk_user";
1133 $sql .=
" AND u.statut = '1'";
1134 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1135 if ($mode ==
'show_day') {
1137 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1138 } elseif ($mode ==
'show_week') {
1140 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1141 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1142 } elseif ($mode ==
'show_month') {
1144 $sql .=
" AND x.date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1145 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1147 if (!$user->hasRight(
'holiday',
'readall')) {
1148 $sql.=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1151 $resql = $db->query($sql);
1153 $num = $db->num_rows($resql);
1157 $obj = $db->fetch_object($resql);
1162 $event->id = $obj->rowid;
1163 $event->ref = $event->id;
1165 $event->type_code =
'HOLIDAY';
1166 $event->type_label =
'';
1167 $event->type_color =
'';
1168 $event->type =
'holiday';
1169 $event->type_picto =
'holiday';
1171 $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1172 $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1173 $event->date_start_in_calendar = $event->datep;
1174 $event->date_end_in_calendar = $event->datef;
1176 if ($obj->status == 3) {
1178 $event->percentage = -1;
1179 } elseif ($obj->status == 2) {
1181 $event->percentage = 0;
1184 $event->label = $langs->trans(
"Holiday");
1186 $daycursor = $event->date_start_in_calendar;
1191 $daycursorend = $event->date_end_in_calendar;
1192 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1193 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1194 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1197 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1198 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1203 $firstdayofholiday = ($ifornbofdays == 1);
1204 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1213 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1216 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1217 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1218 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1219 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1221 $eventarray[$daykey][] = $newevent;
1223 $eventarray[$daykey][] = $event;
1226 $daykey += 60 * 60 * 24;
1227 $daykeygmt += 60 * 60 * 24;
1228 }
while ($daykey <= $event->date_end_in_calendar);
1237if (count($listofextcals)) {
1238 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1240 foreach ($listofextcals as $key => $extcal) {
1241 $url = $extcal[
'src'];
1242 $namecal = $extcal[
'name'];
1243 $offsettz = $extcal[
'offsettz'];
1244 $colorcal = $extcal[
'color'];
1245 $buggedfile = $extcal[
'buggedfile'];
1251 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1254 $listofextcals[$key][
'error'] = $ical->error;
1255 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1260 $icalevents = array();
1261 if (is_array($ical->get_event_list())) {
1262 $icalevents = array_merge($icalevents, $ical->get_event_list());
1264 if (is_array($ical->get_freebusy_list())) {
1265 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1268 if (count($icalevents) > 0) {
1270 $moreicalevents = array();
1271 foreach ($icalevents as $icalevent) {
1272 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1275 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1278 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1279 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1280 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1281 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1283 $tmpcurstart = $datecurstart;
1284 $tmpcurend = $datecurend;
1285 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1286 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1289 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1290 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1292 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1294 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1295 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1297 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1304 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1309 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1310 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1311 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1312 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1315 if ($datecurstart >= $lastdaytoshow) {
1320 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1321 if ($datecurend >= $firstdaytoshow) {
1322 $newevent = $icalevent;
1323 unset($newevent[
'RRULE']);
1324 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1325 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1326 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1328 $newevent[
'DTSTART'] = $datecurstart;
1329 $newevent[
'DTEND'] = $datecurend;
1331 $moreicalevents[] = $newevent;
1335 $savdatecurstart = $datecurstart;
1336 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1340 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1343 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1346 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1351 if ($savdatecurstart >= $datecurstart) {
1352 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1353 $datecurstart += 3600 * 24 * 7;
1354 $datecurend += 3600 * 24 * 7;
1359 $icalevents = array_merge($icalevents, $moreicalevents);
1362 foreach ($icalevents as $icalevent) {
1367 if (!empty($icalevent[
'RRULE'])) {
1374 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1377 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1378 $dateend = $datestart + 86400 - 1;
1384 $event->fulldayevent = 1;
1386 } elseif (!is_array($icalevent[
'DTSTART'])) {
1387 $datestart = $icalevent[
'DTSTART'];
1388 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1390 $datestart += +($offsettz * 3600);
1391 $dateend += +($offsettz * 3600);
1396 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1397 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1398 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1400 $datestart += +($offsettz * 3600);
1401 $dateend += +($offsettz * 3600);
1404 if ($buggedfile ===
'uselocalandtznodaylight') {
1408 if ($buggedfile ===
'uselocalandtzdaylight') {
1409 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1410 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1411 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1412 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1413 $tmps = -1 * $localtzs->getOffset($localdts);
1414 $tmpe = -1 * $localtze->getOffset($localdte);
1415 $datestart += $tmps;
1423 $event->id = $icalevent[
'UID'];
1424 $event->ref = $event->id;
1425 $userId = $userstatic->findUserIdByEmail($namecal);
1426 if (!empty($userId) && $userId > 0) {
1427 $event->userassigned[$userId] = $userId;
1428 $event->percentage = -1;
1431 $event->type_code =
"ICALEVENT";
1432 $event->type_label = $namecal;
1433 $event->type_color = $colorcal;
1434 $event->type =
'icalevent';
1435 $event->type_picto =
'rss';
1437 $event->icalname = $namecal;
1438 $event->icalcolor = $colorcal;
1440 $event->datep = $datestart + $usertime;
1441 $event->datef = $dateend + $usertime;
1443 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1445 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1448 $event->label = $langs->trans(
"ExtSiteNoLabel");
1455 if (!empty($icalevent[
'PRIORITY'])) {
1456 $event->priority = $icalevent[
'PRIORITY'];
1460 if (!empty($icalevent[
'TRANSP'])) {
1461 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1462 $event->transparency = 0;
1464 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1465 $event->transparency = 1;
1476 if (!empty($icalevent[
'LOCATION'])) {
1477 $event->location = $icalevent[
'LOCATION'];
1480 $event->date_start_in_calendar = $event->datep;
1482 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1483 $event->date_end_in_calendar = $event->datef;
1485 $event->date_end_in_calendar = $event->datep;
1489 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1495 if ($event->date_start_in_calendar < $firstdaytoshow) {
1496 $event->date_start_in_calendar = $firstdaytoshow;
1498 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1499 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1503 $daycursor = $event->date_start_in_calendar;
1512 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1513 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1516 $eventarray[$daykey][] = $event;
1517 $daykey += 60 * 60 * 24;
1518 $daykeygmt += 60 * 60 * 24;
1519 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1531$parameters = array();
1533$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1534if (!empty($hookmanager->resArray[
'eventarray'])) {
1535 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1536 if (!isset($eventarray[$keyDate])) {
1537 $eventarray[$keyDate] = array();
1539 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1544foreach ($eventarray as $keyDate => &$dateeventarray) {
1545 usort($dateeventarray,
'sort_events_by_date');
1550$cachethirdparties = array();
1551$cachecontacts = array();
1552$cacheusers = array();
1555$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
1556if (is_readable($color_file)) {
1557 include $color_file;
1559if (!is_array($theme_datacolor)) {
1560 $theme_datacolor = array(array(137, 86, 161), array(60, 147, 183), array(250, 190, 80), array(80, 166, 90), array(190, 190, 100), array(91, 115, 247), array(140, 140, 220), array(190, 120, 120), array(115, 125, 150), array(100, 170, 20), array(150, 135, 125), array(85, 135, 150), array(150, 135, 80), array(150, 80, 150));
1563$massactionbutton =
'';
1565print_barre_liste($langs->trans(
"Agenda"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1,
'object_action', 0, $nav.
'<span class="marginleftonly"></span>'.$newcardbutton,
'', $limit, 1, 0, 1, $viewmode);
1571if (empty($mode) || $mode ==
'show_month') {
1573 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1574 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1575 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1576 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1577 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1578 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1579 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1580 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1581 $newparam .=
'&viewcal=1';
1583 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1584 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1587 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1588 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1589 print
' <tr class="liste_titre">';
1591 echo
' <td class="center">#</td>';
1594 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1595 $numdayinweek = (($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7);
1596 if (!empty(
$conf->dol_optimize_smallscreen)) {
1597 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
1598 print $langs->trans($labelshort[$numdayinweek]);
1600 print $langs->trans(
"Day".$numdayinweek);
1602 print
' </td>'.
"\n";
1608 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1612 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1616 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1617 } elseif ($tmpday <= $max_day_in_month) {
1618 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1620 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1623 $numweek0 = date(
"W", strtotime(date($currdate0)));
1625 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1627 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1630 $style =
'cal_other_month cal_past';
1631 if ($iter_day == 6) {
1632 $style .=
' cal_other_month_right';
1634 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1636 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1638 } elseif ($tmpday <= $max_day_in_month) {
1640 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1641 $style =
'cal_current_month';
1642 if ($iter_day == 6) {
1643 $style .=
' cal_current_month_right';
1646 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1650 $style =
'cal_today';
1652 if ($curtime < $todaytms) {
1653 $style .=
' cal_past';
1656 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1658 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1662 $style =
'cal_other_month';
1663 if ($iter_day == 6) {
1664 $style .=
' cal_other_month_right';
1666 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1668 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1678 print
'<input type="hidden" name="actionmove" value="mupdate">';
1679 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1680 print
'<input type="hidden" name="newdate" id="newdate">';
1681} elseif ($mode ==
'show_week') {
1684 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1685 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1686 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1687 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1688 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1689 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1690 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1691 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1692 $newparam .=
'&viewweek=1';
1694 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1695 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1698 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1699 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1700 print
' <tr class="liste_titre">';
1703 echo
' <td class="center bold uppercase tdfordaytitle">'.$langs->trans(
"Day".(($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7)).
"</td>\n";
1710 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1717 $style =
'cal_current_month';
1718 if ($iter_day == 6) {
1719 $style .=
' cal_other_month_right';
1724 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1728 $style =
'cal_today';
1731 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1733 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1741 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1742 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1743 echo
'<input type="hidden" name="newdate" id="newdate">';
1746 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1747 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1748 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1749 $newparam .=
'&viewday=1';
1751 $style =
'cal_current_month cal_current_month_oneday';
1754 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1759 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1762 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1763 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1766 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1767 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore" style="margin-bottom: 10px !important;">';
1769 echo
' <tr class="tagtr liste_titre">';
1770 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1787 print
'<div class="div-table-responsive-no-min">';
1789 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1791 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1792 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1797 $minhour = round((
float) $tmp[0], 0);
1798 $maxhour = round((
float) $tmp[1], 0);
1799 if ($minhour > 23) {
1805 if ($maxhour <= $minhour) {
1806 $maxhour = $minhour + 1;
1812 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1813 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1814 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1815 echo
' </div>'.
"\n";
1820 echo
'</div></div>';
1823 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1827 print
'<div class="div-table-responsive-no-min">';
1830 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1842print
"\n".
'</form>';
1868function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
1870 global $user,
$conf, $langs;
1871 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1872 global $theme_datacolor;
1873 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1874 global $hookmanager;
1876 '@phan-var-force array{0:array{0:int,1:int,2:int},1:array{0:int,1:int,2:int},2:array{0:int,1:int,2:int},3:array{0:int,1:int,2:int}} $theme_datacolor
1877 @phan-var-force User[] $cacheusers
1878 @phan-var-force array<int<0,3>> $colorindexused';
1880 if (
$conf->use_javascript_ajax) {
1881 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1884 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1890 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1891 $urltoshow = DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&day='.str_pad((
string) $day, 2,
"0", STR_PAD_LEFT).
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year.$newparam;
1893 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
1894 $newparam .=
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1895 $hourminsec =
'100000';
1896 $urltocreate = DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $year, $month, $day).$hourminsec.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
1900 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1903 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1904 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1906 print dol_print_date($curtime, 'daytextshort');
1908 print dol_print_date($curtime, '%d');
1911 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1912 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
1913 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, useful for nojs interfaces
1914 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1917 print '</div></div></div>'."\n
";
1925 // Line with td contains all div of each events
1926 print '<div class="tagtr
">';
1927 print '<div class="tagtd centpercent agendacell sortable
">';
1929 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1936 $numicals = array();
1937 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1939 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1940 $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1941 //var_dump($colorindexused);
1943 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1944 $tmpholiday = new Holiday($db);
1946 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1947 $annee = (int) dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1948 $mois = (int) dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1949 $jour = (int) dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1951 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1952 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' day='.$day.' month='.$month.' year='.$year."<br>\n
";
1954 if ($day == $jour && $month == $mois && $year == $annee) {
1955 foreach ($eventarray[$daykey] as $index => $event) {
1956 if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) {
1957 $keysofuserassigned = array_keys($event->userassigned);
1959 // Define $color (Hex string like '0088FF') and $cssclass of event
1963 if (in_array($user->id, $keysofuserassigned)) {
1964 $cssclass = 'family_mytasks';
1966 if (empty($cacheusers[$event->userownerid])) {
1967 $newuser = new User($db);
1968 $newuser->fetch($event->userownerid);
1969 $cacheusers[$event->userownerid] = $newuser;
1971 //var_dump($cacheusers[$event->userownerid]->color);
1973 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1974 if (!empty($cacheusers[$event->userownerid]->color)) {
1975 $color = $cacheusers[$event->userownerid]->color;
1978 /* May be we need this: if (getDolGlobalString('AGENDA_USE_COLOR_PER_EVENT_TYPE')) {
1979 $color = $event->type_color;
1981 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
1983 if (!empty($event->icalname)) {
1984 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1985 $numicals[dol_string_nospecial($event->icalname)] = 0;
1987 $numicals[dol_string_nospecial($event->icalname)]++;
1990 $color = ($event->icalcolor ? $event->icalcolor : -1);
1991 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1992 } elseif ($event->type_code == 'BIRTHDAY') {
1995 $cssclass = 'family_birthday ';
1996 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1997 } elseif ($event->type == 'bookcal_calendar') {
2000 $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink
"]) ? $bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar] : "");
2001 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2004 $color = ($event->icalcolor ? $event->icalcolor : -1);
2005 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
2007 if (empty($cacheusers[$event->userownerid])) {
2008 $newuser = new User($db);
2009 $newuser->fetch($event->userownerid);
2010 $cacheusers[$event->userownerid] = $newuser;
2012 //var_dump($cacheusers[$event->userownerid]->color);
2014 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
2015 if (!empty($cacheusers[$event->userownerid]->color)) {
2016 $color = $cacheusers[$event->userownerid]->color;
2020 if ($color < 0) { // Color was not set on user card. Set color according to color index.
2021 // Define color index if not yet defined
2022 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2023 if (isset($colorindexused[$idusertouse])) {
2024 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
2026 $colorindex = $nextindextouse;
2027 $colorindexused[$idusertouse] = $colorindex;
2028 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2029 $nextindextouse++; // Prepare to use next color
2032 if (isset($theme_datacolor[$colorindex])) {
2033 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2034 } elseif (getDolGlobalString('THEME_ELDY_BACKBODY')) {
2035 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2036 $color = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_BACKBODY'), array()), '');
2041 $cssclass = $cssclass.' eventday_'.$ymd;
2043 // Defined style to disable drag and drop feature
2044 if ($event->type_code == 'AC_OTH_AUTO') {
2045 $cssclass .= " unmovable
";
2046 } elseif ($event->type_code == 'HOLIDAY') {
2047 $cssclass .= " unmovable
";
2048 } elseif ($event->type_code == 'BIRTHDAY') {
2049 $cssclass .= " unmovable
";
2050 } elseif ($event->type_code == 'ICALEVENT') {
2051 $cssclass .= " unmovable
";
2052 } elseif ($event->date_start_in_calendar && $event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
2053 // If the event is on several days
2054 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2055 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2056 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2057 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
2058 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
2059 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
2061 $cssclass .= ' movable cursormove';
2064 if ($user->hasRight('agenda', 'allactions', 'create') ||
2065 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
2066 $cssclass .= " movable cursormove
";
2068 $cssclass .= " unmovable
";
2074 if ($mode == 'show_day') {
2075 $h = 'height: 100%; ';
2078 if ($mode == 'show_week') {
2079 $h = 'height: 100%; ';
2085 print '<!-- start event '.$i.' -->'."\n
";
2088 if ($maxprint && $ireallyshown >= $maxprint) {
2089 $morecss = 'showifmore';
2091 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
2092 $morecss = 'hidden';
2094 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
2095 $morecss = 'hidden';
2097 /* I comment this because it hides event recorded from bookcal online page
2098 if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar])) {
2099 $morecss = 'hidden';
2101 if ($morecss != 'hidden') {
2104 if ($morecss != 'showifmore' && $morecss != 'hidden') {
2108 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
2109 if (isModEnabled("bookcal
") && $event->type == 'bookcal_calendar') {
2110 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.'_
'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2112 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2114 //print ' style="height: 100px;
';
2115 //print ' position: absolute; top: 40px; width: 50%;
';
2119 //var_dump($event->userassigned);
2120 //var_dump($event->transparency);
2121 print '<table class="centpercent cal_event
';
2122 print (empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
2123 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
2124 print '" style="'.$h;
2125 $colortouse = $color;
2126 // If colortouse is similar than background, we force to change it.
2127 if (empty($event->transparency) && !getDolGlobalString('AGENDA_NO_TRANSPARENT_ON_NOT_BUSY
')) {
2128 print 'background: #f0f0f0;
';
2129 print 'border-left: 5px solid #
'.$colortouse.';
';
2131 print 'background: #f0f0f0;
';
2132 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
2133 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
2135 //print 'background: #
'.$colortouse.';
';
2136 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
2137 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
2138 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
2139 //print ' -moz-border-radius:4px;
"';
2140 //print 'border: 1px solid #ccc" width=
"100%"';
2143 // First the tr of the event (only one tr for event is used, but several td)
2145 print '<td class="tdoverflow nobottom small centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
2146 print '<!-- left section of event -->';
2150 $parameters = array();
2151 $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
2153 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2155 '@phan-var-force ActionComm $event';
2156 if (empty($reshook)) {
2159 if (empty($event->fulldayevent)) {
2160 //print $event->getNomUrl(2).' ';
2164 if ($event->type_code == 'BIRTHDAY') {
2165 // It's birthday calendar
2166 $picb = img_picto('', 'birthday-cake', 'class="pictofixedwidth
"');
2167 print $picb.$langs->trans("Birthday
").'<br>';
2171 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY') {
2172 if (empty($event->fulldayevent)) {
2173 // Show hours (start ... end)
2174 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2175 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2176 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2177 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
2178 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
2179 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
2182 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
2183 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
2184 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2185 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
2192 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2193 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
2194 $daterange .= '...';
2198 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2199 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
2200 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
2205 print $langs->trans("EventOnFullDay
")."<br>\n
";
2211 $titletoshow = $daterange;
2212 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label);
2214 if ($event->type_code != 'ICALEVENT' && $event->type_code != 'BIRTHDAY') {
2215 $savlabel = $event->label;
2216 $event->label = $titletoshow;
2217 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2218 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2219 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title valignmiddle', '', 0, 0); // do not add 'inline-block' in css here: it makes the title transformed completely into '...'
2220 $event->label = $savlabel;
2223 // Loop on each assigned user
2224 $listofusertoshow = '';
2225 $posuserassigned = 0;
2226 foreach ($event->userassigned as $tmpid => $tmpdata) {
2227 if (!$posuserassigned && $titletoshow) {
2228 $listofusertoshow .= '<br>';
2231 if (empty($cacheusers[$tmpid])) {
2232 $newuser = new User($db);
2233 $newuser->fetch($tmpid);
2234 $cacheusers[$tmpid] = $newuser;
2237 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block');
2240 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') {
2242 print $listofusertoshow.' ';
2245 if ($event->type_code == 'ICALEVENT') {
2246 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2249 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2250 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2252 // If action related to company / contact
2253 $linerelatedto = '';
2254 if ($thirdparty_id > 0) {
2255 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2256 $thirdparty = new Societe($db);
2257 $thirdparty->fetch($thirdparty_id);
2258 $cachethirdparties[$thirdparty_id] = $thirdparty;
2260 $thirdparty = $cachethirdparties[$thirdparty_id];
2262 if (!empty($thirdparty->id)) {
2263 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
2266 if (!empty($contact_id) && $contact_id > 0) {
2267 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
2268 $contact = new Contact($db);
2269 $contact->fetch($contact_id);
2270 $cachecontacts[$contact_id] = $contact;
2272 $contact = $cachecontacts[$contact_id];
2274 if ($linerelatedto) {
2275 $linerelatedto .= ' ';
2277 if (!empty($contact->id)) {
2278 $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
2281 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) {
2282 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2283 if ($linerelatedto) {
2284 $linerelatedto .= '<br>';
2286 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2288 if ($linerelatedto) {
2289 print ' '.$linerelatedto;
2291 } elseif (!empty($reshook)) {
2292 print $hookmanager->resPrint;
2296 if ($event->type_code == 'HOLIDAY') {
2297 // It's holiday calendar
2298 $tmpholiday->fetch($event->id);
2300 print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block');
2302 $tmpid = $tmpholiday->fk_user;
2303 if (empty($cacheusers[$tmpid])) {
2304 $newuser = new User($db);
2305 $newuser->fetch($tmpid);
2306 $cacheusers[$tmpid] = $newuser;
2309 $listofusertoshow = '';
2310 $listofusertoshow .= "\n
".'<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block')."\n
";
2311 print $listofusertoshow;
2316 if ($event->location) {
2318 print $langs->trans("Location
").': '.$event->location;
2326 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2328 if ($event->percentage >= 0) {
2332 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2334 print $event->getLibStatut(3, 1);
2338 print '</td></tr></table>';
2339 print '</div><!-- end event '.$i.' -->'."\n
";
2343 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2344 print($status ? '&
status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2345 print($filtert ? '&search_filtert=
'.urlencode((string) $filtert) : '');
2346 print($usergroup ? '&search_usergroup=
'.urlencode($usergroup) : '');
2347 print($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2348 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2349 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2352 //$ok=false; // To avoid to show twice the link
2359 if (!$i) { // No events
2363 if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) {
2364 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2365 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2367 print '<script type="text/javascript
">'."\n
";
2368 print 'jQuery(document).ready(function () {'."\n
";
2369 print ' var open=0;'."\n
";
2370 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2371 print ' function reinit_day_'.$ymd.'() {'."\n
";
2372 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2373 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2374 print ' if (open) { ';
2375 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2377 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2381 print '</script>'."\n
";
2384 print '</div></div>'; // td tr
2386 print '</div>'; // table
2399function dol_color_minus($color, $minus, $minusunit = 16)
2402 if ($minusunit == 16 && is_array($newcolor)) {
2403 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2404 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2405 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2407 // Not yet implemented
2419function sort_events_by_date($a, $b)
2421 // Sort holidays at first
2422 if ($a->type_code === 'HOLIDAY') {
2425 if ($b->type_code === 'HOLIDAY') {
2429 // datep => Event start time
2430 // datef => Event end time
2432 // Events have different start time
2433 if ($a->datep !== $b->datep) {
2434 return $a->datep - $b->datep;
2437 // Events have same start time and no end time
2438 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2439 return sort_events_by_percentage($a, $b);
2442 // Events have the same start time and same end time
2443 if ($b->datef === $a->datef) {
2444 return sort_events_by_percentage($a, $b);
2447 // Events have the same start time, but have different end time -> longest event first
2448 return $b->datef - $a->datef;
2458function sort_events_by_percentage($a, $b)
2460 // Sort events with no percentage before each other
2461 // (useful to sort holidays, sick days or similar on the top)
2463 if ($a->percentage < 0) {
2467 if ($b->percentage < 0) {
2471 return $b->percentage - $a->percentage;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print_actions_filter( $form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filtered, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid=0, $excludetype='', $resourceid=0, $search_categ_cus=0)
Show filter form in agenda view.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage agenda events (actions)
Class to read/parse ICal calendars.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $nonew=0, $bookcalcalendarsarray=array())
Show event of a particular day.
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_prev_month($month, $year)
Return previous month.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_next_day($day, $month, $year)
Return next day.
dol_get_next_week($day, $week, $month, $year)
Return next week.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_next_month($month, $year)
Return next month.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
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...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
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).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
conf($dolibarr_main_document_root)
Load conf file (file must exists)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.