Exemplo n.º 1
0
/**
 * Show event of a particular day
 *
 * @param	DoliDB	$db              Database handler
 * @param   int		$day             Day
 * @param   int		$month           Month
 * @param   int		$year            Year
 * @param   int		$monthshown      Current month shown in calendar view
 * @param   string	$style           Style to use for this day
 * @param   array	$eventarray      Array of events
 * @param   int		$maxprint        Nb of actions to show each day on month view (0 means no limit)
 * @param   int		$maxnbofchar     Nb of characters to show for event line
 * @param   string	$newparam        Parameters on current URL
 * @param   int		$showinfo        Add extended information (used by day and week view)
 * @param   int		$minheight       Minimum height for each event. 60px by default.
 * @return	void
 */
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60)
{
    global $user, $conf, $langs;
    global $action, $filter, $filtert, $status, $actioncode;
    // Filters used into search form
    global $theme_datacolor;
    global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
    print "\n" . '<div id="dayevent_' . sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day) . '" class="dayevent">';
    // Line with title of day
    $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
    print '<table class="nobordernopadding" width="100%">' . "\n";
    print '<tr><td align="left" class="nowrap">';
    print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?';
    print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
    print $newparam;
    print '">';
    if ($showinfo) {
        print dol_print_date($curtime, 'daytextshort');
    } else {
        print dol_print_date($curtime, '%d');
    }
    print '</a>';
    print '</td><td align="right" class="nowrap">';
    if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
        $newparam .= '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
        //$param='month='.$monthshown.'&year='.$year;
        $hourminsec = '100000';
        print '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&datep=' . sprintf("%04d%02d%02d", $year, $month, $day) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '">';
        print img_picto($langs->trans("NewAction"), 'edit_add.png');
        print '</a>';
    }
    print '</td></tr>' . "\n";
    // Line with td contains all div of each events
    print '<tr height="' . $minheight . '"><td valign="top" colspan="2" class="sortable" style="padding-bottom: 2px;">';
    print '<div style="width: 100%; position: relative;">';
    //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
    $i = 0;
    $nummytasks = 0;
    $numother = 0;
    $numbirthday = 0;
    $numical = 0;
    $numicals = array();
    $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day);
    $nextindextouse = count($colorindexused);
    // At first run this is 0, so fist user has 0, next 1, ...
    //print $nextindextouse;
    foreach ($eventarray as $daykey => $notused) {
        $annee = date('Y', $daykey);
        $mois = date('m', $daykey);
        $jour = date('d', $daykey);
        if ($day == $jour && $month == $mois && $year == $annee) {
            foreach ($eventarray[$daykey] as $index => $event) {
                if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) {
                    $keysofuserassigned = array_keys($event->userassigned);
                    $ponct = $event->date_start_in_calendar == $event->date_end_in_calendar;
                    // Define $color (Hex string like '0088FF') and $cssclass of event
                    $color = -1;
                    $colorindex = -1;
                    if (in_array($user->id, $keysofuserassigned)) {
                        $nummytasks++;
                        $cssclass = 'family_mytasks';
                        if (empty($cacheusers[$event->userownerid])) {
                            $newuser = new User($db);
                            $newuser->fetch($event->userownerid);
                            $cacheusers[$event->userownerid] = $newuser;
                        }
                        //var_dump($cacheusers[$event->userownerid]->color);
                        // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
                        if (!empty($cacheusers[$event->userownerid]->color)) {
                            $color = $cacheusers[$event->userownerid]->color;
                        }
                    } else {
                        if ($event->type_code == 'ICALEVENT') {
                            $numical++;
                            if (!empty($event->icalname)) {
                                if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
                                    $numicals[dol_string_nospecial($event->icalname)] = 0;
                                }
                                $numicals[dol_string_nospecial($event->icalname)]++;
                            }
                            $color = $event->icalcolor;
                            $cssclass = !empty($event->icalname) ? 'family_ext' . md5($event->icalname) : 'family_other';
                        } else {
                            if ($event->type_code == 'BIRTHDAY') {
                                $numbirthday++;
                                $colorindex = 2;
                                $cssclass = 'family_birthday unmovable';
                                $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
                            } else {
                                $numother++;
                                $cssclass = 'family_other';
                                if (empty($cacheusers[$event->userownerid])) {
                                    $newuser = new User($db);
                                    $newuser->fetch($event->userownerid);
                                    $cacheusers[$event->userownerid] = $newuser;
                                }
                                //var_dump($cacheusers[$event->userownerid]->color);
                                // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
                                if (!empty($cacheusers[$event->userownerid]->color)) {
                                    $color = $cacheusers[$event->userownerid]->color;
                                }
                            }
                        }
                    }
                    if ($color == -1) {
                        // Define color index if not yet defined
                        $idusertouse = $event->userownerid ? $event->userownerid : 0;
                        if (isset($colorindexused[$idusertouse])) {
                            $colorindex = $colorindexused[$idusertouse];
                            // Color already assigned to this user
                        } else {
                            $colorindex = $nextindextouse;
                            $colorindexused[$idusertouse] = $colorindex;
                            if (!empty($theme_datacolor[$nextindextouse + 1])) {
                                $nextindextouse++;
                            }
                            // Prepare to use next color
                        }
                        //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
                        // Define color
                        $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
                    }
                    $cssclass = $cssclass . ' ' . $cssclass . '_day_' . $ymd;
                    // Defined style to disable drag and drop feature
                    if ($event->type_code == 'AC_OTH_AUTO') {
                        $cssclass .= " unmovable";
                    } else {
                        if ($event->type_code == 'ICALEVENT') {
                            $cssclass .= " unmovable";
                        } else {
                            if ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
                                $tmpyearend = date('Y', $event->date_end_in_calendar);
                                $tmpmonthend = date('m', $event->date_end_in_calendar);
                                $tmpdayend = date('d', $event->date_end_in_calendar);
                                if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
                                    $cssclass .= " unmovable";
                                }
                            } else {
                                $cssclass .= " movable";
                            }
                        }
                    }
                    $h = '';
                    $nowrapontd = 1;
                    if ($action == 'show_day') {
                        $h = 'height: 100%; ';
                        $nowrapontd = 0;
                    }
                    if ($action == 'show_week') {
                        $h = 'height: 100%; ';
                        $nowrapontd = 0;
                    }
                    // Show rect of event
                    print "\n";
                    print '<!-- start event ' . $i . ' --><div id="event_' . $ymd . '_' . $i . '" class="event ' . $cssclass . '"';
                    //print ' style="height: 100px;';
                    //print ' position: absolute; top: 40px; width: 50%;';
                    //print '"';
                    print '>';
                    print '<ul class="cal_event" style="' . $h . '">';
                    // always 1 li per ul, 1 ul per event
                    print '<li class="cal_event" style="' . $h . '">';
                    print '<table class="cal_event' . (empty($event->transparency) ? '' : ' cal_event_busy') . '" style="' . $h;
                    print 'background: #' . $color . '; background: -webkit-gradient(linear, left top, left bottom, from(#' . $color . '), to(#' . dol_color_minus($color, 1) . '));';
                    //if (! empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));';
                    //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;';
                    print ' -moz-border-radius:4px;" width="100%"><tr>';
                    print '<td class="' . ($nowrapontd ? 'nowrap ' : '') . 'cal_event' . ($event->type_code == 'BIRTHDAY' ? ' cal_event_birthday' : '') . '">';
                    if ($event->type_code == 'BIRTHDAY') {
                        print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
                    }
                    if ($event->type_code != 'BIRTHDAY') {
                        // Picto
                        if (empty($event->fulldayevent)) {
                            //print $event->getNomUrl(2).' ';
                        }
                        // Date
                        if (empty($event->fulldayevent)) {
                            //print '<strong>';
                            $daterange = '';
                            // Show hours (start ... end)
                            $tmpyearstart = date('Y', $event->date_start_in_calendar);
                            $tmpmonthstart = date('m', $event->date_start_in_calendar);
                            $tmpdaystart = date('d', $event->date_start_in_calendar);
                            $tmpyearend = date('Y', $event->date_end_in_calendar);
                            $tmpmonthend = date('m', $event->date_end_in_calendar);
                            $tmpdayend = date('d', $event->date_end_in_calendar);
                            // Hour start
                            if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
                                $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M');
                                // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
                                if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                    if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
                                        $daterange .= '-';
                                    }
                                    //else
                                    //print '...';
                                }
                            }
                            if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
                                    $daterange .= '...';
                                }
                            }
                            // Hour end
                            if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
                                    $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M');
                                }
                                // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
                            }
                            //print $daterange;
                            if ($event->type_code != 'ICALEVENT') {
                                $savlabel = $event->libelle;
                                $event->libelle = $daterange;
                                print $event->getNomUrl(0);
                                $event->libelle = $savlabel;
                            } else {
                                print $daterange;
                            }
                            //print '</strong> ';
                            print "<br>\n";
                        } else {
                            if ($showinfo) {
                                print $langs->trans("EventOnFullDay") . "<br>\n";
                            }
                        }
                        // Show title
                        if ($event->type_code == 'ICALEVENT') {
                            print dol_trunc($event->libelle, $maxnbofchar);
                        } else {
                            print $event->getNomUrl(0, $maxnbofchar, 'cal_event');
                        }
                        if ($event->type_code == 'ICALEVENT') {
                            print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')';
                        }
                        // If action related to company / contact
                        $linerelatedto = '';
                        $length = 16;
                        if (!empty($event->societe->id) && !empty($event->contact->id)) {
                            $length = round($length / 2);
                        }
                        if (!empty($event->societe->id) && $event->societe->id > 0) {
                            if (!isset($cachethirdparties[$event->societe->id]) || !is_object($cachethirdparties[$event->societe->id])) {
                                $thirdparty = new Societe($db);
                                $thirdparty->fetch($event->societe->id);
                                $cachethirdparties[$event->societe->id] = $thirdparty;
                            } else {
                                $thirdparty = $cachethirdparties[$event->societe->id];
                            }
                            if (!empty($thirdparty->id)) {
                                $linerelatedto .= $thirdparty->getNomUrl(1, '', $length);
                            }
                        }
                        if (!empty($event->contact->id) && $event->contact->id > 0) {
                            if (!is_object($cachecontacts[$event->contact->id])) {
                                $contact = new Contact($db);
                                $contact->fetch($event->contact->id);
                                $cachecontacts[$event->contact->id] = $contact;
                            } else {
                                $contact = $cachecontacts[$event->contact->id];
                            }
                            if ($linerelatedto) {
                                $linerelatedto .= ' / ';
                            }
                            if (!empty($contact->id)) {
                                $linerelatedto .= $contact->getNomUrl(1, '', $length);
                            }
                        }
                        if ($linerelatedto) {
                            print '<br>' . $linerelatedto;
                        }
                    }
                    // Show location
                    if ($showinfo) {
                        if ($event->location) {
                            print '<br>';
                            print $langs->trans("Location") . ': ' . $event->location;
                        }
                    }
                    print '</td>';
                    // Status - Percent
                    print '<td align="right" class="nowrap cal_event_right">';
                    if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
                        print $event->getLibStatut(3, 1);
                    } else {
                        print '&nbsp;';
                    }
                    print '</td></tr></table>';
                    print '</li>';
                    print '</ul>';
                    print '</div><!-- end event ' . $i . ' -->' . "\n";
                    $i++;
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?action=' . $action . '&maxprint=0&month=' . $monthshown . '&year=' . $year;
                    print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : '');
                    print $filtert ? '&filtert=' . $filtert : '';
                    print $actioncode != '' ? '&actioncode=' . $actioncode : '';
                    print '">' . img_picto("all", "1downarrow_selected.png") . ' ...';
                    print ' +' . (count($eventarray[$daykey]) - $maxprint);
                    print '</a>';
                    break;
                    //$ok=false;        // To avoid to show twice the link
                }
            }
            break;
        }
    }
    if (!$i) {
        print '&nbsp;';
    }
    if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) {
        print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>';
        //print ' +'.(count($eventarray[$daykey])-$maxprint);
        print '<script type="text/javascript">' . "\n";
        print 'jQuery(document).ready(function () {' . "\n";
        print 'jQuery("#more_' . $ymd . '").click(function() { reinit_day_' . $ymd . '(); });' . "\n";
        print 'function reinit_day_' . $ymd . '() {' . "\n";
        print 'var nb=0;' . "\n";
        // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached
        print 'jQuery(".family_mytasks_day_' . $ymd . '").toggle();';
        print '}' . "\n";
        print '});' . "\n";
        print '</script>' . "\n";
    }
    print '</div>';
    print '</td></tr>';
    print '</table></div>' . "\n";
}
Exemplo n.º 2
0
/**
 * Show event of a particular day
 *
 * @param	DoliDB	$db              Database handler
 * @param   int		$day             Day
 * @param   int		$month           Month
 * @param   int		$year            Year
 * @param   int		$monthshown      Current month shown in calendar view
 * @param   string	$style           Style to use for this day
 * @param   array	$eventarray     Array of events
 * @param   int		$maxprint        Nb of actions to show each day on month view (0 means no limit)
 * @param   int		$maxnbofchar     Nb of characters to show for event line
 * @param   string	$newparam        Parameters on current URL
 * @param   int		$showinfo        Add extended information (used by day view)
 * @param   int		$minheight       Minimum height for each event. 60px by default.
 * @return	void
 */
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60)
{
    global $user, $conf, $langs;
    global $filter, $filtera, $filtert, $filterd, $status, $actioncode;
    // Filters used into search form
    global $theme_datacolor;
    global $cachethirdparties, $cachecontacts, $colorindexused;
    print '<div id="dayevent_' . sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day) . '" class="dayevent">' . "\n";
    $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
    print '<table class="nobordernopadding" width="100%">';
    print '<tr><td align="left" class="nowrap">';
    print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?';
    print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
    print $newparam;
    print '">';
    if ($showinfo) {
        print dol_print_date($curtime, 'daytext');
    } else {
        print dol_print_date($curtime, '%d');
    }
    print '</a>';
    print '</td><td align="right" class="nowrap">';
    if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
        $newparam .= '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
        //$param='month='.$monthshown.'&year='.$year;
        $hourminsec = '100000';
        print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&datep=' . sprintf("%04d%02d%02d", $year, $month, $day) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '">';
        print img_picto($langs->trans("NewAction"), 'edit_add.png');
        print '</a>';
    }
    print '</td></tr>';
    print '<tr height="' . $minheight . '"><td valign="top" colspan="2" class="nowrap" style="padding-bottom: 2px;">';
    //$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
    $i = 0;
    $nummytasks = 0;
    $numother = 0;
    $numbirthday = 0;
    $numical = 0;
    $numicals = array();
    $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day);
    $nextindextouse = count($colorindexused);
    //print $nextindextouse;
    foreach ($eventarray as $daykey => $notused) {
        $annee = date('Y', $daykey);
        $mois = date('m', $daykey);
        $jour = date('d', $daykey);
        if ($day == $jour && $month == $mois && $year == $annee) {
            foreach ($eventarray[$daykey] as $index => $event) {
                if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) {
                    $ponct = $event->date_start_in_calendar == $event->date_end_in_calendar;
                    // Define $color and $cssclass of event
                    $color = -1;
                    $cssclass = '';
                    $colorindex = -1;
                    if (!empty($event->author->id) && $event->author->id == $user->id || !empty($event->usertodo->id) && $event->usertodo->id == $user->id || !empty($event->userdone->id) && $event->userdone->id == $user->id) {
                        $nummytasks++;
                        $cssclass = 'family_mytasks';
                        // TODO Set a color using user color
                        // Must defined rule to choose color of who to use.
                        // event->usertodo->id will still contains user id of owner
                        // event->userstodo will be an array in future.
                        // $color=$user->color;
                    } else {
                        if ($event->type_code == 'ICALEVENT') {
                            $numical++;
                            if (!empty($event->icalname)) {
                                if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
                                    $numicals[dol_string_nospecial($event->icalname)] = 0;
                                }
                                $numicals[dol_string_nospecial($event->icalname)]++;
                            }
                            $color = $event->icalcolor;
                            $cssclass = !empty($event->icalname) ? 'family_' . dol_string_nospecial($event->icalname) : 'family_other';
                        } else {
                            if ($event->type_code == 'BIRTHDAY') {
                                $numbirthday++;
                                $colorindex = 2;
                                $cssclass = 'family_birthday';
                            } else {
                                $numother++;
                                $cssclass = 'family_other';
                            }
                        }
                    }
                    if ($color == -1) {
                        // Define color index if not yet defined
                        $idusertouse = $event->usertodo->id ? $event->usertodo->id : 0;
                        if (isset($colorindexused[$idusertouse])) {
                            $colorindex = $colorindexused[$idusertouse];
                            // Color already assigned to this user
                        } else {
                            $colorindex = $nextindextouse;
                            $colorindexused[$idusertouse] = $colorindex;
                            if (!empty($theme_datacolor[$nextindextouse + 1])) {
                                $nextindextouse++;
                            }
                            // Prepare to use next color
                        }
                        //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
                        // Define color
                        $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
                    }
                    $cssclass = $cssclass . ' ' . $cssclass . '_day_' . $ymd;
                    // Show rect of event
                    print '<div id="event_' . $ymd . '_' . $i . '" class="event ' . $cssclass . '">';
                    print '<ul class="cal_event"><li class="cal_event">';
                    print '<table class="cal_event" style="background: #' . $color . '; -moz-border-radius:4px; background: -webkit-gradient(linear, left top, left bottom, from(#' . $color . '), to(#' . dol_color_minus($color, 1) . ')); " width="100%"><tr>';
                    print '<td class="nowrap cal_event">';
                    if ($event->type_code == 'BIRTHDAY') {
                        print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact');
                    }
                    if ($event->type_code != 'BIRTHDAY') {
                        // Picto
                        if (empty($event->fulldayevent)) {
                            //print $event->getNomUrl(2).' ';
                        }
                        // Date
                        if (empty($event->fulldayevent)) {
                            //print '<strong>';
                            $daterange = '';
                            // Show hours (start ... end)
                            $tmpyearstart = date('Y', $event->date_start_in_calendar);
                            $tmpmonthstart = date('m', $event->date_start_in_calendar);
                            $tmpdaystart = date('d', $event->date_start_in_calendar);
                            $tmpyearend = date('Y', $event->date_end_in_calendar);
                            $tmpmonthend = date('m', $event->date_end_in_calendar);
                            $tmpdayend = date('d', $event->date_end_in_calendar);
                            // Hour start
                            if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
                                $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M');
                                if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                    if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
                                        $daterange .= '-';
                                    }
                                    //else
                                    //print '...';
                                }
                            }
                            if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) {
                                    $daterange .= '...';
                                }
                            }
                            // Hour end
                            if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
                                if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
                                    $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M');
                                }
                            }
                            //print $daterange;
                            if ($event->type_code != 'ICALEVENT') {
                                $savlabel = $event->libelle;
                                $event->libelle = $daterange;
                                print $event->getNomUrl(0);
                                $event->libelle = $savlabel;
                            } else {
                                print $daterange;
                            }
                            //print '</strong> ';
                            print "<br>\n";
                        } else {
                            if ($showinfo) {
                                print $langs->trans("EventOnFullDay") . "<br>\n";
                            }
                        }
                        // Show title
                        if ($event->type_code == 'ICALEVENT') {
                            print dol_trunc($event->libelle, $maxnbofchar);
                        } else {
                            print $event->getNomUrl(0, $maxnbofchar, 'cal_event');
                        }
                        if ($event->type_code == 'ICALEVENT') {
                            print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')';
                        }
                        // If action related to company / contact
                        $linerelatedto = '';
                        $length = 16;
                        if (!empty($event->societe->id) && !empty($event->contact->id)) {
                            $length = round($length / 2);
                        }
                        if (!empty($event->societe->id) && $event->societe->id > 0) {
                            if (!isset($cachethirdparties[$event->societe->id]) || !is_object($cachethirdparties[$event->societe->id])) {
                                $thirdparty = new Societe($db);
                                $thirdparty->fetch($event->societe->id);
                                $cachethirdparties[$event->societe->id] = $thirdparty;
                            } else {
                                $thirdparty = $cachethirdparties[$event->societe->id];
                            }
                            if (!empty($thirdparty->id)) {
                                $linerelatedto .= $thirdparty->getNomUrl(1, '', $length);
                            }
                        }
                        if (!empty($event->contact->id) && $event->contact->id > 0) {
                            if (!is_object($cachecontacts[$event->contact->id])) {
                                $contact = new Contact($db);
                                $contact->fetch($event->contact->id);
                                $cachecontacts[$event->contact->id] = $contact;
                            } else {
                                $contact = $cachecontacts[$event->contact->id];
                            }
                            if ($linerelatedto) {
                                $linerelatedto .= ' / ';
                            }
                            if (!empty($contact->id)) {
                                $linerelatedto .= $contact->getNomUrl(1, '', $length);
                            }
                        }
                        if ($linerelatedto) {
                            print '<br>' . $linerelatedto;
                        }
                    }
                    // Show location
                    if ($showinfo) {
                        if ($event->location) {
                            print '<br>';
                            print $langs->trans("Location") . ': ' . $event->location;
                        }
                    }
                    print '</td>';
                    // Status - Percent
                    print '<td align="right" class="nowrap">';
                    if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
                        print $event->getLibStatut(3, 1);
                    } else {
                        print '&nbsp;';
                    }
                    print '</td></tr></table>';
                    print '</li></ul>';
                    print '</div>';
                    $i++;
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?maxprint=0&month=' . $monthshown . '&year=' . $year;
                    print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : '');
                    print ($filtera ? '&filtera=' . $filtera : '') . ($filtert ? '&filtert=' . $filtert : '') . ($filterd ? '&filterd=' . $filterd : '');
                    print $actioncode != '' ? '&actioncode=' . $actioncode : '';
                    print '">' . img_picto("all", "1downarrow_selected.png") . ' ...';
                    print ' +' . (count($eventarray[$daykey]) - $maxprint);
                    print '</a>';
                    break;
                    //$ok=false;        // To avoid to show twice the link
                }
            }
            break;
        }
    }
    if (!$i) {
        print '&nbsp;';
    }
    if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) {
        print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>';
        //print ' +'.(count($eventarray[$daykey])-$maxprint);
        print '<script type="text/javascript">' . "\n";
        print 'jQuery(document).ready(function () {' . "\n";
        print 'jQuery("#more_' . $ymd . '").click(function() { reinit_day_' . $ymd . '(); });' . "\n";
        print 'function reinit_day_' . $ymd . '() {' . "\n";
        print 'var nb=0;' . "\n";
        // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached
        print 'jQuery(".family_mytasks_day_' . $ymd . '").toggle();';
        print '}' . "\n";
        print '});' . "\n";
        print '</script>' . "\n";
    }
    print '</td></tr>';
    print '</table>';
    print '</div>' . "\n";
}