dolibarr  7.0.0-beta
pertype.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
4  * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
6  * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39 
40 
41 if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
42 
43 $filter = GETPOST("filter",'alpha',3);
44 $filtert = GETPOST("filtert","int",3);
45 $usergroup = GETPOST("usergroup","int",3);
46 //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
47 //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
48 $showbirthday = 0;
49 
50 // If not choice done on calendar owner, we filter on user.
51 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
52 {
53  $filtert=$user->id;
54 }
55 
56 $sortfield = GETPOST("sortfield",'alpha');
57 $sortorder = GETPOST("sortorder",'alpha');
58 $page = GETPOST("page","int");
59 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
60 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
61 $offset = $limit * $page;
62 if (! $sortorder) $sortorder="ASC";
63 if (! $sortfield) $sortfield="a.datec";
64 
65 // Security check
66 $socid = GETPOST("socid","int");
67 if ($user->societe_id) $socid=$user->societe_id;
68 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
69 if ($socid < 0) $socid='';
70 
71 $canedit=1;
72 if (! $user->rights->agenda->myactions->read) accessforbidden();
73 if (! $user->rights->agenda->allactions->read) $canedit=0;
74 if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
75 {
76  $filtert=$user->id;
77 }
78 
79 //$action=GETPOST('action','alpha');
80 $action='show_pertype';
81 $resourceid=GETPOST("resourceid","int");
82 $year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
83 $month=GETPOST("month","int")?GETPOST("month","int"):date("m");
84 $week=GETPOST("week","int")?GETPOST("week","int"):date("W");
85 $day=GETPOST("day","int")?GETPOST("day","int"):date("d");
86 $pid=GETPOST("projectid","int",3);
87 $status=GETPOST("status",'alpha');
88 $type=GETPOST("type",'alpha');
89 $maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
90 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
91 if (GETPOST('actioncode','array'))
92 {
93  $actioncode=GETPOST('actioncode','array',3);
94  if (! count($actioncode)) $actioncode='0';
95 }
96 else
97 {
98  $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
99 }
100 if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
101 
102 $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
103 if ($dateselect > 0)
104 {
105  $day=GETPOST('dateselectday','int');
106  $month=GETPOST('dateselectmonth','int');
107  $year=GETPOST('dateselectyear','int');
108 }
109 
110 $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS;
111 $tmparray=explode('-',$tmp);
112 $begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9);
113 $end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18);
114 if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
115 if ($end_h < 1 || $end_h > 24) $end_h = 18;
116 if ($end_h <= $begin_h) $end_h = $begin_h + 1;
117 
118 $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS;
119 $tmparray=explode('-',$tmp);
120 $begin_d = 1;
121 $end_d = 53;
122 
123 if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
124 if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
125 
126 if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
127  $action='show_month'; $day='';
128 } // View by month
129 if (GETPOST('viewweek','alpha') || $action == 'show_week') {
130  $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d"));
131 } // View by week
132 if (GETPOST('viewday','alpha') || $action == 'show_day') {
133  $action='show_day'; $day=($day?$day:date("d"));
134 } // View by day
135 if (GETPOST('viewyear','alpha') || $action == 'show_year') {
136  $action='show_year';
137 } // View by year
138 
139 
140 $langs->load("users");
141 $langs->load("agenda");
142 $langs->load("other");
143 $langs->load("commercial");
144 
145 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
146 $hookmanager->initHooks(array('agenda'));
147 
148 
149 /*
150  * Actions
151  */
152 
153 if ($action =='delete_action')
154 {
155  $event = new ActionComm($db);
156  $event->fetch($actionid);
157  $result=$event->delete();
158 }
159 
160 
161 
162 /*
163  * View
164  */
165 
166 $form=new Form($db);
167 $companystatic=new Societe($db);
168 
169 $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
170 llxHeader('',$langs->trans("Agenda"),$help_url);
171 
172 $now=dol_now();
173 $nowarray=dol_getdate($now);
174 $nowyear=$nowarray['year'];
175 $nowmonth=$nowarray['mon'];
176 $nowday=$nowarray['mday'];
177 
178 
179 // Define list of all external calendars (global setup)
180 $listofextcals=array();
181 
182 $prev = dol_get_first_day($year, $month);
183 $first_day = 1;
184 $first_month = 1;
185 $first_year = $year;
186 
187 $week = $prev['week'];
188 
189 $day = (int) $day;
190 $next = dol_get_next_day($day, $month, $year);
191 $next_year = $year + 1;
192 $next_month = $month;
193 $next_day = $day;
194 
195 $max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
196 
197 $tmpday = $first_day;
198 //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
199 //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
200 
201 $title=$langs->trans("DoneAndToDoActions");
202 if ($status == 'done') $title=$langs->trans("DoneActions");
203 if ($status == 'todo') $title=$langs->trans("ToDoActions");
204 
205 $param='';
206 if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
207 if ($resourceid > 0) $param.="&resourceid=".$resourceid;
208 if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
209 if ($filter) $param.="&filter=".$filter;
210 if ($filtert) $param.="&filtert=".$filtert;
211 if ($usergroup) $param.="&usergroup=".$usergroup;
212 if ($socid) $param.="&socid=".$socid;
213 if ($showbirthday) $param.="&showbirthday=1";
214 if ($pid) $param.="&projectid=".$pid;
215 if ($type) $param.="&type=".$type;
216 if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param.='&action='.$action;
217 $param.="&maxprint=".$maxprint;
218 
219 $prev = dol_get_first_day($year, 1);
220 $prev_year = $year - 1;
221 $prev_month = $month;
222 $prev_day = $day;
223 $first_day = 1;
224 $first_month= 1;
225 $first_year = $year;
226 
227 $week = $prev['week'];
228 
229 $day = (int) $day;
230 $next = dol_get_next_day(31, 12, $year);
231 $next_year = $year + 1;
232 $next_month = $month;
233 $next_day = $day;
234 
235 // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
236 $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
237 $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
238 //print $firstday.'-'.$first_month.'-'.$first_year;
239 //print dol_print_date($firstdaytoshow,'dayhour');
240 //print dol_print_date($lastdaytoshow,'dayhour');
241 
242 $max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
243 
244 $tmpday = $first_day;
245 
246 $nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
247 $nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y")."</span> \n";
248 $nav.="<a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n";
249 $nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
250 $picto='calendarweek';
251 
252 $nav.=' &nbsp; <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
253 $nav.='<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
254 $nav.='<input type="hidden" name="action" value="' . $action . '">';
255 $nav.='<input type="hidden" name="filtert" value="' . $filtert . '">';
256 $nav.='<input type="hidden" name="usergroup" value="' . $usergroup . '">';
257 $nav.='<input type="hidden" name="actioncode" value="' . $actioncode . '">';
258 $nav.='<input type="hidden" name="resourceid" value="' . $resourceid . '">';
259 $nav.='<input type="hidden" name="status" value="' . $status . '">';
260 $nav.='<input type="hidden" name="socid" value="' . $socid . '">';
261 $nav.='<input type="hidden" name="projectid" value="' . $projectid . '">';
262 $nav.='<input type="hidden" name="begin_h" value="' . $begin_h . '">';
263 $nav.='<input type="hidden" name="end_h" value="' . $end_h . '">';
264 $nav.='<input type="hidden" name="begin_d" value="' . $begin_d . '">';
265 $nav.='<input type="hidden" name="end_d" value="' . $end_d . '">';
266 $nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">';
267 
268 $nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
269 $nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
270 $nav.='</form>';
271 
272 // Must be after the nav definition
273 $param.='&year='.$year.'&month='.$month.($day?'&day='.$day:'');
274 //print 'x'.$param;
275 
276 
277 
278 
279 $tabactive='cardpertype';
280 
281 $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
282 
283 $head = calendars_prepare_head($paramnoaction);
284 
285 dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
286 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
287 dol_fiche_end();
288 
289 $showextcals=$listofextcals;
290 // Legend
291 if ($conf->use_javascript_ajax)
292 {
293  $s='';
294  $s.='<script type="text/javascript">' . "\n";
295  $s.='jQuery(document).ready(function () {' . "\n";
296  $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n";
297  $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n";
298  $s.='jQuery(".family_birthday").toggle();' . "\n";
299  if ($action=="show_week" || $action=="show_month" || empty($action))
300  {
301  $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
302  $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n";
303  }
304  $s.='});' . "\n";
305  $s.='</script>' . "\n";
306  if (! empty($conf->use_javascript_ajax))
307  {
308  $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' &nbsp; </div>';
309  if (is_array($showextcals) && count($showextcals) > 0)
310  {
311  foreach ($showextcals as $val)
312  {
313  $htmlname = md5($val['name']);
314  $s.='<script type="text/javascript">' . "\n";
315  $s.='jQuery(document).ready(function () {' . "\n";
316  $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {';
317  $s.=' /* alert("'.$htmlname.'"); */';
318  $s.=' jQuery(".family_ext' . $htmlname . '").toggle();';
319  $s.=' });' . "\n";
320  $s.='});' . "\n";
321  $s.='</script>' . "\n";
322  $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' &nbsp; </div>';
323  }
324  }
325 
326  //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
327 
328  // Calendars from hooks
329  $parameters=array(); $object=null;
330  $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action);
331  if (empty($reshook))
332  {
333  $s.= $hookmanager->resPrint;
334  }
335  elseif ($reshook > 1)
336  {
337  $s = $hookmanager->resPrint;
338  }
339  }
340 }
341 
342 
343 
344 $link='';
345 print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav, '');
346 
347 
348 // Get event in an array
349 $eventarray=array();
350 
351 $sql = 'SELECT';
352 if ($usergroup > 0) $sql.=" DISTINCT";
353 $sql.= ' a.id, a.label,';
354 $sql.= ' a.datep,';
355 $sql.= ' a.datep2,';
356 $sql.= ' a.percent,';
357 $sql.= ' a.fk_user_author,a.fk_user_action,';
358 $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
359 $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
360 $sql.= ' ca.code, ca.color';
361 $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
362 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
363 // We must filter on resource table
364 if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
365 // We must filter on assignement table
366 if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
367 if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
368 $sql.= ' WHERE a.fk_action = ca.id';
369 $sql.= ' AND a.entity IN ('.getEntity('agenda').')';
370 // Condition on actioncode
371 if (! empty($actioncode))
372 {
373  if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
374  {
375  if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'";
376  elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'";
377  else
378  {
379  if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'";
380  if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'";
381  }
382  }
383  else
384  {
385  if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'";
386  elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'";
387  else
388  {
389  $sql.=" AND ca.code IN ('".implode("','", explode(',',$actioncode))."')";
390  }
391  }
392 }
393 if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
394 if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
395 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
396 if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
397 // We must filter on assignement table
398 if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
399 if ($action == 'show_day')
400 {
401  $sql.= " AND (";
402  $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'";
403  $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')";
404  $sql.= " OR ";
405  $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'";
406  $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')";
407  $sql.= " OR ";
408  $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'";
409  $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')";
410  $sql.= ')';
411 }
412 else
413 {
414  // To limit array
415  $sql.= " AND (";
416  $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,1,1,$year)-(60*60*24*7))."'"; // Start 7 days before
417  $sql.= " AND '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')"; // End 7 days after
418  $sql.= " OR ";
419  $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,1,1,$year)-(60*60*24*7))."'";
420  $sql.= " AND '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')";
421  $sql.= " OR ";
422  $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,12,1,$year)-(60*60*24*7))."'";
423  $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')";
424  $sql.= ')';
425 }
426 if ($type) $sql.= " AND ca.id = ".$type;
427 if ($status == '0') { $sql.= " AND a.percent = 0"; }
428 if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
429 if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
430 if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
431 if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
432 // We must filter on assignement table
433 if ($filtert > 0 || $usergroup > 0)
434 {
435  $sql.= " AND (";
436  if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
437  if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
438  $sql.= ")";
439 }
440 // Sort on date
441 $sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action
442 //print $sql;
443 
444 dol_syslog("comm/action/index.php", LOG_DEBUG);
445 $resql=$db->query($sql);
446 if ($resql)
447 {
448  $num = $db->num_rows($resql);
449  $i=0;
450  while ($i < $num)
451  {
452  $obj = $db->fetch_object($resql);
453 
454  // Discard auto action if option is on
455  if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO')
456  {
457  $i++;
458  continue;
459  }
460 
461  $datep=$db->jdate($obj->datep);
462  $datep2=$db->jdate($obj->datep2);
463 
464  // Create a new object action
465  $event=new ActionComm($db);
466  $event->id=$obj->id;
467  $event->datep=$datep; // datep and datef are GMT date
468  $event->datef=$datep2;
469  $event->type_code=$obj->code;
470  $event->type_color=$obj->color;
471  //$event->libelle=$obj->label; // deprecated
472  $event->label=$obj->label;
473  $event->percentage=$obj->percent;
474  //$event->author->id=$obj->fk_user_author; // user id of creator
475  $event->authorid=$obj->fk_user_author; // user id of creator
476  $event->userownerid=$obj->fk_user_action; // user id of owner
477  $event->priority=$obj->priority;
478  $event->fulldayevent=$obj->fulldayevent;
479  $event->location=$obj->location;
480  $event->transparency=$obj->transparency;
481 
482  $event->fk_project=$obj->fk_project;
483 
484  $event->socid=$obj->fk_soc;
485  $event->contactid=$obj->fk_contact;
486  //$event->societe->id=$obj->fk_soc; // deprecated
487  //$event->contact->id=$obj->fk_contact; // deprecated
488 
489  $event->fk_element=$obj->fk_element;
490  $event->elementtype=$obj->elementtype;
491 
492  // Defined date_start_in_calendar and date_end_in_calendar property
493  // They are date start and end of action but modified to not be outside calendar view.
494  if ($event->percentage <= 0)
495  {
496  $event->date_start_in_calendar=$datep;
497  if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
498  else $event->date_end_in_calendar=$datep;
499  }
500  else
501  {
502  $event->date_start_in_calendar=$datep;
503  if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
504  else $event->date_end_in_calendar=$datep;
505  }
506  // Define ponctual property
507  if ($event->date_start_in_calendar == $event->date_end_in_calendar)
508  {
509  $event->ponctuel=1;
510  }
511 
512  // Check values
513  if ($event->date_end_in_calendar < $firstdaytoshow ||
514  $event->date_start_in_calendar >= $lastdaytoshow)
515  {
516  // This record is out of visible range
517  unset($event);
518  }
519  else
520  {
521  //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
522  $event->fetch_userassigned(); // This load $event->userassigned
523 
524  if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow;
525  if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1);
526 
527  // Add an entry in actionarray for each day
528  $daycursor=$event->date_start_in_calendar;
529  $annee = date('Y',$daycursor);
530  $mois = date('m',$daycursor);
531  $jour = date('d',$daycursor);
532 
533  // Loop on each day covered by action to prepare an index to show on calendar
534  $loop=true; $j=0;
535  $daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
536  do
537  {
538  //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
539 
540  $eventarray[$daykey][]=$event;
541  $j++;
542 
543  $daykey+=60*60*24;
544  if ($daykey > $event->date_end_in_calendar) $loop=false;
545  }
546  while ($loop);
547 
548  //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
549  //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>';
550  }
551  $i++;
552 
553  }
554 }
555 else
556 {
557  dol_print_error($db);
558 }
559 
560 $maxnbofchar=18;
561 $cachethirdparties=array();
562 $cachecontacts=array();
563 
564 // Define theme_datacolor array
565 $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
566 if (is_readable($color_file))
567 {
568  include_once $color_file;
569 }
570 if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220));
571 
572 
573 $newparam=$param; // newparam is for birthday links
574 $newparam=preg_replace('/showbirthday=/i','showbirthday_=',$newparam); // To avoid replacement when replace day= is done
575 $newparam=preg_replace('/action=show_month&?/i','',$newparam);
576 $newparam=preg_replace('/action=show_week&?/i','',$newparam);
577 $newparam=preg_replace('/day=[0-9]+&?/i','',$newparam);
578 $newparam=preg_replace('/month=[0-9]+&?/i','',$newparam);
579 $newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
580 $newparam=preg_replace('/viewweek=[0-9]+&?/i','',$newparam);
581 $newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
582 $newparam.='&viewweek=1';
583 
584 echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">';
585 echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
586 echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
587 echo '<input type="hidden" name="newdate" id="newdate">' ;
588 echo '</form>';
589 
590 
591 // Line header with list of days
592 
593 //print "begin_d=".$begin_d." end_d=".$end_d;
594 
595 
596 echo '<table width="100%" class="nocellnopadd cal_month">';
597 
598 echo '<tr class="liste_titre">';
599 echo '<td></td>';
600 $i=0; // 0 = sunday,
601 echo '<td align="center" colspan="'.($end_d - $begin_d).'">';
602 echo $langs->trans("Year");
603 print "<br>";
604 print $year;
605 echo "</td>\n";
606 echo "</tr>\n";
607 
608 echo '<tr class="liste_titre">';
609 echo '<td></td>';
610 $i=0;
611 for ($h = $begin_d; $h < $end_d; $h++)
612 {
613  echo '<td align="center">';
614  print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>';
615  print "</td>";
616 }
617 echo "</td>\n";
618 echo "</tr>\n";
619 
620 
621 $typeofevents=array();
622 
623 // Load array of colors by type
624 $colorsbytype=array();
625 $labelbytype=array();
626 $sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm";
627 $resql=$db->query($sql);
628 while ($obj = $db->fetch_object($resql))
629 {
630  $colorsbytype[$obj->code]=$obj->color;
631  $labelbytype[$obj->code]=$obj->libelle;
632 }
633 
634 // Loop on each user to show calendar
635 $todayarray=dol_getdate($now,'fast');
636 $sav = $tmpday;
637 $showheader = true;
638 $var = false;
639 foreach ($typeofevents as $typeofevent)
640 {
641  $var = ! $var;
642  echo "<tr>";
643  echo '<td class="cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">' . $username->getNomUrl(1). '</td>';
644  $tmpday = $sav;
645 
646  // Lopp on each day of week
647  $i = 0;
648  for ($iter_day = 0; $iter_day < 8; $iter_day++)
649  {
650  if (($i + 1) < $begin_d || ($i + 1) > $end_d)
651  {
652  $i++;
653  continue;
654  }
655 
656  // Show days of the current week
657  $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
658  $tmparray = dol_getdate($curtime,'fast');
659  $tmpday = $tmparray['mday'];
660  $tmpmonth = $tmparray['mon'];
661  $tmpyear = $tmparray['year'];
662 
663  $style='cal_current_month';
664  if ($iter_day == 6) $style.=' cal_other_month';
665  $today=0;
666  if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1;
667  if ($today) $style='cal_today_peruser';
668 
669  show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
670 
671  $i++;
672  }
673  echo "</tr>\n";
674  $showheader = false;
675 }
676 
677 echo "</table>\n";
678 
679 
680 if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
681 {
682  $langs->load("commercial");
683  print '<br>'.$langs->trans("Legend").': <br>';
684  foreach($colorsbytype as $code => $color)
685  {
686  if ($color)
687  {
688  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
689  print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code];
690  //print $code;
691  print '</div>';
692  }
693  }
694  //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]);
695  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
696  print $langs->trans("Other");
697  print '</div>';
698  /* TODO Show this if at least one cumulated event
699  print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
700  print $langs->trans("SeveralEvents");
701  print '</div>';
702  */
703 }
704 
705 // Add js code to manage click on a box
706 print '<script type="text/javascript" language="javascript">
707 jQuery(document).ready(function() {
708  jQuery(".onclickopenref").click(function() {
709  var ref=$(this).attr(\'ref\');
710  var res = ref.split("_");
711  var userid = res[1];
712  var year = res[2];
713  var month = res[3];
714  var day = res[4];
715  var hour = res[5];
716  var min = res[6];
717  var ids = res[7];
718  if (ids == \'none\') /* No event */
719  {
720  /* alert(\'no event\'); */
721  url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day).'"
722  window.location.href = url;
723  }
724  else if (ids.indexOf(",") > -1) /* There is several events */
725  {
726  /* alert(\'several events\'); */
727  url = "'.DOL_URL_ROOT.'/comm/action/list.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
728  window.location.href = url;
729  }
730  else /* One event */
731  {
732  /* alert(\'one event\'); */
733  url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=view&id="+ids
734  window.location.href = url;
735  }
736  });
737 });
738 </script>';
739 
740 
741 
742 llxFooter();
743 
744 $db->close();
745 
746 
747 
748 
769 function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false)
770 {
771  global $db;
772  global $user, $conf, $langs, $hookmanager, $action;
773  global $filter, $filtert, $status, $actioncode; // Filters used into search form
774  global $theme_datacolor; // Array with a list of different we can use (come from theme)
775  global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused;
776  global $begin_h, $end_h;
777 
778  $cases1 = array(); // Color first half hour
779  $cases2 = array(); // Color second half hour
780 
781  $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
782 
783  $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
784  $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
785 
786  $nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ...
787  //if ($username->id && $day==1) var_dump($eventarray);
788 
789  // We are in a particular day for $username, now we scan all events
790  foreach ($eventarray as $daykey => $notused)
791  {
792  $annee = date('Y',$daykey);
793  $mois = date('m',$daykey);
794  $jour = date('d',$daykey);
795  //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n";
796 
797  if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ?
798  {
799  // Scan all event for this date
800  foreach ($eventarray[$daykey] as $index => $event)
801  {
802  //var_dump($event);
803 
804  $keysofuserassigned=array_keys($event->userassigned);
805  if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show
806  //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
807 
808  $parameters=array();
809  $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks
810  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
811 
812  $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
813 
814  // Define $color (Hex string like '0088FF') and $cssclass of event
815  $color=-1; $cssclass=''; $colorindex=-1;
816  if (in_array($user->id, $keysofuserassigned))
817  {
818  $nummytasks++; $cssclass='family_mytasks';
819  if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color;
820  }
821  else if ($event->type_code == 'ICALEVENT')
822  {
823  $numical++;
824  if (! empty($event->icalname))
825  {
826  if (! isset($numicals[dol_string_nospecial($event->icalname)])) {
827  $numicals[dol_string_nospecial($event->icalname)] = 0;
828  }
829  $numicals[dol_string_nospecial($event->icalname)]++;
830  }
831 
832  $color=$event->icalcolor;
833  $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable');
834  }
835  else if ($event->type_code == 'BIRTHDAY')
836  {
837  $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]);
838  }
839  else
840  {
841  $numother++; $cssclass='family_other';
842  if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color;
843  }
844 
845  if ($color < 0) // Color was not forced. Set color according to color index.
846  {
847  // Define color index if not yet defined
848  $idusertouse=($event->userownerid?$event->userownerid:0);
849  if (isset($colorindexused[$idusertouse]))
850  {
851  $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user
852  }
853  else
854  {
855  $colorindex=$nextindextouse;
856  $colorindexused[$idusertouse]=$colorindex;
857  if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color
858  }
859  // Define color
860  $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]);
861  }
862  //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
863 
864  // Define all rects with event (cases1 is first half hour, cases2 is second half hour)
865  for ($h = $begin_h; $h < $end_h; $h++)
866  {
867  //if ($username->id == 1 && $day==1) print 'h='.$h;
868  $newcolor = ''; //init
869  if (empty($event->fulldayevent))
870  {
871  $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0);
872  $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0);
873  $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0);
874 
875  $dateendtouse=$event->date_end_in_calendar;
876  if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++;
877 
878  //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
879 
880  if ($event->date_start_in_calendar < $b && $dateendtouse > $a)
881  {
882  $busy=$event->transparency;
883  $cases1[$h][$event->id]['busy']=$busy;
884  $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour');
885  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
886  {
887  $tmpa=dol_getdate($event->date_start_in_calendar,true);
888  $tmpb=dol_getdate($event->date_end_in_calendar,true);
889  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour');
890  else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour');
891  }
892  $cases1[$h][$event->id]['string'].=' - '.$event->label;
893  $cases1[$h][$event->id]['typecode']=$event->type_code;
894  $cases1[$h][$event->id]['color']=$color;
895  if ($event->fk_project > 0)
896  {
897  if (empty($cacheprojects[$event->fk_project]))
898  {
899  $tmpproj=new Project($db);
900  $tmpproj->fetch($event->fk_project);
901  $cacheprojects[$event->fk_project]=$tmpproj;
902  }
903  $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
904  }
905  if ($event->socid > 0)
906  {
907  if (empty($cachethirdparties[$event->socid]))
908  {
909  $tmpthirdparty=new Societe($db);
910  $tmpthirdparty->fetch($event->socid);
911  $cachethirdparties[$event->socid]=$tmpthirdparty;
912  }
913  $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
914  }
915  if ($event->contactid > 0)
916  {
917  if (empty($cachecontacts[$event->contactid]))
918  {
919  $tmpcontact=new Contact($db);
920  $tmpcontact->fetch($event->contactid);
921  $cachecontacts[$event->contactid]=$tmpcontact;
922  }
923  $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
924  }
925  }
926  if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
927  {
928  $busy=$event->transparency;
929  $cases2[$h][$event->id]['busy']=$busy;
930  $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour');
931  if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
932  {
933  $tmpa=dol_getdate($event->date_start_in_calendar,true);
934  $tmpb=dol_getdate($event->date_end_in_calendar,true);
935  if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour');
936  else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour');
937  }
938  $cases2[$h][$event->id]['string'].=' - '.$event->label;
939  $cases2[$h][$event->id]['typecode']=$event->type_code;
940  $cases2[$h][$event->id]['color']=$color;
941  if ($event->fk_project > 0)
942  {
943  if (empty($cacheprojects[$event->fk_project]))
944  {
945  $tmpproj=new Project($db);
946  $tmpproj->fetch($event->fk_project);
947  $cacheprojects[$event->fk_project]=$tmpproj;
948  }
949  $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
950  }
951  if ($event->socid > 0)
952  {
953  if (empty($cachethirdparties[$event->socid]))
954  {
955  $tmpthirdparty=new Societe($db);
956  $tmpthirdparty->fetch($event->socid);
957  $cachethirdparties[$event->socid]=$tmpthirdparty;
958  }
959  $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
960  }
961  if ($event->contactid > 0)
962  {
963  if (empty($cachecontacts[$event->contactid]))
964  {
965  $tmpcontact=new Contact($db);
966  $tmpcontact->fetch($event->contactid);
967  $cachecontacts[$event->contactid]=$tmpcontact;
968  }
969  $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
970  }
971  }
972  }
973  else
974  {
975  $busy=$event->transparency;
976  $cases1[$h][$event->id]['busy']=$busy;
977  $cases2[$h][$event->id]['busy']=$busy;
978  $cases1[$h][$event->id]['string']=$event->label;
979  $cases2[$h][$event->id]['string']=$event->label;
980  $cases1[$h][$event->id]['typecode']=$event->type_code;
981  $cases2[$h][$event->id]['typecode']=$event->type_code;
982  $cases1[$h][$event->id]['color']=$color;
983  $cases2[$h][$event->id]['color']=$color;
984  }
985  }
986  $i++;
987  }
988 
989  break; // We found the date we were looking for. No need to search anymore.
990  }
991  }
992 
993  // Now output $casesX
994  for ($h = $begin_h; $h < $end_h; $h++)
995  {
996  $color1='';$color2='';
997  $style1='';$style2='';
998  $string1='&nbsp;';$string2='&nbsp;';
999  $title1='';$title2='';
1000  if (isset($cases1[$h]) && $cases1[$h] != '')
1001  {
1002  //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1003  if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1004  $string1='&nbsp;';
1005  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy';
1006  else $style1='peruser_busy';
1007  foreach($cases1[$h] as $id => $ev)
1008  {
1009  if ($ev['busy']) $style1='peruser_busy';
1010  }
1011  }
1012  if (isset($cases2[$h]) && $cases2[$h] != '')
1013  {
1014  //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1015  if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
1016  $string2='&nbsp;';
1017  if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy';
1018  else $style2='peruser_busy';
1019  foreach($cases2[$h] as $id => $ev)
1020  {
1021  if ($ev['busy']) $style2='peruser_busy';
1022  }
1023  }
1024 
1025  $ids1='';$ids2='';
1026  if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h]));
1027  if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h]));
1028 
1029  if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">';
1030  else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">';
1031  if (count($cases1[$h]) == 1) // only 1 event
1032  {
1033  $output = array_slice($cases1[$h], 0, 1);
1034  $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
1035  if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string'];
1036  if ($output[0]['color']) $color1 = $output[0]['color'];
1037  }
1038  else if (count($cases1[$h]) > 1)
1039  {
1040  $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
1041  $color1='222222';
1042  }
1043 
1044  if (count($cases2[$h]) == 1) // only 1 event
1045  {
1046  $output = array_slice($cases2[$h], 0, 1);
1047  $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
1048  if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string'];
1049  if ($output[0]['color']) $color2 = $output[0]['color'];
1050  }
1051  else if (count($cases2[$h]) > 1)
1052  {
1053  $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
1054  $color2='222222';
1055  }
1056  print '<table class="nobordernopadding" width="100%">';
1057  print '<tr><td '.($color1?'style="background: #'.$color1.';"':'').'class="'.($style1?$style1.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>';
1058  print $string1;
1059  print '</td><td '.($color2?'style="background: #'.$color2.';"':'').'class="'.($style2?$style2.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>';
1060  print $string2;
1061  print '</td></tr>';
1062  print '</table>';
1063  print '</td>';
1064  }
1065 }
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
Class to manage agenda events (actions)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
Class to manage contact/addresses.
calendars_prepare_head($param)
Define head array for tabs of agenda setup pages.
Definition: agenda.lib.php:510
img_previous($titlealt= 'default', $moreatt='')
Show previous logo.
img_next($titlealt= 'default', $moreatt='')
Show next logo.
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
Show filter form in agenda view.
Definition: agenda.lib.php:50
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
dol_get_next_day($day, $month, $year)
Return next day.
Definition: date.lib.php:348
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='')
Clean a string from all punctuation characters to use it as a ref or login.
type
Definition: viewcat.php:283
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.