31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
42 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
44 $filter =
GETPOST(
"search_filter",
'alpha', 3) ?
GETPOST(
"search_filter",
'alpha', 3) :
GETPOST(
"filter",
'alpha', 3);
45 $filtert =
GETPOST(
"search_filtert",
"int", 3) ?
GETPOST(
"search_filtert",
"int", 3) :
GETPOST(
"filtert",
"int", 3);
46 $usergroup =
GETPOST(
"search_usergroup",
"int", 3) ?
GETPOST(
"search_usergroup",
"int", 3) :
GETPOST(
"usergroup",
"int", 3);
57 $sortfield =
GETPOST(
"sortfield",
'alpha');
58 $sortorder =
GETPOST(
"sortorder",
'alpha');
60 if (empty($page) || $page == -1) { $page = 0; }
61 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
62 $offset = $limit * $page;
63 if (!$sortorder) $sortorder =
"ASC";
64 if (!$sortfield) $sortfield =
"a.datec";
68 if ($user->socid) $socid = $user->socid;
70 if ($socid < 0) $socid =
'';
74 if (!$user->rights->agenda->allactions->read) $canedit = 0;
75 if (!$user->rights->agenda->allactions->read || $filter ==
'mine')
81 $action =
'show_peruser';
82 $resourceid =
GETPOST(
"search_resourceid",
"int") ?
GETPOST(
"search_resourceid",
"int") :
GETPOST(
"resourceid",
"int");
83 $year =
GETPOST(
"year",
"int") ?
GETPOST(
"year",
"int") : date(
"Y");
84 $month =
GETPOST(
"month",
"int") ?
GETPOST(
"month",
"int") : date(
"m");
85 $week =
GETPOST(
"week",
"int") ?
GETPOST(
"week",
"int") : date(
"W");
87 $pid =
GETPOST(
"search_projectid",
"int", 3) ?
GETPOST(
"search_projectid",
"int", 3) :
GETPOST(
"projectid",
"int", 3);
88 $status =
GETPOST(
"search_status",
'alpha') ?
GETPOST(
"search_status",
'alpha') :
GETPOST(
"status",
'alpha');
90 $maxprint = ((
GETPOST(
"maxprint",
'int') !=
'') ?
GETPOST(
"maxprint",
'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
91 $optioncss =
GETPOST(
'optioncss',
'aZ');
93 if (
GETPOST(
'search_actioncode',
'array'))
95 $actioncode =
GETPOST(
'search_actioncode',
'array', 3);
96 if (!count($actioncode)) $actioncode =
'0';
98 $actioncode =
GETPOST(
"search_actioncode",
"alpha", 3) ?
GETPOST(
"search_actioncode",
"alpha", 3) : (
GETPOST(
"search_actioncode",
"alpha") ==
'0' ?
'0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
100 if ($actioncode ==
'' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
105 $day =
GETPOST(
'dateselectday',
'int');
106 $month =
GETPOST(
'dateselectmonth',
'int');
107 $year =
GETPOST(
'dateselectyear',
'int');
110 $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ?
'9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
111 $tmp = str_replace(
' ',
'', $tmp);
112 $tmparray = explode(
'-', $tmp);
113 $begin_h =
GETPOST(
'begin_h',
'int') !=
'' ?
GETPOST(
'begin_h',
'int') : ($tmparray[0] !=
'' ? $tmparray[0] : 9);
114 $end_h =
GETPOST(
'end_h',
'int') ?
GETPOST(
'end_h',
'int') : ($tmparray[1] !=
'' ? $tmparray[1] : 18);
115 if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
116 if ($end_h < 1 || $end_h > 24) $end_h = 18;
117 if ($end_h <= $begin_h) $end_h = $begin_h + 1;
119 $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ?
'1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
120 $tmp = str_replace(
' ',
'', $tmp);
121 $tmparray = explode(
'-', $tmp);
122 $begin_d =
GETPOST(
'begin_d',
'int') ?
GETPOST(
'begin_d',
'int') : ($tmparray[0] !=
'' ? $tmparray[0] : 1);
123 $end_d =
GETPOST(
'end_d',
'int') ?
GETPOST(
'end_d',
'int') : ($tmparray[1] !=
'' ? $tmparray[1] : 5);
124 if ($begin_d < 1 || $begin_d > 7) $begin_d = 1;
125 if ($end_d < 1 || $end_d > 7) $end_d = 7;
126 if ($end_d < $begin_d) $end_d = $begin_d + 1;
128 if ($status ==
'' && !
GETPOSTISSET(
'status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
129 if (empty($action) && !
GETPOSTISSET(
'action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ?
'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
131 if (
GETPOST(
'viewcal',
'alpha') && $action !=
'show_day' && $action !=
'show_week' && $action !=
'show_peruser') {
132 $action =
'show_month'; $day =
'';
134 if (
GETPOST(
'viewweek',
'alpha') || $action ==
'show_week') {
135 $action =
'show_week'; $week = ($week ? $week : date(
"W")); $day = ($day ? $day : date(
"d"));
137 if (
GETPOST(
'viewday',
'alpha') || $action ==
'show_day') {
138 $action =
'show_day'; $day = ($day ? $day : date(
"d"));
142 $langs->loadLangs(array(
'users',
'agenda',
'other',
'commercial'));
145 $hookmanager->initHooks(array(
'agenda'));
152 if ($action ==
'delete_action')
155 $event->fetch($actionid);
156 $event->fetch_optionals();
157 $event->fetch_userassigned();
158 $event->oldcopy = clone $event;
160 $result = $event->delete();
176 'maxprint' => $maxprint,
178 'filtert' => $filtert,
179 'showbirthday' => $showbirthday,
180 'canedit' => $canedit,
181 'optioncss' => $optioncss,
182 'actioncode' => $actioncode,
184 'resourceid' => $resourceid,
185 'usergroup' => $usergroup,
187 $reshook = $hookmanager->executeHooks(
'beforeAgendaPerUser', $parameters, $object, $action);
188 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
190 $form =
new Form($db);
191 $companystatic =
new Societe($db);
193 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
194 llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
198 $nowyear = $nowarray[
'year'];
199 $nowmonth = $nowarray[
'mon'];
200 $nowday = $nowarray[
'mday'];
204 $listofextcals = array();
207 $first_day = $prev[
'first_day'];
208 $first_month = $prev[
'first_month'];
209 $first_year = $prev[
'first_year'];
211 $week = $prev[
'week'];
215 $next_year = $next[
'year'];
216 $next_month = $next[
'month'];
217 $next_day = $next[
'day'];
219 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year));
221 $tmpday = $first_day;
225 $title = $langs->trans(
"DoneAndToDoActions");
226 if ($status ==
'done') $title = $langs->trans(
"DoneActions");
227 if ($status ==
'todo') $title = $langs->trans(
"ToDoActions");
231 if (is_array($actioncode)) {
232 foreach ($actioncode as $str_action) $param .=
"&search_actioncode[]=".urlencode($str_action);
233 }
else $param .=
"&search_actioncode=".urlencode($actioncode);
235 if ($resourceid > 0) $param .=
"&search_resourceid=".urlencode($resourceid);
236 if ($status ||
GETPOSTISSET(
'status')) $param .=
"&search_status=".urlencode($status);
237 if ($filter) $param .=
"&search_filter=".urlencode($filter);
238 if ($filtert) $param .=
"&search_filtert=".urlencode($filtert);
239 if ($usergroup) $param .=
"&search_usergroup=".urlencode($usergroup);
240 if ($socid) $param .=
"&search_socid=".urlencode($socid);
241 if ($showbirthday) $param .=
"&search_showbirthday=1";
242 if ($pid) $param .=
"&search_projectid=".urlencode($pid);
243 if ($type) $param .=
"&search_type=".urlencode($type);
244 if ($action ==
'show_day' || $action ==
'show_week' || $action ==
'show_month' || $action !=
'show_peruser') $param .=
'&action='.urlencode($action);
245 if ($begin_h !=
'') $param .=
'&begin_h='.urlencode($begin_h);
246 if ($end_h !=
'') $param .=
'&end_h='.urlencode($end_h);
247 if ($begin_d !=
'') $param .=
'&begin_d='.urlencode($begin_d);
248 if ($end_d !=
'') $param .=
'&end_d='.urlencode($end_d);
249 $param .=
"&maxprint=".urlencode($maxprint);
255 $prev_year = $prev[
'prev_year'];
256 $prev_month = $prev[
'prev_month'];
257 $prev_day = $prev[
'prev_day'];
258 $first_day = $prev[
'first_day'];
259 $first_month = $prev[
'first_month'];
260 $first_year = $prev[
'first_year'];
262 $week = $prev[
'week'];
266 $next_year = $next[
'year'];
267 $next_month = $next[
'month'];
268 $next_day = $next[
'day'];
271 $firstdaytoshow =
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year,
'gmt');
273 $nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((
int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7;
279 $max_day_in_month = date(
"t",
dol_mktime(0, 0, 0, $month, 1, $year,
'gmt'));
281 $tmpday = $first_day;
282 $picto =
'calendarweek';
284 $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";
285 $nav .=
" <span id=\"month_name\">".dol_print_date(
dol_mktime(0, 0, 0, $first_month, $first_day, $first_year),
"%Y").
", ".$langs->trans(
"Week").
" ".$week;
286 $nav .=
" </span>\n";
287 $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";
288 if (empty($conf->dol_optimize_smallscreen)) {
289 $nav .=
" <a href=\"?year=".$nowyear.
"&month=".$nowmonth.
"&day=".$nowday.$param.
"\">".$langs->trans(
"Today").
"</a> ";
291 $nav .= $form->selectDate($dateselect,
'dateselect', 0, 0, 1,
'', 1, 0);
292 $nav .=
' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
295 $param .=
'&year='.urlencode($year).
'&month='.urlencode($month).($day ?
'&day='.urlencode($day) :
'');
299 $paramnoaction = preg_replace(
'/action=[a-z_]+/',
'', $param);
303 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
305 $showextcals = $listofextcals;
307 if ($conf->use_javascript_ajax)
310 $s .=
'<script type="text/javascript">'.
"\n";
311 $s .=
'jQuery(document).ready(function () {'.
"\n";
312 $s .=
'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'.
"\n";
313 $s .=
'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'.
"\n";
314 $s .=
'jQuery(".family_birthday").toggle();'.
"\n";
315 if ($action ==
"show_week" || $action ==
"show_month" || empty($action))
317 $s .=
'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
318 $s .=
'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'.
"\n";
321 $s .=
'</script>'.
"\n";
322 if (!empty($conf->use_javascript_ajax))
324 $s .=
'<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' </div>';
325 if (is_array($showextcals) && count($showextcals) > 0)
327 foreach ($showextcals as $val)
329 $htmlname = md5($val[
'name']);
330 $s .=
'<script type="text/javascript">'.
"\n";
331 $s .=
'jQuery(document).ready(function () {'.
"\n";
332 $s .=
' jQuery("#check_ext'.$htmlname.
'").click(function() {';
333 $s .=
' /* alert("'.$htmlname.
'"); */';
334 $s .=
' jQuery(".family_ext'.$htmlname.
'").toggle();';
337 $s .=
'</script>'.
"\n";
338 $s .=
'<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.
'" name="check_ext'.$htmlname.
'" checked> '.$val [
'name'].
' </div>';
345 $parameters = array(); $object = null;
346 $reshook = $hookmanager->executeHooks(
'addCalendarChoice', $parameters, $object, $action);
349 $s .= $hookmanager->resPrint;
350 } elseif ($reshook > 1)
352 $s = $hookmanager->resPrint;
357 $massactionbutton =
'';
360 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
362 $viewmode .=
img_picto($langs->trans(
"List"),
'object_list-alt',
'class="pictoactionview block"');
364 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewList").
'</span></a>';
366 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
368 $viewmode .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview block"');
370 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span></a>';
372 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
374 $viewmode .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview block"');
376 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span></a>';
378 $viewmode .=
'<a class="btnTitle reposition" href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
380 $viewmode .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview block"');
382 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span></a>';
384 $viewmode .=
'<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?action=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
386 $viewmode .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview block"');
388 $viewmode .=
'<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span></a>';
390 $viewmode .=
'<span class="marginrightonly"></span>';
393 $parameters = array(); $object = null;
394 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
395 if (empty($reshook)) {
396 $viewmode .= $hookmanager->resPrint;
397 } elseif ($reshook > 1) {
398 $viewmode = $hookmanager->resPrint;
403 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
407 $newparam .=
'&month='.urlencode(str_pad($month, 2,
"0", STR_PAD_LEFT)).
'&year='.urlencode($tmpforcreatebutton[
'year']);
408 if ($begin_h !==
'') $newparam .=
'&begin_h='.urlencode($begin_h);
409 if ($end_h !==
'') $newparam .=
'&end_h='.urlencode($end_h);
410 if ($begin_d !==
'') $newparam .=
'&begin_d='.urlencode($begin_d);
411 if ($end_d !==
'') $newparam .=
'&end_d='.urlencode($end_d);
414 $hourminsec =
'100000';
415 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $tmpforcreatebutton[
'year'], $tmpforcreatebutton[
'mon'], $tmpforcreatebutton[
'mday']).$hourminsec.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
'')));
418 print_barre_liste($langs->trans(
"Agenda"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1,
'object_action', 0, $nav.
'<span class="marginleftonly"></span>'.$newcardbutton,
'', $limit, 1, 0, 1, $viewmode);
424 $newtitle =
'<div class="nowrap clear inline-block minheight30">';
425 $newtitle .=
'<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans(
"LocalAgenda").
' ';
426 $newtitle .=
'</div>';
433 print '<div class="liste_titre liste_titre_bydiv centpercent">';
434 print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup,
'', $resourceid);
440 $eventarray = array();
443 if ($usergroup > 0) $sql .=
" DISTINCT";
444 $sql .=
' a.id, a.label,';
446 $sql .=
' a.datep2,';
447 $sql .=
' a.percent,';
448 $sql .=
' a.fk_user_author,a.fk_user_action,';
449 $sql .=
' a.transparency, a.priority, a.fulldayevent, a.location,';
450 $sql .=
' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
451 $sql .=
' ca.code, ca.color';
452 $sql .=
' FROM '.MAIN_DB_PREFIX.
'c_actioncomm as ca, '.MAIN_DB_PREFIX.
"actioncomm as a";
453 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
455 if ($resourceid > 0) $sql .=
", ".MAIN_DB_PREFIX.
"element_resources as r";
457 if ($filtert > 0 || $usergroup > 0) $sql .=
", ".MAIN_DB_PREFIX.
"actioncomm_resources as ar";
458 if ($usergroup > 0) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
459 $sql .=
' WHERE a.fk_action = ca.id';
460 $sql .=
' AND a.entity IN ('.getEntity(
'agenda').
')';
462 if (!empty($actioncode))
464 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
466 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND ca.type != 'systemauto'";
467 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND ca.
type = 'systemauto'";
469 if ($actioncode ==
'AC_OTH') $sql .=
" AND ca.type != 'systemauto'";
470 if ($actioncode ==
'AC_OTH_AUTO') $sql .=
" AND ca.type = 'systemauto'";
473 if ($actioncode ==
'AC_NON_AUTO') $sql .=
" AND ca.type != 'systemauto'";
474 elseif ($actioncode ==
'AC_ALL_AUTO') $sql .= " AND ca.
type = 'systemauto'";
476 if (is_array($actioncode))
478 $sql .=
" AND ca.code IN ('".implode(
"','", $actioncode).
"')";
480 $sql .=
" AND ca.code IN ('".implode(
"','", explode(
',', $actioncode)).
"')";
485 if ($resourceid > 0) $sql .=
" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
486 if ($pid) $sql .=
" AND a.fk_project=".$db->escape($pid);
487 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.
")";
488 if ($socid > 0) $sql .=
' AND a.fk_soc = '.$socid;
490 if ($filtert > 0 || $usergroup > 0) $sql .=
" AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
491 if ($action ==
'show_day')
494 $sql .=
" (a.datep BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
495 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
497 $sql .=
" (a.datep2 BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
498 $sql .=
" AND '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
500 $sql .=
" (a.datep < '".$db->idate(
dol_mktime(0, 0, 0, $month, $day, $year,
'tzuserrel')).
"'";
501 $sql .=
" AND a.datep2 > '".$db->idate(
dol_mktime(23, 59, 59, $month, $day, $year,
'tzuserrel')).
"')";
506 $sql .=
" (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
507 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
509 $sql .=
" (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
510 $sql .=
" AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
512 $sql .=
" (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2)).
"'";
513 $sql .=
" AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2)).
"')";
516 if ($type) $sql .=
" AND ca.id = ".$type;
517 if ($status ==
'0') { $sql .=
" AND a.percent = 0"; }
518 if ($status ==
'-1') { $sql .=
" AND a.percent = -1"; }
519 if ($status ==
'50') { $sql .=
" AND (a.percent > 0 AND a.percent < 100)"; }
520 if ($status ==
'done' || $status ==
'100') { $sql .=
" AND (a.percent = 100)"; }
521 if ($status ==
'todo') { $sql .=
" AND (a.percent >= 0 AND a.percent < 100)"; }
523 if ($filtert > 0 || $usergroup > 0)
526 if ($filtert > 0) $sql .=
"ar.fk_element = ".$filtert;
527 if ($usergroup > 0) $sql .= ($filtert > 0 ?
" OR " :
"").
" ugu.fk_usergroup = ".$usergroup;
531 $sql .=
' ORDER BY fk_user_action, datep';
534 dol_syslog(
"comm/action/peruser.php", LOG_DEBUG);
535 $resql = $db->query($sql);
538 $num = $db->num_rows(
$resql);
543 $obj = $db->fetch_object(
$resql);
546 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code ==
'AC_OTH_AUTO')
552 $datep = $db->jdate($obj->datep);
553 $datep2 = $db->jdate($obj->datep2);
557 $event->id = $obj->id;
558 $event->datep = $datep;
559 $event->datef = $datep2;
560 $event->type_code = $obj->code;
561 $event->type_color = $obj->color;
562 $event->label = $obj->label;
563 $event->percentage = $obj->percent;
564 $event->authorid = $obj->fk_user_author;
565 $event->userownerid = $obj->fk_user_action;
566 $event->priority = $obj->priority;
567 $event->fulldayevent = $obj->fulldayevent;
568 $event->location = $obj->location;
569 $event->transparency = $obj->transparency;
571 $event->fk_project = $obj->fk_project;
573 $event->socid = $obj->fk_soc;
574 $event->contact_id = $obj->fk_contact;
576 $event->fk_element = $obj->fk_element;
577 $event->elementtype = $obj->elementtype;
581 if ($event->percentage <= 0)
583 $event->date_start_in_calendar = $datep;
584 if ($datep2 !=
'' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
585 else $event->date_end_in_calendar = $datep;
587 $event->date_start_in_calendar = $datep;
588 if ($datep2 !=
'' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
589 else $event->date_end_in_calendar = $datep;
592 if ($event->date_start_in_calendar == $event->date_end_in_calendar)
594 $event->ponctuel = 1;
598 if ($event->date_end_in_calendar < $firstdaytoshow ||
599 $event->date_start_in_calendar >= $lastdaytoshow)
605 $event->fetch_userassigned();
607 if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
608 if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
611 $daycursor = $event->date_start_in_calendar;
618 $loop =
true; $j = 0;
619 $daykey =
dol_mktime(0, 0, 0, $mois, $jour, $annee,
'gmt');
623 $eventarray[$daykey][] = $event;
626 $daykey += 60 * 60 * 24;
627 if ($daykey > $event->date_end_in_calendar) $loop =
false;
641 $cachethirdparties = array();
642 $cachecontacts = array();
643 $cacheusers = array();
646 $color_file = DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
647 if (is_readable($color_file))
649 include_once $color_file;
651 if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
655 $newparam = preg_replace(
'/showbirthday=/i',
'showbirthday_=', $newparam);
656 $newparam = preg_replace(
'/action=show_month&?/i',
'', $newparam);
657 $newparam = preg_replace(
'/action=show_week&?/i',
'', $newparam);
658 $newparam = preg_replace(
'/day=[0-9]+&?/i',
'', $newparam);
659 $newparam = preg_replace(
'/month=[0-9]+&?/i',
'', $newparam);
660 $newparam = preg_replace(
'/year=[0-9]+&?/i',
'', $newparam);
661 $newparam = preg_replace(
'/viewweek=[0-9]+&?/i',
'', $newparam);
662 $newparam = preg_replace(
'/showbirthday_=/i',
'showbirthday=', $newparam);
663 $newparam .=
'&viewweek=1';
665 echo
'<input type="hidden" name="actionmove" value="mupdate">';
666 echo
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?'.
dol_escape_htmltag($_SERVER[
'QUERY_STRING']).
'">';
667 echo
'<input type="hidden" name="newdate" id="newdate">';
674 $currentdaytoshow = $firstdaytoshow;
675 echo
'<div class="div-table-responsive">';
677 while ($currentdaytoshow < $lastdaytoshow) {
678 echo
'<table width="100%" class="noborder nocellnopadd cal_month">';
680 echo
'<tr class="liste_titre">';
681 echo
'<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">';
683 if ($canedit && $action ==
'show_peruser')
686 print img_picto(
'',
'clock',
'class="fawidth30 inline-block paddingleft"');
687 print '<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleTimeRange").
'">'.$langs->trans(
"Hours").
'</span>';
688 print "\n".
'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">';
689 print '<input type="number" class="short" name="begin_h" value="'.$begin_h.
'" min="0" max="23">';
690 if (empty($conf->dol_use_jmobile))
print ' - ';
691 else print '</div><div class="ui-block-b">';
692 print '<input type="number" class="short" name="end_h" value="'.$end_h.
'" min="1" max="24">';
693 if (empty($conf->dol_use_jmobile))
print ' '.$langs->trans(
"H");
694 print '</div></div>';
699 print img_picto(
'',
'clock',
'class="fawidth30 inline-block paddingleft"');
700 print '<span class="hideonsmartphone" title="'.$langs->trans(
"VisibleDaysRange").
'">'.$langs->trans(
"DaysOfWeek").
'</span>';
701 print "\n".
'<div class="ui-grid-a inline-block"><div class="ui-block-a">';
702 print '<input type="number" class="short" name="begin_d" value="'.$begin_d.
'" min="1" max="7">';
703 if (empty($conf->dol_use_jmobile))
print ' - ';
704 else print '</div><div class="ui-block-b">';
705 print '<input type="number" class="short" name="end_d" value="'.$end_d.
'" min="1" max="7">';
706 print '</div></div>';
713 if (($i + 1) < $begin_d || ($i + 1) > $end_d)
718 echo
'<td align="center" colspan="'.($end_h - $begin_h).
'">';
719 echo
'<span class="bold spandayofweek">'.$langs->trans(
"Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).
'</span>';
728 echo
'<tr class="liste_titre">';
733 if (($i + 1) < $begin_d || ($i + 1) > $end_d)
738 for ($h = $begin_h; $h < $end_h; $h++)
740 echo
'<td class="center">';
741 print '<small style="font-family: courier">'.sprintf(
"%02d", $h).
'</small>';
751 $usernames = array();
752 $usernamesid = array();
754 if (!empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW))
756 foreach ($eventarray as $daykey => $notused)
759 foreach ($eventarray[$daykey] as $index => $event)
761 $event->fetch_userassigned();
762 $listofuserid = $event->userassigned;
763 foreach ($listofuserid as $userid => $tmp) {
764 if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid;
770 $sql =
"SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
771 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
772 if ($usergroup > 0) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ug ON u.rowid = ug.fk_user";
773 $sql .=
" WHERE u.statut = 1 AND u.entity IN (".getEntity(
'user').
")";
774 if ($usergroup > 0) $sql .=
" AND ug.fk_usergroup = ".$usergroup;
776 $resql = $db->query($sql);
778 $num = $db->num_rows(
$resql);
784 $obj = $db->fetch_object(
$resql);
785 $usernamesid[$obj->rowid] = $obj->rowid;
792 foreach ($usernamesid as $id)
794 $tmpuser =
new User($db);
795 $result = $tmpuser->fetch($id);
796 $usernames[] = $tmpuser;
820 $colorsbytype = array();
821 $labelbytype = array();
822 $sql =
"SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX.
"c_actioncomm ORDER BY position";
823 $resql = $db->query($sql);
824 while ($obj = $db->fetch_object(
$resql))
826 $colorsbytype[$obj->code] = $obj->color;
827 $labelbytype[$obj->code] = $obj->label;
835 foreach ($usernames as $username)
839 echo
'<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ?
' cal_impair' :
'').
'">';
840 print $username->getNomUrl(-1,
'', 0, 0, 20, 1,
'');
846 for ($iter_day = 0; $iter_day < 8; $iter_day++)
848 if (($i + 1) < $begin_d || ($i + 1) > $end_d)
857 $tmpday = $tmparray[
'mday'];
858 $tmpmonth = $tmparray[
'mon'];
859 $tmpyear = $tmparray[
'year'];
862 $style =
'cal_current_month';
863 if ($iter_day == 6) $style .=
' cal_other_month';
865 if ($todayarray[
'mday'] == $tmpday && $todayarray[
'mon'] == $tmpmonth && $todayarray[
'year'] == $tmpyear) $today = 1;
866 if ($today) $style =
'cal_today_peruser';
868 show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
884 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && !empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE))
886 $langs->load(
"commercial");
887 print '<br>'.$langs->trans(
"Legend").
': <br>';
888 foreach ($colorsbytype as $code => $color)
892 print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ?
'background: #'.$color.
';' :
'').
'width:16px; float: left; margin-right: 4px;"> </div>';
893 print $langs->trans(
"Action".$code) !=
"Action".$code ? $langs->trans(
"Action".$code) : $labelbytype[$code];
899 print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>';
900 print $langs->trans(
"Other");
909 print "\n".
'</form>';
913 print '<script type="text/javascript" language="javascript">
914 jQuery(document).ready(function() {
915 jQuery(".onclickopenref").click(function() {
916 var ref=$(this).attr(\'ref\');
917 var res = ref.split("_");
925 if (ids == \'none\') /* No event */
927 /* alert(\'no event\'); */
928 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 :
'')).
'"
929 window.location.href = url;
931 else if (ids.indexOf(",") > -1) /* There is several events */
933 /* alert(\'several events\'); */
934 url = "'.DOL_URL_ROOT.
'/comm/action/list.php?action=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
935 window.location.href = url;
939 /* alert(\'one event\'); */
940 url = "'.DOL_URL_ROOT.
'/comm/action/card.php?action=view&id="+ids
941 window.location.href = url;
974 function 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)
977 global $user, $conf, $langs, $hookmanager, $action;
978 global $filter, $filtert, $status, $actioncode;
979 global $theme_datacolor;
980 global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused;
981 global $begin_h, $end_h;
986 $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array();
989 $colorindexused[$user->id] = 0;
990 $nextindextouse = count($colorindexused);
994 foreach ($eventarray as $daykey => $notused)
1000 if ($day == $jour && $month == $mois && $year == $annee)
1003 foreach ($eventarray[$daykey] as $index => $event)
1008 $keysofuserassigned = array_keys($event->userassigned);
1009 $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
1011 if (!in_array($username->id, $keysofuserassigned))
continue;
1014 $parameters = array();
1015 $reshook = $hookmanager->executeHooks(
'formatEvent', $parameters, $event, $action);
1016 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1019 $color = -1; $cssclass =
''; $colorindex = -1;
1020 if (in_array($user->id, $keysofuserassigned))
1022 $cssclass =
'family_mytasks';
1024 if (empty($cacheusers[$event->userownerid]))
1026 $newuser =
new User($db);
1027 $newuser->fetch($event->userownerid);
1028 $cacheusers[$event->userownerid] = $newuser;
1033 if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color;
1035 if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color;
1036 } elseif ($event->type_code ==
'ICALEVENT')
1039 if (!empty($event->icalname))
1047 $color = $event->icalcolor;
1048 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other unsortable');
1049 } elseif ($event->type_code ==
'BIRTHDAY')
1051 $numbirthday++; $colorindex = 2; $cssclass =
'family_birthday unsortable'; $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1054 $color = ($event->icalcolor ? $event->icalcolor : -1);
1055 $cssclass = (!empty($event->icalname) ?
'family_ext'.md5($event->icalname) :
'family_other');
1057 if (empty($cacheusers[$event->userownerid]))
1059 $newuser =
new User($db);
1060 $newuser->fetch($event->userownerid);
1061 $cacheusers[$event->userownerid] = $newuser;
1066 if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color;
1068 if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color;
1074 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
1075 if (isset($colorindexused[$idusertouse]))
1077 $colorindex = $colorindexused[$idusertouse];
1079 $colorindex = $nextindextouse;
1080 $colorindexused[$idusertouse] = $colorindex;
1081 if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++;
1084 $color = sprintf(
"%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1088 for ($h = $begin_h; $h < $end_h; $h++)
1092 if (empty($event->fulldayevent))
1094 $a =
dol_mktime((
int) $h, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1095 $b =
dol_mktime((
int) $h, 30, 0, $month, $day, $year,
'tzuserrel', 0);
1096 $c =
dol_mktime((
int) $h + 1, 0, 0, $month, $day, $year,
'tzuserrel', 0);
1098 $dateendtouse = $event->date_end_in_calendar;
1099 if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++;
1103 if ($event->date_start_in_calendar < $b && $dateendtouse > $a)
1105 $busy = $event->transparency;
1106 $cases1[$h][$event->id][
'busy'] = $busy;
1107 $cases1[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1108 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
1110 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1111 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1112 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1113 else $cases1[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1115 if ($event->label) $cases1[$h][$event->id][
'string'] .=
' - '.$event->label;
1116 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1117 $cases1[$h][$event->id][
'color'] = $color;
1118 if ($event->fk_project > 0)
1120 if (empty($cacheprojects[$event->fk_project]))
1123 $tmpproj->fetch($event->fk_project);
1124 $cacheprojects[$event->fk_project] = $tmpproj;
1126 $cases1[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1128 if ($event->socid > 0)
1130 if (empty($cachethirdparties[$event->socid]))
1132 $tmpthirdparty =
new Societe($db);
1133 $tmpthirdparty->fetch($event->socid);
1134 $cachethirdparties[$event->socid] = $tmpthirdparty;
1136 $cases1[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1138 if ($event->contact_id > 0)
1140 if (empty($cachecontacts[$event->contact_id]))
1142 $tmpcontact =
new Contact($db);
1143 $tmpcontact->fetch($event->contact_id);
1144 $cachecontacts[$event->contact_id] = $tmpcontact;
1146 $cases1[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1149 if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
1151 $busy = $event->transparency;
1152 $cases2[$h][$event->id][
'busy'] = $busy;
1153 $cases2[$h][$event->id][
'string'] =
dol_print_date($event->date_start_in_calendar,
'dayhour',
'tzuserrel');
1154 if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
1156 $tmpa =
dol_getdate($event->date_start_in_calendar,
true);
1157 $tmpb =
dol_getdate($event->date_end_in_calendar,
true);
1158 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'hour',
'tzuserrel');
1159 else $cases2[$h][$event->id][
'string'] .=
'-'.dol_print_date($event->date_end_in_calendar,
'dayhour',
'tzuserrel');
1161 if ($event->label) $cases2[$h][$event->id][
'string'] .=
' - '.$event->label;
1162 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1163 $cases2[$h][$event->id][
'color'] = $color;
1164 if ($event->fk_project > 0)
1166 if (empty($cacheprojects[$event->fk_project]))
1169 $tmpproj->fetch($event->fk_project);
1170 $cacheprojects[$event->fk_project] = $tmpproj;
1172 $cases2[$h][$event->id][
'string'] .=
', '.$langs->trans(
"Project").
': '.$cacheprojects[$event->fk_project]->ref.
' - '.$cacheprojects[$event->fk_project]->title;
1174 if ($event->socid > 0)
1176 if (empty($cachethirdparties[$event->socid]))
1178 $tmpthirdparty =
new Societe($db);
1179 $tmpthirdparty->fetch($event->socid);
1180 $cachethirdparties[$event->socid] = $tmpthirdparty;
1182 $cases2[$h][$event->id][
'string'] .=
', '.$cachethirdparties[$event->socid]->name;
1184 if ($event->contact_id > 0)
1186 if (empty($cachecontacts[$event->contact_id]))
1188 $tmpcontact =
new Contact($db);
1189 $tmpcontact->fetch($event->contact_id);
1190 $cachecontacts[$event->contact_id] = $tmpcontact;
1192 $cases2[$h][$event->id][
'string'] .=
', '.$cachecontacts[$event->contact_id]->getFullName($langs);
1196 $busy = $event->transparency;
1197 $cases1[$h][$event->id][
'busy'] = $busy;
1198 $cases2[$h][$event->id][
'busy'] = $busy;
1199 $cases1[$h][$event->id][
'string'] = $event->label;
1200 $cases2[$h][$event->id][
'string'] = $event->label;
1201 $cases1[$h][$event->id][
'typecode'] = $event->type_code;
1202 $cases2[$h][$event->id][
'typecode'] = $event->type_code;
1203 $cases1[$h][$event->id][
'color'] = $color;
1204 $cases2[$h][$event->id][
'color'] = $color;
1215 for ($h = $begin_h; $h < $end_h; $h++)
1217 $color1 =
''; $color2 =
'';
1218 $style1 =
''; $style2 =
'';
1219 $string1 =
' '; $string2 =
' ';
1220 $title1 =
''; $title2 =
'';
1221 if (isset($cases1[$h]) && $cases1[$h] !=
'')
1224 if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).
' '.(count($cases1[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1225 $string1 =
' ';
1226 if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 =
'peruser_notbusy';
1227 else $style1 =
'peruser_busy';
1228 foreach ($cases1[$h] as $id => $ev)
1230 if ($ev[
'busy']) $style1 =
'peruser_busy';
1233 if (isset($cases2[$h]) && $cases2[$h] !=
'')
1236 if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).
' '.(count($cases2[$h]) == 1 ? $langs->trans(
"Event") : $langs->trans(
"Events"));
1237 $string2 =
' ';
1238 if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 =
'peruser_notbusy';
1239 else $style2 =
'peruser_busy';
1240 foreach ($cases2[$h] as $id => $ev)
1242 if ($ev[
'busy']) $style2 =
'peruser_busy';
1248 if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(
',', array_keys($cases1[$h]));
1249 if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(
',', array_keys($cases2[$h]));
1251 if ($h == $begin_h) echo
'<td class="'.$style.
'_peruserleft cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1252 else echo
'<td class="'.$style.
' cal_peruser'.($var ?
' cal_impair '.$style.
'_impair' :
'').
'">';
1253 if (is_array($cases1[$h]) && count($cases1[$h]) == 1)
1255 $output = array_slice($cases1[$h], 0, 1);
1256 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1257 if ($output[0][
'string']) $title1 .= ($title1 ?
' - ' :
'').$output[0][
'string'];
1258 if ($output[0][
'color']) $color1 = $output[0][
'color'];
1259 } elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1)
1261 $title1 = $langs->trans(
"Ref").
' '.$ids1.($title1 ?
' - '.$title1 :
'');
1265 if (is_array($cases2[$h]) && count($cases2[$h]) == 1)
1267 $output = array_slice($cases2[$h], 0, 1);
1268 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1269 if ($output[0][
'string']) $title2 .= ($title2 ?
' - ' :
'').$output[0][
'string'];
1270 if ($output[0][
'color']) $color2 = $output[0][
'color'];
1271 } elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1)
1273 $title2 = $langs->trans(
"Ref").
' '.$ids2.($title2 ?
' - '.$title2 :
'');
1276 print '<table class="nobordernopadding" width="100%">';
1278 if ($style1 ==
'peruser_notbusy')
print 'style="border: 1px solid #'.($color1 ? $color1 :
"888").
' !important" ';
1281 print ($color1 ?
'style="background: #'.$color1.
';"' :
'');
1284 print ($style1 ? $style1.
' ' :
'');
1285 print 'onclickopenref'.($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.
'"' :
'').
'>';
1288 if ($style2 ==
'peruser_notbusy')
print 'style="border: 1px solid #'.($color2 ? $color2 :
"888").
' !important" ';
1291 print ($color2 ?
'style="background: #'.$color2.
';"' :
'');
1294 print ($style2 ? $style2.
' ' :
'');
1295 print 'onclickopenref'.($title2 ?
' classfortooltip' :
'').($title1 ?
' cursorpointer' :
'').
'" ref="ref_'.$username->id.
'_'.sprintf(
"%04d", $year).
'_'.sprintf(
"%02d", $month).
'_'.sprintf(
"%02d", $day).
'_'.sprintf(
"%02d", $h).
'_30_'.($ids2 ? $ids2 :
'none').
'"'.($title2 ?
' title="'.$title2.
'"' :
'').
'>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage agenda events (actions)
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_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
dol_now($mode= 'auto')
Return date for now.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Class to manage Dolibarr users.
dol_string_nospecial($str, $newstr= '_', $badcharstoreplace= '')
Clean a string from all punctuation characters to use it as a ref or login.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
dol_get_next_week($day, $week, $month, $year)
Return next week.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode= '', $usergroupid= '', $excludetype= '', $resourceid=0)
Show filter form in agenda view.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...