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';
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 =
GETPOSTINT(
'disabledefaultvalues');
52$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
66$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69if (empty($page) || $page == -1) {
73$offset = $limit * $page;
78 $sortfield =
"a.datec";
85 $socid = $user->socid;
93if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
96if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
99if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
100 $filtert = $user->id;
103$mode =
'show_pertype';
109$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
110$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
111$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'alpha') :
GETPOST(
"type",
'alpha');
112$maxprint = ((
GETPOSTINT(
"maxprint") !=
'') ?
GETPOSTINT(
"maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
113$optioncss =
GETPOST(
'optioncss',
'aZ');
116if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
117 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
118 if (!count($actioncode)) {
122 $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')));
126if ($dateselect > 0) {
133$tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_HOURS') ?
'9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
134$tmp = str_replace(
' ',
'', $tmp);
135$tmparray = explode(
'-', $tmp);
136$begin_h =
GETPOSTINT(
'begin_h') !=
'' ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
138if ($begin_h < 0 || $begin_h > 23) {
141if ($end_h < 1 || $end_h > 24) {
144if ($end_h <= $begin_h) {
145 $end_h = $begin_h + 1;
150$tmp = str_replace(
' ',
'', $tmp);
151$tmparray = explode(
'-', $tmp);
155if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
158if (empty($mode) && !GETPOSTISSET(
'mode')) {
163if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
164 $mode =
'show_month';
168if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
170 $week = ($week ? $week : date(
"W"));
171 $day = ($day ? $day : date(
"d"));
174if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
176 $day = ($day ? $day : date(
"d"));
179if (
GETPOST(
'viewyear',
'alpha') || $mode ==
'show_year') {
187$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
190$hookmanager->initHooks(array(
'agenda'));
193if ($user->socid && $socid) {
197$search_status = $status;
218 'maxprint' => $maxprint,
220 'filtert' => $filtert,
221 'showbirthday' => $showbirthday,
222 'canedit' => $canedit,
223 'optioncss' => $optioncss,
224 'actioncode' => $actioncode,
226 'resourceid' => $resourceid,
227 'usergroup' => $usergroup,
230$reshook = $hookmanager->executeHooks(
'beforeAgendaPerType', $parameters, $object, $action);
235$form =
new Form($db);
236$companystatic =
new Societe($db);
238$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
239llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
243$nowyear = $nowarray[
'year'];
244$nowmonth = $nowarray[
'mon'];
245$nowday = $nowarray[
'mday'];
249$listofextcals = array();
256$week = $prev[
'week'];
260$next_year = $year + 1;
264$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
270$title = $langs->trans(
"DoneAndToDoActions");
271if ($status ==
'done') {
272 $title = $langs->trans(
"DoneActions");
274if ($status ==
'todo') {
275 $title = $langs->trans(
"ToDoActions");
279if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
280 if (is_array($actioncode)) {
281 foreach ($actioncode as $str_action) {
282 $param .=
"&search_actioncode[]=".urlencode($str_action);
285 $param .=
"&search_actioncode=".urlencode($actioncode);
288if ($resourceid > 0) {
289 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
291if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
292 $param .=
"&search_status=".urlencode($status);
295 $param .=
"&search_filter=".urlencode($filter);
298 $param .=
"&search_filtert=".urlencode($filtert);
301 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
304 $param .=
"&search_socid=".urlencode((
string) ($socid));
307 $param .=
"&search_showbirthday=1";
310 $param .=
"&search_projectid=".urlencode((
string) ($pid));
313 $param .=
"&search_type=".urlencode($type);
315if ($mode !=
'show_pertype') {
316 $param .=
'&mode='.urlencode((
string) $mode);
319 $param .=
'&begin_h='.urlencode($begin_h);
322 $param .=
'&end_h='.urlencode($end_h);
325 $param .=
'&begin_d='.urlencode((
string) ($begin_d));
328 $param .=
'&end_d='.urlencode((
string) ($end_d));
330$param .=
"&maxprint=".urlencode((
string) ($maxprint));
332$paramnoactionodate = $param;
335$prev_year = $year - 1;
342$week = $prev[
'week'];
346$next_year = $year + 1;
352$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
358$max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
361$picto =
'calendarweek';
364$nav =
'<div class="navselectiondate inline-block nowraponall">';
365$nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\">".
img_previous($langs->trans(
"Previous")).
"</a>\n";
366$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
"</span> \n";
367$nav .=
"<a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\">".
img_next($langs->trans(
"Next")).
"</a>\n";
368if (empty($conf->dol_optimize_smallscreen)) {
369 $nav .=
" (<a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
"</a>)";
373$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
374$nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
377$param .=
'&year='.urlencode((
string) ($year)).
'&month='.urlencode((
string) ($month)).($day ?
'&day='.urlencode((
string) ($day)) :
'');
381$paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
385print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
387$showextcals = $listofextcals;
389if ($conf->use_javascript_ajax) {
391 $s .=
'<script type="text/javascript">'.
"\n";
392 $s .=
'jQuery(document).ready(function () {'.
"\n";
393 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
394 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
395 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
396 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
397 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
400 $s .=
'</script>'.
"\n";
401 if (!empty($conf->use_javascript_ajax)) {
402 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
403 if (is_array($showextcals) && count($showextcals) > 0) {
404 foreach ($showextcals as $val) {
405 $htmlname = md5($val[
'name']);
406 $s .=
'<script type="text/javascript">'.
"\n";
407 $s .=
'jQuery(document).ready(function () {'.
"\n";
408 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
409 $s .=
' /* alert("'.$htmlname.
'"); */';
410 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
413 $s .=
'</script>'.
"\n";
414 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
421 $parameters = array();
422 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
423 if (empty($reshook)) {
424 $s .= $hookmanager->resPrint;
425 } elseif ($reshook > 1) {
426 $s = $hookmanager->resPrint;
431$massactionbutton =
'';
433$viewmode =
'<div class="navmode inline-block">';
435$viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
437$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
439$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
443$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
445$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
449$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
451$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
455$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
457$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
461$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
463$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
466$parameters = array();
468$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
469if (empty($reshook)) {
470 $viewmode .= $hookmanager->resPrint;
471} elseif ($reshook > 1) {
472 $viewmode = $hookmanager->resPrint;
475$viewmode .=
'</div>';
477$viewmode .=
'<span class="marginrightonly"></span>';
482if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
485 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
487 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
488 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
489 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
491 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
494print_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);
501$newtitle =
'<div class="nowrap clear inline-block minheight30">';
502$newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
503$newtitle .=
'</div>';
510print
'<div class="liste_titre liste_titre_bydiv centpercent">';
511print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
516$eventarray = array();
524$sql .=
' a.id, a.label,';
527$sql .=
' a.percent,';
528$sql .=
' a.fk_user_author,a.fk_user_action,';
529$sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
530$sql .=
' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
531$sql .=
' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
532$sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
534if ($resourceid > 0) {
535 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
538if ($filtert > 0 || $usergroup > 0) {
539 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
542 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
544$sql .=
' WHERE a.fk_action = ca.id';
545$sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
547if (!empty($actioncode)) {
549 if ($actioncode ==
'AC_NON_AUTO') {
550 $sql .=
" AND ca.type != 'systemauto'";
551 } elseif ($actioncode ==
'AC_ALL_AUTO') {
552 $sql .=
" AND ca.type = 'systemauto'";
554 if ($actioncode ==
'AC_OTH') {
555 $sql .=
" AND ca.type != 'systemauto'";
557 if ($actioncode ==
'AC_OTH_AUTO') {
558 $sql .=
" AND ca.type = 'systemauto'";
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 (is_array($actioncode)) {
568 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
570 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
575if ($resourceid > 0) {
576 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
579 $sql .=
" AND a.fk_project = ".((int) $pid);
583if (!$user->hasRight(
'societe',
'client',
'voir')) {
584 $search_sale = $user->id;
587if ($search_sale && $search_sale !=
'-1') {
588 if ($search_sale == -2) {
589 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
590 } elseif ($search_sale > 0) {
591 $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).
")";
596 $sql .=
" AND a.fk_soc = ".((int) $socid);
599if ($filtert > 0 || $usergroup > 0) {
600 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
602if ($mode ==
'show_day') {
604 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
605 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
607 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
608 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
610 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
611 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
616 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
617 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
619 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
620 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
622 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7)).
"'";
623 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
627 $sql .=
" AND ca.id = ".((int) $type);
630 $sql .=
" AND a.percent = 0";
632if ($status ===
'na') {
634 $sql .=
" AND a.percent = -1";
636if ($status ==
'50') {
638 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
640if ($status ==
'done' || $status ==
'100') {
641 $sql .=
" AND (a.percent = 100)";
643if ($status ==
'todo') {
644 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
647if ($filtert > 0 || $usergroup > 0) {
650 $sql .=
"ar.fk_element = ".$filtert;
652 if ($usergroup > 0) {
653 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
658$sql .=
' ORDER BY fk_user_action, datep';
661dol_syslog(
"comm/action/pertype.php", LOG_DEBUG);
662$resql = $db->query($sql);
664 $num = $db->num_rows($resql);
667 $obj = $db->fetch_object($resql);
675 $datep = $db->jdate($obj->datep);
676 $datep2 = $db->jdate($obj->datep2);
680 $event->id = $obj->id;
681 $event->datep = $datep;
682 $event->datef = $datep2;
683 $event->type_code = $obj->code;
684 $event->type_color = $obj->color;
685 $event->label = $obj->label;
686 $event->percentage = $obj->percent;
687 $event->authorid = $obj->fk_user_author;
688 $event->userownerid = $obj->fk_user_action;
689 $event->priority = $obj->priority;
690 $event->fulldayevent = $obj->fulldayevent;
691 $event->location = $obj->location;
692 $event->transparency = $obj->transparency;
694 $event->fk_project = $obj->fk_project;
696 $event->socid = $obj->fk_soc;
697 $event->contact_id = $obj->fk_contact;
699 $event->fk_element = $obj->fk_element;
700 $event->elementtype = $obj->elementtype;
704 $event->date_start_in_calendar = $datep;
705 if ($datep2 !=
'' && $datep2 >= $datep) {
706 $event->date_end_in_calendar = $datep2;
708 $event->date_end_in_calendar = $datep;
712 if ($event->date_end_in_calendar < $firstdaytoshow ||
713 $event->date_start_in_calendar >= $lastdaytoshow) {
718 $event->fetch_userassigned();
720 if ($event->date_start_in_calendar < $firstdaytoshow) {
721 $event->date_start_in_calendar = $firstdaytoshow;
723 if ($event->date_end_in_calendar >= $lastdaytoshow) {
724 $event->date_end_in_calendar = ($lastdaytoshow - 1);
728 $daycursor = $event->date_start_in_calendar;
736 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
740 $eventarray[$daykey][] = $event;
743 $daykey += 60 * 60 * 24;
744 if ($daykey > $event->date_end_in_calendar) {
760$cachethirdparties = array();
761$cachecontacts = array();
762$cacheusers = array();
765$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
766if (is_readable($color_file)) {
769if (!is_array($theme_datacolor)) {
770 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
775$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
776$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
777$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
778$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
779$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
780$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
781$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
782$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
783$newparam .=
'&viewweek=1';
785print
'<input type="hidden" name="action" value="mupdate">';
786echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
787echo
'<input type="hidden" name="token" value="'.newToken().
'">';
788echo
'<input type="hidden" name="newdate" id="newdate">';
795echo
'<div class="div-table-responsive">';
797echo
'<table class="centpercent nocellnopadd cal_month">';
799echo
'<tr class="liste_titre">';
802echo
'<td align="center" colspan="'.($end_d - $begin_d).
'">';
803echo $langs->trans(
"Year");
809echo
'<tr class="liste_titre">';
812for ($h = $begin_d; $h < $end_d; $h++) {
813 echo
'<td class="center">';
814 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
821$typeofevents = array();
824$colorsbytype = array();
825$labelbytype = array();
826$sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
827$resql = $db->query($sql);
828while ($obj = $db->fetch_object($resql)) {
829 $typeofevents[$obj->code] = $obj->code;
830 $colorsbytype[$obj->code] = $obj->color;
831 $labelbytype[$obj->code] = $obj->label;
839foreach ($typeofevents as $typeofevent) {
842 echo
'<td class="cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">'.$typeofevent.
'</td>';
847 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
848 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
861 $style =
'cal_current_month';
862 if ($iter_day == 6) {
863 $style .=
' cal_other_month';
866 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
870 $style =
'cal_today_peruser';
873 show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
887 $langs->load(
"commercial");
888 print
'<br>'.$langs->trans(
"Legend").
': <br>';
889 foreach ($colorsbytype as $code => $color) {
891 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
892 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
898 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
899 print $langs->trans(
"Other");
912print
'<script type="text/javascript">
913jQuery(document).ready(function() {
914 jQuery(".onclickopenref").click(function() {
915 var ref=$(this).attr(\'ref\');
916 var res = ref.split("_");
924 if (ids == \'none\') /* No event */
926 /* alert(\'no event\'); */
927 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).
'"
928 window.location.href = url;
930 else if (ids.indexOf(",") > -1) /* There is several events */
932 /* alert(\'several events\'); */
933 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
934 window.location.href = url;
938 /* alert(\'one event\'); */
939 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
940 window.location.href = url;
973function 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)
976 global $user, $conf, $langs, $hookmanager, $action;
977 global $filter, $filtert, $status, $actioncode;
978 global $theme_datacolor;
979 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
980 global $begin_h, $end_h;
991 $ymd = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
993 $nextindextouse = count($colorindexused);
999 foreach ($eventarray as $daykey => $notused) {
1004 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1006 foreach ($eventarray[$daykey] as $index => $event) {
1010 $keysofuserassigned = array_keys($event->userassigned);
1011 if (!in_array($username->id, $keysofuserassigned)) {
1016 $parameters = array();
1017 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1022 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1028 if (in_array($user->id, $keysofuserassigned)) {
1030 $cssclass =
'family_mytasks';
1032 $color = $event->type_color;
1034 } elseif ($event->type_code ==
'ICALEVENT') {
1036 if (!empty($event->icalname)) {
1043 $color = $event->icalcolor;
1044 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1045 } elseif ($event->type_code ==
'BIRTHDAY') {
1048 $cssclass =
'family_birthday unsortable';
1049 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1052 $cssclass =
'family_other';
1054 $color = $event->type_color;
1060 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1061 if (isset($colorindexused[$idusertouse])) {
1062 $colorindex = $colorindexused[$idusertouse];
1064 $colorindex = $nextindextouse;
1065 $colorindexused[$idusertouse] = $colorindex;
1066 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1071 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1076 for ($h = $begin_h; $h < $end_h; $h++) {
1079 if (empty($event->fulldayevent)) {
1080 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1081 $b =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1082 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1084 $dateendtouse = $event->date_end_in_calendar;
1085 if ($dateendtouse == $event->date_start_in_calendar) {
1091 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1092 $busy = $event->transparency;
1093 $cases1[$h][$event->id][
'busy'] = $busy;
1094 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1095 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1096 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1097 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1098 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1099 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1101 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1104 if ($event->label) {
1105 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1107 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1108 $cases1[$h][$event->id][
'color'] = $color;
1109 if ($event->fk_project > 0) {
1110 if (empty($cacheprojects[$event->fk_project])) {
1112 $tmpproj->fetch($event->fk_project);
1113 $cacheprojects[$event->fk_project] = $tmpproj;
1115 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1117 if ($event->socid > 0) {
1118 if (empty($cachethirdparties[$event->socid])) {
1119 $tmpthirdparty =
new Societe($db);
1120 $tmpthirdparty->fetch($event->socid);
1121 $cachethirdparties[$event->socid] = $tmpthirdparty;
1123 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1125 if ($event->contact_id > 0) {
1126 if (empty($cachecontacts[$event->contact_id])) {
1127 $tmpcontact =
new Contact($db);
1128 $tmpcontact->fetch($event->contact_id);
1129 $cachecontacts[$event->contact_id] = $tmpcontact;
1131 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1134 if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
1135 $busy = $event->transparency;
1136 $cases2[$h][$event->id][
'busy'] = $busy;
1137 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1138 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1139 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1140 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1141 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1142 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1144 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1147 if ($event->label) {
1148 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1150 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1151 $cases2[$h][$event->id][
'color'] = $color;
1152 if ($event->fk_project > 0) {
1153 if (empty($cacheprojects[$event->fk_project])) {
1155 $tmpproj->fetch($event->fk_project);
1156 $cacheprojects[$event->fk_project] = $tmpproj;
1158 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1160 if ($event->socid > 0) {
1161 if (empty($cachethirdparties[$event->socid])) {
1162 $tmpthirdparty =
new Societe($db);
1163 $tmpthirdparty->fetch($event->socid);
1164 $cachethirdparties[$event->socid] = $tmpthirdparty;
1166 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1168 if ($event->contact_id > 0) {
1169 if (empty($cachecontacts[$event->contact_id])) {
1170 $tmpcontact =
new Contact($db);
1171 $tmpcontact->fetch($event->contact_id);
1172 $cachecontacts[$event->contact_id] = $tmpcontact;
1174 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1178 $busy = $event->transparency;
1179 $cases1[$h][$event->id][
'busy'] = $busy;
1180 $cases2[$h][$event->id][
'busy'] = $busy;
1181 $cases1[$h][$event->id][
'string'] = $event->label;
1182 $cases2[$h][$event->id][
'string'] = $event->label;
1183 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1184 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1185 $cases1[$h][$event->id][
'color'] = $color;
1186 $cases2[$h][$event->id][
'color'] = $color;
1197 for ($h = $begin_h; $h < $end_h; $h++) {
1202 $string1 =
' ';
1203 $string2 =
' ';
1206 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1208 if (count($cases1[$h]) > 1) {
1209 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1213 $style1 =
'peruser_notbusy';
1215 $style1 =
'peruser_busy';
1217 foreach ($cases1[$h] as
$id => $ev) {
1219 $style1 =
'peruser_busy';
1223 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1225 if (count($cases2[$h]) > 1) {
1226 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1230 $style2 =
'peruser_notbusy';
1232 $style2 =
'peruser_busy';
1234 foreach ($cases2[$h] as
$id => $ev) {
1236 $style2 =
'peruser_busy';
1243 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1244 $ids1 = implode(
',', array_keys($cases1[$h]));
1246 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1247 $ids2 = implode(
',', array_keys($cases2[$h]));
1250 if ($h == $begin_h) {
1251 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1253 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1255 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1256 $output = array_slice($cases1[$h], 0, 1);
1257 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1258 if ($output[0][
'string']) {
1259 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1261 if ($output[0][
'color']) {
1262 $color1 = $output[0][
'color'];
1264 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1265 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1269 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1270 $output = array_slice($cases2[$h], 0, 1);
1271 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1272 if ($output[0][
'string']) {
1273 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1275 if ($output[0][
'color']) {
1276 $color2 = $output[0][
'color'];
1278 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1279 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1282 print
'<table class="nobordernopadding" width="100%">';
1283 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.
'"' :
'').
'>';
1285 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.
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.
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.
print_barre_liste($title, $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.
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...
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.