33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
44if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
45 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
48$action =
GETPOST(
'action',
'aZ09');
50$disabledefaultvalues =
GETPOST(
'disabledefaultvalues',
'int');
52$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
53$filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
54$usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
65$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
68if (empty($page) || $page == -1) {
71$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
72$offset = $limit * $page;
77 $sortfield =
"a.datec";
82 $socid = $user->socid;
89if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
92if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
95if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
99$mode =
'show_peruser';
100$resourceid =
GETPOST(
"search_resourceid",
"int") ?
GETPOST(
"search_resourceid",
"int") :
GETPOST(
"resourceid",
"int");
101$year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
102$month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
103$week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
105$pid = GETPOSTISSET(
"search_projectid") ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
106$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
107$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'alpha') :
GETPOST(
"type",
'alpha');
108$maxprint = ((
GETPOST(
"maxprint",
'int') !=
'') ?
GETPOST(
"maxprint",
'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
109$optioncss =
GETPOST(
'optioncss',
'aZ');
111if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
112 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
113 if (!count($actioncode)) {
117 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode",
"alpha") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
121if ($dateselect > 0) {
122 $day =
GETPOST(
'dateselectday',
'int');
123 $month =
GETPOST(
'dateselectmonth',
'int');
124 $year =
GETPOST(
'dateselectyear',
'int');
127$tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_HOURS') ?
'9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
128$tmp = str_replace(
' ',
'', $tmp);
129$tmparray = explode(
'-', $tmp);
130$begin_h =
GETPOST(
'begin_h',
'int') !=
'' ?
GETPOST(
'begin_h',
'int') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
131$end_h =
GETPOST(
'end_h',
'int') ?
GETPOST(
'end_h',
'int') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
132if ($begin_h < 0 || $begin_h > 23) {
135if ($end_h < 1 || $end_h > 24) {
138if ($end_h <= $begin_h) {
139 $end_h = $begin_h + 1;
142$tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_DAYS') ?
'1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
143$tmp = str_replace(
' ',
'', $tmp);
144$tmparray = explode(
'-', $tmp);
145$begin_d =
GETPOST(
'begin_d',
'int') ?
GETPOST(
'begin_d',
'int') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
146$end_d =
GETPOST(
'end_d',
'int') ?
GETPOST(
'end_d',
'int') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
147if ($begin_d < 1 || $begin_d > 7) {
150if ($end_d < 1 || $end_d > 7) {
153if ($end_d < $begin_d) {
154 $end_d = $begin_d + 1;
157if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
158 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
161if (empty($mode) && !GETPOSTISSET(
'mode')) {
162 $mode = (!
getDolGlobalString(
'AGENDA_DEFAULT_VIEW') ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
165if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
166 $mode =
'show_month';
169if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
171 $week = ($week ? $week : date(
"W"));
172 $day = ($day ? $day : date(
"d"));
174if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
176 $day = ($day ? $day : date(
"d"));
182$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
185$hookmanager->initHooks(array(
'agenda'));
188if ($user->socid && $socid) {
192$search_status = $status;
213 'maxprint' => $maxprint,
215 'filtert' => $filtert,
216 'showbirthday' => $showbirthday,
217 'canedit' => $canedit,
218 'optioncss' => $optioncss,
219 'actioncode' => $actioncode,
221 'resourceid' => $resourceid,
222 'usergroup' => $usergroup,
224$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
229$form =
new Form($db);
230$companystatic =
new Societe($db);
232$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
233llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
237$nowyear = $nowarray[
'year'];
238$nowmonth = $nowarray[
'mon'];
239$nowday = $nowarray[
'mday'];
243$listofextcals = array();
246$first_day = $prev[
'first_day'];
247$first_month = $prev[
'first_month'];
248$first_year = $prev[
'first_year'];
250$week = $prev[
'week'];
254$next_year = $next[
'year'];
255$next_month = $next[
'month'];
256$next_day = $next[
'day'];
258$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
264$title = $langs->trans(
"DoneAndToDoActions");
265if ($status ==
'done') {
266 $title = $langs->trans(
"DoneActions");
268if ($status ==
'todo') {
269 $title = $langs->trans(
"ToDoActions");
273if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
274 if (is_array($actioncode)) {
275 foreach ($actioncode as $str_action) {
276 $param .=
"&search_actioncode[]=".urlencode($str_action);
279 $param .=
"&search_actioncode=".urlencode($actioncode);
282if ($resourceid > 0) {
283 $param .=
"&search_resourceid=".urlencode($resourceid);
286if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
287 $param .=
"&search_status=".urlencode($status);
290 $param .=
"&search_filter=".urlencode($filter);
293 $param .=
"&search_filtert=".urlencode($filtert);
296 $param .=
"&search_usergroup=".urlencode($usergroup);
299 $param .=
"&search_socid=".urlencode($socid);
302 $param .=
"&search_showbirthday=1";
305 $param .=
"&search_projectid=".urlencode($pid);
308 $param .=
"&search_type=".urlencode($type);
310if ($mode !=
'show_peruser') {
311 $param .=
'&mode='.urlencode($mode);
314 $param .=
'&begin_h='.urlencode($begin_h);
317 $param .=
'&end_h='.urlencode($end_h);
320 $param .=
'&begin_d='.urlencode($begin_d);
323 $param .=
'&end_d='.urlencode($end_d);
325$param .=
"&maxprint=".urlencode($maxprint);
327$paramnoactionodate = $param;
332$prev_year = $prev[
'prev_year'];
333$prev_month = $prev[
'prev_month'];
334$prev_day = $prev[
'prev_day'];
335$first_day = $prev[
'first_day'];
336$first_month = $prev[
'first_month'];
337$first_year = $prev[
'first_year'];
339$week = $prev[
'week'];
343$next_year = $next[
'year'];
344$next_month = $next[
'month'];
345$next_day = $next[
'day'];
349$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
350$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
356$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
359$picto =
'calendarweek';
362$nav =
'<div class="navselectiondate inline-block nowraponall">';
363$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";
364$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
366$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";
367if (empty($conf->dol_optimize_smallscreen)) {
368 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
371$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
372$nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
375$param .=
'&year='.urlencode($year).
'&month='.urlencode($month).($day ?
'&day='.urlencode($day) :
'');
379$paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
383print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
385$showextcals = $listofextcals;
387if ($conf->use_javascript_ajax) {
389 $s .=
'<script type="text/javascript">'.
"\n";
390 $s .=
'jQuery(document).ready(function () {'.
"\n";
391 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
392 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
393 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
394 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
395 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
398 $s .=
'</script>'.
"\n";
399 if (!empty($conf->use_javascript_ajax)) {
400 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
401 if (is_array($showextcals) && count($showextcals) > 0) {
402 foreach ($showextcals as $val) {
403 $htmlname = md5($val[
'name']);
404 $s .=
'<script type="text/javascript">'.
"\n";
405 $s .=
'jQuery(document).ready(function () {'.
"\n";
406 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
407 $s .=
' /* alert("'.$htmlname.
'"); */';
408 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
411 $s .=
'</script>'.
"\n";
412 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
419 $parameters = array();
420 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
421 if (empty($reshook)) {
422 $s .= $hookmanager->resPrint;
423 } elseif ($reshook > 1) {
424 $s = $hookmanager->resPrint;
429$massactionbutton =
'';
432$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
434$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
436$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
438$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').$paramnoactionodate.
'">';
440$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
442$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
444$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').$paramnoactionodate.
'">';
446$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
448$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
450$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').$paramnoactionodate.
'">';
452$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
454$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
456$viewmode .=
'<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').$paramnoactionodate.
'">';
458$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
460$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
462$viewmode .=
'<span class="marginrightonly"></span>';
465$parameters = array(); $object =
null;
466$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
467if (empty($reshook)) {
468 $viewmode .= $hookmanager->resPrint;
469} elseif ($reshook > 1) {
470 $viewmode = $hookmanager->resPrint;
476if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
479 $newparam .=
'&month='.urlencode(str_pad($month, 2,
"0", STR_PAD_LEFT)).
'&year='.urlencode($tmpforcreatebutton[
'year']);
480 if ($begin_h !==
'') {
481 $newparam .=
'&begin_h='.urlencode($begin_h);
484 $newparam .=
'&end_h='.urlencode($end_h);
486 if ($begin_d !==
'') {
487 $newparam .=
'&begin_d='.urlencode($begin_d);
490 $newparam .=
'&end_d='.urlencode($end_d);
494 $hourminsec =
'100000';
495 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $tmpforcreatebutton[
'year'], $tmpforcreatebutton[
'mon'], $tmpforcreatebutton[
'mday']).$hourminsec.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
'')));
500print_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);
506$newtitle =
'<div class="nowrap clear inline-block minheight30">';
507$newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
508$newtitle .=
'</div>';
515print
'<div class="liste_titre liste_titre_bydiv centpercent">';
516print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
521$eventarray = array();
529$sql .=
" a.id, a.label,";
532$sql .=
" a.percent,";
533$sql .=
" a.fk_user_author,a.fk_user_action,";
534$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
535$sql .=
" a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,";
536$sql .=
" ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto";
537$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
538if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
539 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
542if ($resourceid > 0) {
543 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
546if ($filtert > 0 || $usergroup > 0) {
547 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
548 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
550 $sql .=
" AND ar.fk_element = ".((int) $filtert);
552 if ($usergroup > 0) {
553 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
557$sql .=
" WHERE a.fk_action = ca.id";
558$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
560if (!empty($actioncode)) {
562 if ($actioncode ==
'AC_NON_AUTO') {
563 $sql .=
" AND ca.type != 'systemauto'";
564 } elseif ($actioncode ==
'AC_ALL_AUTO') {
565 $sql .=
" AND ca.type = 'systemauto'";
567 if ($actioncode ==
'AC_OTH') {
568 $sql .=
" AND ca.type != 'systemauto'";
570 if ($actioncode ==
'AC_OTH_AUTO') {
571 $sql .=
" AND ca.type = 'systemauto'";
575 if ($actioncode ==
'AC_NON_AUTO') {
576 $sql .=
" AND ca.type != 'systemauto'";
577 } elseif ($actioncode ==
'AC_ALL_AUTO') {
578 $sql .=
" AND ca.type = 'systemauto'";
580 if (is_array($actioncode)) {
581 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
583 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
588if ($resourceid > 0) {
589 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
592 $sql .=
" AND a.fk_project = ".((int) $pid);
594if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
595 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
598 $sql .=
" AND a.fk_soc = ".((int) $socid);
601if ($mode ==
'show_day') {
603 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
604 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
606 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
607 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
609 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
610 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
615 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
616 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
618 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
619 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
621 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
622 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
626 $sql .=
" AND ca.id = ".((int) $type);
629 $sql .=
" AND a.percent = 0";
631if ($status ===
'na') {
633 $sql .=
" AND a.percent = -1";
635if ($status ==
'50') {
637 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
639if ($status ==
'done' || $status ==
'100') {
640 $sql .=
" AND (a.percent = 100)";
642if ($status ==
'todo') {
643 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
646$sql .= $db->order(
"fk_user_action, datep");
649dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
650$resql = $db->query($sql);
652 $num = $db->num_rows($resql);
656 $obj = $db->fetch_object($resql);
665 $datep = $db->jdate($obj->datep);
666 $datep2 = $db->jdate($obj->datep2);
671 $event->id = $obj->id;
672 $event->datep = $datep;
673 $event->datef = $datep2;
674 $event->type_code = $obj->code;
675 $event->type_color = $obj->color;
676 $event->label = $obj->label;
677 $event->percentage = $obj->percent;
678 $event->authorid = $obj->fk_user_author;
679 $event->userownerid = $obj->fk_user_action;
680 $event->priority = $obj->priority;
681 $event->fulldayevent = $obj->fulldayevent;
682 $event->location = $obj->location;
683 $event->transparency = $obj->transparency;
685 $event->fk_project = $obj->fk_project;
687 $event->socid = $obj->fk_soc;
688 $event->contact_id = $obj->fk_contact;
690 $event->fk_element = $obj->fk_element;
691 $event->elementtype = $obj->elementtype;
695 if ($event->percentage <= 0) {
696 $event->date_start_in_calendar = $datep;
697 if ($datep2 !=
'' && $datep2 >= $datep) {
698 $event->date_end_in_calendar = $datep2;
700 $event->date_end_in_calendar = $datep;
703 $event->date_start_in_calendar = $datep;
704 if ($datep2 !=
'' && $datep2 >= $datep) {
705 $event->date_end_in_calendar = $datep2;
707 $event->date_end_in_calendar = $datep;
714 if ($event->date_end_in_calendar < $firstdaytoshow ||
715 $event->date_start_in_calendar >= $lastdaytoshow) {
720 $event->fetch_userassigned();
722 if ($event->date_start_in_calendar < $firstdaytoshow) {
723 $event->date_start_in_calendar = $firstdaytoshow;
725 if ($event->date_end_in_calendar >= $lastdaytoshow) {
726 $event->date_end_in_calendar = ($lastdaytoshow - 1);
730 $daycursor = $event->date_start_in_calendar;
739 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
743 $eventarray[$daykey][] = $event;
746 $daykey += 60 * 60 * 24;
747 if ($daykey > $event->date_end_in_calendar) {
763$cachethirdparties = array();
764$cachecontacts = array();
765$cacheusers = array();
768$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
769if (is_readable($color_file)) {
772if (!is_array($theme_datacolor)) {
773 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
778$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
779$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
780$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
781$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
782$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
783$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
784$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
785$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
786$newparam .=
'&viewweek=1';
788echo
'<input type="hidden" name="actionmove" value="mupdate">';
789echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
790echo
'<input type="hidden" name="newdate" id="newdate">';
797$currentdaytoshow = $firstdaytoshow;
798echo
'<div class="div-table-responsive">';
801while ($currentdaytoshow < $lastdaytoshow) {
802 echo
'<table class="centpercent noborder nocellnopadd cal_month">';
804 echo
'<tr class="liste_titre">';
805 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
807 if ($canedit && $mode ==
'show_peruser') {
809 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block paddingleft"');
810 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">'.$langs->trans(
"Hours").
'</span>';
811 print
"\n".
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
812 print
'<input type="number" class="short" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
813 if (empty($conf->dol_use_jmobile)) {
816 print
'</div><div class="ui-block-b">';
818 print
'<input type="number" class="short" name="end_h" value="'.$end_h.
'" min="1" max="24">';
819 if (empty($conf->dol_use_jmobile)) {
820 print
' '.$langs->trans(
"H");
822 print
'</div></div>';
827 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block paddingleft"');
828 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">'.$langs->trans(
"DaysOfWeek").
'</span>';
829 print
"\n".
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
830 print
'<input type="number" class="short" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
831 if (empty($conf->dol_use_jmobile)) {
834 print
'</div><div class="ui-block-b">';
836 print
'<input type="number" class="short" name="end_d" value="'.$end_d.
'" min="1" max="7">';
837 print
'</div></div>';
843 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
847 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
848 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
860 echo
'<tr class="liste_titre">';
864 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
868 for ($h = $begin_h; $h < $end_h; $h++) {
869 echo
'<td class="center">';
870 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
880 $usernames = array();
881 $usernamesid = array();
884 foreach ($eventarray as $daykey => $notused) {
886 foreach ($eventarray[$daykey] as $index => $event) {
887 $event->fetch_userassigned();
888 $listofuserid = $event->userassigned;
889 foreach ($listofuserid as $userid => $tmp) {
890 if (!in_array($userid, $usernamesid)) {
891 $usernamesid[$userid] = $userid;
898 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
899 $sql .=
" FROM ".$db->prefix().
"user as u";
900 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
901 $sql .=
" WHERE u.rowid IN (";
902 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
903 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
904 if ($usergroup > 0) {
905 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
909 if ($usergroup > 0) {
910 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
912 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
913 if ($usergroup > 0) {
914 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
917 $sql .=
" AND u.statut = 1";
919 $sql .=
" AND u.rowid = ".((int) $filtert);
921 if ($usergroup > 0) {
922 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
924 if ($user->socid > 0) {
926 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
930 $resql = $db->query($sql);
932 $num = $db->num_rows($resql);
936 $obj = $db->fetch_object($resql);
937 $usernamesid[$obj->rowid] = $obj->rowid;
946 foreach ($usernamesid as $id) {
947 $tmpuser =
new User($db);
948 $result = $tmpuser->fetch($id);
949 $usernames[] = $tmpuser;
953 $colorsbytype = array();
954 $labelbytype = array();
955 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
956 $resql = $db->query($sql);
957 while ($obj = $db->fetch_object($resql)) {
958 $colorsbytype[$obj->code] = $obj->color;
959 $labelbytype[$obj->code] = $obj->label;
967 foreach ($usernames as $username) {
972 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
973 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
979 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
980 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
993 $style =
'cal_current_month';
994 if ($iter_day == 6) {
995 $style .=
' cal_other_month';
998 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1002 $style =
'cal_today_peruser';
1005 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1010 $showheader =
false;
1022 $langs->load(
"commercial");
1023 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1024 foreach ($colorsbytype as $code => $color) {
1026 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
1027 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1033 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1034 print $langs->trans(
"Other");
1043print
"\n".
'</form>';
1047print
'<script type="text/javascript">
1048jQuery(document).ready(function() {
1049 jQuery(".onclickopenref").click(function() {
1050 console.log("We click on a class onclickopenref");
1052 var ref=$(this).attr(\'ref\');
1053 var res = ref.split("_");
1054 var userid = res[1];
1061 if (ids == \'none\') /* No event */
1063 /* alert(\'no event\'); */
1064 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?year='.$year.
'&month='.$month.
'&day='.$day.($begin_h !==
'' ?
'&begin_h='.$begin_h :
'').($end_h !==
'' ?
'&end_h='.$end_h :
'').($begin_d !==
'' ?
'&begin_d='.$begin_d :
'').($end_d !==
'' ?
'&end_d='.$end_d :
'')).
'"
1065 window.location.href = url;
1067 else if (ids.indexOf(",") > -1) /* There is several events */
1069 /* alert(\'several events\'); */
1070 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&search_actioncode="+jQuery("#search_actioncode").val()+"&search_status="+jQuery("#selectsearch_status").val()+"&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
1071 window.location.href = url;
1073 else /* One event */
1075 /* alert(\'one event\'); */
1076 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1077 window.location.href = url;
1110function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $showheader =
false, $colorsbytype = array(), $var =
false)
1113 global $user, $conf, $langs, $hookmanager, $action;
1114 global $filter, $filtert, $status, $actioncode;
1115 global $theme_datacolor;
1116 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1117 global $begin_h, $end_h;
1128 $numicals = array();
1131 $colorindexused[$user->id] = 0;
1132 $nextindextouse = count($colorindexused);
1139 foreach ($eventarray as $daykey => $notused) {
1146 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1150 foreach ($eventarray[$daykey] as $index => $event) {
1154 $keysofuserassigned = array_keys($event->userassigned);
1155 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1157 if (!in_array($username->id, $keysofuserassigned)) {
1162 $parameters = array();
1163 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1172 if (in_array($user->id, $keysofuserassigned)) {
1173 $cssclass =
'family_mytasks';
1175 if (empty($cacheusers[$event->userownerid])) {
1176 $newuser =
new User($db);
1177 $newuser->fetch($event->userownerid);
1178 $cacheusers[$event->userownerid] = $newuser;
1183 if (!empty($cacheusers[$event->userownerid]->color)) {
1184 $color = $cacheusers[$event->userownerid]->color;
1188 $color = $event->type_color;
1190 } elseif ($event->type_code ==
'ICALEVENT') {
1192 if (!empty($event->icalname)) {
1199 $color = $event->icalcolor;
1200 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1201 } elseif ($event->type_code ==
'BIRTHDAY') {
1204 $cssclass =
'family_birthday unsortable';
1205 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1208 $color = ($event->icalcolor ? $event->icalcolor : -1);
1209 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1211 if (empty($cacheusers[$event->userownerid])) {
1212 $newuser =
new User($db);
1213 $newuser->fetch($event->userownerid);
1214 $cacheusers[$event->userownerid] = $newuser;
1219 if (!empty($cacheusers[$event->userownerid]->color)) {
1220 $color = $cacheusers[$event->userownerid]->color;
1224 $color = $event->type_color;
1230 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1231 if (isset($colorindexused[$idusertouse])) {
1232 $colorindex = $colorindexused[$idusertouse];
1234 $colorindex = $nextindextouse;
1235 $colorindexused[$idusertouse] = $colorindex;
1236 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1241 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1245 for ($h = $begin_h; $h < $end_h; $h++) {
1248 if (empty($event->fulldayevent)) {
1249 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1250 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
1251 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1252 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
1253 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1255 $dateendtouse = $event->date_end_in_calendar;
1256 if ($dateendtouse == $event->date_start_in_calendar) {
1262 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1263 $busy = $event->transparency;
1264 $cases1[$h][$event->id][
'busy'] = $busy;
1265 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1266 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1267 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1268 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1269 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1270 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1272 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1275 if ($event->label) {
1276 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1278 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1279 $cases1[$h][$event->id][
'color'] = $color;
1280 if ($event->fk_project > 0) {
1281 if (empty($cacheprojects[$event->fk_project])) {
1283 $tmpproj->fetch($event->fk_project);
1284 $cacheprojects[$event->fk_project] = $tmpproj;
1286 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1288 if ($event->socid > 0) {
1289 if (empty($cachethirdparties[$event->socid])) {
1290 $tmpthirdparty =
new Societe($db);
1291 $tmpthirdparty->fetch($event->socid);
1292 $cachethirdparties[$event->socid] = $tmpthirdparty;
1294 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1296 if ($event->contact_id > 0) {
1297 if (empty($cachecontacts[$event->contact_id])) {
1298 $tmpcontact =
new Contact($db);
1299 $tmpcontact->fetch($event->contact_id);
1300 $cachecontacts[$event->contact_id] = $tmpcontact;
1302 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1305 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
1306 $busy = $event->transparency;
1307 $cases2[$h][$event->id][
'busy'] = $busy;
1308 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1309 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1310 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1311 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1312 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1313 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1315 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1318 if ($event->label) {
1319 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1321 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1322 $cases2[$h][$event->id][
'color'] = $color;
1323 if ($event->fk_project > 0) {
1324 if (empty($cacheprojects[$event->fk_project])) {
1326 $tmpproj->fetch($event->fk_project);
1327 $cacheprojects[$event->fk_project] = $tmpproj;
1329 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1331 if ($event->socid > 0) {
1332 if (empty($cachethirdparties[$event->socid])) {
1333 $tmpthirdparty =
new Societe($db);
1334 $tmpthirdparty->fetch($event->socid);
1335 $cachethirdparties[$event->socid] = $tmpthirdparty;
1337 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1339 if ($event->contact_id > 0) {
1340 if (empty($cachecontacts[$event->contact_id])) {
1341 $tmpcontact =
new Contact($db);
1342 $tmpcontact->fetch($event->contact_id);
1343 $cachecontacts[$event->contact_id] = $tmpcontact;
1345 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1348 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
1349 $busy = $event->transparency;
1350 $cases3[$h][$event->id][
'busy'] = $busy;
1351 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1352 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1353 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1354 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1355 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1356 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1358 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1361 if ($event->label) {
1362 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
1364 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1365 $cases3[$h][$event->id][
'color'] = $color;
1366 if ($event->fk_project > 0) {
1367 if (empty($cacheprojects[$event->fk_project])) {
1369 $tmpproj->fetch($event->fk_project);
1370 $cacheprojects[$event->fk_project] = $tmpproj;
1372 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1374 if ($event->socid > 0) {
1375 if (empty($cachethirdparties[$event->socid])) {
1376 $tmpthirdparty =
new Societe($db);
1377 $tmpthirdparty->fetch($event->socid);
1378 $cachethirdparties[$event->socid] = $tmpthirdparty;
1380 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1382 if ($event->contact_id > 0) {
1383 if (empty($cachecontacts[$event->contact_id])) {
1384 $tmpcontact =
new Contact($db);
1385 $tmpcontact->fetch($event->contact_id);
1386 $cachecontacts[$event->contact_id] = $tmpcontact;
1388 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1391 if ($event->date_start_in_calendar < $c && $dateendtouse > $b2) {
1392 $busy = $event->transparency;
1393 $cases4[$h][$event->id][
'busy'] = $busy;
1394 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1395 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1396 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1397 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1398 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1399 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1401 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1404 if ($event->label) {
1405 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
1407 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1408 $cases4[$h][$event->id][
'color'] = $color;
1409 if ($event->fk_project > 0) {
1410 if (empty($cacheprojects[$event->fk_project])) {
1412 $tmpproj->fetch($event->fk_project);
1413 $cacheprojects[$event->fk_project] = $tmpproj;
1415 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1417 if ($event->socid > 0) {
1418 if (empty($cachethirdparties[$event->socid])) {
1419 $tmpthirdparty =
new Societe($db);
1420 $tmpthirdparty->fetch($event->socid);
1421 $cachethirdparties[$event->socid] = $tmpthirdparty;
1423 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1425 if ($event->contact_id > 0) {
1426 if (empty($cachecontacts[$event->contact_id])) {
1427 $tmpcontact =
new Contact($db);
1428 $tmpcontact->fetch($event->contact_id);
1429 $cachecontacts[$event->contact_id] = $tmpcontact;
1431 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1435 $busy = $event->transparency;
1436 $cases1[$h][$event->id][
'busy'] = $busy;
1437 $cases2[$h][$event->id][
'busy'] = $busy;
1438 $cases3[$h][$event->id][
'busy'] = $busy;
1439 $cases4[$h][$event->id][
'busy'] = $busy;
1440 $cases1[$h][$event->id][
'string'] = $event->label;
1441 $cases2[$h][$event->id][
'string'] = $event->label;
1442 $cases3[$h][$event->id][
'string'] = $event->label;
1443 $cases4[$h][$event->id][
'string'] = $event->label;
1444 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1445 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1446 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1447 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1448 $cases1[$h][$event->id][
'color'] = $color;
1449 $cases2[$h][$event->id][
'color'] = $color;
1450 $cases3[$h][$event->id][
'color'] = $color;
1451 $cases4[$h][$event->id][
'color'] = $color;
1462 for ($h = $begin_h; $h < $end_h; $h++) {
1471 $string1 =
' ';
1472 $string2 =
' ';
1473 $string3 =
' ';
1474 $string4 =
' ';
1479 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1481 if (count($cases1[$h]) > 1) {
1482 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1484 $string1 =
' ';
1486 $style1 =
'peruser_notbusy';
1488 $style1 =
'peruser_busy';
1490 foreach ($cases1[$h] as $id => $ev) {
1492 $style1 =
'peruser_busy';
1496 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1498 if (count($cases2[$h]) > 1) {
1499 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1501 $string2 =
' ';
1503 $style2 =
'peruser_notbusy';
1505 $style2 =
'peruser_busy';
1507 foreach ($cases2[$h] as $id => $ev) {
1509 $style2 =
'peruser_busy';
1513 if (isset($cases3[$h]) && $cases3[$h] !=
'') {
1515 if (count($cases3[$h]) > 1) {
1516 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1518 $string3 =
' ';
1520 $style3 =
'peruser_notbusy';
1522 $style3 =
'peruser_busy';
1524 foreach ($cases3[$h] as $id => $ev) {
1526 $style3 =
'peruser_busy';
1530 if (isset($cases4[$h]) && $cases4[$h] !=
'') {
1532 if (count($cases4[$h]) > 1) {
1533 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1535 $string4 =
' ';
1537 $style4 =
'peruser_notbusy';
1539 $style4 =
'peruser_busy';
1541 foreach ($cases4[$h] as $id => $ev) {
1543 $style4 =
'peruser_busy';
1552 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1553 $ids1 = join(
', ', array_keys($cases1[$h]));
1555 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1556 $ids2 = join(
', ', array_keys($cases2[$h]));
1558 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
1559 $ids3 = join(
',', array_keys($cases3[$h]));
1561 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
1562 $ids4 = join(
',', array_keys($cases4[$h]));
1565 if ($h == $begin_h) {
1566 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1568 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1571 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1572 $output = array_slice($cases1[$h], 0, 1);
1573 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1574 if ($output[0][
'string']) {
1575 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1577 if ($output[0][
'color']) {
1578 $color1 = $output[0][
'color'];
1580 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1581 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1586 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1587 $output = array_slice($cases2[$h], 0, 1);
1588 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1589 if ($output[0][
'string']) {
1590 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1592 if ($output[0][
'color']) {
1593 $color2 = $output[0][
'color'];
1595 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1596 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1601 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
1602 $output = array_slice($cases3[$h], 0, 1);
1603 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1604 if ($output[0][
'string']) {
1605 $title3 .= ($title3 ?
' - ' :
'').$output[0][
'string'];
1607 if ($output[0][
'color']) {
1608 $color3 = $output[0][
'color'];
1610 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
1611 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1616 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
1617 $output = array_slice($cases4[$h], 0, 1);
1618 $title4 = $langs->trans(
"Ref").
' '.$ids3.($title4 ?
' - '.$title4 :
'');
1619 if ($output[0][
'string']) {
1620 $title4 .= ($title4 ?
' - ' :
'').$output[0][
'string'];
1622 if ($output[0][
'color']) {
1623 $color4 = $output[0][
'color'];
1625 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
1626 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
1630 print
'<table class="nobordernopadding case centpercent">';
1633 if ($style1 ==
'peruser_notbusy') {
1634 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
1635 } elseif ($color1) {
1636 print($color1 ?
'style="background: #'.$color1.
';"' :
'');
1639 print($style1 ? $style1.
' ' :
'');
1640 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"'.($title1 ?
' title="'.$title1.
'"' :
'').
'>';
1645 if ($style2 ==
'peruser_notbusy') {
1646 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
1647 } elseif ($color2) {
1648 print($color2 ?
'style="background: #'.$color2.
';"' :
'');
1651 print($style2 ? $style2.
' ' :
'');
1652 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"'.($title2 ?
' title="'.$title2.
'"' :
'').
'>';
1657 if ($style3 ==
'peruser_notbusy') {
1658 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
1659 } elseif ($color3) {
1660 print($color3 ?
'style="background: #'.$color3.
';"' :
'');
1663 print($style3 ? $style3.
' ' :
'');
1664 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"'.($title3 ?
' title="'.$title3.
'"' :
'').
'>';
1669 if ($style4 ==
'peruser_notbusy') {
1670 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
1671 } elseif ($color4) {
1672 print($color4 ?
'style="background: #'.$color4.
';"' :
'');
1675 print($style4 ? $style4.
' ' :
'');
1676 print
'onclickopenref center'.($title3 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"'.($title4 ?
' title="'.$title4.
'"' :
'').
'>';
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
Show filter form in agenda view.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage agenda events (actions)
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
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.