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