36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56$action =
GETPOST(
'action',
'aZ09');
57$optioncss =
GETPOST(
'optioncss',
'aZ');
59if (empty($mode) && preg_match(
'/show_/', $action)) {
63$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
66$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
67$filtert =
GETPOST(
"search_filtert",
"intcomma", 3) ?
GETPOST(
"search_filtert",
"intcomma", 3) :
GETPOST(
"filtert",
"intcomma", 3);
68$usergroup =
GETPOST(
"search_usergroup",
"intcomma", 3) ?
GETPOST(
"search_usergroup",
"intcomma", 3) :
GETPOST(
"usergroup",
"intcomma", 3);
69$showbirthday = empty(
$conf->use_javascript_ajax) ?
GETPOSTINT(
"showbirthday") : 1;
70$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma', 3) ?
GETPOST(
"search_categ_cus",
'intcomma', 3) : 0;
74 $filtert = (string) $user->id;
84$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
85$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
87if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
91$offset = $limit * $page;
96 $sortfield =
"a.datec";
102 $socid = $user->socid;
109if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
112if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
115if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
116 $filtert = (string) $user->id;
124$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
125$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
126$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'aZ09') :
GETPOST(
"type",
'aZ09');
130if ($dateselect > 0) {
137if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
138 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
139 if (!count($actioncode)) {
143 $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')));
145if (is_scalar($actioncode) && $actioncode ==
'-1') {
149if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
155if (empty($mode) && !GETPOSTISSET(
'mode')) {
156 $mode = $defaultview;
158if ($mode ==
'default') {
159 $mode = (($defaultview !=
'show_list') ? $defaultview :
'show_month');
162 $mode =
'show_month';
167 $week = ($week ? $week : date(
"W"));
168 $day = ($day ? $day : date(
"d"));
172 $day = ($day ? $day : date(
"d"));
178$langs->loadLangs(array(
'agenda',
'other',
'commercial'));
181$hookmanager->initHooks(array(
'agenda'));
183$result =
restrictedArea($user,
'agenda', 0,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
184if ($user->socid && $socid) {
193if (
GETPOST(
"viewlist",
'alpha') || $mode ==
'show_list') {
195 if (is_array($_POST)) {
196 foreach ($_POST as $key => $val) {
197 if ($key ==
'token') {
200 $param .=
'&'.urlencode($key).
'='.urlencode($val);
203 if (!preg_match(
'/action=/', $param)) {
204 $param .= ($param ?
'&' :
'').
'mode=show_list';
207 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/list.php?'.$param);
211if (
GETPOST(
"viewperuser",
'alpha') || $mode ==
'show_peruser') {
213 if (is_array($_POST)) {
214 foreach ($_POST as $key => $val) {
215 if ($key ==
'token') {
218 $param .=
'&'.urlencode($key).
'='.urlencode($val);
222 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/peruser.php?'.$param);
238 'maxprint' => $maxprint,
240 'filtert' => $filtert,
241 'showbirthday' => $showbirthday,
242 'canedit' => $canedit,
243 'optioncss' => $optioncss,
244 'actioncode' => $actioncode,
246 'resourceid' => $resourceid,
247 'usergroup' => $usergroup,
249$reshook = $hookmanager->executeHooks(
'beforeAgenda', $parameters, $object, $action);
254$form =
new Form($db);
255$companystatic =
new Societe($db);
256$contactstatic =
new Contact($db);
257$userstatic =
new User($db);
259$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
260llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
264$nowyear = $nowarray[
'year'];
265$nowmonth = $nowarray[
'mon'];
266$nowday = $nowarray[
'mday'];
268$listofextcals = array();
273 while ($i < $MAXAGENDA) {
275 $source =
'AGENDA_EXT_SRC'.$i;
276 $name =
'AGENDA_EXT_NAME'.$i;
277 $offsettz =
'AGENDA_EXT_OFFSETTZ'.$i;
278 $color =
'AGENDA_EXT_COLOR'.$i;
279 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT'.$i;
280 $buggedfile =
'AGENDA_EXT_BUGGEDFILE'.$i;
283 $listofextcals[] = array(
284 'type' =>
'globalsetup',
300 while ($i < $MAXAGENDA) {
302 $source =
'AGENDA_EXT_SRC_'.$user->id.
'_'.$i;
303 $name =
'AGENDA_EXT_NAME_'.$user->id.
'_'.$i;
304 $offsettz =
'AGENDA_EXT_OFFSETTZ_'.$user->id.
'_'.$i;
305 $color =
'AGENDA_EXT_COLOR_'.$user->id.
'_'.$i;
306 $enabled =
'AGENDA_EXT_ENABLED_'.$user->id.
'_'.$i;
307 $default =
'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.
'_'.$i;
308 $buggedfile =
'AGENDA_EXT_BUGGEDFILE_'.$user->id.
'_'.$i;
312 $listofextcals[] = array(
313 'type' =>
'usersetup',
316 'offsettz' => (
int) (empty($user->conf->$offsettz) ? 0 : $user->
conf->$offsettz),
326$max_day_in_month = 0;
337$max_day_in_prev_month = 0;
341if (empty($mode) || $mode ==
'show_month') {
343 $prev_year = $prev[
'year'];
344 $prev_month = $prev[
'month'];
346 $next_year = $next[
'year'];
347 $next_month = $next[
'month'];
349 $max_day_in_prev_month = (int) date(
"t",
dol_mktime(12, 0, 0, $prev_month, 1, $prev_year,
'gmt'));
350 $max_day_in_month = (int) date(
"t",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt'));
352 $tmpday = - (int) date(
"w",
dol_mktime(12, 0, 0, $month, 1, $year,
'gmt')) + 2;
353 $tmpday += ((isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1) - 1);
358 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year,
'tzuserrel');
359 $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
363 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
365if ($mode ==
'show_week') {
367 $prev_year = $prev[
'prev_year'];
368 $prev_month = $prev[
'prev_month'];
369 $prev_day = $prev[
'prev_day'];
370 $first_day = $prev[
'first_day'];
371 $first_month = $prev[
'first_month'];
372 $first_year = $prev[
'first_year'];
374 $week = $prev[
'week'];
378 $next_year = $next[
'year'];
379 $next_month = $next[
'month'];
380 $next_day = $next[
'day'];
383 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
386 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
388 $tmpday = $first_day;
390if ($mode ==
'show_day') {
392 $prev_year = $prev[
'year'];
393 $prev_month = $prev[
'month'];
394 $prev_day = $prev[
'day'];
396 $next_year = $next[
'year'];
397 $next_month = $next[
'month'];
398 $next_day = $next[
'day'];
400 $firstdaytoshow =
dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year,
'tzuserrel');
401 $lastdaytoshow =
dol_mktime(0, 0, 0, $next_month, $next_day, $next_year,
'tzuserrel');
417if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
418 if (is_array($actioncode)) {
419 foreach ($actioncode as $str_action) {
420 $param .=
"&search_actioncode[]=".urlencode($str_action);
423 $param .=
"&search_actioncode=".urlencode($actioncode);
426if ($resourceid > 0) {
427 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
429if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
430 $param .=
"&search_status=".urlencode($status);
433 $param .=
"&search_filter=".urlencode((
string) $filter);
436 $param .=
"&search_filtert=".urlencode((
string) $filtert);
439 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
442 $param .=
"&search_socid=".urlencode((
string) ($socid));
445 $param .=
"&search_showbirthday=1";
448 $param .=
"&search_projectid=".urlencode((
string) ($pid));
451 $param .=
"&search_type=".urlencode($type);
453$param .=
"&maxprint=".urlencode((
string) ($maxprint));
454if ($mode ==
'show_day' || $mode ==
'show_week' || $mode ==
'show_month') {
455 $param .=
'&mode='.urlencode($mode);
457if ($search_categ_cus != 0) {
458 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
461 $param .=
'&check_holiday=1';
466$nav .=
'<div class="navselectiondate inline-block nowraponall">';
467if (empty($mode) || $mode ==
'show_month') {
468 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
469 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, 1, $year),
"%b %Y");
470 $nav .=
" </span>\n";
471 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
474if ($mode ==
'show_week') {
475 $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";
476 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"WeekShort").
" ".$week;
477 $nav .=
" </span>\n";
478 $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";
479 $picto =
'calendarweek';
481if ($mode ==
'show_day') {
482 $nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\"></i></a> \n";
483 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $month, $day, $year),
"daytextshort");
484 $nav .=
" </span>\n";
485 $nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\"></i></a>\n";
486 $picto =
'calendarday';
488if (empty(
$conf->dol_optimize_smallscreen)) {
489 $nav .=
' <a href="?year='.$nowyear.
'&month='.$nowmonth.
'&day='.$nowday.$param.
'" class="datenowlink marginleftonly marginrightonly">'.$langs->trans(
"Today").
'</a> ';
493$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
495$nav .=
'<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
498$paramnodate = $param;
499$param .=
'&year='.$year.
'&month='.$month.($day ?
'&day='.$day :
'');
514$paramnoaction = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $param));
515$paramnoactionodate = preg_replace(
'/mode=[a-z_]+/',
'', preg_replace(
'/action=[a-z_]+/',
'', $paramnodate));
519print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
520if ($optioncss !=
'') {
521 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
523print
'<input type="hidden" name="token" value="'.newToken().
'">';
524print
'<input type="hidden" name="mode" value="'.$mode.
'">';
527$viewmode =
'<div class="navmode inline-block">';
529$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
531$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
533$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
535$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.
'">';
537$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
539$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
541$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.
'">';
543$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
545$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
547$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.
'">';
549$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
551$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
553$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.
'">';
555$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
557$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
560$parameters = array();
562$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
563if (empty($reshook)) {
564 $viewmode .= $hookmanager->resPrint;
565} elseif ($reshook > 1) {
566 $viewmode = $hookmanager->resPrint;
569$viewmode .=
'</div>';
571$viewmode .=
'<span class="marginrightonly"></span>';
576if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
579 $newparam .=
'&month='.((int) $month).
'&year='.((int) $tmpforcreatebutton[
'year']).
'&mode='.urlencode($mode);
584 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
585 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
586 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
588 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
595$showextcals = $listofextcals;
596$bookcalcalendars = array();
599if (isModEnabled(
"bookcal")) {
600 $sql =
"SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal";
601 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookcal_availabilities as ba";
602 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"bookcal_calendar as bc";
603 $sql .=
" ON bc.rowid = ba.fk_bookcal_calendar";
604 $sql .=
" WHERE bc.status = 1";
605 $sql .=
" AND ba.status = 1";
606 $sql .=
" AND bc.entity IN (".getEntity(
'agenda').
")";
607 if (!empty($filtert) && $filtert !=
'-1') {
608 $sql .=
" AND bc.visibility IN (".$db->sanitize($filtert, 0, 0, 0, 0).
")";
610 $resql = $db->query($sql);
612 $num = $db->num_rows($resql);
615 $objp = $db->fetch_object($resql);
616 $label = !empty($objp->label) ? $objp->label : $objp->ref;
617 $bookcalcalendars[
"calendars"][$objp->id_cal] = array(
"id" => $objp->id_cal,
"label" => $label);
618 $bookcalcalendars[
"availabilitieslink"][$objp->rowid] = $objp->id_cal;
626if (!empty(
$conf->use_javascript_ajax)) {
627 $s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
629 $s .=
'<script type="text/javascript">'.
"\n";
630 $s .=
'jQuery(document).ready(function () {'.
"\n";
631 $s .=
'jQuery(".check_birthday").click(function() { console.log("Toggle class .family_birthday"); jQuery(".family_birthday").toggle(); });'.
"\n";
632 $s .=
'jQuery(".check_holiday").click(function() { console.log("Toggle class .family_holiday"); jQuery(".family_holiday").toggle(); jQuery(this).closest("form").submit(); });'.
"\n";
633 if (isModEnabled(
"bookcal") && !empty($bookcalcalendars[
"calendars"])) {
634 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
635 $s .=
'jQuery(".check_bookcal_calendar_'.$value[
'id'].
'").click(function() { console.log("Toggle Bookcal Calendar '.$value[
'id'].
'"); jQuery(".family_bookcal_calendar_'.$value[
'id'].
'").toggle(); });'.
"\n";
638 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
640 $s .=
'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'.
"\n";
642 $s .=
'console.log("submit form to record new event");'.
"\n";
644 $s .=
'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'.
"\n";
645 $s .=
'console.log("found parent div.dayevent with id = "+newval);'.
"\n";
646 $s .=
'var frm=jQuery("#searchFormList");'.
"\n";
647 $s .=
'var newurl = ui.item.find("a.cal_event").attr("href");'.
"\n";
648 $s .=
'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'.
"\n";
649 $s .=
'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'.
"\n";
653 $s .=
'</script>'.
"\n";
656 $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>';
659 if ($user->hasRight(
"holiday",
"read")) {
661 <div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"' . ($check_holiday
662 ?
' checked' :
'') .
'>
663 <label for="check_holiday" class="labelcalendar">
664 <span class="check_holiday_text">' . $langs->trans(
"Holidays") .
'</span>
670 if (is_array($showextcals) && count($showextcals) > 0) {
671 $s .=
'<script type="text/javascript">'.
"\n";
672 $s .=
'jQuery(document).ready(function () {
673 jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) {
674 var name = jQuery(elem).attr("name");
675 if (jQuery(elem).is(":checked")) {
676 jQuery(".family_ext" + name.replace("check_ext", "")).show();
678 jQuery(".family_ext" + name.replace("check_ext", "")).hide();
682 jQuery("div input[name^=\"check_ext\"]").click(function() {
683 var name = $(this).attr("name");
684 jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
687 $s .=
'</script>'.
"\n";
689 foreach ($showextcals as $val) {
690 $htmlname = md5($val[
'name']);
692 if (!empty($val[
'default']) ||
GETPOSTINT(
'check_ext'.$htmlname)) {
693 $default =
"checked";
698 $tooltip = $langs->trans(
"Cache").
' '.round($DELAYFORCACHE / 60).
'mn';
700 $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>';
705 $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>';
708 if (isModEnabled(
"bookcal")) {
709 if (!empty($bookcalcalendars[
"calendars"])) {
710 foreach ($bookcalcalendars[
"calendars"] as $key => $value) {
711 $label = $value[
'label'];
712 $s .=
'<div class="nowrap inline-block minheight30">';
713 $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'].
'">';
714 $s .=
'<label for="check_bookcal_calendar_'.$value[
'id'].
'" class="labelcalendar">';
715 $s .=
'<span class="check_bookcal_calendar_'.$value[
'id'].
'_text">'.$langs->trans(
"AgendaShowBookcalCalendar", $label).
'</span>';
716 $s .=
'</label> </div>';
722 $parameters = array();
723 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
724 if (empty($reshook)) {
725 $s .= $hookmanager->resPrint;
726 } elseif ($reshook > 1) {
727 $s = $hookmanager->resPrint;
730 $s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
733 $newparam = preg_replace(
'/showbirthday=[0-1]/i',
'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
734 if (!preg_match(
'/showbirthday=/i', $newparam)) {
735 $newparam .=
'&showbirthday=1';
739 if (empty($showbirthday)) {
740 $s .= $langs->trans(
"AgendaShowBirthdayEvents");
742 $s .= $langs->trans(
"AgendaHideBirthdayEvents");
749$eventarray = array();
757$sql .=
' a.id, a.label,';
760$sql .=
' a.percent,';
761$sql .=
' a.fk_user_author,a.fk_user_action,';
762$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
763$sql .=
' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,';
764$sql .=
' a.fk_element, a.elementtype,';
765$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';
768$parameters = array();
769$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
770$sql .= $hookmanager->resPrint;
774$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
777if (($filtert !=
'-1' && $filtert !=
'-2') || $usergroup > 0) {
779 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user'";
780 if ($filtert !=
'-1' && $filtert !=
'-2' && $filtert !=
'-3') {
781 $sql .=
" AND (ar.fk_element IN (".$db->sanitize($filtert).
") OR (ar.fk_element IS NULL AND a.fk_user_action = ".((int) $filtert).
"))";
782 } elseif ($filtert ==
'-3') {
783 $sql .=
" AND ar.fk_element IN (".$db->sanitize(implode(
',', $user->getAllChildIds(1))).
")";
785 if ($usergroup > 0) {
786 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
791if ($resourceid > 0) {
792 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
796$parameters = array();
797$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
798$sql .= $hookmanager->resPrint;
800$sql .=
" WHERE a.fk_action = ca.id";
801$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
803if (!empty($actioncode)) {
805 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ==
'AC_NON_AUTO') {
806 $sql .=
" AND ca.type != 'systemauto'";
807 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ==
'AC_ALL_AUTO') {
808 $sql .=
" AND ca.type = 'systemauto'";
810 if ((is_array($actioncode) && in_array(
'AC_OTH', $actioncode)) || $actioncode ==
'AC_OTH') {
811 $sql .=
" AND ca.type != 'systemauto'";
813 if ((is_array($actioncode) && in_array(
'AC_OTH_AUTO', $actioncode)) || $actioncode ==
'AC_OTH_AUTO') {
814 $sql .=
" AND ca.type = 'systemauto'";
818 if ((is_array($actioncode) && in_array(
'AC_NON_AUTO', $actioncode)) || $actioncode ===
'AC_NON_AUTO') {
819 $sql .=
" AND ca.type != 'systemauto'";
820 } elseif ((is_array($actioncode) && in_array(
'AC_ALL_AUTO', $actioncode)) || $actioncode ===
'AC_ALL_AUTO') {
821 $sql .=
" AND ca.type = 'systemauto'";
823 if (is_array($actioncode)) {
825 $actioncode = array_filter(
832 return ((
string) $value !==
'-1');
835 if (count($actioncode)) {
836 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
838 } elseif ($actioncode !==
'-1') {
839 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
844if ($resourceid > 0) {
845 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
848 $sql .=
" AND a.fk_project=".((int) $pid);
852if (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
853 $search_sale = $user->id;
856if ($search_sale && $search_sale !=
'-1') {
857 if ($search_sale == -2) {
858 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
859 } elseif ($search_sale > 0) {
860 $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).
")";
865 $sql .=
" AND a.fk_soc = ".((int) $socid);
868if ($mode ==
'show_day') {
870 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
871 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
873 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
874 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
876 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
877 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
882 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
883 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
885 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
886 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
888 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)).
"'";
889 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)).
"')";
893 $sql .=
" AND ca.id = ".((int) $type);
897 $sql .=
" AND a.percent = 0";
899if ($status ===
'na') {
901 $sql .=
" AND a.percent = -1";
903if ($status ==
'50') {
905 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
907if ($status ==
'done' || $status ==
'100') {
908 $sql .=
" AND (a.percent = 100)";
910if ($status ==
'todo') {
911 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
915if ($search_categ_cus != -1) {
916 if ($search_categ_cus == -2) {
917 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
918 } elseif ($search_categ_cus > 0) {
919 $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).
"))";
924$sql .= $db->order(
"datep");
927dol_syslog(
"comm/action/index.php", LOG_DEBUG);
928$resql = $db->query($sql);
930 $num = $db->num_rows($resql);
932 $MAXONSAMEPAGE = 10000;
934 while ($i < $num && $i < $MAXONSAMEPAGE) {
935 $obj = $db->fetch_object($resql);
938 if (
getDolGlobalString(
'AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code ==
'AC_OTH_AUTO') {
946 $event->id = $obj->id;
947 $event->ref = (string) $event->id;
949 $event->fulldayevent = $obj->fulldayevent;
952 if ($event->fulldayevent) {
954 $event->datep = $db->jdate($obj->datep, $tzforfullday ?
'tzuser' :
'tzserver');
955 $event->datef = $db->jdate($obj->datep2, $tzforfullday ?
'tzuser' :
'tzserver');
958 $event->datep = $db->jdate($obj->datep,
'tzserver');
959 $event->datef = $db->jdate($obj->datep2,
'tzserver');
965 $event->type_code = $obj->type_code;
966 $event->type_label = $obj->type_label;
967 $event->type_color = $obj->type_color;
968 $event->type = $obj->type_type;
969 $event->type_picto = $obj->type_picto;
971 $event->label = $obj->label;
972 $event->percentage = $obj->percent;
974 $event->authorid = $obj->fk_user_author;
975 $event->userownerid = $obj->fk_user_action;
976 $event->fetch_userassigned();
978 $event->priority = $obj->priority;
979 $event->location = $obj->location;
980 $event->transparency = $obj->transparency;
981 $event->fk_element = $obj->fk_element;
982 $event->elementid = $obj->fk_element;
983 $event->elementtype = $obj->elementtype;
985 $event->fk_project = $obj->fk_project;
987 $event->socid = $obj->fk_soc;
988 $event->contact_id = $obj->fk_contact;
989 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
990 if (!empty($event->fk_bookcal_calendar)) {
991 $event->type =
"bookcal_calendar";
996 $event->date_start_in_calendar = $event->datep;
997 if ($event->datef !=
'' && $event->datef >= $event->datep) {
998 $event->date_end_in_calendar = $event->datef;
1000 $event->date_end_in_calendar = $event->datep;
1004 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1007 if ($event->date_start_in_calendar < $firstdaytoshow) {
1008 $event->date_start_in_calendar = $firstdaytoshow;
1010 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1011 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1015 $daycursor = $event->date_start_in_calendar;
1020 $daycursorend = $event->date_end_in_calendar;
1021 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1022 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1023 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1032 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1033 $daykeyend =
dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend,
'gmt');
1047 $eventarray[$daykey][] = $event;
1050 $daykey += 60 * 60 * 24;
1052 if ($daykey > $daykeyend) {
1061 $parameters[
'obj'] = $obj;
1062 $reshook = $hookmanager->executeHooks(
'hookEventElements', $parameters, $event, $action);
1063 $event = $hookmanager->resPrint;
1080 $sql =
'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1081 $sql .=
' FROM '.MAIN_DB_PREFIX.
'socpeople as sp';
1082 $sql .=
' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).
'))';
1083 $sql .=
" AND sp.entity IN (".getEntity(
'contact').
")";
1084 if ($mode ==
'show_day') {
1085 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1086 $sql .=
' AND DAY(birthday) = '.((int) $day);
1088 $sql .=
' AND MONTH(birthday) = '.((int) $month);
1090 $sql .=
' ORDER BY birthday';
1092 dol_syslog(
"comm/action/index.php", LOG_DEBUG);
1093 $resql = $db->query($sql);
1095 $num = $db->num_rows($resql);
1098 $obj = $db->fetch_object($resql);
1102 $event->id = $obj->rowid;
1103 $event->ref = (string) $event->id;
1108 $event->datep =
dol_mktime(0, 0, 0, $datearray[
'mon'], $datearray[
'mday'], $year,
true);
1109 $event->datef = $event->datep;
1111 $event->type_code =
'BIRTHDAY';
1112 $event->type_label =
'';
1113 $event->type_color =
'';
1114 $event->type =
'birthdate';
1115 $event->type_picto =
'birthdate';
1117 $event->label = $langs->trans(
"Birthday").
' '.
dolGetFirstLastname($obj->firstname, $obj->lastname);
1118 $event->percentage = 100;
1119 $event->fulldayevent = 1;
1121 $event->contact_id = $obj->rowid;
1123 $event->date_start_in_calendar = $db->jdate($event->datep);
1124 $event->date_end_in_calendar = $db->jdate($event->datef);
1127 $daycursor = $event->datep;
1132 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1134 $eventarray[$daykey][] = $event;
1152if ($user->hasRight(
"holiday",
"read")) {
1153 $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";
1154 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as x, ".MAIN_DB_PREFIX.
"user as u";
1155 $sql .=
" WHERE u.rowid = x.fk_user";
1156 $sql .=
" AND u.statut = '1'";
1157 $sql .=
" AND (x.statut = '2' OR x.statut = '3')";
1158 if ($mode ==
'show_day') {
1160 $sql .=
" AND '".$db->escape($year).
"-".$db->escape($month).
"-".$db->escape($day).
"' BETWEEN x.date_debut AND x.date_fin";
1161 } elseif ($mode ==
'show_week') {
1163 $sql .=
" AND x.date_debut < '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1164 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1165 } elseif ($mode ==
'show_month') {
1167 $sql .=
" AND x.date_debut <= '".$db->idate(
dol_get_last_day($year, $month)).
"'";
1168 $sql .=
" AND x.date_fin >= '".$db->idate(
dol_get_first_day($year, $month)).
"'";
1170 if (!$user->hasRight(
'holiday',
'readall') || $filtert ==
'-3') {
1172 $sql .=
" AND x.fk_user IN(".$db->sanitize(implode(
", ", $user->getAllChildIds(1))).
") ";
1176 $sql .=
" AND x.fk_user = ".((int) $filtert);
1179 $resql = $db->query($sql);
1181 $num = $db->num_rows($resql);
1185 $obj = $db->fetch_object($resql);
1190 $event->id = $obj->rowid;
1191 $event->ref = (string) $event->id;
1193 $event->type_code =
'HOLIDAY';
1194 $event->type_label =
'';
1195 $event->type_color =
'';
1196 $event->type =
'holiday';
1197 $event->type_picto =
'holiday';
1199 $event->datep = $db->jdate($obj->date_start) + (empty($obj->halfday) || $obj->halfday == 1 ? 0 : 12) * 60 * 60;
1200 $event->datef = $db->jdate($obj->date_end) + (empty($obj->halfday) || $obj->halfday == -1 ? 24 : 12) * 60 * 60 - 1;
1201 $event->date_start_in_calendar = $event->datep;
1202 $event->date_end_in_calendar = $event->datef;
1204 if ($obj->status == 3) {
1206 $event->percentage = -1;
1207 } elseif ($obj->status == 2) {
1209 $event->percentage = 0;
1212 $event->label = $langs->trans(
"Holiday");
1214 $daycursor = $event->date_start_in_calendar;
1219 $daycursorend = $event->date_end_in_calendar;
1220 $anneeend = (int)
dol_print_date($daycursorend,
'%Y',
'tzuserrel');
1221 $moisend = (int)
dol_print_date($daycursorend,
'%m',
'tzuserrel');
1222 $jourend = (int)
dol_print_date($daycursorend,
'%d',
'tzuserrel');
1225 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1226 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1231 $firstdayofholiday = ($ifornbofdays == 1);
1232 $lastdayofholiday = ($daykeygmt ==
dol_get_first_hour($event->date_end_in_calendar,
'gmt'));
1241 if ((in_array($obj->halfday, array(1, 2)) == 1 && $lastdayofholiday) || (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday)) {
1244 if (in_array($obj->halfday, array(1, 2)) && $lastdayofholiday) {
1245 $newevent->label .=
' ('.$langs->trans(
"Morning").
')';
1246 } elseif (in_array($obj->halfday, array(-1, 2)) && $firstdayofholiday) {
1247 $newevent->label .=
' ('.$langs->trans(
"Afternoon").
')';
1249 $eventarray[$daykey][] = $newevent;
1251 $eventarray[$daykey][] = $event;
1254 $daykey += 60 * 60 * 24;
1255 $daykeygmt += 60 * 60 * 24;
1256 }
while ($daykey <= $event->date_end_in_calendar);
1265if (count($listofextcals)) {
1266 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/ical.class.php';
1268 foreach ($listofextcals as $key => $extcal) {
1269 $url = $extcal[
'src'];
1270 $namecal = $extcal[
'name'];
1271 $offsettz = $extcal[
'offsettz'];
1272 $colorcal = $extcal[
'color'];
1273 $buggedfile = $extcal[
'buggedfile'];
1279 $ical->parse($url, $pathforcachefile, $DELAYFORCACHE);
1282 $listofextcals[$key][
'error'] = $ical->error;
1283 $s .=
'<br><div class="warning">'.dol_escape_htmltag($listofextcals[$key][
'name']).
': '.$url.
'<br>Error message: '.
dol_escape_htmltag($ical->error).
'</div>';
1288 $icalevents = array();
1289 if (is_array($ical->get_event_list())) {
1290 $icalevents = array_merge($icalevents, $ical->get_event_list());
1292 if (is_array($ical->get_freebusy_list())) {
1293 $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
1296 if (count($icalevents) > 0) {
1298 $moreicalevents = array();
1299 foreach ($icalevents as $icalevent) {
1300 if (isset($icalevent[
'RRULE']) && is_array($icalevent[
'RRULE'])) {
1303 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1306 } elseif (is_array($icalevent[
'DTSTART']) && !empty($icalevent[
'DTSTART'][
'unixtime'])) {
1307 $datecurstart = $icalevent[
'DTSTART'][
'unixtime'];
1308 $datecurend = $icalevent[
'DTEND'][
'unixtime'];
1309 if (!empty($ical->cal[
'DAYLIGHT'][
'DTSTART']) && $datecurstart) {
1311 $tmpcurstart = $datecurstart;
1312 $tmpcurend = $datecurend;
1313 $tmpdaylightstart =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'DAYLIGHT'][
'DTSTART'];
1314 $tmpdaylightend =
dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal[
'STANDARD'][
'DTSTART'];
1317 if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1318 $datecurstart -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1320 $datecurstart -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1322 if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
1323 $datecurend -= ((int) $ical->cal[
'DAYLIGHT'][
'TZOFFSETTO']) * 36;
1325 $datecurend -= ((int) $ical->cal[
'STANDARD'][
'TZOFFSETTO']) * 36;
1332 dol_syslog(
"Found a not recognized repeatable record with unknown date start", LOG_ERR);
1337 $interval = (empty($icalevent[
'RRULE'][
'INTERVAL']) ? 1 : $icalevent[
'RRULE'][
'INTERVAL']);
1338 $until = empty($icalevent[
'RRULE'][
'UNTIL']) ? 0 :
dol_stringtotime($icalevent[
'RRULE'][
'UNTIL'], 1);
1339 $maxrepeat = empty($icalevent[
'RRULE'][
'COUNT']) ? 0 : $icalevent[
'RRULE'][
'COUNT'];
1340 if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
1343 if ($datecurstart >= $lastdaytoshow) {
1348 while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
1349 if ($datecurend >= $firstdaytoshow) {
1350 $newevent = $icalevent;
1351 unset($newevent[
'RRULE']);
1352 if ($icalevent[
'DTSTART;VALUE=DATE']) {
1353 $newevent[
'DTSTART;VALUE=DATE'] =
dol_print_date($datecurstart,
'%Y%m%d');
1354 $newevent[
'DTEND;VALUE=DATE'] =
dol_print_date($datecurend + 1,
'%Y%m%d');
1356 $newevent[
'DTSTART'] = $datecurstart;
1357 $newevent[
'DTEND'] = $datecurend;
1359 $moreicalevents[] = $newevent;
1363 $savdatecurstart = $datecurstart;
1364 if ($icalevent[
'RRULE'][
'FREQ'] ==
'DAILY') {
1368 if ($icalevent[
'RRULE'][
'FREQ'] ==
'WEEKLY') {
1371 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'MONTHLY') {
1374 } elseif ($icalevent[
'RRULE'][
'FREQ'] ==
'YEARLY') {
1379 if ($savdatecurstart >= $datecurstart) {
1380 dol_syslog(
"Found a rule freq ".$icalevent[
'RRULE'][
'FREQ'].
" not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
1381 $datecurstart += 3600 * 24 * 7;
1382 $datecurend += 3600 * 24 * 7;
1387 $icalevents = array_merge($icalevents, $moreicalevents);
1390 foreach ($icalevents as $icalevent) {
1395 if (!empty($icalevent[
'RRULE'])) {
1402 if (isset($icalevent[
'DTSTART;VALUE=DATE'])) {
1405 if (empty($icalevent[
'DTEND;VALUE=DATE'])) {
1406 $dateend = $datestart + 86400 - 1;
1412 $event->fulldayevent = 1;
1414 } elseif (!is_array($icalevent[
'DTSTART'])) {
1415 $datestart = $icalevent[
'DTSTART'];
1416 $dateend = empty($icalevent[
'DTEND']) ? $datestart : $icalevent[
'DTEND'];
1418 $datestart += +($offsettz * 3600);
1419 $dateend += +($offsettz * 3600);
1424 } elseif (isset($icalevent[
'DTSTART'][
'unixtime'])) {
1425 $datestart = $icalevent[
'DTSTART'][
'unixtime'];
1426 $dateend = $icalevent[
'DTEND'][
'unixtime'];
1428 $datestart += +($offsettz * 3600);
1429 $dateend += +($offsettz * 3600);
1432 if ($buggedfile ===
'uselocalandtznodaylight') {
1436 if ($buggedfile ===
'uselocalandtzdaylight') {
1437 $localtzs =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTSTART'][
'TZID']));
1438 $localtze =
new DateTimeZone(preg_replace(
'/"/',
'', $icalevent[
'DTEND'][
'TZID']));
1439 $localdts =
new DateTime(
dol_print_date($datestart,
'dayrfc',
'gmt'), $localtzs);
1440 $localdte =
new DateTime(
dol_print_date($dateend,
'dayrfc',
'gmt'), $localtze);
1441 $tmps = -1 * $localtzs->getOffset($localdts);
1442 $tmpe = -1 * $localtze->getOffset($localdte);
1443 $datestart += $tmps;
1451 $event->id = $icalevent[
'UID'];
1452 $event->ref = (string) $event->id;
1453 $userId = $userstatic->findUserIdByEmail($namecal);
1454 if (!empty($userId) && $userId > 0) {
1455 $event->userassigned[$userId] = $userId;
1456 $event->percentage = -1;
1459 $event->type_code =
"ICALEVENT";
1460 $event->type_label = $namecal;
1461 $event->type_color = $colorcal;
1462 $event->type =
'icalevent';
1463 $event->type_picto =
'rss';
1465 $event->icalname = $namecal;
1466 $event->icalcolor = $colorcal;
1468 $event->datep = $datestart + $usertime;
1469 $event->datef = $dateend + $usertime;
1471 if (isset($icalevent[
'SUMMARY']) && $icalevent[
'SUMMARY']) {
1473 } elseif (isset($icalevent[
'DESCRIPTION']) && $icalevent[
'DESCRIPTION']) {
1476 $event->label = $langs->trans(
"ExtSiteNoLabel");
1483 if (!empty($icalevent[
'PRIORITY'])) {
1484 $event->priority = $icalevent[
'PRIORITY'];
1488 if (!empty($icalevent[
'TRANSP'])) {
1489 if ($icalevent[
'TRANSP'] ==
"TRANSPARENT") {
1490 $event->transparency = 0;
1492 if ($icalevent[
'TRANSP'] ==
"OPAQUE") {
1493 $event->transparency = 1;
1504 if (!empty($icalevent[
'LOCATION'])) {
1505 $event->location = $icalevent[
'LOCATION'];
1508 $event->date_start_in_calendar = $event->datep;
1510 if ($event->datef !=
'' && $event->datef >= $event->datep) {
1511 $event->date_end_in_calendar = $event->datef;
1513 $event->date_end_in_calendar = $event->datep;
1517 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1523 if ($event->date_start_in_calendar < $firstdaytoshow) {
1524 $event->date_start_in_calendar = $firstdaytoshow;
1526 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1527 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1531 $daycursor = $event->date_start_in_calendar;
1540 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1541 $daykeygmt =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
1544 $eventarray[$daykey][] = $event;
1545 $daykey += 60 * 60 * 24;
1546 $daykeygmt += 60 * 60 * 24;
1547 if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1559$parameters = array();
1561$reshook = $hookmanager->executeHooks(
'getCalendarEvents', $parameters, $object, $action);
1562if (!empty($hookmanager->resArray[
'eventarray'])) {
1563 foreach ($hookmanager->resArray[
'eventarray'] as $keyDate => $events) {
1564 if (!isset($eventarray[$keyDate])) {
1565 $eventarray[$keyDate] = array();
1567 $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
1572foreach ($eventarray as $keyDate => &$dateeventarray) {
1573 usort($dateeventarray,
'sort_events_by_date');
1578$cachethirdparties = array();
1579$cachecontacts = array();
1580$cacheusers = array();
1583$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
1584if (is_readable($color_file)) {
1585 include $color_file;
1587if (!is_array($theme_datacolor)) {
1588 $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));
1591$massactionbutton =
'';
1593print_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);
1599if (empty($mode) || $mode ==
'show_month') {
1601 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1602 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1603 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1604 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1605 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1606 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1607 $newparam = preg_replace(
'/viewcal=[0-9]+&?/i',
'', $newparam);
1608 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1609 $newparam .=
'&viewcal=1';
1611 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1612 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
1615 print
'<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
1616 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1617 print
' <tr class="liste_titre">';
1619 echo
' <td class="center">#</td>';
1622 print
' <td class="center bold uppercase tdfordaytitle'.($i == 0 ?
' borderleft' :
'').
'">';
1623 $numdayinweek = (($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7);
1624 if (!empty(
$conf->dol_optimize_smallscreen)) {
1625 $labelshort = array(0 =>
'SundayMin', 1 =>
'MondayMin', 2 =>
'TuesdayMin', 3 =>
'WednesdayMin', 4 =>
'ThursdayMin', 5 =>
'FridayMin', 6 =>
'SaturdayMin');
1626 print $langs->trans($labelshort[$numdayinweek]);
1628 print $langs->trans(
"Day".$numdayinweek);
1630 print
' </td>'.
"\n";
1636 $todaytms =
dol_mktime(0, 0, 0, $todayarray[
'mon'], $todayarray[
'mday'], $todayarray[
'year']);
1640 for ($iter_week = 0; $iter_week < 6; $iter_week++) {
1644 $currdate0 = sprintf(
"%04d", $prev_year).sprintf(
"%02d", $prev_month).sprintf(
"%02d", $max_day_in_prev_month + $tmpday);
1645 } elseif ($tmpday <= $max_day_in_month) {
1646 $currdate0 = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $tmpday);
1648 $currdate0 = sprintf(
"%04d", $next_year).sprintf(
"%02d", $next_month).sprintf(
"%02d", $tmpday - $max_day_in_month);
1651 $numweek0 = date(
"W", strtotime(date($currdate0)));
1653 echo
' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.
'</td>';
1655 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1658 $style =
'cal_other_month cal_past';
1659 if ($iter_day == 6) {
1660 $style .=
' cal_other_month_right';
1662 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1664 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1666 } elseif ($tmpday <= $max_day_in_month) {
1668 $curtime =
dol_mktime(0, 0, 0, $month, $tmpday, $year);
1669 $style =
'cal_current_month';
1670 if ($iter_day == 6) {
1671 $style .=
' cal_current_month_right';
1674 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1678 $style =
'cal_today';
1680 if ($curtime < $todaytms) {
1681 $style .=
' cal_past';
1684 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1686 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars);
1690 $style =
'cal_other_month';
1691 if ($iter_day == 6) {
1692 $style .=
' cal_other_month_right';
1694 echo
' <td class="'.$style.
' nowrap tdtop" width="14%">';
1696 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1706 print
'<input type="hidden" name="actionmove" value="mupdate">';
1707 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_month&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1708 print
'<input type="hidden" name="newdate" id="newdate">';
1709} elseif ($mode ==
'show_week') {
1712 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
1713 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1714 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1715 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
1716 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
1717 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
1718 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
1719 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
1720 $newparam .=
'&viewweek=1';
1722 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1723 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1726 print
'<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
1727 print
'<table class="centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore">';
1728 print
' <tr class="liste_titre">';
1731 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";
1738 for ($iter_day = 0; $iter_day < 7; $iter_day++) {
1745 $style =
'cal_current_month';
1746 if ($iter_day == 6) {
1747 $style .=
' cal_other_month_right';
1752 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1756 $style =
'cal_today';
1759 echo
' <td class="'.$style.
'" width="14%" valign="top">';
1761 show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1769 echo
'<input type="hidden" name="actionmove" value="mupdate">';
1770 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?mode=show_week&'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
1771 echo
'<input type="hidden" name="newdate" id="newdate">';
1774 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
1775 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
1776 $newparam = preg_replace(
'/viewday=[0-9]+&?/i',
'', $newparam);
1777 $newparam .=
'&viewday=1';
1779 $style =
'cal_current_month cal_current_month_oneday';
1782 if ($todayarray[
'mday'] == $day && $todayarray[
'mon'] == $month && $todayarray[
'year'] == $year) {
1787 $timestamp =
dol_mktime(12, 0, 0, $month, $day, $year);
1790 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1791 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
1794 print
'<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
1795 echo
'<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month listwithfilterbefore" style="margin-bottom: 10px !important;">';
1797 echo
' <tr class="tagtr liste_titre">';
1798 echo
' <td class="tagtd center bold uppercase">'.$langs->trans(
"Day".$arraytimestamp[
'wday']).
"</td>\n";
1815 print
'<div class="div-table-responsive-no-min">';
1817 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 500) ? ($_SESSION[
"dol_screenheight"] - 200) : 660;
1819 echo
'<div style="max-height: '.$maxheightwin.
'px;">';
1820 echo
'<div class="tagtable centpercent calendarviewcontainer">';
1825 $minhour = round((
float) $tmp[0], 0);
1826 $maxhour = round((
float) $tmp[1], 0);
1827 if ($minhour > 23) {
1833 if ($maxhour <= $minhour) {
1834 $maxhour = $minhour + 1;
1840 echo
' <div class="tagtr calendarviewcontainertr">'.
"\n";
1841 echo
' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600,
'hour',
'gmt').
'</div>';
1842 echo
' <div class="tagtd '.$style.
' tdtop"></div>'.
"\n";
1843 echo
' </div>'.
"\n";
1848 echo
'</div></div>';
1851 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
1855 print
'<div class="div-table-responsive-no-min">';
1858 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars);
1870print
"\n".
'</form>';
1896function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
1898 global $user,
$conf, $langs;
1899 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
1900 global $theme_datacolor;
1901 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1902 global $hookmanager;
1904 '@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
1905 @phan-var-force User[] $cacheusers
1906 @phan-var-force array<int<0,3>> $colorindexused';
1908 if (
$conf->use_javascript_ajax) {
1909 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
1912 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1918 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
1919 $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;
1921 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
1922 $newparam .=
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
1923 $hourminsec =
'100000';
1924 $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 :
''));
1928 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
1931 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
1932 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
1934 print dol_print_date($curtime, 'daytextshort');
1936 print dol_print_date($curtime, '%d');
1939 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
1940 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
1941 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, useful for nojs interfaces
1942 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
1945 print '</div></div></div>'."\n
";
1953 // Line with td contains all div of each events
1954 print '<div class="tagtr
">';
1955 print '<div class="tagtd centpercent agendacell sortable
">';
1957 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
1964 $numicals = array();
1965 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
1967 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1968 $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1969 //var_dump($colorindexused);
1971 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1972 $tmpholiday = new Holiday($db);
1974 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
1975 $annee = (int) dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1976 $mois = (int) dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1977 $jour = (int) dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
1979 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
1980 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' day='.$day.' month='.$month.' year='.$year."<br>\n
";
1982 if ($day == $jour && $month == $mois && $year == $annee) {
1983 foreach ($eventarray[$daykey] as $index => $event) {
1984 if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) {
1985 $keysofuserassigned = array_keys($event->userassigned);
1987 // Define $color (Hex string like '0088FF') and $cssclass of event
1991 if (in_array($user->id, $keysofuserassigned)) {
1992 $cssclass = 'family_mytasks';
1994 if (empty($cacheusers[$event->userownerid])) {
1995 $newuser = new User($db);
1996 $newuser->fetch($event->userownerid);
1997 $cacheusers[$event->userownerid] = $newuser;
1999 //var_dump($cacheusers[$event->userownerid]->color);
2001 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
2002 if (!empty($cacheusers[$event->userownerid]->color)) {
2003 $color = $cacheusers[$event->userownerid]->color;
2006 /* May be we need this: if (getDolGlobalString('AGENDA_USE_COLOR_PER_EVENT_TYPE')) {
2007 $color = $event->type_color;
2009 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
2011 if (!empty($event->icalname)) {
2012 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
2013 $numicals[dol_string_nospecial($event->icalname)] = 0;
2015 $numicals[dol_string_nospecial($event->icalname)]++;
2018 $color = ($event->icalcolor ? $event->icalcolor : -1);
2019 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
2020 } elseif ($event->type_code == 'BIRTHDAY') {
2023 $cssclass = 'family_birthday ';
2024 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2025 } elseif ($event->type == 'bookcal_calendar') {
2028 $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink
"]) ? $bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar] : "");
2029 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2032 $color = ($event->icalcolor ? $event->icalcolor : -1);
2033 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
2035 if (empty($cacheusers[$event->userownerid])) {
2036 $newuser = new User($db);
2037 $newuser->fetch($event->userownerid);
2038 $cacheusers[$event->userownerid] = $newuser;
2040 //var_dump($cacheusers[$event->userownerid]->color);
2042 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
2043 if (!empty($cacheusers[$event->userownerid]->color)) {
2044 $color = $cacheusers[$event->userownerid]->color;
2048 if ($color < 0) { // Color was not set on user card. Set color according to color index.
2049 // Define color index if not yet defined
2050 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
2051 if (isset($colorindexused[$idusertouse])) {
2052 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
2054 $colorindex = $nextindextouse;
2055 $colorindexused[$idusertouse] = $colorindex;
2056 if (!empty($theme_datacolor[$nextindextouse + 1])) {
2057 $nextindextouse++; // Prepare to use next color
2060 if (isset($theme_datacolor[$colorindex])) {
2061 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
2062 } elseif (getDolGlobalString('THEME_ELDY_BACKBODY')) {
2063 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2064 $color = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_BACKBODY'), array()), '');
2069 $cssclass = $cssclass.' eventday_'.$ymd;
2071 // Defined style to disable drag and drop feature
2072 if ($event->type_code == 'AC_OTH_AUTO') {
2073 $cssclass .= " unmovable
";
2074 } elseif ($event->type_code == 'HOLIDAY') {
2075 $cssclass .= " unmovable
";
2076 } elseif ($event->type_code == 'BIRTHDAY') {
2077 $cssclass .= " unmovable
";
2078 } elseif ($event->type_code == 'ICALEVENT') {
2079 $cssclass .= " unmovable
";
2080 } 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)) {
2081 // If the event is on several days
2082 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2083 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2084 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2085 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
2086 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
2087 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
2089 $cssclass .= ' movable cursormove';
2092 if ($user->hasRight('agenda', 'allactions', 'create') ||
2093 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
2094 $cssclass .= " movable cursormove
";
2096 $cssclass .= " unmovable
";
2102 if ($mode == 'show_day') {
2103 $h = 'height: 100%; ';
2106 if ($mode == 'show_week') {
2107 $h = 'height: 100%; ';
2113 print '<!-- start event '.$i.' -->'."\n
";
2116 if ($maxprint && $ireallyshown >= $maxprint) {
2117 $morecss = 'showifmore';
2119 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
2120 $morecss = 'hidden';
2122 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
2123 $morecss = 'hidden';
2125 /* I comment this because it hides event recorded from bookcal online page
2126 if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar])) {
2127 $morecss = 'hidden';
2129 if ($morecss != 'hidden') {
2132 if ($morecss != 'showifmore' && $morecss != 'hidden') {
2136 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
2137 if (isModEnabled("bookcal
") && $event->type == 'bookcal_calendar') {
2138 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.'_
'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2140 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
2142 //print ' style="height: 100px;
';
2143 //print ' position: absolute; top: 40px; width: 50%;
';
2147 //var_dump($event->userassigned);
2148 //var_dump($event->transparency);
2149 print '<table class="centpercent cal_event
';
2150 print(empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
2151 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
2152 print '" style="'.$h;
2153 $colortouse = $color;
2154 // If colortouse is similar than background, we force to change it.
2155 if (empty($event->transparency) && !getDolGlobalString('AGENDA_NO_TRANSPARENT_ON_NOT_BUSY
')) {
2156 print 'background: #f0f0f0;
';
2157 print 'border-left: 5px solid #
'.$colortouse.';
';
2159 print 'background: #f0f0f0;
';
2160 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
2161 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
2163 //print 'background: #
'.$colortouse.';
';
2164 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
2165 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
2166 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
2167 //print ' -moz-border-radius:4px;
"';
2168 //print 'border: 1px solid #ccc" width=
"100%"';
2171 // First the tr of the event (only one tr for event is used, but several td)
2173 print '<td class="tdoverflow nobottom small centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
2174 print '<!-- left section of event -->';
2178 $parameters = array();
2179 $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
2181 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2183 '@phan-var-force ActionComm $event';
2184 if (empty($reshook)) {
2187 if (empty($event->fulldayevent)) {
2188 //print $event->getNomUrl(2).' ';
2192 if ($event->type_code == 'BIRTHDAY') {
2193 // It's birthday calendar
2194 $picb = img_picto('', 'birthday-cake', 'class="pictofixedwidth
"');
2195 print $picb.$langs->trans("Birthday
").'<br>';
2199 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY') {
2200 if (empty($event->fulldayevent)) {
2201 // Show hours (start ... end)
2202 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
2203 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
2204 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
2205 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
2206 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
2207 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
2210 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
2211 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
2212 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2213 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
2220 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2221 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
2222 $daterange .= '...';
2226 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
2227 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
2228 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
2233 print $langs->trans("EventOnFullDay
")."<br>\n
";
2239 $titletoshow = $daterange;
2240 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label);
2242 if ($event->type_code != 'ICALEVENT' && $event->type_code != 'BIRTHDAY') {
2243 $savlabel = $event->label;
2244 $event->label = $titletoshow;
2245 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
2246 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
2247 $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 '...'
2248 $event->label = $savlabel;
2251 // Loop on each assigned user
2252 $listofusertoshow = '';
2253 $posuserassigned = 0;
2254 foreach ($event->userassigned as $tmpid => $tmpdata) {
2255 if (!$posuserassigned && $titletoshow) {
2256 $listofusertoshow .= '<br>';
2259 if (empty($cacheusers[$tmpid])) {
2260 $newuser = new User($db);
2261 $newuser->fetch($tmpid);
2262 $cacheusers[$tmpid] = $newuser;
2265 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block');
2268 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') {
2270 print $listofusertoshow.' ';
2273 if ($event->type_code == 'ICALEVENT') {
2274 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
2277 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
2278 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
2280 // If action related to company / contact
2281 $linerelatedto = '';
2282 if ($thirdparty_id > 0) {
2283 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
2284 $thirdparty = new Societe($db);
2285 $thirdparty->fetch($thirdparty_id);
2286 $cachethirdparties[$thirdparty_id] = $thirdparty;
2288 $thirdparty = $cachethirdparties[$thirdparty_id];
2290 if (!empty($thirdparty->id)) {
2291 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
2294 if (!empty($contact_id) && $contact_id > 0) {
2295 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
2296 $contact = new Contact($db);
2297 $contact->fetch($contact_id);
2298 $cachecontacts[$contact_id] = $contact;
2300 $contact = $cachecontacts[$contact_id];
2302 if ($linerelatedto) {
2303 $linerelatedto .= ' ';
2305 if (!empty($contact->id)) {
2306 $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
2309 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) {
2310 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2311 if ($linerelatedto) {
2312 $linerelatedto .= '<br>';
2314 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
2316 if ($linerelatedto) {
2317 print ' '.$linerelatedto;
2319 } elseif (!empty($reshook)) {
2320 print $hookmanager->resPrint;
2324 if ($event->type_code == 'HOLIDAY') {
2325 // It's holiday calendar
2326 $tmpholiday->fetch($event->id);
2328 print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block');
2330 $tmpid = $tmpholiday->fk_user;
2331 if (empty($cacheusers[$tmpid])) {
2332 $newuser = new User($db);
2333 $newuser->fetch($tmpid);
2334 $cacheusers[$tmpid] = $newuser;
2337 $listofusertoshow = '';
2338 $listofusertoshow .= "\n
".'<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block')."\n
";
2339 print $listofusertoshow;
2344 if ($event->location) {
2346 print $langs->trans("Location
").': '.$event->location;
2354 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
2356 if ($event->percentage >= 0) {
2360 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
2362 print $event->getLibStatut(3, 1);
2366 print '</td></tr></table>';
2367 print '</div><!-- end event '.$i.' -->'."\n
";
2371 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
2372 print($status ? '&
status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
2373 print($filtert ? '&search_filtert=
'.urlencode((string) $filtert) : '');
2374 print($usergroup ? '&search_usergroup=
'.urlencode((string) $usergroup) : '');
2375 print($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
2376 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
2377 print ' +'.(count($eventarray[$daykey]) - $maxprint);
2380 //$ok=false; // To avoid to show twice the link
2387 if (!$i) { // No events
2391 if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) {
2392 print '<div class="center cursorpointer
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
2393 //print ' +'.(count($eventarray[$daykey])-$maxprint);
2395 print '<script type="text/javascript
">'."\n
";
2396 print 'jQuery(document).ready(function () {'."\n
";
2397 print ' var open=0;'."\n
";
2398 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
2399 print ' function reinit_day_'.$ymd.'() {'."\n
";
2400 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
2401 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
2402 print ' if (open) { ';
2403 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
2405 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
2409 print '</script>'."\n
";
2412 print '</div></div>'; // td tr
2414 print '</div>'; // table
2427function dol_color_minus($color, $minus, $minusunit = 16)
2430 if ($minusunit == 16 && is_array($newcolor)) {
2431 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
2432 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
2433 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
2435 // Not yet implemented
2447function sort_events_by_date($a, $b)
2449 // Sort holidays at first
2450 if ($a->type_code === 'HOLIDAY') {
2453 if ($b->type_code === 'HOLIDAY') {
2457 // datep => Event start time
2458 // datef => Event end time
2460 // Events have different start time
2461 if ($a->datep !== $b->datep) {
2462 return $a->datep - $b->datep;
2465 // Events have same start time and no end time
2466 if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) {
2467 return sort_events_by_percentage($a, $b);
2470 // Events have the same start time and same end time
2471 if ($b->datef === $a->datef) {
2472 return sort_events_by_percentage($a, $b);
2475 // Events have the same start time, but have different end time -> longest event first
2476 return $b->datef - $a->datef;
2486function sort_events_by_percentage($a, $b)
2488 // Sort events with no percentage before each other
2489 // (useful to sort holidays, sick days or similar on the top)
2491 if ($a->percentage < 0) {
2495 if ($b->percentage < 0) {
2499 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.