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';
52if (!isset(
$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
53 $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
56$action =
GETPOST(
'action',
'aZ09');
58$disabledefaultvalues =
GETPOSTINT(
'disabledefaultvalues');
60$filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
73$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
76if (empty($page) || $page == -1) {
80$offset = $limit * $page;
85 $sortfield =
"a.datec";
90 $socid = $user->socid;
97if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
100if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
103if (!$user->hasRight(
'agenda',
'allactions',
'read') || $filter ==
'mine') {
104 $filtert = $user->id;
107$mode =
'show_peruser';
113$pid = GETPOSTISSET(
"search_projectid") ?
GETPOSTINT(
"search_projectid", 3) :
GETPOSTINT(
"projectid", 3);
114$status = GETPOSTISSET(
"search_status") ?
GETPOST(
"search_status",
'aZ09') :
GETPOST(
"status",
'aZ09');
115$type = GETPOSTISSET(
"search_type") ?
GETPOST(
"search_type",
'alpha') :
GETPOST(
"type",
'alpha');
117$optioncss =
GETPOST(
'optioncss',
'aZ');
120if (
GETPOST(
'search_actioncode',
'array:aZ09')) {
121 $actioncode =
GETPOST(
'search_actioncode',
'array:aZ09', 3);
122 if (!count($actioncode)) {
126 $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')));
130if ($dateselect > 0) {
137$tmp = str_replace(
' ',
'', $tmp);
138$tmparray = explode(
'-', $tmp);
139$begin_h = GETPOSTISSET(
'begin_h') ?
GETPOSTINT(
'begin_h') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
140$end_h = GETPOSTISSET(
'end_h') ?
GETPOSTINT(
'end_h') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
141if ($begin_h < 0 || $begin_h > 23) {
144if ($end_h < 1 || $end_h > 24) {
147if ($end_h <= $begin_h) {
148 $end_h = $begin_h + 1;
152$tmp = str_replace(
' ',
'', $tmp);
153$tmparray = explode(
'-', $tmp);
154$begin_d = GETPOSTISSET(
'begin_d') ?
GETPOSTINT(
'begin_d') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
155$end_d = GETPOSTISSET(
'end_d') ?
GETPOSTINT(
'end_d') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
156if ($begin_d < 1 || $begin_d > 7) {
159if ($end_d < 1 || $end_d > 7) {
162if ($end_d < $begin_d) {
163 $end_d = $begin_d + 1;
166if ($status ==
'' && !GETPOSTISSET(
'search_status')) {
167 $status = ((!
getDolGlobalString(
'AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ?
'' :
$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
170if (empty($mode) && !GETPOSTISSET(
'mode')) {
174if (
GETPOST(
'viewcal',
'alpha') && $mode !=
'show_day' && $mode !=
'show_week' && $mode !=
'show_peruser') {
175 $mode =
'show_month';
178if (
GETPOST(
'viewweek',
'alpha') || $mode ==
'show_week') {
180 $week = ($week ? $week : idate(
"W"));
181 $day = ($day ? $day : idate(
"d"));
183if (
GETPOST(
'viewday',
'alpha') || $mode ==
'show_day') {
185 $day = ($day ? $day : idate(
"d"));
191$langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
194$hookmanager->initHooks(array(
'agenda'));
197if ($user->socid && $socid) {
201$search_status = $status;
222 'maxprint' => $maxprint,
224 'filtert' => $filtert,
225 'showbirthday' => $showbirthday,
226 'canedit' => $canedit,
227 'optioncss' => $optioncss,
228 'actioncode' => $actioncode,
230 'resourceid' => $resourceid,
231 'usergroup' => $usergroup,
233$reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
238$form =
new Form($db);
239$companystatic =
new Societe($db);
241$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
242llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
246$nowyear = $nowarray[
'year'];
247$nowmonth = $nowarray[
'mon'];
248$nowday = $nowarray[
'mday'];
252$listofextcals = array();
255$first_day = $prev[
'first_day'];
256$first_month = $prev[
'first_month'];
257$first_year = $prev[
'first_year'];
259$week = $prev[
'week'];
263$next_year = $next[
'year'];
264$next_month = $next[
'month'];
265$next_day = $next[
'day'];
267$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
273$title = $langs->trans(
"DoneAndToDoActions");
274if ($status ==
'done') {
275 $title = $langs->trans(
"DoneActions");
277if ($status ==
'todo') {
278 $title = $langs->trans(
"ToDoActions");
282if ($actioncode || GETPOSTISSET(
'search_actioncode')) {
283 if (is_array($actioncode)) {
284 foreach ($actioncode as $str_action) {
285 $param .=
"&search_actioncode[]=".urlencode($str_action);
288 $param .=
"&search_actioncode=".urlencode($actioncode);
291if ($resourceid > 0) {
292 $param .=
"&search_resourceid=".urlencode((
string) ($resourceid));
295if ($status || GETPOSTISSET(
'status') || GETPOSTISSET(
'search_status')) {
296 $param .=
"&search_status=".urlencode($status);
299 $param .=
"&search_filter=".urlencode($filter);
302 $param .=
"&search_filtert=".urlencode((
string) $filtert);
305 $param .=
"&search_usergroup=".urlencode((
string) ($usergroup));
308 $param .=
"&search_socid=".urlencode((
string) ($socid));
311 $param .=
"&search_showbirthday=1";
314 $param .=
"&search_projectid=".urlencode((
string) ($pid));
317 $param .=
"&search_type=".urlencode($type);
319if ($mode !=
'show_peruser') {
320 $param .=
'&mode='.urlencode((
string) $mode);
323 $param .=
'&begin_h='.((int) $begin_h);
326 $param .=
'&end_h='.((int) $end_h);
329 $param .=
'&begin_d='.((int) $begin_d);
332 $param .=
'&end_d='.((int) $end_d);
334if ($search_categ_cus != 0) {
335 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
337$param .=
"&maxprint=".urlencode((
string) ($maxprint));
339$paramnoactionodate = $param;
344$prev_year = $prev[
'prev_year'];
345$prev_month = $prev[
'prev_month'];
346$prev_day = $prev[
'prev_day'];
347$first_day = $prev[
'first_day'];
348$first_month = $prev[
'first_month'];
349$first_year = $prev[
'first_year'];
351$week = $prev[
'week'];
355$next_year = $next[
'year'];
356$next_month = $next[
'month'];
357$next_day = $next[
'day'];
361$firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'tzuserrel');
362$nb_weeks_to_show = (
getDolGlobalString(
'AGENDA_NB_WEEKS_IN_VIEW_PER_USER')) ? ((
int)
$conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
368$max_day_in_month = idate(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
371$picto =
'calendarweek';
374$nav =
'<div class="navselectiondate inline-block nowraponall">';
375$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";
376$nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
378$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";
379if (empty(
$conf->dol_optimize_smallscreen)) {
380 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
'" class="datenowlink">'.$langs->trans(
"Today").
'</a> ';
383$nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
384$nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
387$param .=
'&year='.urlencode((
string) ($year)).
'&month='.urlencode((
string) ($month)).($day ?
'&day='.urlencode((
string) ($day)) :
'');
391$paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
395print
'<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
397$showextcals = $listofextcals;
399if (
$conf->use_javascript_ajax) {
401 $s .=
'<script type="text/javascript">'.
"\n";
402 $s .=
'jQuery(document).ready(function () {'.
"\n";
403 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
404 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
405 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
406 if ($mode ==
"show_week" || $mode ==
"show_month" || empty($mode)) {
407 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
410 $s .=
'</script>'.
"\n";
411 if (!empty(
$conf->use_javascript_ajax)) {
412 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
413 if (is_array($showextcals) && count($showextcals) > 0) {
414 foreach ($showextcals as $val) {
415 $htmlname = md5($val[
'name']);
416 $s .=
'<script type="text/javascript">'.
"\n";
417 $s .=
'jQuery(document).ready(function () {'.
"\n";
418 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
419 $s .=
' /* alert("'.$htmlname.
'"); */';
420 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
423 $s .=
'</script>'.
"\n";
424 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
431 $parameters = array();
432 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
433 if (empty($reshook)) {
434 $s .= $hookmanager->resPrint;
435 } elseif ($reshook > 1) {
436 $s = $hookmanager->resPrint;
441$mode =
'show_peruser';
442$massactionbutton =
'';
445$viewmode =
'<div class="navmode inline-block">';
447$viewmode .=
'<a class="btnTitle'.($mode ==
'list' ?
' btnTitleSelected' :
'').
' reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1'.$paramnoactionodate.
'">';
449$viewmode .=
img_picto($langs->trans(
"List"),
'object_calendarlist',
'class="imgforviewmode pictoactionview block"');
451$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewList").
'</span></a>';
453$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.
'">';
455$viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="pictoactionview block"');
457$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewCal").
'</span></a>';
459$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.
'">';
461$viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
463$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewWeek").
'</span></a>';
465$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.
'">';
467$viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
469$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow">'.$langs->trans(
"ViewDay").
'</span></a>';
471$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.
'">';
473$viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
475$viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone inline-block width75 divoverflow" title="'.dolPrintHTML($langs->trans(
"ViewPerUser")).
'">'.$langs->trans(
"ViewPerUser").
'</span></a>';
478$parameters = array();
480$reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
481if (empty($reshook)) {
482 $viewmode .= $hookmanager->resPrint;
483} elseif ($reshook > 1) {
484 $viewmode = $hookmanager->resPrint;
487$viewmode .=
'</div>';
489$viewmode .=
'<span class="marginrightonly"></span>';
494if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
497 $newparam .=
'&month='.urlencode(str_pad((
string) $month, 2,
"0", STR_PAD_LEFT)).
'&year='.((int) $tmpforcreatebutton[
'year']);
498 if ($begin_h !==
'') {
499 $newparam .=
'&begin_h='.((int) $begin_h);
502 $newparam .=
'&end_h='.((int) $end_h);
504 if ($begin_d !==
'') {
505 $newparam .=
'&begin_d='.((int) $begin_d);
508 $newparam .=
'&end_d='.((int) $end_d);
511 $urltocreateaction = DOL_URL_ROOT.
'/comm/action/card.php?action=create';
512 $urltocreateaction .=
'&apyear='.$tmpforcreatebutton[
'year'].
'&apmonth='.$tmpforcreatebutton[
'mon'].
'&apday='.$tmpforcreatebutton[
'mday'].
'&aphour='.$tmpforcreatebutton[
'hours'].
'&apmin='.$tmpforcreatebutton[
'minutes'];
513 $urltocreateaction .=
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
515 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', $urltocreateaction);
520print_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);
526$s .=
"\n".
'<!-- Div to calendars selectors -->'.
"\n";
529$newtitle =
'<div class="nowrap clear inline-block minheight30">';
530$newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
531$newtitle .=
'</div>';
537$parameters = array();
538$reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
539if (empty($reshook)) {
540 $s .= $hookmanager->resPrint;
541} elseif ($reshook > 1) {
542 $s = $hookmanager->resPrint;
545$s .=
"\n".
'<!-- End div to calendars selectors -->'.
"\n";
549print
'<div class="liste_titre liste_titre_bydiv centpercent">';
550print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday,
'', (
string) $filtert,
'', $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid, $search_categ_cus);
555$eventarray = array();
563$sql .=
" a.id, a.label,";
566$sql .=
" a.percent,";
567$sql .=
" a.fk_user_author,a.fk_user_action,";
568$sql .=
" a.transparency, a.priority, a.fulldayevent, a.location,";
569$sql .=
" a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,";
570$sql .=
" ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto";
571$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as ca, ".MAIN_DB_PREFIX.
"actioncomm as a";
573if ($resourceid > 0) {
574 $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
577if ($filtert > 0 || $usergroup > 0) {
578 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
579 $sql .=
" ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
581 $sql .=
" AND ar.fk_element = ".((int) $filtert);
583 if ($usergroup > 0) {
584 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup = ".((int) $usergroup);
588$sql .=
" WHERE a.fk_action = ca.id";
589$sql .=
" AND a.entity IN (".getEntity(
'agenda').
")";
591if (!empty($actioncode)) {
593 if ($actioncode ==
'AC_NON_AUTO') {
594 $sql .=
" AND ca.type != 'systemauto'";
595 } elseif ($actioncode ==
'AC_ALL_AUTO') {
596 $sql .=
" AND ca.type = 'systemauto'";
598 if ($actioncode ==
'AC_OTH') {
599 $sql .=
" AND ca.type != 'systemauto'";
601 if ($actioncode ==
'AC_OTH_AUTO') {
602 $sql .=
" AND ca.type = 'systemauto'";
606 if ($actioncode ==
'AC_NON_AUTO') {
607 $sql .=
" AND ca.type != 'systemauto'";
608 } elseif ($actioncode ==
'AC_ALL_AUTO') {
609 $sql .=
" AND ca.type = 'systemauto'";
611 if (is_array($actioncode)) {
612 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", $actioncode).
"'", 1).
")";
614 $sql .=
" AND ca.code IN (".$db->sanitize(
"'".implode(
"','", explode(
',', $actioncode)).
"'", 1).
")";
619if ($resourceid > 0) {
620 $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
623 $sql .=
" AND a.fk_project = ".((int) $pid);
627if (!$user->hasRight(
'societe',
'client',
'voir')) {
628 $search_sale = $user->id;
631if ($search_sale && $search_sale !=
'-1') {
632 if ($search_sale == -2) {
633 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)";
634 } elseif ($search_sale > 0) {
635 $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).
")";
640 $sql .=
" AND a.fk_soc = ".((int) $socid);
643if ($mode ==
'show_day') {
645 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
646 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
648 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
649 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
651 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
652 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
657 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
658 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
660 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
661 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
663 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
664 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
668 $sql .=
" AND ca.id = ".((int) $type);
671 $sql .=
" AND a.percent = 0";
673if ($status ===
'na') {
675 $sql .=
" AND a.percent = -1";
677if ($status ==
'50') {
679 $sql .=
" AND (a.percent > 0 AND a.percent < 100)";
681if ($status ==
'done' || $status ==
'100') {
682 $sql .=
" AND (a.percent = 100)";
684if ($status ==
'todo') {
685 $sql .=
" AND (a.percent >= 0 AND a.percent < 100)";
688if ($search_categ_cus != -1) {
689 if ($search_categ_cus == -2) {
690 $sql .=
" AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX.
"categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)";
691 } elseif ($search_categ_cus > 0) {
692 $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).
"))";
696$sql .= $db->order(
"fk_user_action, datep");
699dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
700$resql = $db->query($sql);
702 $num = $db->num_rows($resql);
706 $obj = $db->fetch_object($resql);
715 $datep = $db->jdate($obj->datep);
716 $datep2 = $db->jdate($obj->datep2);
721 $event->id = $obj->id;
722 $event->datep = $datep;
723 $event->datef = $datep2;
724 $event->type_code = $obj->code;
725 $event->type_color = $obj->color;
726 $event->label = $obj->label;
727 $event->percentage = $obj->percent;
728 $event->authorid = $obj->fk_user_author;
729 $event->userownerid = $obj->fk_user_action;
730 $event->priority = $obj->priority;
731 $event->fulldayevent = $obj->fulldayevent;
732 $event->location = $obj->location;
733 $event->transparency = $obj->transparency;
735 $event->fk_project = $obj->fk_project;
737 $event->socid = $obj->fk_soc;
738 $event->contact_id = $obj->fk_contact;
740 $event->fk_element = $obj->fk_element;
741 $event->elementid = $obj->fk_element;
742 $event->elementtype = $obj->elementtype;
746 $event->date_start_in_calendar = $datep;
747 if ($datep2 !=
'' && $datep2 >= $datep) {
748 $event->date_end_in_calendar = $datep2;
750 $event->date_end_in_calendar = $datep;
756 if ($event->date_end_in_calendar < $firstdaytoshow ||
757 $event->date_start_in_calendar >= $lastdaytoshow) {
762 $event->fetch_userassigned();
764 if ($event->date_start_in_calendar < $firstdaytoshow) {
765 $event->date_start_in_calendar = $firstdaytoshow;
767 if ($event->date_end_in_calendar >= $lastdaytoshow) {
768 $event->date_end_in_calendar = ($lastdaytoshow - 1);
772 $daycursor = $event->date_start_in_calendar;
781 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
785 $eventarray[$daykey][] = $event;
788 $daykey += 60 * 60 * 24;
789 if ($daykey > $event->date_end_in_calendar) {
805$cachethirdparties = array();
806$cachecontacts = array();
807$cacheusers = array();
810$color_file = DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
811if (is_readable($color_file)) {
814if (!is_array($theme_datacolor)) {
815 $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
820$newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
821$newparam = preg_replace(
'/mode=show_month&?/i',
'', $newparam);
822$newparam = preg_replace(
'/mode=show_week&?/i',
'', $newparam);
823$newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
824$newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
825$newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
826$newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
827$newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
828$newparam .=
'&viewweek=1';
830echo
'<input type="hidden" name="actionmove" value="mupdate">';
831echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
832echo
'<input type="hidden" name="newdate" id="newdate">';
839$currentdaytoshow = $firstdaytoshow;
840echo
'<div class="div-table-responsive">';
843$colorsbytype = array();
845while ($currentdaytoshow < $lastdaytoshow) {
846 echo
'<table class="centpercent noborder nocellnopadd cal_month listwithfilterbefore">';
848 echo
'<tr class="liste_titre">';
849 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
851 if ($canedit && $mode ==
'show_peruser') {
853 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">';
854 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
855 print $langs->trans(
"DaysOfWeek").
'</span>';
857 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
858 print
'<input type="number" class="short" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
859 if (empty(
$conf->dol_use_jmobile)) {
862 print
'</div><div class="ui-block-b">';
864 print
'<input type="number" class="short" name="end_d" value="'.$end_d.
'" min="1" max="7">';
865 print
'</div></div>';
871 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
875 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
876 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
888 echo
'<tr class="liste_titre">';
892 print
'<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">';
893 print
img_picto(
'',
'clock',
'class="fawidth30 inline-block marginleftonly"');
894 print $langs->trans(
"Hours").
'</span>';
896 print
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
897 print
'<input type="number" class="short" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
898 if (empty(
$conf->dol_use_jmobile)) {
901 print
'</div><div class="ui-block-b">';
903 print
'<input type="number" class="short" name="end_h" value="'.$end_h.
'" min="1" max="24">';
904 if (empty(
$conf->dol_use_jmobile)) {
905 print
' '.$langs->trans(
"H");
907 print
'</div></div>';
912 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
916 for ($h = $begin_h; $h < $end_h; $h++) {
917 echo
'<td class="center">';
918 print
'<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
928 $usernames = array();
929 $usernamesid = array();
932 foreach ($eventarray as $daykey => $notused) {
934 foreach ($eventarray[$daykey] as $index => $event) {
935 $event->fetch_userassigned();
936 $listofuserid = $event->userassigned;
937 foreach ($listofuserid as $userid => $tmp) {
938 if (!in_array($userid, $usernamesid)) {
939 $usernamesid[$userid] = $userid;
946 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
947 $sql .=
" FROM ".$db->prefix().
"user as u";
948 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
949 $sql .=
" WHERE u.rowid IN (";
950 $sql .=
" SELECT ug.fk_user FROM ".$db->prefix().
"usergroup_user as ug";
951 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
952 if ($usergroup > 0) {
953 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
957 if ($usergroup > 0) {
958 $sql .=
" LEFT JOIN ".$db->prefix().
"usergroup_user as ug ON u.rowid = ug.fk_user";
960 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
961 if ($usergroup > 0) {
962 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
965 $sql .=
" AND u.statut = 1";
967 $sql .=
" AND u.rowid = ".((int) $filtert);
969 if ($usergroup > 0) {
970 $sql .=
" AND ug.fk_usergroup = ".((int) $usergroup);
972 if ($user->socid > 0) {
974 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
978 $resql = $db->query($sql);
980 $num = $db->num_rows($resql);
984 $obj = $db->fetch_object($resql);
985 $usernamesid[$obj->rowid] = $obj->rowid;
994 foreach ($usernamesid as
$id) {
995 $tmpuser =
new User($db);
996 $result = $tmpuser->fetch(
$id);
997 $usernames[] = $tmpuser;
1001 $labelbytype = array();
1002 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
1003 $resql = $db->query($sql);
1004 while ($obj = $db->fetch_object($resql)) {
1005 $colorsbytype[$obj->code] = $obj->color;
1006 $labelbytype[$obj->code] = $obj->label;
1014 foreach ($usernames as $username) {
1020 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
1021 print
'<span class="paddingrightimp">';
1022 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'',
'paddingleft');
1029 for ($iter_day = 0; $iter_day < 8; $iter_day++) {
1030 if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
1043 $style =
'cal_current_month';
1044 if ($iter_day == 6) {
1045 $style .=
' cal_other_month';
1048 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) {
1052 $style =
'cal_today_peruser';
1055 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
1060 $showheader =
false;
1072 $langs->load(
"commercial");
1073 print
'<br>'.$langs->trans(
"Legend").
': <br>';
1074 foreach ($colorsbytype as $code => $color) {
1076 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
1077 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
1083 print
'<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
1084 print $langs->trans(
"Other");
1093print
"\n".
'</form>';
1097print
'<script type="text/javascript">
1098jQuery(document).ready(function() {
1099 jQuery(".onclickopenref").click(function() {
1100 console.log("We click on a class onclickopenref");
1102 var ref=$(this).attr(\'ref\');
1103 var res = ref.split("_");
1104 var userid = res[1];
1111 if (ids == \'none\') /* No event */
1113 /* alert(\'no event\'); */
1114 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 :
'')).
'"
1115 window.location.href = url;
1117 else if (ids.indexOf(",") > -1) /* There is several events */
1119 /* alert(\'several events\'); */
1120 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;
1121 window.location.href = url;
1123 else /* One event */
1125 /* alert(\'one event\'); */
1126 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
1127 window.location.href = url;
1160function 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)
1163 global $user,
$conf, $langs, $hookmanager, $action;
1164 global $filter, $filtert, $status, $actioncode;
1165 global $theme_datacolor;
1166 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
1167 global $begin_h, $end_h;
1178 $numicals = array();
1181 $colorindexused[$user->id] = 0;
1182 $nextindextouse = count($colorindexused);
1189 foreach ($eventarray as $daykey => $notused) {
1196 if ($day == $jour && (
int) $month == (
int) $mois && $year == $annee) {
1200 foreach ($eventarray[$daykey] as $index => $event) {
1204 $keysofuserassigned = array_keys($event->userassigned);
1205 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1207 if (!in_array($username->id, $keysofuserassigned)) {
1212 $parameters = array();
1213 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1222 if (in_array($user->id, $keysofuserassigned)) {
1223 $cssclass =
'family_mytasks';
1225 if (empty($cacheusers[$event->userownerid])) {
1226 $newuser =
new User($db);
1227 $newuser->fetch($event->userownerid);
1228 $cacheusers[$event->userownerid] = $newuser;
1233 if (!empty($cacheusers[$event->userownerid]->color)) {
1234 $color = $cacheusers[$event->userownerid]->color;
1238 $color = $event->type_color;
1240 } elseif ($event->type_code ==
'ICALEVENT') {
1242 if (!empty($event->icalname)) {
1249 $color = $event->icalcolor;
1250 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1251 } elseif ($event->type_code ==
'BIRTHDAY') {
1254 $cssclass =
'family_birthday unsortable';
1255 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1258 $color = ($event->icalcolor ? $event->icalcolor : -1);
1259 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1261 if (empty($cacheusers[$event->userownerid])) {
1262 $newuser =
new User($db);
1263 $newuser->fetch($event->userownerid);
1264 $cacheusers[$event->userownerid] = $newuser;
1269 if (!empty($cacheusers[$event->userownerid]->color)) {
1270 $color = $cacheusers[$event->userownerid]->color;
1274 $color = $event->type_color;
1280 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1281 if (isset($colorindexused[$idusertouse])) {
1282 $colorindex = $colorindexused[$idusertouse];
1284 $colorindex = $nextindextouse;
1285 $colorindexused[$idusertouse] = $colorindex;
1286 if (!empty($theme_datacolor[$nextindextouse + 1])) {
1291 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1295 for ($h = $begin_h; $h < $end_h; $h++) {
1298 if (empty($event->fulldayevent)) {
1299 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1300 $b =
dol_mktime((
int) $h, 15, 0, $month, $day, $year,
'tzuserrel', 0);
1301 $b1 =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1302 $b2 =
dol_mktime((
int) $h, 45, 0, $month, $day, $year,
'tzuserrel', 0);
1303 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1305 $dateendtouse = $event->date_end_in_calendar;
1306 if ($dateendtouse == $event->date_start_in_calendar) {
1312 if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
1313 $busy = $event->transparency;
1314 $cases1[$h][$event->id][
'busy'] = $busy;
1315 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1316 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1317 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1318 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1319 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1320 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1322 $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1325 if ($event->label) {
1326 $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1328 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1329 $cases1[$h][$event->id][
'color'] = $color;
1330 if ($event->fk_project > 0) {
1331 if (empty($cacheprojects[$event->fk_project])) {
1333 $tmpproj->fetch($event->fk_project);
1334 $cacheprojects[$event->fk_project] = $tmpproj;
1336 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1338 if ($event->socid > 0) {
1339 if (empty($cachethirdparties[$event->socid])) {
1340 $tmpthirdparty =
new Societe($db);
1341 $tmpthirdparty->fetch($event->socid);
1342 $cachethirdparties[$event->socid] = $tmpthirdparty;
1344 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1346 if ($event->contact_id > 0) {
1347 if (empty($cachecontacts[$event->contact_id])) {
1348 $tmpcontact =
new Contact($db);
1349 $tmpcontact->fetch($event->contact_id);
1350 $cachecontacts[$event->contact_id] = $tmpcontact;
1352 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1355 if ($event->date_start_in_calendar < $b1 && $dateendtouse > $b) {
1356 $busy = $event->transparency;
1357 $cases2[$h][$event->id][
'busy'] = $busy;
1358 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1359 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1360 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1361 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1362 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1363 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1365 $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1368 if ($event->label) {
1369 $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1371 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1372 $cases2[$h][$event->id][
'color'] = $color;
1373 if ($event->fk_project > 0) {
1374 if (empty($cacheprojects[$event->fk_project])) {
1376 $tmpproj->fetch($event->fk_project);
1377 $cacheprojects[$event->fk_project] = $tmpproj;
1379 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1381 if ($event->socid > 0) {
1382 if (empty($cachethirdparties[$event->socid])) {
1383 $tmpthirdparty =
new Societe($db);
1384 $tmpthirdparty->fetch($event->socid);
1385 $cachethirdparties[$event->socid] = $tmpthirdparty;
1387 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1389 if ($event->contact_id > 0) {
1390 if (empty($cachecontacts[$event->contact_id])) {
1391 $tmpcontact =
new Contact($db);
1392 $tmpcontact->fetch($event->contact_id);
1393 $cachecontacts[$event->contact_id] = $tmpcontact;
1395 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1398 if ($event->date_start_in_calendar < $b2 && $dateendtouse > $b1) {
1399 $busy = $event->transparency;
1400 $cases3[$h][$event->id][
'busy'] = $busy;
1401 $cases3[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1402 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1403 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1404 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1405 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1406 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1408 $cases3[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1411 if ($event->label) {
1412 $cases3[$h][$event->id][
'string'] .=
' - '.$event->label;
1414 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1415 $cases3[$h][$event->id][
'color'] = $color;
1416 if ($event->fk_project > 0) {
1417 if (empty($cacheprojects[$event->fk_project])) {
1419 $tmpproj->fetch($event->fk_project);
1420 $cacheprojects[$event->fk_project] = $tmpproj;
1422 $cases3[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1424 if ($event->socid > 0) {
1425 if (empty($cachethirdparties[$event->socid])) {
1426 $tmpthirdparty =
new Societe($db);
1427 $tmpthirdparty->fetch($event->socid);
1428 $cachethirdparties[$event->socid] = $tmpthirdparty;
1430 $cases3[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1432 if ($event->contact_id > 0) {
1433 if (empty($cachecontacts[$event->contact_id])) {
1434 $tmpcontact =
new Contact($db);
1435 $tmpcontact->fetch($event->contact_id);
1436 $cachecontacts[$event->contact_id] = $tmpcontact;
1438 $cases3[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1441 if ($event->date_start_in_calendar < $c && $dateendtouse > $b2) {
1442 $busy = $event->transparency;
1443 $cases4[$h][$event->id][
'busy'] = $busy;
1444 $cases4[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1445 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
1446 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1447 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1448 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1449 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1451 $cases4[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1454 if ($event->label) {
1455 $cases4[$h][$event->id][
'string'] .=
' - '.$event->label;
1457 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1458 $cases4[$h][$event->id][
'color'] = $color;
1459 if ($event->fk_project > 0) {
1460 if (empty($cacheprojects[$event->fk_project])) {
1462 $tmpproj->fetch($event->fk_project);
1463 $cacheprojects[$event->fk_project] = $tmpproj;
1465 $cases4[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1467 if ($event->socid > 0) {
1468 if (empty($cachethirdparties[$event->socid])) {
1469 $tmpthirdparty =
new Societe($db);
1470 $tmpthirdparty->fetch($event->socid);
1471 $cachethirdparties[$event->socid] = $tmpthirdparty;
1473 $cases4[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1475 if ($event->contact_id > 0) {
1476 if (empty($cachecontacts[$event->contact_id])) {
1477 $tmpcontact =
new Contact($db);
1478 $tmpcontact->fetch($event->contact_id);
1479 $cachecontacts[$event->contact_id] = $tmpcontact;
1481 $cases4[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1485 $busy = $event->transparency;
1486 $cases1[$h][$event->id][
'busy'] = $busy;
1487 $cases2[$h][$event->id][
'busy'] = $busy;
1488 $cases3[$h][$event->id][
'busy'] = $busy;
1489 $cases4[$h][$event->id][
'busy'] = $busy;
1490 $cases1[$h][$event->id][
'string'] = $event->label;
1491 $cases2[$h][$event->id][
'string'] = $event->label;
1492 $cases3[$h][$event->id][
'string'] = $event->label;
1493 $cases4[$h][$event->id][
'string'] = $event->label;
1494 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1495 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1496 $cases3[$h][$event->id][
'typecode'] = $event->type_code;
1497 $cases4[$h][$event->id][
'typecode'] = $event->type_code;
1498 $cases1[$h][$event->id][
'color'] = $color;
1499 $cases2[$h][$event->id][
'color'] = $color;
1500 $cases3[$h][$event->id][
'color'] = $color;
1501 $cases4[$h][$event->id][
'color'] = $color;
1512 for ($h = $begin_h; $h < $end_h; $h++) {
1521 $string1 =
' ';
1522 $string2 =
' ';
1523 $string3 =
' ';
1524 $string4 =
' ';
1529 if (isset($cases1[$h]) && $cases1[$h] !=
'') {
1531 if (count($cases1[$h]) > 1) {
1532 $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1536 $style1 =
'peruser_notbusy';
1538 $style1 =
'peruser_busy';
1540 foreach ($cases1[$h] as
$id => $ev) {
1542 $style1 =
'peruser_busy';
1546 if (isset($cases2[$h]) && $cases2[$h] !=
'') {
1548 if (count($cases2[$h]) > 1) {
1549 $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1553 $style2 =
'peruser_notbusy';
1555 $style2 =
'peruser_busy';
1557 foreach ($cases2[$h] as
$id => $ev) {
1559 $style2 =
'peruser_busy';
1563 if (isset($cases3[$h]) && $cases3[$h] !=
'') {
1565 if (count($cases3[$h]) > 1) {
1566 $title3 .= count($cases3[$h]).
' '.(count($cases3[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1570 $style3 =
'peruser_notbusy';
1572 $style3 =
'peruser_busy';
1574 foreach ($cases3[$h] as
$id => $ev) {
1576 $style3 =
'peruser_busy';
1580 if (isset($cases4[$h]) && $cases4[$h] !=
'') {
1582 if (count($cases4[$h]) > 1) {
1583 $title4 .= count($cases4[$h]).
' '.(count($cases4[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1587 $style4 =
'peruser_notbusy';
1589 $style4 =
'peruser_busy';
1591 foreach ($cases4[$h] as
$id => $ev) {
1593 $style4 =
'peruser_busy';
1602 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
1603 $ids1 = implode(
', ', array_keys($cases1[$h]));
1605 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
1606 $ids2 = implode(
', ', array_keys($cases2[$h]));
1608 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) && array_keys($cases3[$h])) {
1609 $ids3 = implode(
',', array_keys($cases3[$h]));
1611 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) && array_keys($cases4[$h])) {
1612 $ids4 = implode(
',', array_keys($cases4[$h]));
1615 if ($h == $begin_h) {
1616 echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1618 echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1621 if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) {
1622 $output = array_slice($cases1[$h], 0, 1);
1623 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1624 if ($output[0][
'string']) {
1625 $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1627 if ($output[0][
'color']) {
1628 $color1 = $output[0][
'color'];
1630 } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
1631 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1636 if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) {
1637 $output = array_slice($cases2[$h], 0, 1);
1638 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1639 if ($output[0][
'string']) {
1640 $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1642 if ($output[0][
'color']) {
1643 $color2 = $output[0][
'color'];
1645 } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
1646 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1651 if (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) == 1) {
1652 $output = array_slice($cases3[$h], 0, 1);
1653 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1654 if ($output[0][
'string']) {
1655 $title3 .= ($title3 ?
' - ' :
'').$output[0][
'string'];
1657 if ($output[0][
'color']) {
1658 $color3 = $output[0][
'color'];
1660 } elseif (!empty($cases3[$h]) && is_array($cases3[$h]) && count($cases3[$h]) > 1) {
1661 $title3 = $langs->trans(
"Ref").
' '.$ids3.($title3 ?
' - '.$title3 :
'');
1666 if (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) == 1) {
1667 $output = array_slice($cases4[$h], 0, 1);
1668 $title4 = $langs->trans(
"Ref").
' '.$ids3.($title4 ?
' - '.$title4 :
'');
1669 if ($output[0][
'string']) {
1670 $title4 .= ($title4 ?
' - ' :
'').$output[0][
'string'];
1672 if ($output[0][
'color']) {
1673 $color4 = $output[0][
'color'];
1675 } elseif (!empty($cases4[$h]) && is_array($cases4[$h]) && count($cases4[$h]) > 1) {
1676 $title4 = $langs->trans(
"Ref").
' '.$ids4.($title4 ?
' - '.$title4 :
'');
1680 print
'<table class="nobordernopadding case centpercent">';
1683 if ($style1 ==
'peruser_notbusy') {
1684 print
'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
1685 } elseif ($color1) {
1686 print($color1 ?
'style="background: #'.$color1.
';"' :
'');
1689 print($style1 ? $style1.
' ' :
'');
1690 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.
'"' :
'').
'>';
1695 if ($style2 ==
'peruser_notbusy') {
1696 print
'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
1697 } elseif ($color2) {
1698 print($color2 ?
'style="background: #'.$color2.
';"' :
'');
1701 print($style2 ? $style2.
' ' :
'');
1702 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.
'"' :
'').
'>';
1707 if ($style3 ==
'peruser_notbusy') {
1708 print
'style="border: 1px solid #'.($color3 ? $color3 :
"888").
' !important" ';
1709 } elseif ($color3) {
1710 print($color3 ?
'style="background: #'.$color3.
';"' :
'');
1713 print($style3 ? $style3.
' ' :
'');
1714 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.
'"' :
'').
'>';
1719 if ($style4 ==
'peruser_notbusy') {
1720 print
'style="border: 1px solid #'.($color4 ? $color4 :
"888").
' !important" ';
1721 } elseif ($color4) {
1722 print($color4 ?
'style="background: #'.$color4.
';"' :
'');
1725 print($style4 ? $style4.
' ' :
'');
1726 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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_now($mode='auto')
Return date for now.
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).
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.