68 $showextcals = array(),
73 $search_categ_cus = 0,
74 $search_import_key =
''
76 global $user, $langs,
$db, $hookmanager;
79 $langs->load(
"companies");
81 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
85 print
'<input type="hidden" name="token" value="'.newToken().
'">';
86 print
'<input type="hidden" name="year" value="'.((int) $year).
'">';
87 print
'<input type="hidden" name="month" value="'.((int) $month).
'">';
88 print
'<input type="hidden" name="day" value="'.((int) $day).
'">';
89 if ($massaction !=
'predelete' && $massaction !=
'preaffecttag') {
90 print
'<input type="hidden" name="action" value="'.$action.
'">';
92 print
'<input type="hidden" name="search_showbirthday" value="'.((int) $showbirthday).
'">';
94 print
'<div class="divsearchfield">';
100 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="pictofixedwidth inline-block" style="color: #ddd;"');
101 print $formactions->select_type_actions($actioncode,
"search_actioncode", $excludetype, (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1), 0, $multiselect, 0,
'minwidth150 maxwidth200 widthcentpercentminusx', 1);
106 print
'<div class="divsearchfield">';
107 print
img_picto($langs->trans(
"ActionsToDoBy"),
'user',
'class="pictofixedwidth inline-block"');
108 print $form->select_dolusers($filtert,
'search_filtert', 1,
null, (
int) !$canedit,
'',
'',
'0', 0, 0,
'', 2,
'',
'minwidth100 maxwidth250 widthcentpercentminusx');
112 print
'<div class="divsearchfield">';
113 print
img_picto($langs->trans(
"ToUserOfGroup"),
'object_group',
'class="pictofixedwidth inline-block"');
114 print $form->select_dolgroups($usergroupid,
'usergroup', 1,
'', (
int) !$canedit,
'', array(),
'0',
false,
'minwidth100 maxwidth250 widthcentpercentminusx');
118 include_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
122 print
'<div class="divsearchfield">';
123 print
img_picto($langs->trans(
"Resource"),
'object_resource',
'class="pictofixedwidth inline-block"');
124 print $formresource->select_resource_list($resourceid,
"search_resourceid",
'', 1, 0, 0, [],
'', 2, 0,
'minwidth100 maxwidth250 widthcentpercentminusx');
129 if (
isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire')) {
130 print
'<div class="divsearchfield">';
131 print
img_picto($langs->trans(
"ThirdParty"),
'company',
'class="pictofixedwidth inline-block"');
132 print $form->select_company($socid,
'search_socid',
'',
' ', 0, 0, array(), 0,
'minwidth100 maxwidth250 widthcentpercentminusx');
136 if (
isModEnabled(
'project') && $user->hasRight(
'projet',
'lire')) {
137 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
140 print
'<div class="divsearchfield">';
141 print
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth inline-block"');
142 print $formproject->select_projects($socid ? $socid : -1, (
string) $pid,
'search_projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'minwidth100 maxwidth250 widthcentpercentminusx');
146 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
147 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
148 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
150 $langs->load(
'categories');
152 print
'<div class="divsearchfield">';
153 print
img_picto($langs->trans(
'Categories'),
'category',
'class="pictofixedwidth"');
154 print $formother->select_categories(
'actioncomm', $search_categ_cus,
'search_categ_cus', 1, $langs->trans(
'Categories'),
'minwidth100 maxwidth250 widthcentpercentminusx');
158 if ($canedit && !preg_match(
'/list/', $_SERVER[
"PHP_SELF"])) {
160 print
'<div class="divsearchfield">';
161 print
img_picto($langs->trans(
"Status"),
'status',
'class="pictofixedwidth inline-block"');
162 $formactions->form_select_status_action(
'formaction', $status, 1,
'search_status', 1, 2,
'minwidth100');
167 $parameters = array(
'canedit' => $canedit,
'pid' => $pid,
'socid' => $socid);
169 $reshook = $hookmanager->executeHooks(
'searchAgendaFrom', $parameters,
$object, $action);
171 print
'<div class="clearboth"></div>';
183 global $langs,
$conf, $user,
$db, $socid;
187 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
188 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
190 $sql =
"SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent";
191 $sql .=
", c.code, c.libelle as type_label";
192 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
193 $sql .=
", s.code_client, s.code_compta, s.client";
194 $sql .=
", s.logo, s.email, s.entity";
195 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a LEFT JOIN ";
196 $sql .=
" ".MAIN_DB_PREFIX.
"c_actioncomm as c ON c.id = a.fk_action";
197 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
198 if (!$user->hasRight(
'societe',
'client',
'voir')) {
199 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
201 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
202 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now).
"'))";
203 if (!$user->hasRight(
'societe',
'client',
'voir')) {
204 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
207 $sql .=
" AND s.rowid = ".((int) $socid);
209 $sql .=
" ORDER BY a.datep DESC, a.id DESC";
210 $sql .=
$db->plimit($max, 0);
212 $resql =
$db->query($sql);
214 $num =
$db->num_rows($resql);
216 print
'<div class="div-table-responsive-no-min">';
217 print
'<table class="noborder centpercent">';
218 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastActionsToDo", $max).
'</th>';
219 print
'<th colspan="2" class="right"><a class="commonlink" href="'.dolBuildUrl(DOL_URL_ROOT.
'/comm/action/list.php', [
'mode' =>
'show_list',
'status' =>
'todo']).
'">'.$langs->trans(
"FullList").
'</a></th>';
228 $obj =
$db->fetch_object($resql);
231 print
'<tr class="oddeven">';
233 $staticaction->type_code = $obj->code;
234 $staticaction->label = ($obj->label ? $obj->label : $obj->type_label);
235 $staticaction->id = $obj->id;
236 print
'<td>'.$staticaction->getNomUrl(1, 34).
'</td>';
241 if ($obj->socid > 0) {
242 $customerstatic->id = $obj->socid;
243 $customerstatic->name = $obj->name;
245 $customerstatic->code_client = $obj->code_client;
246 $customerstatic->code_compta = $obj->code_compta;
247 $customerstatic->code_compta_client = $obj->code_compta;
248 $customerstatic->client = $obj->client;
249 $customerstatic->logo = $obj->logo;
250 $customerstatic->email = $obj->email;
251 $customerstatic->entity = $obj->entity;
252 print $customerstatic->getNomUrl(1,
'', 40);
256 $datep =
$db->jdate($obj->dp);
257 $datep2 =
$db->jdate($obj->dp2);
260 print
'<td width="100" class="right tddate">'.dol_print_date($datep,
'day').
' ';
262 if ($obj->percent == 0 && $datep && $datep < time()) {
265 if ($obj->percent == 0 && !$datep && $datep2 && $datep2 < time()) {
268 if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) {
271 if ($obj->percent > 0 && $obj->percent < 100 && !$datep2 && $datep && $datep < time()) {
280 print
'<td class="right" width="14">'.$staticaction->LibStatut($obj->percent, 3).
"</td>\n";
286 print
"</table></div><br>";
303 global $langs,
$conf, $user,
$db, $socid;
307 $sql =
"SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label";
308 $sql .=
", c.code, c.libelle";
309 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
310 $sql .=
", s.code_client, s.code_compta, s.client";
311 $sql .=
", s.logo, s.email, s.entity";
312 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a LEFT JOIN ";
313 $sql .=
" ".MAIN_DB_PREFIX.
"c_actioncomm as c ON c.id = a.fk_action ";
314 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
315 if (!$user->hasRight(
'societe',
'client',
'voir')) {
316 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
318 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
319 $sql .=
" AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now).
"'))";
320 if (!$user->hasRight(
'societe',
'client',
'voir')) {
321 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
324 $sql .=
" AND s.rowid = ".((int) $socid);
326 $sql .=
" ORDER BY a.datep2 DESC";
327 $sql .=
$db->plimit($max, 0);
329 $resql =
$db->query($sql);
331 $num =
$db->num_rows($resql);
333 print
'<div class="div-table-responsive-no-min">';
334 print
'<table class="noborder centpercent">';
335 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastDoneTasks", $max).
'</th>';
336 print
'<th colspan="2" class="right"><a class="commonlink" href="'.dolBuildUrl(DOL_URL_ROOT.
'/comm/action/list.php', [
'mode'=>
'show_list',
'status' =>
'done']).
'">'.$langs->trans(
"FullList").
'</a></th>';
345 $obj =
$db->fetch_object($resql);
348 print
'<tr class="oddeven">';
350 $staticaction->type_code = $obj->code;
351 $staticaction->label = $obj->label;
352 $staticaction->id = $obj->id;
353 print
'<td>'.$staticaction->getNomUrl(1, 34).
'</td>';
358 if ($obj->socid > 0) {
359 $customerstatic->id = $obj->socid;
360 $customerstatic->name = $obj->name;
362 $customerstatic->code_client = $obj->code_client;
363 $customerstatic->code_compta = $obj->code_compta;
364 $customerstatic->code_compta_client = $obj->code_compta;
365 $customerstatic->client = $obj->client;
366 $customerstatic->logo = $obj->logo;
367 $customerstatic->email = $obj->email;
368 $customerstatic->entity = $obj->entity;
369 print $customerstatic->getNomUrl(1,
'', 30);
374 print
'<td width="100" class="right tddate">'.dol_print_date(
$db->jdate($obj->da2),
'day');
378 print
'<td class="right" width="14">'.$staticaction->LibStatut($obj->percent, 3).
"</td>\n";
385 print
"</table></div><br>";
401 global $langs,
$conf, $user, $extrafields;
403 $extrafields->fetch_name_optionals_label(
'actioncomm');
408 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/agenda_other.php");
409 $head[$h][1] = $langs->trans(
"Miscellaneous");
410 $head[$h][2] =
'other';
413 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/agenda.php");
414 $head[$h][1] = $langs->trans(
"AutoActions");
415 $head[$h][2] =
'autoactions';
418 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/agenda_reminder.php");
419 $head[$h][1] = $langs->trans(
"Reminders");
420 $head[$h][2] =
'reminders';
423 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/agenda_xcal.php");
424 $head[$h][1] = $langs->trans(
"ExportCal");
425 $head[$h][2] =
'xcal';
428 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/agenda_extsites.php");
429 $head[$h][1] = $langs->trans(
"ExtSites");
430 $head[$h][2] =
'extsites';
435 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/extrafields.php', array(
'elementtype' =>
'agenda'));
436 $head[$h][1] = $langs->trans(
"ExtraFields");
437 $nbExtrafields = $extrafields->attributes[
'actioncomm'][
'count'];
438 if ($nbExtrafields > 0) {
439 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
441 $head[$h][2] =
'attributes';
463 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/card.php', [
'id'=>
$object->id]);
464 $head[$h][1] = $langs->trans(
"CardAction");
465 $head[$h][2] =
'card';
470 include_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
473 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/resource/element_resource.php', [
'element' =>
'action',
'element_id'=>
$object->id]);
474 $listofresourcelinked = $resource->getElementResources(
$object->element,
$object->id);
475 $nbResources = (is_array($listofresourcelinked) ? count($listofresourcelinked) : 0);
476 $head[$h][1] = $langs->trans(
"Resources");
477 if ($nbResources > 0) {
478 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.($nbResources).
'</span>' :
'');
480 $head[$h][2] =
'resources';
485 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
486 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
487 $upload_dir =
$conf->agenda->dir_output.
"/".
$object->id;
488 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
490 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/document.php', [
'id' =>
$object->id]);
491 $head[$h][1] = $langs->trans(
"Documents");
492 if (($nbFiles + $nbLinks) > 0) {
493 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>' :
'');
495 $head[$h][2] =
'documents';
498 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/info.php', [
'id' =>
$object->id]);
499 $head[$h][1] = $langs->trans(
'Info');
500 $head[$h][2] =
'info';
519 global $langs,
$conf, $user;
524 parse_str($param, $query);
526 $query = array_merge($query, [
'mode' =>
'show_list']);
527 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/list.php', $query);
528 $head[$h][1] = $langs->trans(
"ViewList");
529 $head[$h][2] =
'cardlist';
532 $query[
'mode'] =
'show_month';
533 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/index.php', $query);
534 $head[$h][1] = $langs->trans(
"ViewCal");
535 $head[$h][2] =
'cardmonth';
538 $query[
'mode'] =
'show_week';
539 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/index.php', $query);
540 $head[$h][1] = $langs->trans(
"ViewWeek");
541 $head[$h][2] =
'cardweek';
544 $query[
'mode'] =
'show_day';
545 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/index.php', $query);
546 $head[$h][1] = $langs->trans(
"ViewDay");
547 $head[$h][2] =
'cardday';
550 unset($query[
'mode']);
552 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/pertype.php', $query);
553 $head[$h][1] = $langs->trans(
"ViewPerType");
554 $head[$h][2] =
'cardpertype';
559 $newparam = preg_replace(
'/&?search_filtert=\d+/',
'', $newparam);
561 parse_str($newparam, $query);
563 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/action/peruser.php', $query);
564 $head[$h][1] = $langs->trans(
"ViewPerUser");
565 $head[$h][2] =
'cardperuser';
599function show_day_events(
$db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam =
'', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
601 global $user,
$conf, $langs;
602 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup;
604 global $cachethirdparties, $cachecontacts,
$cacheusers, $colorindexused;
607 '@phan-var-force array{0:array{0:int,1:int,2:int},1:array{0:int,1:int,2:int},2:array{0:int,1:int,2:int},3:array{0:int,1:int,2:int}} $theme_datacolor
608 @phan-var-force User[] $cacheusers
609 @phan-var-force array<int<0,3>> $colorindexused';
616 if (
$conf->use_javascript_ajax) {
617 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
620 $dateint = sprintf(
"%04d", $year).sprintf(
"%02d", $month).sprintf(
"%02d", $day);
626 $curtime =
dol_mktime(0, 0, 0, $month, $day, $year);
627 $urltoshow = DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&day='.str_pad((
string) $day, 2,
"0", STR_PAD_LEFT).
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year.$newparam;
629 if ($user->hasRight(
'agenda',
'myactions',
'create') || $user->hasRight(
'agenda',
'allactions',
'create')) {
630 $newparam .=
'&month='.str_pad((
string) $month, 2,
"0", STR_PAD_LEFT).
'&year='.$year;
632 if (empty($hourminsec) || !preg_match(
'/^[0-9]{6}$/', $hourminsec)) {
633 $hourminsec =
'100000';
635 $urltocreate = DOL_URL_ROOT.
'/comm/action/card.php?action=create&datep='.sprintf(
"%04d%02d%02d", $year, $month, $day).$hourminsec.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($newparam ?
'?'.$newparam :
''));
639 print
'<div id="dayevent_'.$dateint.
'" class="dayevent tagtable centpercent nobordernopadding">'.
"\n";
642 print
'<div class="tagtr cursorpointer" onclick="window.location=\''.$urltocreate.
'\';
"><div class="nowrap tagtd
"><div class="left
inline-block
">';
643 print '<a class="dayevent-aday
" style="color: #666
" href="'.$urltoshow.'">';
644 print($datenowint == $dateint ? '<span class="badgeliketopmenu
">' : '');
646 print dol_print_date($curtime, 'daytextshort');
648 print dol_print_date($curtime, '%d');
650 print($datenowint == $dateint ? '</span>' : '');
652 print '</div><div class="nowrap floatright
inline-block marginrightonly
">';
653 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
654 print '<a class="cursoradd
" href="'.$urltocreate.'">'; // Explicit link, useful for nojs interfaces
655 print img_picto($langs->trans("NewAction
"), 'edit_add.png');
658 print '</div></div></div>'."\n
";
666 // Line with td contains all div of each events
667 print '<div class="tagtr
">';
668 print '<div class="tagtd centpercent agendacell sortable
">';
670 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
678 $ymd = sprintf("%04d
", $year).sprintf("%02d
", $month).sprintf("%02d
", $day);
680 $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
681 $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
682 //var_dump($colorindexused);
684 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
685 $tmpholiday = new Holiday($db);
687 foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user
688 $annee = (int) dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
689 $mois = (int) dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
690 $jour = (int) dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD'
692 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."<br>\n
";
693 //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' day='.$day.' month='.$month.' year='.$year."<br>\n
";
695 if ($day == $jour && $month == $mois && $year == $annee) {
696 foreach ($eventarray[$daykey] as $index => $event) {
697 if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) {
698 $keysofuserassigned = array_keys($event->userassigned);
700 // Define $color (Hex string like '0088FF') and $cssclass of event
704 if (in_array($user->id, $keysofuserassigned)) {
705 $cssclass = 'family_mytasks';
707 if (empty($cacheusers[$event->userownerid])) {
708 $newuser = new User($db);
709 $newuser->fetch($event->userownerid);
710 $cacheusers[$event->userownerid] = $newuser;
712 //var_dump($cacheusers[$event->userownerid]->color);
714 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
715 if (!empty($cacheusers[$event->userownerid]->color)) {
716 $color = $cacheusers[$event->userownerid]->color;
719 /* May be we need this: if (getDolGlobalString('AGENDA_USE_COLOR_PER_EVENT_TYPE')) {
720 $color = $event->type_color;
722 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
724 if (!empty($event->icalname)) {
725 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
726 $numicals[dol_string_nospecial($event->icalname)] = 0;
728 $numicals[dol_string_nospecial($event->icalname)]++;
731 $color = ($event->icalcolor ? $event->icalcolor : -1);
732 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
733 } elseif ($event->type_code == 'BIRTHDAY') {
736 $cssclass = 'family_birthday ';
737 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
738 } elseif ($event->type == 'bookcal_calendar') {
741 $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink
"]) ? $bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar] : "");
742 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
745 $color = ($event->icalcolor ? $event->icalcolor : -1);
746 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
748 if (empty($cacheusers[$event->userownerid])) {
749 $newuser = new User($db);
750 $newuser->fetch($event->userownerid);
751 $cacheusers[$event->userownerid] = $newuser;
753 //var_dump($cacheusers[$event->userownerid]->color);
755 // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
756 if (!empty($cacheusers[$event->userownerid]->color)) {
757 $color = $cacheusers[$event->userownerid]->color;
761 if ($color < 0) { // Color was not set on user card. Set color according to color index.
762 // Define color index if not yet defined
763 $idusertouse = ($event->userownerid ? $event->userownerid : 0);
764 if (isset($colorindexused[$idusertouse])) {
765 $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
767 $colorindex = $nextindextouse;
768 $colorindexused[$idusertouse] = $colorindex;
769 if (!empty($theme_datacolor[$nextindextouse + 1])) {
770 $nextindextouse++; // Prepare to use next color
773 if (isset($theme_datacolor[$colorindex])) {
774 $color = sprintf("%02x%02x%02x
", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
775 } elseif (getDolGlobalString('THEME_ELDY_BACKBODY')) {
776 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
777 $color = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_BACKBODY'), array()), '');
782 $cssclass = $cssclass.' eventday_'.$ymd;
784 // Defined style to disable drag and drop feature
785 if ($event->type_code == 'AC_OTH_AUTO') {
786 $cssclass .= " unmovable
";
787 } elseif ($event->type_code == 'HOLIDAY') {
788 $cssclass .= " unmovable
";
789 } elseif ($event->type_code == 'BIRTHDAY') {
790 $cssclass .= " unmovable
";
791 } elseif ($event->type_code == 'ICALEVENT') {
792 $cssclass .= " unmovable
";
793 } elseif ($event->date_start_in_calendar && $event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
794 // If the event is on several days
795 $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
796 $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
797 $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
798 //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
799 if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
800 $cssclass .= " unmovable unmovable-mustusefirstdaytodrag
";
802 $cssclass .= ' movable cursormove';
805 if ($user->hasRight('agenda', 'allactions', 'create') ||
806 (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
807 $cssclass .= " movable cursormove
";
809 $cssclass .= " unmovable
";
815 if ($mode == 'show_day') {
816 $h = 'height: 100%; ';
819 if ($mode == 'show_week') {
820 $h = 'height: 100%; ';
826 print '<!-- start event '.$i.' -->'."\n
";
829 if ($maxprint && $ireallyshown >= $maxprint) {
830 $morecss = 'showifmore';
832 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
835 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
838 /* I comment this because it hides event recorded from bookcal online page
839 if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink
"][$event->fk_bookcal_calendar])) {
842 if ($morecss != 'hidden') {
845 if ($morecss != 'showifmore' && $morecss != 'hidden') {
849 //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow);
850 if (isModEnabled("bookcal
") && $event->type == 'bookcal_calendar') {
851 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.'_
'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
853 print '<div id="event_
'.$ymd.'_
'.$i.'" class="event family_
'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
855 //print ' style="height: 100px;
';
856 //print ' position: absolute; top: 40px; width: 50%;
';
860 //var_dump($event->userassigned);
861 //var_dump($event->transparency);
862 print '<table class="centpercent cal_event
';
863 print(empty($event->transparency) ? ' cal_event_notbusy
' : ' cal_event_busy
');
864 //if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium
'; // Not busy
865 print '" style="'.$h;
866 $colortouse = $color;
867 // If colortouse is similar than background, we force to change it.
868 if (empty($event->transparency) && !getDolGlobalString('AGENDA_NO_TRANSPARENT_ON_NOT_BUSY
')) {
869 print 'background: #f0f0f0;
';
870 print 'border-left: 5px solid #
'.$colortouse.';
';
872 print 'background: #f0f0f0;
';
873 print 'border-left: 5px solid #
'.dol_color_minus($colortouse, -3).';
';
874 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($colortouse, -3).'), to(#
'.dol_color_minus($colortouse, -1).'));
';
876 //print 'background: #
'.$colortouse.';
';
877 //print 'background: -webkit-gradient(linear, left top, left bottom, from(#
'.dol_color_minus($color, -3).'), to(#
'.dol_color_minus($color, -1).'));
';
878 //if (!empty($event->transparency)) print 'background: #
'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#
'.$color.'), to(#
'.dol_color_minus($color,1).'));
';
879 //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;
';
880 //print ' -moz-border-radius:4px;
"';
881 //print 'border: 1px solid #ccc" width=
"100%"';
884 // First the tr of the event (only one tr for event is used, but several td)
886 print '<td class="tdoverflow nobottom small centpercent
'.($nowrapontd ? 'nowrap
' : '').'cal_event
'.($event->type_code == 'BIRTHDAY
' ? ' cal_event_birthday
' : '').'">';
887 print '<!-- left section of event -->';
891 $parameters = array();
892 $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
894 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
896 '@phan-var-force ActionComm $event';
897 if (empty($reshook)) {
900 if (empty($event->fulldayevent)) {
901 //print $event->getNomUrl(2).' ';
905 if ($event->type_code == 'BIRTHDAY') {
906 // It's birthday calendar
907 $picb = img_picto('', 'birthday-cake', 'class="pictofixedwidth
"');
908 print $picb.$langs->trans("Birthday
").'<br>';
912 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY') {
913 if (empty($event->fulldayevent)) {
914 // Show hours (start ... end)
915 $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
916 $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
917 $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
918 $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel');
919 $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel');
920 $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel');
923 if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
924 $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel');
925 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
926 if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
933 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
934 if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
939 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
940 if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
941 $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
946 print $langs->trans("EventOnFullDay
")."<br>\n
";
952 $titletoshow = $daterange;
953 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label);
955 if ($event->type_code != 'ICALEVENT' && $event->type_code != 'BIRTHDAY') {
956 $savlabel = $event->label;
957 $event->label = $titletoshow;
958 // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
959 $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
960 $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title valignmiddle', '', 0, 0); // do not add 'inline-block' in css here: it makes the title transformed completely into '...'
961 $event->label = $savlabel;
964 // Loop on each assigned user
965 $listofusertoshow = '';
966 $posuserassigned = 0;
967 foreach ($event->userassigned as $tmpid => $tmpdata) {
968 if (!$posuserassigned && $titletoshow) {
969 $listofusertoshow .= '<br>';
972 if (empty($cacheusers[$tmpid])) {
973 $newuser = new User($db);
974 $newuser->fetch($tmpid);
975 $cacheusers[$tmpid] = $newuser;
978 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block');
981 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') {
983 print $listofusertoshow.' ';
986 if ($event->type_code == 'ICALEVENT') {
987 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
990 $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0));
991 $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0));
993 // If action related to company / contact
995 if ($thirdparty_id > 0) {
996 if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) {
997 $thirdparty = new Societe($db);
998 $thirdparty->fetch($thirdparty_id);
999 $cachethirdparties[$thirdparty_id] = $thirdparty;
1001 $thirdparty = $cachethirdparties[$thirdparty_id];
1003 if (!empty($thirdparty->id)) {
1004 $linerelatedto .= $thirdparty->getNomUrl(1, '', 0, 0, -1, 0, '', 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
1007 if (!empty($contact_id) && $contact_id > 0) {
1008 if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) {
1009 $contact = new Contact($db);
1010 $contact->fetch($contact_id);
1011 $cachecontacts[$contact_id] = $contact;
1013 $contact = $cachecontacts[$contact_id];
1015 if ($linerelatedto) {
1016 $linerelatedto .= ' ';
1018 if (!empty($contact->id)) {
1019 $linerelatedto .= $contact->getNomUrl(1, '', 0, '', -1, 0, 'valignmiddle inline'); // using inline-block make the content completely replace with ... when too large
1022 if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) {
1023 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1024 if ($linerelatedto) {
1025 $linerelatedto .= '<br>';
1027 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
1029 if ($linerelatedto) {
1030 print ' '.$linerelatedto;
1032 } elseif (!empty($reshook)) {
1033 print $hookmanager->resPrint;
1037 if ($event->type_code == 'HOLIDAY') {
1038 // It's holiday calendar
1039 $tmpholiday->fetch($event->id);
1041 print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block');
1043 $tmpid = $tmpholiday->fk_user;
1044 if (empty($cacheusers[$tmpid])) {
1045 $newuser = new User($db);
1046 $newuser->fetch($tmpid);
1047 $cacheusers[$tmpid] = $newuser;
1050 $listofusertoshow = '';
1051 $listofusertoshow .= "\n
".'<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block')."\n
";
1052 print $listofusertoshow;
1057 if ($event->location) {
1059 print $langs->trans("Location
").': '.$event->location;
1067 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
1069 if ($event->percentage >= 0) {
1073 print '<td class="nobottom right nowrap cal_event_right
'.($withstatus >= 2 ? ' cal_event_right_status
' : '').'">';
1075 print $event->getLibStatut(3, 1);
1079 print '</td></tr></table>';
1080 print '</div><!-- end event '.$i.' -->'."\n
";
1084 print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=
'.$mode.'&maxprint=0&month=
'.((int) $monthshown).'&year=
'.((int) $year);
1085 print($status ? '&
status=
'.$status : '').($filter ? '&filter=
'.urlencode($filter) : '');
1086 print($filtert ? '&search_filtert=
'.urlencode((string) $filtert) : '');
1087 print($usergroup ? '&search_usergroup=
'.urlencode((string) $usergroup) : '');
1088 print($actioncode != '' ? '&search_actioncode=
'.urlencode($actioncode) : '');
1089 print '">'.img_picto("all
", "1downarrow_selected.png
").' ...';
1090 print ' +'.(count($eventarray[$daykey]) - $maxprint);
1093 //$ok=false; // To avoid to show twice the link
1100 if (!$i) { // No events
1104 if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) {
1105 print '<div class="center cursorpointer cal_showmore
" id="more_
'.$ymd.'">'.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'</div>';
1106 //print ' +'.(count($eventarray[$daykey])-$maxprint);
1108 print '<script type="text/javascript
">'."\n
";
1109 print 'jQuery(document).ready(function () {'."\n
";
1110 print ' var open=0;'."\n
";
1111 print ' jQuery("#more_
'.$ymd.'").click(function() { console.log("Click on showmore
for '.$ymd.'"); reinit_day_'.$ymd.'(); event.stopImmediatePropagation(); });'."\n
";
1112 print ' function reinit_day_'.$ymd.'() {'."\n
";
1113 print ' jQuery(".eventday_
'.$ymd.'.showifmore
").toggle();'."\n
";
1114 print ' open = open + 1; if (open > 1) { open = 0; }'."\n
";
1115 print ' if (open) { ';
1116 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-up
", 'class="warning
"').'\');'."\n
";
1118 print ' jQuery("#more_
'.$ymd.'").html(\''.img_picto("All
", "angle-
double-down
", 'class="warning
"').' +'.($itoshow - $ireallyshown).'\');'."\n
";
1122 print '</script>'."\n
";
1125 print '</div></div>'; // td tr
1127 print '</div>'; // table
1140function dol_color_minus($color, $minus, $minusunit = 16)
1143 if ($minusunit == 16 && is_array($newcolor)) {
1144 $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
1145 $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
1146 $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
1148 // Not yet implemented
1173function agenda_build_eventarray($db, $hookmanager, $user, &$object, &$action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters, $sincedatec = null)
1175 $usergroup = $filters['usergroup'];
1176 $filtert = $filters['filtert'];
1177 $resourceid = $filters['resourceid'];
1178 $actioncode = $filters['actioncode'];
1179 $pid = $filters['pid'];
1180 $socid = $filters['socid'];
1181 $type = $filters['type'];
1182 $status = $filters['status'];
1183 $search_categ_cus = $filters['search_categ_cus'];
1185 // Load events from database into $eventarray
1186 $eventarray = array();
1189 // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
1191 if ($usergroup > 0) {
1192 $sql .= " DISTINCT
";
1194 $sql .= ' a.id, a.label,';
1195 $sql .= ' a.datep,';
1196 $sql .= ' a.datep2,';
1197 $sql .= ' a.percent,';
1198 $sql .= ' a.fk_user_author,a.fk_user_action,';
1199 $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
1200 $sql .= ' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,';
1201 $sql .= ' a.fk_element, a.elementtype,';
1202 $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto';
1204 // Add fields from hooks
1205 $parameters = array();
1206 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1207 $sql .= $hookmanager->resPrint;
1209 $sqlfields = $sql; // $sql fields to remove for count total
1211 $sql .= " FROM
".MAIN_DB_PREFIX."c_actioncomm as ca,
".MAIN_DB_PREFIX."actioncomm as a
";
1213 // We must filter on assignment table
1214 if (($filtert != '-1' && $filtert != '-2') || $usergroup > 0) {
1215 // TODO Replace with a AND EXISTS
1216 $sql .= " INNER JOIN
".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type =
'user'";
1217 if ($filtert != '-1' && $filtert != '-2' && $filtert != '-3') {
1218 $sql .= " AND (ar.fk_element IN (
".$db->sanitize($filtert).") OR (ar.fk_element IS NULL AND a.fk_user_action =
".((int) $filtert)."))
"; // The OR is for backward compatibility
1219 } elseif ($filtert == '-3') {
1220 $sql .= " AND ar.fk_element IN (
".$db->sanitize(implode(',', $user->getAllChildIds(1))).")
";
1222 if ($usergroup > 0) {
1223 $sql .= " INNER JOIN
".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element AND ugu.fk_usergroup =
".((int) $usergroup);
1227 // We must filter on resource table
1228 if ($resourceid > 0) {
1229 $sql .= ",
".MAIN_DB_PREFIX."element_resources as r
";
1232 // Add table from hooks
1233 $parameters = array();
1234 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1235 $sql .= $hookmanager->resPrint;
1237 $sql .= " WHERE a.fk_action = ca.id
";
1238 $sql .= " AND a.entity IN (
".getEntity('agenda').")
"; // bookcal is a "virtual view
" of agenda
1239 // Condition on actioncode
1240 if (!empty($actioncode)) {
1241 if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
1242 if ((is_array($actioncode) && in_array('AC_NON_AUTO', $actioncode)) || $actioncode == 'AC_NON_AUTO') {
1243 $sql .= " AND ca.type !=
'systemauto'";
1244 } elseif ((is_array($actioncode) && in_array('AC_ALL_AUTO', $actioncode)) || $actioncode == 'AC_ALL_AUTO') {
1245 $sql .= " AND ca.type =
'systemauto'";
1247 if ((is_array($actioncode) && in_array('AC_OTH', $actioncode)) || $actioncode == 'AC_OTH') {
1248 $sql .= " AND ca.type !=
'systemauto'";
1250 if ((is_array($actioncode) && in_array('AC_OTH_AUTO', $actioncode)) || $actioncode == 'AC_OTH_AUTO') {
1251 $sql .= " AND ca.type =
'systemauto'";
1255 if ((is_array($actioncode) && in_array('AC_NON_AUTO', $actioncode)) || $actioncode === 'AC_NON_AUTO') {
1256 $sql .= " AND ca.type !=
'systemauto'";
1257 } elseif ((is_array($actioncode) && in_array('AC_ALL_AUTO', $actioncode)) || $actioncode === 'AC_ALL_AUTO') {
1258 $sql .= " AND ca.type =
'systemauto'";
1260 if (is_array($actioncode)) {
1261 // Remove all -1 values
1262 $actioncode = array_filter(
1269 return ((string) $value !== '-1');
1272 if (count($actioncode)) {
1273 $sql .= " AND ca.code IN (
".$db->sanitize("'".implode("',
'", $actioncode)."'", 1).")
";
1275 } elseif ($actioncode !== '-1') {
1276 $sql .= " AND ca.code IN (
".$db->sanitize("'".implode("',
'", explode(',
', $actioncode))."'", 1).")
";
1281 if ($resourceid > 0) {
1282 $sql .= " AND r.element_type =
'action' AND r.element_id = a.id AND r.resource_id =
".((int) $resourceid);
1285 $sql .= " AND a.fk_project=
".((int) $pid);
1287 // If the internal user must only see his customers, force searching by him
1289 if (isModEnabled("societe
") && !$user->hasRight('societe', 'client', 'voir')) {
1290 $search_sale = $user->id;
1292 // Search on sale representative
1293 if ($search_sale && $search_sale != '-1') {
1294 if ($search_sale == -2) {
1295 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM
".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc)
";
1296 } elseif ($search_sale > 0) {
1297 $sql .= " AND (a.fk_soc IS NULL OR 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)."))
";
1302 $sql .= " AND a.fk_soc =
".((int) $socid);
1304 //var_dump($day.' '.$month.' '.$year);
1305 if ($mode == 'show_day') {
1307 $sql .= " (a.datep BETWEEN
'".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel
'))."'";
1308 $sql .= " AND
'".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel
'))."')
";
1310 $sql .= " (a.datep2 BETWEEN
'".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel
'))."'";
1311 $sql .= " AND
'".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel
'))."')
";
1313 $sql .= " (a.datep <
'".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel
'))."'";
1314 $sql .= " AND a.datep2 >
'".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel
'))."')
";
1319 $sql .= " (a.datep BETWEEN
'".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
1320 $sql .= " AND
'".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')
"; // End 7 days after + 3 to go from 28 to 31
1322 $sql .= " (a.datep2 BETWEEN
'".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
1323 $sql .= " AND
'".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')
";
1325 $sql .= " (a.datep <
'".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
1326 $sql .= " AND a.datep2 >
'".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')
";
1329 if ($sincedatec !== null) {
1330 $sql .= " AND (a.datec >
'".$db->idate($sincedatec)."' OR a.tms >
'".$db->idate($sincedatec)."')
";
1333 $sql .= " AND ca.id =
".((int) $type);
1335 if ($status == '0') {
1336 // To do (not started)
1337 $sql .= " AND a.percent = 0
";
1339 if ($status === 'na') {
1341 $sql .= " AND a.percent = -1
";
1343 if ($status == '50') {
1344 // Running already started
1345 $sql .= " AND (a.percent > 0 AND a.percent < 100)
";
1347 if ($status == 'done' || $status == '100') {
1348 $sql .= " AND (a.percent = 100)
";
1350 if ($status == 'todo') {
1351 $sql .= " AND (a.percent >= 0 AND a.percent < 100)
";
1354 // Search in categories, -1 is all and -2 is no categories
1355 if ($search_categ_cus != -1) {
1356 if ($search_categ_cus == -2) {
1357 $sql .= " AND NOT EXISTS (SELECT ca.fk_actioncomm FROM
".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)
";
1358 } elseif ($search_categ_cus > 0) {
1359 $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((string) $search_categ_cus)."))
";
1364 $sql .= $db->order("datep
");
1366 $MAXONSAMEPAGE = getDolGlobalInt('AGENDA_MAX_ON_SAME_PAGE', 5000); // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import)
1368 $sql .= $db->plimit($MAXONSAMEPAGE + 1);
1372 $resql = $db->query($sql);
1374 $num = $db->num_rows($resql);
1378 while ($i < $num && $i < $MAXONSAMEPAGE) {
1379 $obj = $db->fetch_object($resql);
1381 // Discard auto action if option is on
1382 if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') {
1387 // Create a new object action
1388 $event = new ActionComm($db);
1390 $event->id = $obj->id;
1391 $event->ref = (string) $event->id;
1393 $event->fulldayevent = $obj->fulldayevent;
1395 // event->datep and event->datef must be GMT date.
1396 if ($event->fulldayevent) {
1397 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1398 $event->datep = $db->jdate($obj->datep, $tzforfullday ? 'tzuser' : 'tzserver'); // If saved in $tzforfullday = gmt, we must invert date to be in user tz
1399 $event->datef = $db->jdate($obj->datep2, $tzforfullday ? 'tzuser' : 'tzserver');
1401 // Example: $obj->datep = '1970-01-01 01:00:00', jdate will return 0 if TZ of PHP server is Europe/Berlin (+1)
1402 $event->datep = $db->jdate($obj->datep, 'tzserver');
1403 $event->datef = $db->jdate($obj->datep2, 'tzserver');
1405 //$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt');
1406 //var_dump($obj->id.' '.$obj->datep.' '.dol_print_date($obj->datep, 'dayhour', 'gmt'));
1407 //var_dump($obj->id.' '.$event->datep.' '.dol_print_date($event->datep, 'dayhour', 'gmt'));
1409 $event->type_code = $obj->type_code;
1410 $event->type_label = $obj->type_label;
1411 $event->type_color = $obj->type_color;
1412 $event->type = $obj->type_type;
1413 $event->type_picto = $obj->type_picto;
1415 $event->label = $obj->label;
1416 $event->percentage = $obj->percent;
1418 $event->authorid = $obj->fk_user_author; // user id of creator
1419 $event->userownerid = $obj->fk_user_action; // user id of owner
1420 $event->fetch_userassigned(); // This load $event->userassigned
1422 $event->priority = $obj->priority;
1423 $event->location = $obj->location;
1424 $event->transparency = $obj->transparency;
1425 $event->fk_element = $obj->fk_element;
1426 $event->elementid = $obj->fk_element;
1427 $event->elementtype = $obj->elementtype;
1429 $event->fk_project = $obj->fk_project;
1431 $event->socid = $obj->fk_soc;
1432 $event->contact_id = $obj->fk_contact;
1433 $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar;
1434 if (!empty($event->fk_bookcal_calendar)) {
1435 $event->type = "bookcal_calendar
";
1438 // Defined date_start_in_calendar and date_end_in_calendar property
1439 // They are date start and end of action but modified to not be outside calendar view.
1440 $event->date_start_in_calendar = $event->datep;
1441 if ($event->datef != '' && $event->datef >= $event->datep) {
1442 $event->date_end_in_calendar = $event->datef;
1444 $event->date_end_in_calendar = $event->datep;
1448 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1449 // This record is out of visible range
1451 if ($event->date_start_in_calendar < $firstdaytoshow) {
1452 $event->date_start_in_calendar = $firstdaytoshow;
1454 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1455 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1458 // Add an entry in actionarray for each day
1459 $daycursor = $event->date_start_in_calendar;
1460 $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel');
1461 $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel');
1462 $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel');
1464 $daycursorend = $event->date_end_in_calendar;
1465 $anneeend = (int) dol_print_date($daycursorend, '%Y', 'tzuserrel');
1466 $moisend = (int) dol_print_date($daycursorend, '%m', 'tzuserrel');
1467 $jourend = (int) dol_print_date($daycursorend, '%d', 'tzuserrel');
1469 //var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt')); // Hour at greenwich
1470 //var_dump($annee.'-'.$mois.'-'.$jour);
1471 //print 'annee='.$annee.' mois='.$mois.' jour='.$jour.'<br>';
1473 // Loop on each day covered by action to prepare an index to show on calendar
1476 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz
1477 $daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz
1479 print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'<br>';
1480 print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'<br>';
1481 print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'<br>';
1482 print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'<br>';
1483 print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'<br>';
1484 print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'<br>';
1487 //if ($event->id==408)
1488 //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'<br>';
1489 //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'tzuserrel').' - '.dol_print_date($event->datep, 'dayhour', 'tzuserrel').' '.dol_print_date($event->datef, 'dayhour', 'tzuserrel').'<br>';
1491 $eventarray[$daykey][] = $event;
1494 $daykey += 60 * 60 * 24;
1495 //if ($daykey > $event->date_end_in_calendar) {
1496 if ($daykey > $daykeyend) {
1500 //var_dump($eventarray);
1501 //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
1502 //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
1505 $parameters['obj'] = $obj;
1506 $reshook = $hookmanager->executeHooks('hookEventElements', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
1507 $event = $hookmanager->resPrint;
1509 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1515 dol_print_error($db);
1517 //var_dump($eventarray);
1519 return array('eventarray' => $eventarray, 'nbevents' => $nbevents, 'maxonsamepage' => $MAXONSAMEPAGE);
1537function agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, &$eventarray, &$nbevents)
1539 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1541 $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
1542 $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
1543 $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))';
1544 $sql .= " AND sp.entity IN (
".getEntity('contact').")
";
1545 if ($mode == 'show_day') {
1546 $sql .= ' AND MONTH(birthday) = '.((int) $month);
1547 $sql .= ' AND DAY(birthday) = '.((int) $day);
1549 $sql .= ' AND MONTH(birthday) = '.((int) $month);
1551 $sql .= ' ORDER BY birthday';
1553 dol_syslog("agenda.lib.php::agenda_get_birthday_events
", LOG_DEBUG);
1554 $resql = $db->query($sql);
1556 dol_print_error($db);
1560 $num = $db->num_rows($resql);
1565 $obj = $db->fetch_object($resql);
1567 $event = new ActionComm($db);
1569 $event->id = $obj->rowid; // We put contact id in action id for birthdays events
1570 $event->ref = (string) $event->id;
1572 $datebirth = dol_stringtotime($obj->birthday, 1);
1573 $datearray = dol_getdate($datebirth, true);
1574 $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they won't but converted during output
1575 $event->datef = $event->datep;
1577 $event->type_code = 'BIRTHDAY';
1578 $event->type_label = '';
1579 $event->type_color = '';
1580 $event->type = 'birthdate';
1581 $event->type_picto = 'birthdate';
1583 $event->label = $langs->trans("Birthday
").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
1584 $event->percentage = 100;
1585 $event->fulldayevent = 1;
1587 $event->contact_id = $obj->rowid;
1589 $event->date_start_in_calendar = $event->datep;
1590 $event->date_end_in_calendar = $event->datef;
1592 // Add an entry in eventarray for each day
1593 $daycursor = $event->datep;
1594 $annee = (int) dol_print_date($daycursor, '%Y', 'tzuserrel');
1595 $mois = (int) dol_print_date($daycursor, '%m', 'tzuserrel');
1596 $jour = (int) dol_print_date($daycursor, '%d', 'tzuserrel');
1598 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
1600 $eventarray[$daykey][] = $event;
if(! $sortfield) if(! $sortorder) $object
show_array_actions_to_do($max=5)
Show actions to do array.
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, $search_import_key='')
Show filter form in agenda view.
show_array_last_actions_done($max=5)
Show last actions array.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
agenda_prepare_head()
Prepare array with list of tabs.
actions_prepare_head($object)
Prepare array with list of tabs.
agenda_build_eventarray($db, $hookmanager, $user, &$object, &$action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters, $sincedatec=null)
Build $eventarray (list of ActionComm objects, indexed by day) for the agenda calendar views (month/w...
Class to manage agenda events (actions)
Class to manage customers or prospects.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage third parties objects (customers, suppliers, prospects...)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
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...
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string