33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
51if (!isset(
$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
52 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
55$action =
GETPOST(
'action',
'aZ09');
57$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
59$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
73$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
76if (empty($page) || $page == -1) {
80$offset = $limit * $page;
85 $sortfield =
"a.datec";
92 $socid = $user->socid;
100if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
103if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
106if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
107 $filtert = $user->id;
110$mode =
'show_pertype';
116$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
117$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
118$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'alpha') :
GETPOST(
"type",
'alpha');
120$optioncss =
GETPOST(
'optioncss',
'aZ');
123if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
124 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
125 if (!count($actioncode)) {
129 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode",
"alpha") ==
'0' ?
'0' : ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ?
'' :
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_TYPE')));
133if ($dateselect > 0) {
141$tmp = str_replace(
' ',
'', $tmp);
142$tmparray = explode(
'-', $tmp);
143$begin_h =
GETPOSTINT(
'begin_h') !=
'' ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
145if ($begin_h < 0 || $begin_h > 23) {
148if ($end_h < 1 || $end_h > 24) {
151if ($end_h <= $begin_h) {
152 $end_h = $begin_h + 1;
157$tmp = str_replace(
' ',
'', $tmp);
158$tmparray = explode(
'-', $tmp);
162if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
165if (empty($mode) && !GETPOSTISSET(
'mode')) {
170if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
171 $mode =
'show_month';
175if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
177 $week = ($week ? $week : date(
"W"));
178 $day = ($day ? $day : date(
"d"));
181if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
183 $day = ($day ? $day : date(
"d"));
186if (
GETPOST(
'viewyear',
'alpha') || $mode ==
'show_year') {
194$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
197$hookmanager->initHooks(array(
'agenda'));
200if ($user->socid && $socid) {
204$search_status = $status;
225 'maxprint' => $maxprint,
227 'filtert' => $filtert,
228 'showbirthday' => $showbirthday,
229 'canedit' => $canedit,
230 'optioncss' => $optioncss,
231 'actioncode' => $actioncode,
233 'resourceid' => $resourceid,
234 'usergroup' => $usergroup,
237$reshook = $hookmanager->executeHooks(
'beforeAgendaPerType', $parameters, $object, $action);
242$form =
new Form($db);
243$companystatic =
new Societe($db);
245$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
246llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
250$nowyear = $nowarray[
'year'];
251$nowmonth = $nowarray[
'mon'];
252$nowday = $nowarray[
'mday'];
256$listofextcals = array();
263$week = $prev[
'week'];
267$next_year = $year + 1;
271$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
277$title = $langs->trans(
"DoneAndToDoActions");
278if ($status ==
'done') {
279 $title = $langs->trans(
"DoneActions");
281if ($status ==
'todo') {
282 $title = $langs->trans(
"ToDoActions");
286if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
287 if (is_array($actioncode)) {
288 foreach ($actioncode as $str_action) {
289 $param .=
"&search_actioncode[]=".urlencode($str_action);
292 $param .=
"&search_actioncode=".urlencode($actioncode);
295if ($resourceid > 0) {
296 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
298if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
299 $param .=
"&search_status=".urlencode($status);
302 $param .=
"&search_filter=".urlencode($filter);
305 $param .=
"&search_filtert=".urlencode((
string) $filtert);
308 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
311 $param .=
"&search_socid=".urlencode((
string) ($socid));
314 $param .=
"&search_showbirthday=1";
317 $param .=
"&search_projectid=".urlencode((
string) ($pid));
320 $param .=
"&search_type=".urlencode($type);
322if ($mode !=
'show_pertype') {
323 $param .=
'&mode='.urlencode((
string) $mode);
326 $param .=
'&begin_h='.urlencode($begin_h);
329 $param .=
'&end_h='.urlencode($end_h);
332 $param .=
'&begin_d='.urlencode((
string) ($begin_d));
335 $param .=
'&end_d='.urlencode((
string) ($end_d));
337$param .=
"&maxprint=".urlencode((
string) ($maxprint));
339$paramnoactionodate = $param;
342$prev_year = $year - 1;
349$week = $prev[
'week'];
353$next_year = $year + 1;
359$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
365$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
368$picto =
'calendarweek';
371$nav =
'<div class="navselectiondate inline-block nowraponall">';
372$nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\">".
img_previous($langs->trans(
"Previous")).
"</a>\n";
373$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
"</span> \n";
374$nav .=
"<a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\">".
img_next($langs->trans(
"Next")).
"</a>\n";
375if (empty(
$conf->dol_optimize_smallscreen)) {
376 $nav .=
" (<a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
"</a>)";
380$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
381$nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
384$param .=
'&year='.urlencode((
string) ($year)).
'&month='.urlencode((
string) ($month)).($day ?
'&day='.urlencode((
string) ($day)) :
'');
388$paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
392print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
394$showextcals = $listofextcals;
396if (
$conf->use_javascript_ajax) {
398 $s .=
'<script type="text/javascript">'.
"\n";
399 $s .=
'jQuery(document).ready(function () {'.
"\n";
400 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
401 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
402 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
403 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
404 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
407 $s .=
'</script>'.
"\n";
408 if (!empty(
$conf->use_javascript_ajax)) {
409 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
410 if (is_array($showextcals) && count($showextcals) > 0) {
411 foreach ($showextcals as $val) {
412 $htmlname = md5($val[
'name']);
413 $s .=
'<script type="text/javascript">'.
"\n";
414 $s .=
'jQuery(document).ready(function () {'.
"\n";
415 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
416 $s .=
' /* alert("'.$htmlname.
'"); */';
417 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
420 $s .=
'</script>'.
"\n";
421 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
428 $parameters = array();
429 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
430 if (empty($reshook)) {
431 $s .= $hookmanager->resPrint;
432 } elseif ($reshook > 1) {
433 $s = $hookmanager->resPrint;
438$massactionbutton =
'';
440$viewmode =
'<div class="navmode inline-block">';
442$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
444$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
446$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
450$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
452$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
456$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
458$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
462$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
464$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
468$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
470$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
473$parameters = array();
475$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
476if (empty($reshook)) {
477 $viewmode .= $hookmanager->resPrint;
478} elseif ($reshook > 1) {
479 $viewmode = $hookmanager->resPrint;
482$viewmode .=
'</div>';
484$viewmode .=
'<span class="marginrightonly"></span>';
489if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
492 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
494 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
495 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
496 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
498 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
501print_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);
508$newtitle =
'<div class="nowrap clear inline-block minheight30">';
509$newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
510$newtitle .=
'</div>';
517print
'<div class="liste_titre liste_titre_bydiv centpercent">';
518print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
523$eventarray = array();
531$sql .=
' a.id, a.label,';
534$sql .=
' a.percent,';
535$sql .=
' a.fk_user_author,a.fk_user_action,';
536$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
537$sql .=
' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
538$sql .=
' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
539$sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
541if ($resourceid > 0) {
542 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
545if ($filtert > 0 || $usergroup > 0) {
546 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
549 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
551$sql .=
' WHERE a.fk_action = ca.id';
552$sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
554if (!empty($actioncode)) {
556 if ($actioncode ==
'AC_NON_AUTO') {
557 $sql .=
" AND ca.type != 'systemauto'";
558 } elseif ($actioncode ==
'AC_ALL_AUTO') {
559 $sql .=
" AND ca.type = 'systemauto'";
561 if ($actioncode ==
'AC_OTH') {
562 $sql .=
" AND ca.type != 'systemauto'";
564 if ($actioncode ==
'AC_OTH_AUTO') {
565 $sql .=
" AND ca.type = 'systemauto'";
569 if ($actioncode ==
'AC_NON_AUTO') {
570 $sql .=
" AND ca.type != 'systemauto'";
571 } elseif ($actioncode ==
'AC_ALL_AUTO') {
572 $sql .=
" AND ca.type = 'systemauto'";
574 if (is_array($actioncode)) {
575 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
577 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
582if ($resourceid > 0) {
583 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
586 $sql .=
" AND a.fk_project = ".((int) $pid);
590if (!$user->hasRight(
'societe',
'client',
'voir')) {
591 $search_sale = $user->id;
594if ($search_sale && $search_sale !=
'-1') {
595 if ($search_sale == -2) {
596 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
597 } elseif ($search_sale > 0) {
598 $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).
")";
603 $sql .=
" AND a.fk_soc = ".((int) $socid);
606if ($filtert > 0 || $usergroup > 0) {
607 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
609if ($mode ==
'show_day') {
611 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
612 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
614 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
615 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
617 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
618 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
623 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
624 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
626 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
627 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
629 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7)).
"'";
630 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
634 $sql .=
" AND ca.id = ".((int) $type);
637 $sql .=
" AND a.percent = 0";
639if ($status ===
'na') {
641 $sql .=
" AND a.percent = -1";
643if ($status ==
'50') {
645 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
647if ($status ==
'done' || $status ==
'100') {
648 $sql .=
" AND (a.percent = 100)";
650if ($status ==
'todo') {
651 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
654if ($filtert > 0 || $usergroup > 0) {
657 $sql .=
"ar.fk_element = ".$filtert;
659 if ($usergroup > 0) {
660 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
665$sql .=
' ORDER BY fk_user_action, datep';
668dol_syslog(
"comm/action/pertype.php", LOG_DEBUG);
669$resql = $db->query($sql);
671 $num = $db->num_rows($resql);
674 $obj = $db->fetch_object($resql);
682 $datep = $db->jdate($obj->datep);
683 $datep2 = $db->jdate($obj->datep2);
687 $event->id = $obj->id;
688 $event->datep = $datep;
689 $event->datef = $datep2;
690 $event->type_code = $obj->code;
691 $event->type_color = $obj->color;
692 $event->label = $obj->label;
693 $event->percentage = $obj->percent;
694 $event->authorid = $obj->fk_user_author;
695 $event->userownerid = $obj->fk_user_action;
696 $event->priority = $obj->priority;
697 $event->fulldayevent = $obj->fulldayevent;
698 $event->location = $obj->location;
699 $event->transparency = $obj->transparency;
701 $event->fk_project = $obj->fk_project;
703 $event->socid = $obj->fk_soc;
704 $event->contact_id = $obj->fk_contact;
706 $event->fk_element = $obj->fk_element;
707 $event->elementid = $obj->fk_element;
708 $event->elementtype = $obj->elementtype;
712 $event->date_start_in_calendar = $datep;
713 if ($datep2 !=
'' && $datep2 >= $datep) {
714 $event->date_end_in_calendar = $datep2;
716 $event->date_end_in_calendar = $datep;
720 if ($event->date_end_in_calendar < $firstdaytoshow ||
721 $event->date_start_in_calendar >= $lastdaytoshow) {
726 $event->fetch_userassigned();
728 if ($event->date_start_in_calendar < $firstdaytoshow) {
729 $event->date_start_in_calendar = $firstdaytoshow;
731 if ($event->date_end_in_calendar >= $lastdaytoshow) {
732 $event->date_end_in_calendar = ($lastdaytoshow - 1);
736 $daycursor = $event->date_start_in_calendar;
744 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
748 $eventarray[$daykey][] = $event;
751 $daykey += 60 * 60 * 24;
752 if ($daykey > $event->date_end_in_calendar) {
768$cachethirdparties = array();
769$cachecontacts = array();
770$cacheusers = array();
773$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
774if (is_readable($color_file)) {
777if (!is_array($theme_datacolor)) {
778 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
783$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
784$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
785$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
786$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
787$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
788$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
789$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
790$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
791$newparam .=
'&viewweek=1';
793print
'<input type="hidden" name="action" value="mupdate">';
794echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
795echo
'<input type="hidden" name="token" value="'.newToken().
'">';
796echo
'<input type="hidden" name="newdate" id="newdate">';
803echo
'<div class="div-table-responsive">';
805echo
'<table class="centpercent nocellnopadd cal_month">';
807echo
'<tr class="liste_titre">';
810echo
'<td align="center" colspan="'.($end_d - $begin_d).
'">';
811echo $langs->trans(
"Year");
817echo
'<tr class="liste_titre">';
820for ($h = $begin_d; $h < $end_d; $h++) {
821 echo
'<td class="center">';
822 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
829$typeofevents = array();
832$colorsbytype = array();
833$labelbytype = array();
834$sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
835$resql = $db->query($sql);
836while ($obj = $db->fetch_object($resql)) {
837 $typeofevents[(string) $obj->code] = (
string) $obj->code;
838 $colorsbytype[(string) $obj->code] = (
string) $obj->color;
839 $labelbytype[(string) $obj->code] = (
string) $obj->label;
847foreach ($typeofevents as $typeofevent) {
850 echo
'<td class="cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">'.$typeofevent.
'</td>';
855 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
856 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
869 $style =
'cal_current_month';
870 if ($iter_day == 6) {
871 $style .=
' cal_other_month';
874 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
878 $style =
'cal_today_peruser';
881 show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
895 $langs->load(
"commercial");
896 print
'<br>'.$langs->trans(
"Legend").
': <br>';
897 foreach ($colorsbytype as $code => $color) {
899 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
900 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
906 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
907 print $langs->trans(
"Other");
920print
'<script type="text/javascript">
921jQuery(document).ready(function() {
922 jQuery(".onclickopenref").click(function() {
923 var ref=$(this).attr(\'ref\');
924 var res = ref.split("_");
932 if (ids == \'none\') /* No event */
934 /* alert(\'no event\'); */
935 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).
'"
936 window.location.href = url;
938 else if (ids.indexOf(",") > -1) /* There is several events */
940 /* alert(\'several events\'); */
941 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
942 window.location.href = url;
946 /* alert(\'one event\'); */
947 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
948 window.location.href = url;
981function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $showheader =
false, $colorsbytype = array(), $var =
false)
984 global $user,
$conf, $langs, $hookmanager, $action;
985 global $filter, $filtert, $status, $actioncode;
986 global $theme_datacolor;
987 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
988 global $begin_h, $end_h;
999 $ymd = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
1001 $nextindextouse = count($colorindexused);
1007 foreach ($eventarray as $daykey => $notused) {
1012 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1014 foreach ($eventarray[$daykey] as $index => $event) {
1018 $keysofuserassigned = array_keys($event->userassigned);
1019 if (!in_array($username->id, $keysofuserassigned)) {
1024 $parameters = array();
1025 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1030 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1036 if (in_array($user->id, $keysofuserassigned)) {
1038 $cssclass =
'family_mytasks';
1040 $color = $event->type_color;
1042 } elseif ($event->type_code ==
'ICALEVENT') {
1044 if (!empty($event->icalname)) {
1051 $color = $event->icalcolor;
1052 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1053 } elseif ($event->type_code ==
'BIRTHDAY') {
1056 $cssclass =
'family_birthday unsortable';
1057 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1060 $cssclass =
'family_other';
1062 $color = $event->type_color;
1068 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1069 if (isset($colorindexused[$idusertouse])) {
1070 $colorindex = $colorindexused[$idusertouse];
1072 $colorindex = $nextindextouse;
1073 $colorindexused[$idusertouse] = $colorindex;
1074 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1079 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1084 for ($h = $begin_h; $h < $end_h; $h++) {
1087 if (empty($event->fulldayevent)) {
1088 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1089 $b =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1090 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1092 $dateendtouse = $event->date_end_in_calendar;
1093 if ($dateendtouse == $event->date_start_in_calendar) {
1099 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1100 $busy = $event->transparency;
1101 $cases1[$h][$event->id][
'busy'] = $busy;
1102 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1103 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1104 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1105 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1106 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1107 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1109 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1112 if ($event->label) {
1113 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1115 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1116 $cases1[$h][$event->id][
'color'] = $color;
1117 if ($event->fk_project > 0) {
1118 if (empty($cacheprojects[$event->fk_project])) {
1120 $tmpproj->fetch($event->fk_project);
1121 $cacheprojects[$event->fk_project] = $tmpproj;
1123 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1125 if ($event->socid > 0) {
1126 if (empty($cachethirdparties[$event->socid])) {
1127 $tmpthirdparty =
new Societe($db);
1128 $tmpthirdparty->fetch($event->socid);
1129 $cachethirdparties[$event->socid] = $tmpthirdparty;
1131 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1133 if ($event->contact_id > 0) {
1134 if (empty($cachecontacts[$event->contact_id])) {
1135 $tmpcontact =
new Contact($db);
1136 $tmpcontact->fetch($event->contact_id);
1137 $cachecontacts[$event->contact_id] = $tmpcontact;
1139 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1142 if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
1143 $busy = $event->transparency;
1144 $cases2[$h][$event->id][
'busy'] = $busy;
1145 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1146 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1147 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1148 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1149 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1150 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1152 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1155 if ($event->label) {
1156 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1158 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1159 $cases2[$h][$event->id][
'color'] = $color;
1160 if ($event->fk_project > 0) {
1161 if (empty($cacheprojects[$event->fk_project])) {
1163 $tmpproj->fetch($event->fk_project);
1164 $cacheprojects[$event->fk_project] = $tmpproj;
1166 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1168 if ($event->socid > 0) {
1169 if (empty($cachethirdparties[$event->socid])) {
1170 $tmpthirdparty =
new Societe($db);
1171 $tmpthirdparty->fetch($event->socid);
1172 $cachethirdparties[$event->socid] = $tmpthirdparty;
1174 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1176 if ($event->contact_id > 0) {
1177 if (empty($cachecontacts[$event->contact_id])) {
1178 $tmpcontact =
new Contact($db);
1179 $tmpcontact->fetch($event->contact_id);
1180 $cachecontacts[$event->contact_id] = $tmpcontact;
1182 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1186 $busy = $event->transparency;
1187 $cases1[$h][$event->id][
'busy'] = $busy;
1188 $cases2[$h][$event->id][
'busy'] = $busy;
1189 $cases1[$h][$event->id][
'string'] = $event->label;
1190 $cases2[$h][$event->id][
'string'] = $event->label;
1191 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1192 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1193 $cases1[$h][$event->id][
'color'] = $color;
1194 $cases2[$h][$event->id][
'color'] = $color;
1205 for ($h = $begin_h; $h < $end_h; $h++) {
1210 $string1 =
' ';
1211 $string2 =
' ';
1214 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1216 if (count($cases1[$h]) > 1) {
1217 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1221 $style1 =
'peruser_notbusy';
1223 $style1 =
'peruser_busy';
1225 foreach ($cases1[$h] as
$id => $ev) {
1227 $style1 =
'peruser_busy';
1231 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1233 if (count($cases2[$h]) > 1) {
1234 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1238 $style2 =
'peruser_notbusy';
1240 $style2 =
'peruser_busy';
1242 foreach ($cases2[$h] as
$id => $ev) {
1244 $style2 =
'peruser_busy';
1251 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1252 $ids1 = implode(
',', array_keys($cases1[$h]));
1254 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1255 $ids2 = implode(
',', array_keys($cases2[$h]));
1258 if ($h == $begin_h) {
1259 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1261 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1263 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1264 $output = array_slice($cases1[$h], 0, 1);
1265 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1266 if ($output[0][
'string']) {
1267 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1269 if ($output[0][
'color']) {
1270 $color1 = $output[0][
'color'];
1272 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1273 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1277 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1278 $output = array_slice($cases2[$h], 0, 1);
1279 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1280 if ($output[0][
'string']) {
1281 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1283 if ($output[0][
'color']) {
1284 $color2 = $output[0][
'color'];
1286 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1287 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1290 print
'<table class="nobordernopadding" width="100%">';
1291 print
'<tr><td '.($color1 ?
'style="background: #'.$color1.
';"' :
'').
'class="'.($style1 ? $style1.
' ' :
'').
'onclickopenref center'.($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.
'"' :
'').
'>';
1293 print
'</td><td '.($color2 ?
'style="background: #'.$color2.
';"' :
'').
'class="'.($style2 ? $style2.
' ' :
'').
'onclickopenref center'.($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids2 ? $ids2 :
'none').
'"'.($title2 ?
' title="'.$title2.
'"' :
'').
'>';
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 manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_get_next_day($day, $month, $year)
Return next day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
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 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)
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.
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_now($mode='auto')
Return date for now.
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).
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
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_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...
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.