34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
46 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
49$action =
GETPOST(
'action',
'aZ09');
51$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
53$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";
83 $socid = $user->socid;
90if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
93if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
96if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
100$mode =
'show_peruser';
106$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
107$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
108$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'alpha') :
GETPOST(
"type",
'alpha');
109$maxprint = ((
GETPOSTINT(
"maxprint") !=
'') ?
GETPOSTINT(
"maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
110$optioncss =
GETPOST(
'optioncss',
'aZ');
113if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
114 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
115 if (!count($actioncode)) {
119 $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')));
123if ($dateselect > 0) {
129$tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_HOURS') ?
'9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
130$tmp = str_replace(
' ',
'', $tmp);
131$tmparray = explode(
'-', $tmp);
132$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
133$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
134if ($begin_h < 0 || $begin_h > 23) {
137if ($end_h < 1 || $end_h > 24) {
140if ($end_h <= $begin_h) {
141 $end_h = $begin_h + 1;
144$tmp = !
getDolGlobalString(
'MAIN_DEFAULT_WORKING_DAYS') ?
'1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
145$tmp = str_replace(
' ',
'', $tmp);
146$tmparray = explode(
'-', $tmp);
147$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
148$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
149if ($begin_d < 1 || $begin_d > 7) {
152if ($end_d < 1 || $end_d > 7) {
155if ($end_d < $begin_d) {
156 $end_d = $begin_d + 1;
159if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
160 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
163if (empty($mode) && !GETPOSTISSET(
'mode')) {
167if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
168 $mode =
'show_month';
171if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
173 $week = ($week ? $week : idate(
"W"));
174 $day = ($day ? $day : idate(
"d"));
176if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
178 $day = ($day ? $day : idate(
"d"));
184$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
187$hookmanager->initHooks(array(
'agenda'));
190if ($user->socid && $socid) {
194$search_status = $status;
215 'maxprint' => $maxprint,
217 'filtert' => $filtert,
218 'showbirthday' => $showbirthday,
219 'canedit' => $canedit,
220 'optioncss' => $optioncss,
221 'actioncode' => $actioncode,
223 'resourceid' => $resourceid,
224 'usergroup' => $usergroup,
226$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
231$form =
new Form($db);
232$companystatic =
new Societe($db);
234$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
235llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
239$nowyear = $nowarray[
'year'];
240$nowmonth = $nowarray[
'mon'];
241$nowday = $nowarray[
'mday'];
245$listofextcals = array();
248$first_day = $prev[
'first_day'];
249$first_month = $prev[
'first_month'];
250$first_year = $prev[
'first_year'];
252$week = $prev[
'week'];
256$next_year = $next[
'year'];
257$next_month = $next[
'month'];
258$next_day = $next[
'day'];
260$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
266$title = $langs->trans(
"DoneAndToDoActions");
267if ($status ==
'done') {
268 $title = $langs->trans(
"DoneActions");
270if ($status ==
'todo') {
271 $title = $langs->trans(
"ToDoActions");
275if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
276 if (is_array($actioncode)) {
277 foreach ($actioncode as $str_action) {
278 $param .=
"&search_actioncode[]=".urlencode($str_action);
281 $param .=
"&search_actioncode=".urlencode($actioncode);
284if ($resourceid > 0) {
285 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
288if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
289 $param .=
"&search_status=".urlencode($status);
292 $param .=
"&search_filter=".urlencode($filter);
295 $param .=
"&search_filtert=".urlencode($filtert);
298 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
301 $param .=
"&search_socid=".urlencode((
string) ($socid));
304 $param .=
"&search_showbirthday=1";
307 $param .=
"&search_projectid=".urlencode((
string) ($pid));
310 $param .=
"&search_type=".urlencode($type);
312if ($mode !=
'show_peruser') {
313 $param .=
'&mode='.urlencode((
string) $mode);
316 $param .=
'&begin_h='.((int) $begin_h);
319 $param .=
'&end_h='.((int) $end_h);
322 $param .=
'&begin_d='.((int) $begin_d);
325 $param .=
'&end_d='.((int) $end_d);
327if ($search_categ_cus != 0) {
328 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
330$param .=
"&maxprint=".urlencode((
string) ($maxprint));
332$paramnoactionodate = $param;
337$prev_year = $prev[
'prev_year'];
338$prev_month = $prev[
'prev_month'];
339$prev_day = $prev[
'prev_day'];
340$first_day = $prev[
'first_day'];
341$first_month = $prev[
'first_month'];
342$first_year = $prev[
'first_year'];
344$week = $prev[
'week'];
348$next_year = $next[
'year'];
349$next_month = $next[
'month'];
350$next_day = $next[
'day'];
354$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
355$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
361$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
364$picto =
'calendarweek';
367$nav =
'<div class="navselectiondate inline-block nowraponall">';
368$nav .=
"<a href=\"?year=".$prev_year.
"&month=".$prev_month.
"&day=".$prev_day.$param.
"\"><i class=\"fa fa-chevron-left\" title=\"".
dol_escape_htmltag($langs->trans(
"Previous")).
"\"></i></a> \n";
369$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
371$nav .=
" <a href=\"?year=".$next_year.
"&month=".$next_month.
"&day=".$next_day.$param.
"\"><i class=\"fa fa-chevron-right\" title=\"".
dol_escape_htmltag($langs->trans(
"Next")).
"\"></i></a>\n";
372if (empty($conf->dol_optimize_smallscreen)) {
373 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
376$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
377$nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
380$param .=
'&year='.urlencode((
string) ($year)).
'&month='.urlencode((
string) ($month)).($day ?
'&day='.urlencode((
string) ($day)) :
'');
384$paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
388print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
390$showextcals = $listofextcals;
392if ($conf->use_javascript_ajax) {
394 $s .=
'<script type="text/javascript">'.
"\n";
395 $s .=
'jQuery(document).ready(function () {'.
"\n";
396 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
397 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
398 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
399 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
400 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
403 $s .=
'</script>'.
"\n";
404 if (!empty($conf->use_javascript_ajax)) {
405 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
406 if (is_array($showextcals) && count($showextcals) > 0) {
407 foreach ($showextcals as $val) {
408 $htmlname = md5($val[
'name']);
409 $s .=
'<script type="text/javascript">'.
"\n";
410 $s .=
'jQuery(document).ready(function () {'.
"\n";
411 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
412 $s .=
' /* alert("'.$htmlname.
'"); */';
413 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
416 $s .=
'</script>'.
"\n";
417 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
424 $parameters = array();
425 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
426 if (empty($reshook)) {
427 $s .= $hookmanager->resPrint;
428 } elseif ($reshook > 1) {
429 $s = $hookmanager->resPrint;
434$mode =
'show_peruser';
435$massactionbutton =
'';
438$viewmode =
'<div class="navmode inline-block">';
440$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
442$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
444$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
446$viewmode .=
'<a class="btnTitle'.($mode ==
'show_month' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.
dol_print_date(
$object->datep,
'%Y').
'&month='.
dol_print_date(
$object->datep,
'%m').
'&day='.
dol_print_date(
$object->datep,
'%d').$paramnoactionodate.
'">';
448$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
450$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
452$viewmode .=
'<a class="btnTitle'.($mode ==
'show_week' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.
dol_print_date(
$object->datep,
'%Y').
'&month='.
dol_print_date(
$object->datep,
'%m').
'&day='.
dol_print_date(
$object->datep,
'%d').$paramnoactionodate.
'">';
454$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
456$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
458$viewmode .=
'<a class="btnTitle'.($mode ==
'show_day' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.
dol_print_date(
$object->datep,
'%Y').
'&month='.
dol_print_date(
$object->datep,
'%m').
'&day='.
dol_print_date(
$object->datep,
'%d').$paramnoactionodate.
'">';
460$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
462$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
464$viewmode .=
'<a class="btnTitle'.($mode ==
'show_peruser' ?
' btnTitleSelected' :
'').
' reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.
dol_print_date(
$object->datep,
'%Y').
'&month='.
dol_print_date(
$object->datep,
'%m').
'&day='.
dol_print_date(
$object->datep,
'%d').$paramnoactionodate.
'">';
466$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
468$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
471$parameters = array();
473$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
474if (empty($reshook)) {
475 $viewmode .= $hookmanager->resPrint;
476} elseif ($reshook > 1) {
477 $viewmode = $hookmanager->resPrint;
480$viewmode .=
'</div>';
482$viewmode .=
'<span class="marginrightonly"></span>';
487if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
490 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
491 if ($begin_h !==
'') {
492 $newparam .=
'&begin_h='.((int) $begin_h);
495 $newparam .=
'&end_h='.((int) $end_h);
497 if ($begin_d !==
'') {
498 $newparam .=
'&begin_d='.((int) $begin_d);
501 $newparam .=
'&end_d='.((int) $end_d);
504 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
505 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
506 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
508 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
513print_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);
519$s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
522$newtitle =
'<div class="nowrap clear inline-block minheight30">';
523$newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
524$newtitle .=
'</div>';
530$parameters = array();
531$reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
532if (empty($reshook)) {
533 $s .= $hookmanager->resPrint;
534} elseif ($reshook > 1) {
535 $s = $hookmanager->resPrint;
538$s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
542print
'<div class="liste_titre liste_titre_bydiv centpercent">';
543print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
548$eventarray = array();
556$sql .=
" a.id, a.label,";
559$sql .=
" a.percent,";
560$sql .=
" a.fk_user_author,a.fk_user_action,";
561$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
562$sql .=
" a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,";
563$sql .=
" ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto";
564$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
566if ($resourceid > 0) {
567 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
570if ($filtert > 0 || $usergroup > 0) {
571 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
572 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
574 $sql .=
" AND ar.fk_element = ".((int) $filtert);
576 if ($usergroup > 0) {
577 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
581$sql .=
" WHERE a.fk_action = ca.id";
582$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
584if (!empty($actioncode)) {
586 if ($actioncode ==
'AC_NON_AUTO') {
587 $sql .=
" AND ca.type != 'systemauto'";
588 } elseif ($actioncode ==
'AC_ALL_AUTO') {
589 $sql .=
" AND ca.type = 'systemauto'";
591 if ($actioncode ==
'AC_OTH') {
592 $sql .=
" AND ca.type != 'systemauto'";
594 if ($actioncode ==
'AC_OTH_AUTO') {
595 $sql .=
" AND ca.type = 'systemauto'";
599 if ($actioncode ==
'AC_NON_AUTO') {
600 $sql .=
" AND ca.type != 'systemauto'";
601 } elseif ($actioncode ==
'AC_ALL_AUTO') {
602 $sql .=
" AND ca.type = 'systemauto'";
604 if (is_array($actioncode)) {
605 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
607 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
612if ($resourceid > 0) {
613 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
616 $sql .=
" AND a.fk_project = ".((int) $pid);
620if (!$user->hasRight(
'societe',
'client',
'voir')) {
621 $search_sale = $user->id;
624if ($search_sale && $search_sale !=
'-1') {
625 if ($search_sale == -2) {
626 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
627 } elseif ($search_sale > 0) {
628 $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).
")";
633 $sql .=
" AND a.fk_soc = ".((int) $socid);
636if ($mode ==
'show_day') {
638 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
639 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
641 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
642 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
644 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
645 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
650 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
651 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
653 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
654 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
656 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
657 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
661 $sql .=
" AND ca.id = ".((int) $type);
664 $sql .=
" AND a.percent = 0";
666if ($status ===
'na') {
668 $sql .=
" AND a.percent = -1";
670if ($status ==
'50') {
672 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
674if ($status ==
'done' || $status ==
'100') {
675 $sql .=
" AND (a.percent = 100)";
677if ($status ==
'todo') {
678 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
681if ($search_categ_cus != -1) {
682 if ($search_categ_cus == -2) {
683 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
684 } elseif ($search_categ_cus > 0) {
685 $sql .=
" AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".$db->sanitize($search_categ_cus).
"))";
689$sql .= $db->order(
"fk_user_action, datep");
692dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
693$resql = $db->query($sql);
695 $num = $db->num_rows($resql);
699 $obj = $db->fetch_object($resql);
708 $datep = $db->jdate($obj->datep);
709 $datep2 = $db->jdate($obj->datep2);
714 $event->id = $obj->id;
715 $event->datep = $datep;
716 $event->datef = $datep2;
717 $event->type_code = $obj->code;
718 $event->type_color = $obj->color;
719 $event->label = $obj->label;
720 $event->percentage = $obj->percent;
721 $event->authorid = $obj->fk_user_author;
722 $event->userownerid = $obj->fk_user_action;
723 $event->priority = $obj->priority;
724 $event->fulldayevent = $obj->fulldayevent;
725 $event->location = $obj->location;
726 $event->transparency = $obj->transparency;
728 $event->fk_project = $obj->fk_project;
730 $event->socid = $obj->fk_soc;
731 $event->contact_id = $obj->fk_contact;
733 $event->fk_element = $obj->fk_element;
734 $event->elementtype = $obj->elementtype;
738 $event->date_start_in_calendar = $datep;
739 if ($datep2 !=
'' && $datep2 >= $datep) {
740 $event->date_end_in_calendar = $datep2;
742 $event->date_end_in_calendar = $datep;
748 if ($event->date_end_in_calendar < $firstdaytoshow ||
749 $event->date_start_in_calendar >= $lastdaytoshow) {
754 $event->fetch_userassigned();
756 if ($event->date_start_in_calendar < $firstdaytoshow) {
757 $event->date_start_in_calendar = $firstdaytoshow;
759 if ($event->date_end_in_calendar >= $lastdaytoshow) {
760 $event->date_end_in_calendar = ($lastdaytoshow - 1);
764 $daycursor = $event->date_start_in_calendar;
773 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
777 $eventarray[$daykey][] = $event;
780 $daykey += 60 * 60 * 24;
781 if ($daykey > $event->date_end_in_calendar) {
797$cachethirdparties = array();
798$cachecontacts = array();
799$cacheusers = array();
802$color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
803if (is_readable($color_file)) {
806if (!is_array($theme_datacolor)) {
807 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
812$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
813$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
814$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
815$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
816$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
817$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
818$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
819$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
820$newparam .=
'&viewweek=1';
822echo
'<input type="hidden" name="actionmove" value="mupdate">';
823echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
824echo
'<input type="hidden" name="newdate" id="newdate">';
831$currentdaytoshow = $firstdaytoshow;
832echo
'<div class="div-table-responsive">';
835$colorsbytype = array();
837while ($currentdaytoshow < $lastdaytoshow) {
838 echo
'<table class="centpercent noborder nocellnopadd cal_month">';
840 echo
'<tr class="liste_titre">';
841 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
843 if ($canedit && $mode ==
'show_peruser') {
845 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
846 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
847 print $langs->trans(
"DaysOfWeek").
'</span>';
849 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
850 print
'<input type="number" class="short" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
851 if (empty($conf->dol_use_jmobile)) {
854 print
'</div><div class="ui-block-b">';
856 print
'<input type="number" class="short" name="end_d" value="'.$end_d.
'" min="1" max="7">';
857 print
'</div></div>';
863 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
867 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
868 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
880 echo
'<tr class="liste_titre">';
884 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
885 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
886 print $langs->trans(
"Hours").
'</span>';
888 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
889 print
'<input type="number" class="short" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
890 if (empty($conf->dol_use_jmobile)) {
893 print
'</div><div class="ui-block-b">';
895 print
'<input type="number" class="short" name="end_h" value="'.$end_h.
'" min="1" max="24">';
896 if (empty($conf->dol_use_jmobile)) {
897 print
' '.$langs->trans(
"H");
899 print
'</div></div>';
904 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
908 for ($h = $begin_h; $h < $end_h; $h++) {
909 echo
'<td class="center">';
910 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
920 $usernames = array();
921 $usernamesid = array();
924 foreach ($eventarray as $daykey => $notused) {
926 foreach ($eventarray[$daykey] as $index => $event) {
927 $event->fetch_userassigned();
928 $listofuserid = $event->userassigned;
929 foreach ($listofuserid as $userid => $tmp) {
930 if (!in_array($userid, $usernamesid)) {
931 $usernamesid[$userid] = $userid;
938 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
939 $sql .=
" FROM ".$db->prefix().
"user as u";
940 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
941 $sql .=
" WHERE u.rowid IN (";
942 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
943 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
944 if ($usergroup > 0) {
945 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
949 if ($usergroup > 0) {
950 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
952 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
953 if ($usergroup > 0) {
954 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
957 $sql .=
" AND u.statut = 1";
959 $sql .=
" AND u.rowid = ".((int) $filtert);
961 if ($usergroup > 0) {
962 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
964 if ($user->socid > 0) {
966 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
970 $resql = $db->query($sql);
972 $num = $db->num_rows($resql);
976 $obj = $db->fetch_object($resql);
977 $usernamesid[$obj->rowid] = $obj->rowid;
986 foreach ($usernamesid as
$id) {
987 $tmpuser =
new User($db);
988 $result = $tmpuser->fetch(
$id);
989 $usernames[] = $tmpuser;
993 $labelbytype = array();
994 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
995 $resql = $db->query($sql);
996 while ($obj = $db->fetch_object($resql)) {
997 $colorsbytype[$obj->code] = $obj->color;
998 $labelbytype[$obj->code] = $obj->label;
1006 foreach ($usernames as $username) {
1012 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
1013 print
'<span class="paddingrightimp">';
1014 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1021 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1022 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1035 $style =
'cal_current_month';
1036 if ($iter_day == 6) {
1037 $style .=
' cal_other_month';
1040 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1044 $style =
'cal_today_peruser';
1047 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1052 $showheader =
false;
1064 $langs->load(
"commercial");
1065 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1066 foreach ($colorsbytype as $code => $color) {
1068 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
1069 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1075 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1076 print $langs->trans(
"Other");
1085print
"\n".
'</form>';
1089print
'<script type="text/javascript">
1090jQuery(document).ready(function() {
1091 jQuery(".onclickopenref").click(function() {
1092 console.log("We click on a class onclickopenref");
1094 var ref=$(this).attr(\'ref\');
1095 var res = ref.split("_");
1096 var userid = res[1];
1103 if (ids == \'none\') /* No event */
1105 /* alert(\'no event\'); */
1106 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?year='.$year.
'&month='.$month.
'&day='.$day.($begin_h !==
'' ?
'&begin_h='.$begin_h :
'').($end_h !==
'' ?
'&end_h='.$end_h :
'').($begin_d !==
'' ?
'&begin_d='.$begin_d :
'').($end_d !==
'' ?
'&end_d='.$end_d :
'')).
'"
1107 window.location.href = url;
1109 else if (ids.indexOf(",") > -1) /* There is several events */
1111 /* alert(\'several events\'); */
1112 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&search_actioncode="+jQuery("#search_actioncode").val()+"&search_status="+jQuery("#selectsearch_status").val()+"&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
1113 window.location.href = url;
1115 else /* One event */
1117 /* alert(\'one event\'); */
1118 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1119 window.location.href = url;
1152function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $showheader =
false, $colorsbytype = array(), $var =
false)
1155 global $user, $conf, $langs, $hookmanager, $action;
1156 global $filter, $filtert, $status, $actioncode;
1157 global $theme_datacolor;
1158 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1159 global $begin_h, $end_h;
1170 $numicals = array();
1173 $colorindexused[$user->id] = 0;
1174 $nextindextouse = count($colorindexused);
1181 foreach ($eventarray as $daykey => $notused) {
1188 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1192 foreach ($eventarray[$daykey] as $index => $event) {
1196 $keysofuserassigned = array_keys($event->userassigned);
1197 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1199 if (!in_array($username->id, $keysofuserassigned)) {
1204 $parameters = array();
1205 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1214 if (in_array($user->id, $keysofuserassigned)) {
1215 $cssclass =
'family_mytasks';
1217 if (empty($cacheusers[$event->userownerid])) {
1218 $newuser =
new User($db);
1219 $newuser->fetch($event->userownerid);
1220 $cacheusers[$event->userownerid] = $newuser;
1225 if (!empty($cacheusers[$event->userownerid]->color)) {
1226 $color = $cacheusers[$event->userownerid]->color;
1230 $color = $event->type_color;
1232 } elseif ($event->type_code ==
'ICALEVENT') {
1234 if (!empty($event->icalname)) {
1241 $color = $event->icalcolor;
1242 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1243 } elseif ($event->type_code ==
'BIRTHDAY') {
1246 $cssclass =
'family_birthday unsortable';
1247 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1250 $color = ($event->icalcolor ? $event->icalcolor : -1);
1251 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1253 if (empty($cacheusers[$event->userownerid])) {
1254 $newuser =
new User($db);
1255 $newuser->fetch($event->userownerid);
1256 $cacheusers[$event->userownerid] = $newuser;
1261 if (!empty($cacheusers[$event->userownerid]->color)) {
1262 $color = $cacheusers[$event->userownerid]->color;
1266 $color = $event->type_color;
1272 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1273 if (isset($colorindexused[$idusertouse])) {
1274 $colorindex = $colorindexused[$idusertouse];
1276 $colorindex = $nextindextouse;
1277 $colorindexused[$idusertouse] = $colorindex;
1278 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1283 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1287 for ($h = $begin_h; $h < $end_h; $h++) {
1290 if (empty($event->fulldayevent)) {
1291 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1292 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
1293 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1294 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
1295 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1297 $dateendtouse = $event->date_end_in_calendar;
1298 if ($dateendtouse == $event->date_start_in_calendar) {
1304 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1305 $busy = $event->transparency;
1306 $cases1[$h][$event->id][
'busy'] = $busy;
1307 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1308 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1309 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1310 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1311 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1312 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1314 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1317 if ($event->label) {
1318 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1320 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1321 $cases1[$h][$event->id][
'color'] = $color;
1322 if ($event->fk_project > 0) {
1323 if (empty($cacheprojects[$event->fk_project])) {
1325 $tmpproj->fetch($event->fk_project);
1326 $cacheprojects[$event->fk_project] = $tmpproj;
1328 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1330 if ($event->socid > 0) {
1331 if (empty($cachethirdparties[$event->socid])) {
1332 $tmpthirdparty =
new Societe($db);
1333 $tmpthirdparty->fetch($event->socid);
1334 $cachethirdparties[$event->socid] = $tmpthirdparty;
1336 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1338 if ($event->contact_id > 0) {
1339 if (empty($cachecontacts[$event->contact_id])) {
1340 $tmpcontact =
new Contact($db);
1341 $tmpcontact->fetch($event->contact_id);
1342 $cachecontacts[$event->contact_id] = $tmpcontact;
1344 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1347 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
1348 $busy = $event->transparency;
1349 $cases2[$h][$event->id][
'busy'] = $busy;
1350 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1351 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1352 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1353 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1354 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1355 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1357 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1360 if ($event->label) {
1361 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1363 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1364 $cases2[$h][$event->id][
'color'] = $color;
1365 if ($event->fk_project > 0) {
1366 if (empty($cacheprojects[$event->fk_project])) {
1368 $tmpproj->fetch($event->fk_project);
1369 $cacheprojects[$event->fk_project] = $tmpproj;
1371 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1373 if ($event->socid > 0) {
1374 if (empty($cachethirdparties[$event->socid])) {
1375 $tmpthirdparty =
new Societe($db);
1376 $tmpthirdparty->fetch($event->socid);
1377 $cachethirdparties[$event->socid] = $tmpthirdparty;
1379 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1381 if ($event->contact_id > 0) {
1382 if (empty($cachecontacts[$event->contact_id])) {
1383 $tmpcontact =
new Contact($db);
1384 $tmpcontact->fetch($event->contact_id);
1385 $cachecontacts[$event->contact_id] = $tmpcontact;
1387 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1390 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
1391 $busy = $event->transparency;
1392 $cases3[$h][$event->id][
'busy'] = $busy;
1393 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1394 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1395 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1396 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1397 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1398 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1400 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1403 if ($event->label) {
1404 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
1406 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1407 $cases3[$h][$event->id][
'color'] = $color;
1408 if ($event->fk_project > 0) {
1409 if (empty($cacheprojects[$event->fk_project])) {
1411 $tmpproj->fetch($event->fk_project);
1412 $cacheprojects[$event->fk_project] = $tmpproj;
1414 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1416 if ($event->socid > 0) {
1417 if (empty($cachethirdparties[$event->socid])) {
1418 $tmpthirdparty =
new Societe($db);
1419 $tmpthirdparty->fetch($event->socid);
1420 $cachethirdparties[$event->socid] = $tmpthirdparty;
1422 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1424 if ($event->contact_id > 0) {
1425 if (empty($cachecontacts[$event->contact_id])) {
1426 $tmpcontact =
new Contact($db);
1427 $tmpcontact->fetch($event->contact_id);
1428 $cachecontacts[$event->contact_id] = $tmpcontact;
1430 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1433 if ($event->date_start_in_calendar < $c && $dateendtouse > $b2) {
1434 $busy = $event->transparency;
1435 $cases4[$h][$event->id][
'busy'] = $busy;
1436 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1437 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1438 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1439 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1440 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1441 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1443 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1446 if ($event->label) {
1447 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
1449 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1450 $cases4[$h][$event->id][
'color'] = $color;
1451 if ($event->fk_project > 0) {
1452 if (empty($cacheprojects[$event->fk_project])) {
1454 $tmpproj->fetch($event->fk_project);
1455 $cacheprojects[$event->fk_project] = $tmpproj;
1457 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1459 if ($event->socid > 0) {
1460 if (empty($cachethirdparties[$event->socid])) {
1461 $tmpthirdparty =
new Societe($db);
1462 $tmpthirdparty->fetch($event->socid);
1463 $cachethirdparties[$event->socid] = $tmpthirdparty;
1465 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1467 if ($event->contact_id > 0) {
1468 if (empty($cachecontacts[$event->contact_id])) {
1469 $tmpcontact =
new Contact($db);
1470 $tmpcontact->fetch($event->contact_id);
1471 $cachecontacts[$event->contact_id] = $tmpcontact;
1473 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1477 $busy = $event->transparency;
1478 $cases1[$h][$event->id][
'busy'] = $busy;
1479 $cases2[$h][$event->id][
'busy'] = $busy;
1480 $cases3[$h][$event->id][
'busy'] = $busy;
1481 $cases4[$h][$event->id][
'busy'] = $busy;
1482 $cases1[$h][$event->id][
'string'] = $event->label;
1483 $cases2[$h][$event->id][
'string'] = $event->label;
1484 $cases3[$h][$event->id][
'string'] = $event->label;
1485 $cases4[$h][$event->id][
'string'] = $event->label;
1486 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1487 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1488 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1489 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1490 $cases1[$h][$event->id][
'color'] = $color;
1491 $cases2[$h][$event->id][
'color'] = $color;
1492 $cases3[$h][$event->id][
'color'] = $color;
1493 $cases4[$h][$event->id][
'color'] = $color;
1504 for ($h = $begin_h; $h < $end_h; $h++) {
1513 $string1 =
' ';
1514 $string2 =
' ';
1515 $string3 =
' ';
1516 $string4 =
' ';
1521 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1523 if (count($cases1[$h]) > 1) {
1524 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1528 $style1 =
'peruser_notbusy';
1530 $style1 =
'peruser_busy';
1532 foreach ($cases1[$h] as
$id => $ev) {
1534 $style1 =
'peruser_busy';
1538 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1540 if (count($cases2[$h]) > 1) {
1541 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1545 $style2 =
'peruser_notbusy';
1547 $style2 =
'peruser_busy';
1549 foreach ($cases2[$h] as
$id => $ev) {
1551 $style2 =
'peruser_busy';
1555 if (isset($cases3[$h]) && $cases3[$h] !=
'') {
1557 if (count($cases3[$h]) > 1) {
1558 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1562 $style3 =
'peruser_notbusy';
1564 $style3 =
'peruser_busy';
1566 foreach ($cases3[$h] as
$id => $ev) {
1568 $style3 =
'peruser_busy';
1572 if (isset($cases4[$h]) && $cases4[$h] !=
'') {
1574 if (count($cases4[$h]) > 1) {
1575 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1579 $style4 =
'peruser_notbusy';
1581 $style4 =
'peruser_busy';
1583 foreach ($cases4[$h] as
$id => $ev) {
1585 $style4 =
'peruser_busy';
1594 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1595 $ids1 = implode(
', ', array_keys($cases1[$h]));
1597 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1598 $ids2 = implode(
', ', array_keys($cases2[$h]));
1600 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
1601 $ids3 = implode(
',', array_keys($cases3[$h]));
1603 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
1604 $ids4 = implode(
',', array_keys($cases4[$h]));
1607 if ($h == $begin_h) {
1608 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1610 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1613 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1614 $output = array_slice($cases1[$h], 0, 1);
1615 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1616 if ($output[0][
'string']) {
1617 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1619 if ($output[0][
'color']) {
1620 $color1 = $output[0][
'color'];
1622 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1623 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1628 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1629 $output = array_slice($cases2[$h], 0, 1);
1630 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1631 if ($output[0][
'string']) {
1632 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1634 if ($output[0][
'color']) {
1635 $color2 = $output[0][
'color'];
1637 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1638 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1643 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
1644 $output = array_slice($cases3[$h], 0, 1);
1645 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1646 if ($output[0][
'string']) {
1647 $title3 .= ($title3 ?
' - ' :
'').$output[0][
'string'];
1649 if ($output[0][
'color']) {
1650 $color3 = $output[0][
'color'];
1652 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
1653 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1658 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
1659 $output = array_slice($cases4[$h], 0, 1);
1660 $title4 = $langs->trans(
"Ref").
' '.$ids3.($title4 ?
' - '.$title4 :
'');
1661 if ($output[0][
'string']) {
1662 $title4 .= ($title4 ?
' - ' :
'').$output[0][
'string'];
1664 if ($output[0][
'color']) {
1665 $color4 = $output[0][
'color'];
1667 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
1668 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
1672 print
'<table class="nobordernopadding case centpercent">';
1675 if ($style1 ==
'peruser_notbusy') {
1676 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
1677 } elseif ($color1) {
1678 print($color1 ?
'style="background: #'.$color1.
';"' :
'');
1681 print($style1 ? $style1.
' ' :
'');
1682 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_00_'.($ids1 ? $ids1 :
'none').
'"'.($title1 ?
' title="'.$title1.
'"' :
'').
'>';
1687 if ($style2 ==
'peruser_notbusy') {
1688 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
1689 } elseif ($color2) {
1690 print($color2 ?
'style="background: #'.$color2.
';"' :
'');
1693 print($style2 ? $style2.
' ' :
'');
1694 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_15_'.($ids2 ? $ids2 :
'none').
'"'.($title2 ?
' title="'.$title2.
'"' :
'').
'>';
1699 if ($style3 ==
'peruser_notbusy') {
1700 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
1701 } elseif ($color3) {
1702 print($color3 ?
'style="background: #'.$color3.
';"' :
'');
1705 print($style3 ? $style3.
' ' :
'');
1706 print
'onclickopenref center'.($title2 ?
' classfortooltip' :
'').($title3 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids3 ? $ids3 :
'none').
'"'.($title3 ?
' title="'.$title3.
'"' :
'').
'>';
1711 if ($style4 ==
'peruser_notbusy') {
1712 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
1713 } elseif ($color4) {
1714 print($color4 ?
'style="background: #'.$color4.
';"' :
'');
1717 print($style4 ? $style4.
' ' :
'');
1718 print
'onclickopenref center'.($title3 ?
' classfortooltip' :
'').($title4 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_45_'.($ids4 ? $ids4 :
'none').
'"'.($title4 ?
' title="'.$title4.
'"' :
'').
'>';
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...)
Class to manage Dolibarr users.
dol_get_next_week($day, $week, $month, $year)
Return next week.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed 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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
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.