dolibarr 25.0.0-alpha
agenda.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2022-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
55 $form,
56 $canedit,
57 $status,
58 $year,
59 $month,
60 $day,
61 $showbirthday,
62 $filtera,
63 $filtert,
64 $filtered,
65 $pid,
66 $socid,
67 $action,
68 $showextcals = array(),
69 $actioncode = '',
70 $usergroupid = 0,
71 $excludetype = '',
72 $resourceid = 0,
73 $search_categ_cus = 0,
74 $search_import_key = ''
75) {
76 global $user, $langs, $db, $hookmanager;
77 global $massaction;
78
79 $langs->load("companies");
80
81 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
82 $formactions = new FormActions($db);
83
84 // Filters
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') { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
90 print '<input type="hidden" name="action" value="'.$action.'">';
91 }
92 print '<input type="hidden" name="search_showbirthday" value="'.((int) $showbirthday).'">';
93
94 print '<div class="divsearchfield">';
95 // Type
96 $multiselect = 0;
97 if (getDolGlobalString('MAIN_ENABLE_MULTISELECT_TYPE')) { // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
98 $multiselect = (getDolGlobalString('AGENDA_USE_EVENT_TYPE'));
99 }
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);
102 print '</div>';
103
104 if ($canedit) {
105 // Assigned to user
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');
109 print '</div>';
110
111 // Assigned to user group
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');
115 print '</div>';
116
117 if (isModEnabled('resource')) {
118 include_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
119 $formresource = new FormResource($db);
120
121 // Resource
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');
125 print '</div>';
126 }
127 }
128
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', '', '&nbsp;', 0, 0, array(), 0, 'minwidth100 maxwidth250 widthcentpercentminusx');
133 print '</div>';
134 }
135
136 if (isModEnabled('project') && $user->hasRight('projet', 'lire')) {
137 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
138 $formproject = new FormProjets($db);
139
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');
143 print '</div>';
144 }
145
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';
149 $formother = new FormOther($db);
150 $langs->load('categories');
151
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');
155 print '</div>';
156 }
157
158 if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) {
159 // Status
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');
163 print '</div>';
164 }
165
166 // Hooks
167 $parameters = array('canedit' => $canedit, 'pid' => $pid, 'socid' => $socid);
168 $object = null; // Null on purpose: @phan-suppress-next-line PhanPluginConstantVariableNull
169 $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been
170
171 print '<div class="clearboth"></div>';
172}
173
174
181function show_array_actions_to_do($max = 5)
182{
183 global $langs, $conf, $user, $db, $socid;
184
185 $now = dol_now();
186
187 include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
188 include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
189
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";
200 }
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);
205 }
206 if ($socid) {
207 $sql .= " AND s.rowid = ".((int) $socid);
208 }
209 $sql .= " ORDER BY a.datep DESC, a.id DESC";
210 $sql .= $db->plimit($max, 0);
211
212 $resql = $db->query($sql);
213 if ($resql) {
214 $num = $db->num_rows($resql);
215
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>';
220 print '</tr>';
221
222 $i = 0;
223
224 $staticaction = new ActionComm($db);
225 $customerstatic = new Client($db);
226
227 while ($i < $num) {
228 $obj = $db->fetch_object($resql);
229
230
231 print '<tr class="oddeven">';
232
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>';
237
238 // print '<td>'.dol_trunc($obj->label,22).'</td>';
239
240 print '<td>';
241 if ($obj->socid > 0) {
242 $customerstatic->id = $obj->socid;
243 $customerstatic->name = $obj->name;
244 //$customerstatic->name_alias = $obj->name_alias;
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);
253 }
254 print '</td>';
255
256 $datep = $db->jdate($obj->dp);
257 $datep2 = $db->jdate($obj->dp2);
258
259 // Date
260 print '<td width="100" class="right tddate">'.dol_print_date($datep, 'day').'&nbsp;';
261 $late = 0;
262 if ($obj->percent == 0 && $datep && $datep < time()) {
263 $late = 1;
264 }
265 if ($obj->percent == 0 && !$datep && $datep2 && $datep2 < time()) {
266 $late = 1;
267 }
268 if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) {
269 $late = 1;
270 }
271 if ($obj->percent > 0 && $obj->percent < 100 && !$datep2 && $datep && $datep < time()) {
272 $late = 1;
273 }
274 if ($late) {
275 print img_warning($langs->trans("Late"));
276 }
277 print "</td>";
278
279 // Statut
280 print '<td class="right" width="14">'.$staticaction->LibStatut($obj->percent, 3)."</td>\n";
281
282 print "</tr>\n";
283
284 $i++;
285 }
286 print "</table></div><br>";
287
288 $db->free($resql);
289 } else {
291 }
292}
293
294
302{
303 global $langs, $conf, $user, $db, $socid;
304
305 $now = dol_now();
306
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";
317 }
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);
322 }
323 if ($socid) {
324 $sql .= " AND s.rowid = ".((int) $socid);
325 }
326 $sql .= " ORDER BY a.datep2 DESC";
327 $sql .= $db->plimit($max, 0);
328
329 $resql = $db->query($sql);
330 if ($resql) {
331 $num = $db->num_rows($resql);
332
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>';
337 print '</tr>';
338
339 $i = 0;
340
341 $staticaction = new ActionComm($db);
342 $customerstatic = new Societe($db);
343
344 while ($i < $num) {
345 $obj = $db->fetch_object($resql);
346
347
348 print '<tr class="oddeven">';
349
350 $staticaction->type_code = $obj->code;
351 $staticaction->label = $obj->label;
352 $staticaction->id = $obj->id;
353 print '<td>'.$staticaction->getNomUrl(1, 34).'</td>';
354
355 //print '<td>'.dol_trunc($obj->label,24).'</td>';
356
357 print '<td>';
358 if ($obj->socid > 0) {
359 $customerstatic->id = $obj->socid;
360 $customerstatic->name = $obj->name;
361 //$customerstatic->name_alias = $obj->name_alias;
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);
370 }
371 print '</td>';
372
373 // Date
374 print '<td width="100" class="right tddate">'.dol_print_date($db->jdate($obj->da2), 'day');
375 print "</td>";
376
377 // Status
378 print '<td class="right" width="14">'.$staticaction->LibStatut($obj->percent, 3)."</td>\n";
379
380 print "</tr>\n";
381 $i++;
382 }
383 // TODO Add a reminder for "contracts need to be put in service."
384 // TODO Add reminder for "contracts expiring soon."
385 print "</table></div><br>";
386
387 $db->free($resql);
388 } else {
390 }
391}
392
393
400{
401 global $langs, $conf, $user, $extrafields;
402
403 $extrafields->fetch_name_optionals_label('actioncomm');
404
405 $h = 0;
406 $head = array();
407
408 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_other.php");
409 $head[$h][1] = $langs->trans("Miscellaneous");
410 $head[$h][2] = 'other';
411 $h++;
412
413 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda.php");
414 $head[$h][1] = $langs->trans("AutoActions");
415 $head[$h][2] = 'autoactions';
416 $h++;
417
418 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_reminder.php");
419 $head[$h][1] = $langs->trans("Reminders");
420 $head[$h][2] = 'reminders';
421 $h++;
422
423 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_xcal.php");
424 $head[$h][1] = $langs->trans("ExportCal");
425 $head[$h][2] = 'xcal';
426 $h++;
427
428 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_extsites.php");
429 $head[$h][1] = $langs->trans("ExtSites");
430 $head[$h][2] = 'extsites';
431 $h++;
432
433 complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin');
434
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>';
440 }
441 $head[$h][2] = 'attributes';
442 $h++;
443
444 complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin', 'remove');
445
446
447 return $head;
448}
449
457{
458 global $db, $langs, $conf, $user;
459
460 $h = 0;
461 $head = array();
462
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';
466 $h++;
467
468 // Tab to link resources
469 if (isModEnabled('resource')) {
470 include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
471 $resource = new Dolresource($db);
472
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>' : '');
479 }
480 $head[$h][2] = 'resources';
481 $h++;
482 }
483
484 // Attached files
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)$'));
489 $nbLinks = Link::count($db, $object->element, $object->id);
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>' : '');
494 }
495 $head[$h][2] = 'documents';
496 $h++;
497
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';
501 $h++;
502
503 complete_head_from_modules($conf, $langs, $object, $head, $h, 'action');
504
505 complete_head_from_modules($conf, $langs, $object, $head, $h, 'action', 'remove');
506
507 return $head;
508}
509
510
518{
519 global $langs, $conf, $user;
520
521 $h = 0;
522 $head = array();
523 $query = [];
524 parse_str($param, $query);
525
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';
530 $h++;
531
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';
536 $h++;
537
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';
542 $h++;
543
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';
548 $h++;
549
550 unset($query['mode']);
551 if (getDolGlobalString('AGENDA_SHOW_PERTYPE')) {
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';
555 $h++;
556 }
557
558 $newparam = $param;
559 $newparam = preg_replace('/&?search_filtert=\d+/', '', $newparam);
560 $query = [];
561 parse_str($newparam, $query);
562
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';
566 $h++;
567
568
569 // Show more tabs from modules
570 // Entries must be declared in modules descriptor with line
571 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
572 // $this->tabs = array('entity:-tabname); to remove a tab
573 complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda');
574
575 complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda', 'remove');
576
577 return $head;
578}
579
599function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array())
600{
601 global $user, $conf, $langs;
602 global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form
603 global $theme_datacolor;
604 global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
605 global $hookmanager;
606
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) { // Enable the "Show more button..."
617 $conf->global->MAIN_JS_SWITCH_AGENDA = 1;
618 }
619
620 $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
621 $datenowint = dol_print_date(dol_now(), "%Y%m%d");
622 //print 'show_day_events day='.$day.' month='.$month.' year='.$year.' dateint='.$dateint.' datenowint='.$datenowint;
623
624 print "\n";
625
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;
628 $urltocreate = '';
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;
631 $hourminsec = getDolGlobalString('AGENDA_DEFAULT_BEGIN_TIME');
632 if (empty($hourminsec) || !preg_match('/^[0-9]{6}$/', $hourminsec)) {
633 $hourminsec = '100000';
634 }
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 : ''));
636 }
637
638 // Line with title of day
639 print '<div id="dayevent_'.$dateint.'" class="dayevent tagtable centpercent nobordernopadding">'."\n";
640
641 if ($nonew <= 0) {
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">' : '');
645 if ($showinfo) {
646 print dol_print_date($curtime, 'daytextshort');
647 } else {
648 print dol_print_date($curtime, '%d');
649 }
650 print($datenowint == $dateint ? '</span>' : '');
651 print '</a>';
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');
656 print '</a>';
657 }
658 print '</div></div></div>'."\n";
659 }
660
661 if ($nonew < 0) {
662 print '</div>';
663 return;
664 }
665
666 // Line with td contains all div of each events
667 print '<div class="tagtr">';
668 print '<div class="tagtd centpercent agendacell sortable">';
669
670 //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
671 $i = 0;
672 $ireallyshown = 0;
673 $itoshow = 0;
674 $numother = 0;
675 $numbirthday = 0;
676 $numical = 0;
677 $numicals = array();
678 $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
679
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);
683
684 include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
685 $tmpholiday = new Holiday($db);
686
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'
691
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";
694
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);
699
700 // Define $color (Hex string like '0088FF') and $cssclass of event
701 $color = -1;
702 $cssclass = '';
703 $colorindex = -1;
704 if (in_array($user->id, $keysofuserassigned)) {
705 $cssclass = 'family_mytasks';
706
707 if (empty($cacheusers[$event->userownerid])) {
708 $newuser = new User($db);
709 $newuser->fetch($event->userownerid);
710 $cacheusers[$event->userownerid] = $newuser;
711 }
712 //var_dump($cacheusers[$event->userownerid]->color);
713
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;
717 }
718
719 /* May be we need this: if (getDolGlobalString('AGENDA_USE_COLOR_PER_EVENT_TYPE')) {
720 $color = $event->type_color;
721 }*/
722 } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file
723 $numical++;
724 if (!empty($event->icalname)) {
725 if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
726 $numicals[dol_string_nospecial($event->icalname)] = 0;
727 }
728 $numicals[dol_string_nospecial($event->icalname)]++;
729 }
730
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') {
734 $numbirthday++;
735 $colorindex = 2;
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') {
739 $numbirthday++;
740 $colorindex = 3;
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]);
743 } else {
744 $numother++;
745 $color = ($event->icalcolor ? $event->icalcolor : -1);
746 $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
747
748 if (empty($cacheusers[$event->userownerid])) {
749 $newuser = new User($db);
750 $newuser->fetch($event->userownerid);
751 $cacheusers[$event->userownerid] = $newuser;
752 }
753 //var_dump($cacheusers[$event->userownerid]->color);
754
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;
758 }
759 }
760
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
766 } else {
767 $colorindex = $nextindextouse;
768 $colorindexused[$idusertouse] = $colorindex;
769 if (!empty($theme_datacolor[$nextindextouse + 1])) {
770 $nextindextouse++; // Prepare to use next color
771 }
772 }
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()), '');
778 } else {
779 $color = "ffffff";
780 }
781 }
782 $cssclass = $cssclass.' eventday_'.$ymd;
783
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";
801 } else {
802 $cssclass .= ' movable cursormove';
803 }
804 } else {
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";
808 } else {
809 $cssclass .= " unmovable";
810 }
811 }
812
813 $h = '';
814 $nowrapontd = 1;
815 if ($mode == 'show_day') {
816 $h = 'height: 100%; ';
817 $nowrapontd = 0;
818 }
819 if ($mode == 'show_week') {
820 $h = 'height: 100%; ';
821 $nowrapontd = 0;
822 }
823
824 // Show event box
825 print "\n";
826 print '<!-- start event '.$i.' -->'."\n";
827
828 $morecss = '';
829 if ($maxprint && $ireallyshown >= $maxprint) {
830 $morecss = 'showifmore';
831 }
832 if ($event->type == 'birthdate' && !GETPOST('check_birthday')) {
833 $morecss = 'hidden';
834 }
835 if ($event->type == 'holiday' && !GETPOST('check_holiday')) {
836 $morecss = 'hidden';
837 }
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])) {
840 $morecss = 'hidden';
841 } */
842 if ($morecss != 'hidden') {
843 $itoshow++;
844 }
845 if ($morecss != 'showifmore' && $morecss != 'hidden') {
846 $ireallyshown++;
847 }
848
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 : '').'"';
852 } else {
853 print '<div id="event_'.$ymd.'_'.$i.'" class="event family_'.$event->type.' '.$cssclass.($morecss ? ' '.$morecss : '').'"';
854 }
855 //print ' style="height: 100px;';
856 //print ' position: absolute; top: 40px; width: 50%;';
857 //print '"';
858 print '>';
859
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.';';
871 } else {
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).'));';
875 }
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%"';
882 print '">';
883
884 // First the tr of the event (only one tr for event is used, but several td)
885 print '<tr>';
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 -->';
888
889 $daterange = '';
890
891 $parameters = array();
892 $reshook = $hookmanager->executeHooks('eventOptions', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
893 if ($reshook < 0) {
894 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
895 } else {
896 '@phan-var-force ActionComm $event';
897 if (empty($reshook)) {
898 // Other calendar
899 /*
900 if (empty($event->fulldayevent)) {
901 //print $event->getNomUrl(2).' ';
902 }
903 */
904
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>';
909 }
910
911 // Date
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');
921
922 // Hour start
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) {
927 $daterange .= '-';
928 }
929 //else
930 //print '...';
931 }
932 }
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) {
935 $daterange .= '...';
936 }
937 }
938 // Hour end
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');
942 }
943 }
944 } else {
945 if ($showinfo) {
946 print $langs->trans("EventOnFullDay")."<br>\n";
947 }
948 }
949 }
950
951 // Show title
952 $titletoshow = $daterange;
953 $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label);
954
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;
962 }
963
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>';
970 }
971 $posuserassigned++;
972 if (empty($cacheusers[$tmpid])) {
973 $newuser = new User($db);
974 $newuser->fetch($tmpid);
975 $cacheusers[$tmpid] = $newuser;
976 }
977
978 $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle inline-block');
979 }
980
981 if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') {
982 print $titletoshow;
983 print $listofusertoshow.' &nbsp;';
984 }
985
986 if ($event->type_code == 'ICALEVENT') {
987 print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
988 }
989
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));
992
993 // If action related to company / contact
994 $linerelatedto = '';
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;
1000 } else {
1001 $thirdparty = $cachethirdparties[$thirdparty_id];
1002 }
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
1005 }
1006 }
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;
1012 } else {
1013 $contact = $cachecontacts[$contact_id];
1014 }
1015 if ($linerelatedto) {
1016 $linerelatedto .= '&nbsp;';
1017 }
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
1020 }
1021 }
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>';
1026 }
1027 $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
1028 }
1029 if ($linerelatedto) {
1030 print ' '.$linerelatedto;
1031 }
1032 } elseif (!empty($reshook)) {
1033 print $hookmanager->resPrint;
1034 }
1035 }
1036
1037 if ($event->type_code == 'HOLIDAY') {
1038 // It's holiday calendar
1039 $tmpholiday->fetch($event->id);
1040
1041 print $tmpholiday->getNomUrl(1, -1, 0, 'valignmiddle inline-block');
1042
1043 $tmpid = $tmpholiday->fk_user;
1044 if (empty($cacheusers[$tmpid])) {
1045 $newuser = new User($db);
1046 $newuser->fetch($tmpid);
1047 $cacheusers[$tmpid] = $newuser;
1048 }
1049
1050 $listofusertoshow = '';
1051 $listofusertoshow .= "\n".'<br>'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle inline-block')."\n";
1052 print $listofusertoshow;
1053 }
1054
1055 // Show location
1056 if ($showinfo) {
1057 if ($event->location) {
1058 print '<br>';
1059 print $langs->trans("Location").': '.$event->location;
1060 }
1061 }
1062
1063 print '</td>';
1064
1065 // Status - Percent
1066 $withstatus = 0;
1067 if ($event->type_code != 'HOLIDAY' && $event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
1068 $withstatus = 1;
1069 if ($event->percentage >= 0) {
1070 $withstatus = 2;
1071 }
1072 }
1073 print '<td class="nobottom right nowrap cal_event_right'.($withstatus >= 2 ? ' cal_event_right_status' : '').'">';
1074 if ($withstatus) {
1075 print $event->getLibStatut(3, 1);
1076 } else {
1077 print '&nbsp;';
1078 }
1079 print '</td></tr></table>';
1080 print '</div><!-- end event '.$i.' -->'."\n";
1081
1082 $i++;
1083 } else {
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);
1091 print '</a>';
1092 break;
1093 //$ok=false; // To avoid to show twice the link
1094 }
1095 }
1096
1097 break;
1098 }
1099 }
1100 if (!$i) { // No events
1101 print '&nbsp;';
1102 }
1103
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);
1107
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";
1117 print ' } else { ';
1118 print ' jQuery("#more_'.$ymd.'").html(\''.img_picto("All", "angle-double-down", 'class="warning"').' +'.($itoshow - $ireallyshown).'\');'."\n";
1119 print ' }'."\n";
1120 print ' }'."\n";
1121 print '});'."\n";
1122 print '</script>'."\n";
1123 }
1124
1125 print '</div></div>'; // td tr
1126
1127 print '</div>'; // table
1128 print "\n";
1129}
1130
1131
1140function dol_color_minus($color, $minus, $minusunit = 16)
1141{
1142 $newcolor = $color;
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));
1147 } else {
1148 // Not yet implemented
1149 }
1150 return $newcolor;
1151}
1152
1173function agenda_build_eventarray($db, $hookmanager, $user, &$object, &$action, $mode, $year, $month, $day, $firstdaytoshow, $lastdaytoshow, $filters, $sincedatec = null)
1174{
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'];
1184
1185 // Load events from database into $eventarray
1186 $eventarray = array();
1187 $nbevents = 0;
1188
1189 // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
1190 $sql = 'SELECT ';
1191 if ($usergroup > 0) {
1192 $sql .= " DISTINCT";
1193 }
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';
1203
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;
1208
1209 $sqlfields = $sql; // $sql fields to remove for count total
1210
1211 $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as ca, ".MAIN_DB_PREFIX."actioncomm as a";
1212
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))).")";
1221 }
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);
1224 }
1225 }
1226
1227 // We must filter on resource table
1228 if ($resourceid > 0) {
1229 $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
1230 }
1231
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;
1236
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'";
1246 } else {
1247 if ((is_array($actioncode) && in_array('AC_OTH', $actioncode)) || $actioncode == 'AC_OTH') {
1248 $sql .= " AND ca.type != 'systemauto'";
1249 }
1250 if ((is_array($actioncode) && in_array('AC_OTH_AUTO', $actioncode)) || $actioncode == 'AC_OTH_AUTO') {
1251 $sql .= " AND ca.type = 'systemauto'";
1252 }
1253 }
1254 } else {
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'";
1259 } else {
1260 if (is_array($actioncode)) {
1261 // Remove all -1 values
1262 $actioncode = array_filter(
1263 $actioncode,
1268 function ($value) {
1269 return ((string) $value !== '-1');
1270 }
1271 );
1272 if (count($actioncode)) {
1273 $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
1274 }
1275 } elseif ($actioncode !== '-1') {
1276 $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
1277 }
1278 }
1279 }
1280 }
1281 if ($resourceid > 0) {
1282 $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid);
1283 }
1284 if ($pid) {
1285 $sql .= " AND a.fk_project=".((int) $pid);
1286 }
1287 // If the internal user must only see his customers, force searching by him
1288 $search_sale = 0;
1289 if (isModEnabled("societe") && !$user->hasRight('societe', 'client', 'voir')) {
1290 $search_sale = $user->id;
1291 }
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)."))";
1298 }
1299 }
1300 // Search on socid
1301 if ($socid > 0) {
1302 $sql .= " AND a.fk_soc = ".((int) $socid);
1303 }
1304 //var_dump($day.' '.$month.' '.$year);
1305 if ($mode == 'show_day') {
1306 $sql .= " AND (";
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'))."')";
1309 $sql .= " OR ";
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'))."')";
1312 $sql .= " OR ";
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'))."')";
1315 $sql .= ')';
1316 } else {
1317 // To limit array
1318 $sql .= " AND (";
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
1321 $sql .= " OR ";
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))."')";
1324 $sql .= " OR ";
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))."')";
1327 $sql .= ')';
1328 }
1329 if ($sincedatec !== null) {
1330 $sql .= " AND (a.datec > '".$db->idate($sincedatec)."' OR a.tms > '".$db->idate($sincedatec)."')";
1331 }
1332 if ($type) {
1333 $sql .= " AND ca.id = ".((int) $type);
1334 }
1335 if ($status == '0') {
1336 // To do (not started)
1337 $sql .= " AND a.percent = 0";
1338 }
1339 if ($status === 'na') {
1340 // Not applicable
1341 $sql .= " AND a.percent = -1";
1342 }
1343 if ($status == '50') {
1344 // Running already started
1345 $sql .= " AND (a.percent > 0 AND a.percent < 100)";
1346 }
1347 if ($status == 'done' || $status == '100') {
1348 $sql .= " AND (a.percent = 100)";
1349 }
1350 if ($status == 'todo') {
1351 $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
1352 }
1353
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)."))";
1360 }
1361 }
1362
1363 // Sort on date
1364 $sql .= $db->order("datep");
1365
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)
1367
1368 $sql .= $db->plimit($MAXONSAMEPAGE + 1);
1369
1370 dol_syslog("agenda_build_eventarray", LOG_DEBUG);
1371
1372 $resql = $db->query($sql);
1373 if ($resql) {
1374 $num = $db->num_rows($resql);
1375 $nbevents += $num;
1376
1377 $i = 0;
1378 while ($i < $num && $i < $MAXONSAMEPAGE) {
1379 $obj = $db->fetch_object($resql);
1380
1381 // Discard auto action if option is on
1382 if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') {
1383 $i++;
1384 continue;
1385 }
1386
1387 // Create a new object action
1388 $event = new ActionComm($db);
1389
1390 $event->id = $obj->id;
1391 $event->ref = (string) $event->id;
1392
1393 $event->fulldayevent = $obj->fulldayevent;
1394
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');
1400 } else {
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');
1404 }
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'));
1408
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;
1414
1415 $event->label = $obj->label;
1416 $event->percentage = $obj->percent;
1417
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
1421
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;
1428
1429 $event->fk_project = $obj->fk_project;
1430
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";
1436 }
1437
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;
1443 } else {
1444 $event->date_end_in_calendar = $event->datep;
1445 }
1446
1447 // Check values
1448 if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) {
1449 // This record is out of visible range
1450 } else {
1451 if ($event->date_start_in_calendar < $firstdaytoshow) {
1452 $event->date_start_in_calendar = $firstdaytoshow;
1453 }
1454 if ($event->date_end_in_calendar >= $lastdaytoshow) {
1455 $event->date_end_in_calendar = ($lastdaytoshow - 1);
1456 }
1457
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');
1463
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');
1468
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>';
1472
1473 // Loop on each day covered by action to prepare an index to show on calendar
1474 $loop = true;
1475 $j = 0;
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
1478 /*
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>';
1485 */
1486 do {
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>';
1490
1491 $eventarray[$daykey][] = $event;
1492 $j++;
1493
1494 $daykey += 60 * 60 * 24;
1495 //if ($daykey > $event->date_end_in_calendar) {
1496 if ($daykey > $daykeyend) {
1497 $loop = false;
1498 }
1499 } while ($loop);
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>';
1503 }
1504
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;
1508 if ($reshook < 0) {
1509 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1510 }
1511
1512 $i++;
1513 }
1514 } else {
1515 dol_print_error($db);
1516 }
1517 //var_dump($eventarray);
1518
1519 return array('eventarray' => $eventarray, 'nbevents' => $nbevents, 'maxonsamepage' => $MAXONSAMEPAGE);
1520}
1521
1537function agenda_get_birthday_events($db, $langs, $user, $mode, $month, $day, $year, &$eventarray, &$nbevents)
1538{
1539 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
1540
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);
1548 } else {
1549 $sql .= ' AND MONTH(birthday) = '.((int) $month);
1550 }
1551 $sql .= ' ORDER BY birthday';
1552
1553 dol_syslog("agenda.lib.php::agenda_get_birthday_events", LOG_DEBUG);
1554 $resql = $db->query($sql);
1555 if (!$resql) {
1556 dol_print_error($db);
1557 return -1;
1558 }
1559
1560 $num = $db->num_rows($resql);
1561 $nbevents += $num;
1562
1563 $i = 0;
1564 while ($i < $num) {
1565 $obj = $db->fetch_object($resql);
1566
1567 $event = new ActionComm($db);
1568
1569 $event->id = $obj->rowid; // We put contact id in action id for birthdays events
1570 $event->ref = (string) $event->id;
1571
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;
1576
1577 $event->type_code = 'BIRTHDAY';
1578 $event->type_label = '';
1579 $event->type_color = '';
1580 $event->type = 'birthdate';
1581 $event->type_picto = 'birthdate';
1582
1583 $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
1584 $event->percentage = 100;
1585 $event->fulldayevent = 1;
1586
1587 $event->contact_id = $obj->rowid;
1588
1589 $event->date_start_in_calendar = $event->datep;
1590 $event->date_end_in_calendar = $event->datef;
1591
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');
1597
1598 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
1599
1600 $eventarray[$daykey][] = $event;
1601
1602 $i++;
1603 }
1604
1605 return $num;
1606}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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...
print $object position
Definition edit.php:206
Class to manage agenda events (actions)
Class to manage customers or prospects.
DAO Resource object.
Class to manage building of HTML components.
Class to help generate other html components Only common components are here.
Class to manage building of HTML components.
Class to manage forms for the module resource.
Class to manage third parties objects (customers, suppliers, prospects...)
$theme_datacolor
Definition index.php:1217
$cacheusers
Definition index.php:1215
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...
Definition index.php:169
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
Definition files.lib.php:65
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