33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
44 if (!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');
69 if (empty($page) || $page == -1) {
73 $offset = $limit * $page;
78 $sortfield =
"a.datec";
85 $socid = $user->socid;
93 if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
96 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
99 if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
100 $filtert = $user->id;
103 $mode =
'show_pertype';
112 $maxprint = ((
GETPOSTINT(
"maxprint") !=
'') ?
GETPOSTINT(
"maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
113 $optioncss =
GETPOST(
'optioncss',
'aZ');
116 if (
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) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
126 if ($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);
138 if ($begin_h < 0 || $begin_h > 23) {
141 if ($end_h < 1 || $end_h > 24) {
144 if ($end_h <= $begin_h) {
145 $end_h = $begin_h + 1;
149 $tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_DAYS') ?
'1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
150 $tmp = str_replace(
' ',
'', $tmp);
151 $tmparray = explode(
'-', $tmp);
156 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
159 $mode = (!
getDolGlobalString(
'AGENDA_DEFAULT_VIEW') ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
163 if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
164 $mode =
'show_month';
168 if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
170 $week = ($week ? $week : date(
"W"));
171 $day = ($day ? $day : date(
"d"));
174 if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
176 $day = ($day ? $day : date(
"d"));
179 if (
GETPOST(
'viewyear',
'alpha') || $mode ==
'show_year') {
187 $langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
190 $hookmanager->initHooks(array(
'agenda'));
193 if ($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);
236 $companystatic =
new Societe($db);
238 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
243 $nowyear = $nowarray[
'year'];
244 $nowmonth = $nowarray[
'mon'];
245 $nowday = $nowarray[
'mday'];
249 $listofextcals = array();
256 $week = $prev[
'week'];
260 $next_year = $year + 1;
261 $next_month = $month;
264 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
266 $tmpday = $first_day;
270 $title = $langs->trans(
"DoneAndToDoActions");
271 if ($status ==
'done') {
272 $title = $langs->trans(
"DoneActions");
274 if ($status ==
'todo') {
275 $title = $langs->trans(
"ToDoActions");
280 if (is_array($actioncode)) {
281 foreach ($actioncode as $str_action) {
282 $param .=
"&search_actioncode[]=".urlencode($str_action);
285 $param .=
"&search_actioncode=".urlencode($actioncode);
288 if ($resourceid > 0) {
289 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
292 $param .=
"&search_status=".urlencode($status);
295 $param .=
"&search_filter=".urlencode($filter);
298 $param .=
"&search_filtert=".urlencode($filtert);
300 if ($usergroup > 0) {
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);
315 if ($mode !=
'show_pertype') {
316 $param .=
'&mode='.urlencode($mode);
318 if ($begin_h !=
'') {
319 $param .=
'&begin_h='.urlencode($begin_h);
322 $param .=
'&end_h='.urlencode($end_h);
324 if ($begin_d !=
'') {
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;
336 $prev_month = $month;
342 $week = $prev[
'week'];
346 $next_year = $year + 1;
347 $next_month = $month;
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'));
360 $tmpday = $first_day;
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";
368 if (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);
385 print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
387 $showextcals = $listofextcals;
389 if ($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 =
'';
434 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
436 $viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
438 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
442 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
444 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
448 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
450 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
454 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
456 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
460 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
462 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
464 $viewmode .=
'<span class="marginrightonly"></span>';
467 $parameters = array();
469 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
470 if (empty($reshook)) {
471 $viewmode .= $hookmanager->resPrint;
472 } elseif ($reshook > 1) {
473 $viewmode = $hookmanager->resPrint;
478 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
481 $newparam .=
'&month='.str_pad($month, 2,
"0", STR_PAD_LEFT).
'&year='.$tmpforcreatebutton[
'year'];
483 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
484 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
485 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
487 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
490 print_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);
497 $newtitle =
'<div class="nowrap clear inline-block minheight30">';
498 $newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
499 $newtitle .=
'</div>';
506 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
507 print_actions_filter(
$form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
512 $eventarray = array();
517 if ($usergroup > 0) {
520 $sql .=
' a.id, a.label,';
522 $sql .=
' a.datep2,';
523 $sql .=
' a.percent,';
524 $sql .=
' a.fk_user_author,a.fk_user_action,';
525 $sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
526 $sql .=
' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
527 $sql .=
' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
528 $sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
530 if ($resourceid > 0) {
531 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
534 if ($filtert > 0 || $usergroup > 0) {
535 $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
537 if ($usergroup > 0) {
538 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
540 $sql .=
' WHERE a.fk_action = ca.id';
541 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
543 if (!empty($actioncode)) {
545 if ($actioncode ==
'AC_NON_AUTO') {
546 $sql .=
" AND ca.type != 'systemauto'";
547 } elseif ($actioncode ==
'AC_ALL_AUTO') {
548 $sql .=
" AND ca.type = 'systemauto'";
550 if ($actioncode ==
'AC_OTH') {
551 $sql .=
" AND ca.type != 'systemauto'";
553 if ($actioncode ==
'AC_OTH_AUTO') {
554 $sql .=
" AND ca.type = 'systemauto'";
558 if ($actioncode ==
'AC_NON_AUTO') {
559 $sql .=
" AND ca.type != 'systemauto'";
560 } elseif ($actioncode ==
'AC_ALL_AUTO') {
561 $sql .=
" AND ca.type = 'systemauto'";
563 if (is_array($actioncode)) {
564 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
566 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
571 if ($resourceid > 0) {
572 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
575 $sql .=
" AND a.fk_project = ".((int) $pid);
579 if (!$user->hasRight(
'societe',
'client',
'voir')) {
580 $search_sale = $user->id;
583 if ($search_sale && $search_sale !=
'-1') {
584 if ($search_sale == -2) {
585 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
586 } elseif ($search_sale > 0) {
587 $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).
")";
592 $sql .=
" AND a.fk_soc = ".((int) $socid);
595 if ($filtert > 0 || $usergroup > 0) {
596 $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
598 if ($mode ==
'show_day') {
600 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
601 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
603 $sql .=
" (a.datep2 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.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
607 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
612 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
613 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
615 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7)).
"'";
616 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
618 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7)).
"'";
619 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7)).
"')";
623 $sql .=
" AND ca.id = ".((int) $type);
625 if ($status ==
'0') {
626 $sql .=
" AND a.percent = 0";
628 if ($status ===
'na') {
630 $sql .=
" AND a.percent = -1";
632 if ($status ==
'50') {
634 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
636 if ($status ==
'done' || $status ==
'100') {
637 $sql .=
" AND (a.percent = 100)";
639 if ($status ==
'todo') {
640 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
643 if ($filtert > 0 || $usergroup > 0) {
646 $sql .=
"ar.fk_element = ".$filtert;
648 if ($usergroup > 0) {
649 $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".((
int) $usergroup);
654 $sql .=
' ORDER BY fk_user_action, datep';
657 dol_syslog(
"comm/action/pertype.php", LOG_DEBUG);
658 $resql = $db->query(
$sql);
660 $num = $db->num_rows($resql);
663 $obj = $db->fetch_object($resql);
671 $datep = $db->jdate($obj->datep);
672 $datep2 = $db->jdate($obj->datep2);
676 $event->id = $obj->id;
677 $event->datep = $datep;
678 $event->datef = $datep2;
679 $event->type_code = $obj->code;
680 $event->type_color = $obj->color;
681 $event->label = $obj->label;
682 $event->percentage = $obj->percent;
683 $event->authorid = $obj->fk_user_author;
684 $event->userownerid = $obj->fk_user_action;
685 $event->priority = $obj->priority;
686 $event->fulldayevent = $obj->fulldayevent;
687 $event->location = $obj->location;
688 $event->transparency = $obj->transparency;
690 $event->fk_project = $obj->fk_project;
692 $event->socid = $obj->fk_soc;
693 $event->contact_id = $obj->fk_contact;
695 $event->fk_element = $obj->fk_element;
696 $event->elementtype = $obj->elementtype;
700 $event->date_start_in_calendar = $datep;
701 if ($datep2 !=
'' && $datep2 >= $datep) {
702 $event->date_end_in_calendar = $datep2;
704 $event->date_end_in_calendar = $datep;
708 if ($event->date_end_in_calendar < $firstdaytoshow ||
709 $event->date_start_in_calendar >= $lastdaytoshow) {
714 $event->fetch_userassigned();
716 if ($event->date_start_in_calendar < $firstdaytoshow) {
717 $event->date_start_in_calendar = $firstdaytoshow;
719 if ($event->date_end_in_calendar >= $lastdaytoshow) {
720 $event->date_end_in_calendar = ($lastdaytoshow - 1);
724 $daycursor = $event->date_start_in_calendar;
732 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
736 $eventarray[$daykey][] = $event;
739 $daykey += 60 * 60 * 24;
740 if ($daykey > $event->date_end_in_calendar) {
756 $cachethirdparties = array();
757 $cachecontacts = array();
758 $cacheusers = array();
761 $color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
762 if (is_readable($color_file)) {
765 if (!is_array($theme_datacolor)) {
766 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
771 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
772 $newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
773 $newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
774 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
775 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
776 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
777 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
778 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
779 $newparam .=
'&viewweek=1';
781 print
'<input type="hidden" name="action" value="mupdate">';
782 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
783 echo
'<input type="hidden" name="token" value="'.newToken().
'">';
784 echo
'<input type="hidden" name="newdate" id="newdate">';
791 echo
'<div class="div-table-responsive">';
793 echo
'<table class="centpercent nocellnopadd cal_month">';
795 echo
'<tr class="liste_titre">';
798 echo
'<td align="center" colspan="'.($end_d - $begin_d).
'">';
799 echo $langs->trans(
"Year");
805 echo
'<tr class="liste_titre">';
808 for ($h = $begin_d; $h < $end_d; $h++) {
809 echo
'<td class="center">';
810 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
817 $typeofevents = array();
820 $colorsbytype = array();
821 $labelbytype = array();
822 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
823 $resql = $db->query(
$sql);
824 while ($obj = $db->fetch_object($resql)) {
825 $typeofevents[$obj->code] = $obj->code;
826 $colorsbytype[$obj->code] = $obj->color;
827 $labelbytype[$obj->code] = $obj->label;
835 foreach ($typeofevents as $typeofevent) {
838 echo
'<td class="cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">'.$typeofevent.
'</td>';
843 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
844 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
857 $style =
'cal_current_month';
858 if ($iter_day == 6) {
859 $style .=
' cal_other_month';
862 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
866 $style =
'cal_today_peruser';
869 show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
883 $langs->load(
"commercial");
884 print
'<br>'.$langs->trans(
"Legend").
': <br>';
885 foreach ($colorsbytype as $code => $color) {
887 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
888 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
894 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
895 print $langs->trans(
"Other");
904 print
"\n".
'</form>';
908 print
'<script type="text/javascript">
909 jQuery(document).ready(function() {
910 jQuery(".onclickopenref").click(function() {
911 var ref=$(this).attr(\'ref\');
912 var res = ref.split("_");
920 if (ids == \'none\') /* No event */
922 /* alert(\'no event\'); */
923 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).
'"
924 window.location.href = url;
926 else if (ids.indexOf(",") > -1) /* There is several events */
928 /* alert(\'several events\'); */
929 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
930 window.location.href = url;
934 /* alert(\'one event\'); */
935 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
936 window.location.href = url;
969 function 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)
972 global $user, $conf, $langs, $hookmanager, $action;
973 global $filter, $filtert, $status, $actioncode;
974 global $theme_datacolor;
975 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
976 global $begin_h, $end_h;
987 $ymd = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
989 $nextindextouse = count($colorindexused);
995 foreach ($eventarray as $daykey => $notused) {
1000 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1002 foreach ($eventarray[$daykey] as $index => $event) {
1006 $keysofuserassigned = array_keys($event->userassigned);
1007 if (!in_array($username->id, $keysofuserassigned)) {
1012 $parameters = array();
1013 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1018 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1024 if (in_array($user->id, $keysofuserassigned)) {
1026 $cssclass =
'family_mytasks';
1028 $color = $event->type_color;
1030 } elseif ($event->type_code ==
'ICALEVENT') {
1032 if (!empty($event->icalname)) {
1039 $color = $event->icalcolor;
1040 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1041 } elseif ($event->type_code ==
'BIRTHDAY') {
1044 $cssclass =
'family_birthday unsortable';
1045 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1048 $cssclass =
'family_other';
1050 $color = $event->type_color;
1056 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1057 if (isset($colorindexused[$idusertouse])) {
1058 $colorindex = $colorindexused[$idusertouse];
1060 $colorindex = $nextindextouse;
1061 $colorindexused[$idusertouse] = $colorindex;
1062 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1067 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1072 for ($h = $begin_h; $h < $end_h; $h++) {
1075 if (empty($event->fulldayevent)) {
1076 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1077 $b =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1078 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1080 $dateendtouse = $event->date_end_in_calendar;
1081 if ($dateendtouse == $event->date_start_in_calendar) {
1087 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1088 $busy = $event->transparency;
1089 $cases1[$h][$event->id][
'busy'] = $busy;
1090 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1091 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1092 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1093 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1094 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1095 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1097 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1100 if ($event->label) {
1101 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1103 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1104 $cases1[$h][$event->id][
'color'] = $color;
1105 if ($event->fk_project > 0) {
1106 if (empty($cacheprojects[$event->fk_project])) {
1108 $tmpproj->fetch($event->fk_project);
1109 $cacheprojects[$event->fk_project] = $tmpproj;
1111 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1113 if ($event->socid > 0) {
1114 if (empty($cachethirdparties[$event->socid])) {
1115 $tmpthirdparty =
new Societe($db);
1116 $tmpthirdparty->fetch($event->socid);
1117 $cachethirdparties[$event->socid] = $tmpthirdparty;
1119 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1121 if ($event->contact_id > 0) {
1122 if (empty($cachecontacts[$event->contact_id])) {
1123 $tmpcontact =
new Contact($db);
1124 $tmpcontact->fetch($event->contact_id);
1125 $cachecontacts[$event->contact_id] = $tmpcontact;
1127 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1130 if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
1131 $busy = $event->transparency;
1132 $cases2[$h][$event->id][
'busy'] = $busy;
1133 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1134 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1135 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1136 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1137 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1138 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1140 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1143 if ($event->label) {
1144 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1146 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1147 $cases2[$h][$event->id][
'color'] = $color;
1148 if ($event->fk_project > 0) {
1149 if (empty($cacheprojects[$event->fk_project])) {
1151 $tmpproj->fetch($event->fk_project);
1152 $cacheprojects[$event->fk_project] = $tmpproj;
1154 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1156 if ($event->socid > 0) {
1157 if (empty($cachethirdparties[$event->socid])) {
1158 $tmpthirdparty =
new Societe($db);
1159 $tmpthirdparty->fetch($event->socid);
1160 $cachethirdparties[$event->socid] = $tmpthirdparty;
1162 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1164 if ($event->contact_id > 0) {
1165 if (empty($cachecontacts[$event->contact_id])) {
1166 $tmpcontact =
new Contact($db);
1167 $tmpcontact->fetch($event->contact_id);
1168 $cachecontacts[$event->contact_id] = $tmpcontact;
1170 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1174 $busy = $event->transparency;
1175 $cases1[$h][$event->id][
'busy'] = $busy;
1176 $cases2[$h][$event->id][
'busy'] = $busy;
1177 $cases1[$h][$event->id][
'string'] = $event->label;
1178 $cases2[$h][$event->id][
'string'] = $event->label;
1179 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1180 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1181 $cases1[$h][$event->id][
'color'] = $color;
1182 $cases2[$h][$event->id][
'color'] = $color;
1193 for ($h = $begin_h; $h < $end_h; $h++) {
1198 $string1 =
' ';
1199 $string2 =
' ';
1202 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1204 if (count($cases1[$h]) > 1) {
1205 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1209 $style1 =
'peruser_notbusy';
1211 $style1 =
'peruser_busy';
1213 foreach ($cases1[$h] as $id => $ev) {
1215 $style1 =
'peruser_busy';
1219 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1221 if (count($cases2[$h]) > 1) {
1222 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1226 $style2 =
'peruser_notbusy';
1228 $style2 =
'peruser_busy';
1230 foreach ($cases2[$h] as $id => $ev) {
1232 $style2 =
'peruser_busy';
1239 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1240 $ids1 = implode(
',', array_keys($cases1[$h]));
1242 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1243 $ids2 = implode(
',', array_keys($cases2[$h]));
1246 if ($h == $begin_h) {
1247 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1249 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1251 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1252 $output = array_slice($cases1[$h], 0, 1);
1253 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1254 if ($output[0][
'string']) {
1255 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1257 if ($output[0][
'color']) {
1258 $color1 = $output[0][
'color'];
1260 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1261 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1265 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1266 $output = array_slice($cases2[$h], 0, 1);
1267 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1268 if ($output[0][
'string']) {
1269 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1271 if ($output[0][
'color']) {
1272 $color2 = $output[0][
'color'];
1274 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1275 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1278 print
'<table class="nobordernopadding" width="100%">';
1279 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.
'"' :
'').
'>';
1281 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
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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()
Empty header.
Class to manage agenda events (actions)
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
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.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.