diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 7c7f79ad59a..f5a78a35799 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -33,11 +33,14 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
+if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
+
$filter=GETPOST("filter");
$filtera = GETPOST("userasked","int")?GETPOST("userasked","int"):GETPOST("filtera","int");
$filtert = GETPOST("usertodo","int")?GETPOST("usertodo","int"):GETPOST("filtert","int");
$filterd = GETPOST("userdone","int")?GETPOST("userdone","int"):GETPOST("filterd","int");
-$showbirthday = GETPOST("showbirthday","int");
+$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
+
$sortfield = GETPOST("sortfield");
$sortorder = GETPOST("sortorder");
@@ -72,7 +75,8 @@ $day=GETPOST("day","int")?GETPOST("day","int"):0;
$actioncode=GETPOST("actioncode");
$pid=GETPOST("projectid","int")?GETPOST("projectid","int"):0;
$status=GETPOST("status");
-$maxprint=GETPOST("maxprint");
+$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
+
if (GETPOST('viewcal')) {
$action='show_month'; $day='';
} // View by month
@@ -86,7 +90,6 @@ if (GETPOST('viewday')) {
$langs->load("other");
$langs->load("commercial");
-if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
/*
@@ -127,6 +130,25 @@ $contactstatic=new Contact($db);
$now=dol_now('tzref');
+// Define list of all external calendars
+$listofextcals=array();
+if (empty($conf->global->AGENDA_DISABLE_EXT) && $conf->global->AGENDA_EXT_NB > 0)
+{
+ $i=0;
+ while($i < $conf->global->AGENDA_EXT_NB)
+ {
+ $i++;
+ $paramkey='AGENDA_EXT_SRC'.$i;
+ $url=$conf->global->$paramkey;
+ $paramkey='AGENDA_EXT_NAME'.$i;
+ $namecal = $conf->global->$paramkey;
+ $paramkey='AGENDA_EXT_COLOR'.$i;
+ $colorcal = $conf->global->$paramkey;
+ if ($url && $namecal) $listofextcals[]=array('src'=>$url,'name'=>$namecal,'color'=>$colorcal);
+ }
+}
+
+
if (empty($action) || $action=='show_month')
{
$prev = dol_get_prev_month($month, $year);
@@ -208,7 +230,7 @@ if ($pid) $param.="&projectid=".$pid;
if ($actioncode) $param.="&actioncode=".$actioncode;
if (GETPOST("type")) $param.="&type=".GETPOST("type");
if ($action == 'show_day' || $action == 'show_week') $param.='&action='.$action;
-if ($maxprint) $param.="&maxprint=on";
+$param.="&maxprint=".$maxprint;
// Show navigation bar
if (empty($action) || $action=='show_month')
@@ -243,29 +265,28 @@ $param.='&year='.$year.'&month='.$month.($day?'&day='.$day:'');
-
-
$head = calendars_prepare_head('');
dol_fiche_head($head, 'card', $langs->trans('Events'), 0, $picto);
-print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid);
+print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals);
dol_fiche_end();
+$link='';
// Add link to show birthdays
-$newparam=$param; // newparam is for birthday links
-$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
-if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
-$link='';
-if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
-else $link.=$langs->trans("AgendaHideBirthdayEvents");
-$link.='';
+if (empty($conf->use_javascript_ajax))
+{
+ $newparam=$param; // newparam is for birthday links
+ $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
+ if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
+ $link='';
+ if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
+ else $link.=$langs->trans("AgendaHideBirthdayEvents");
+ $link.='';
+}
print_fiche_titre($title,$link.' '.$nav, '');
-//print '
';
-
-//print_fiche_titre($link,'','');
// Get event in an array
@@ -492,25 +513,6 @@ if ($showbirthday)
}
}
-//Exernal Calendars
-$listofextcals=array();
-
-if (empty($conf->global->AGENDA_DISABLE_EXT) && $conf->global->AGENDA_EXT_NB > 0)
-{
- $i=0;
- while($i < $conf->global->AGENDA_EXT_NB)
- {
- $i++;
- $paramkey='AGENDA_EXT_SRC'.$i;
- $url=$conf->global->$paramkey;
- $paramkey='AGENDA_EXT_NAME'.$i;
- $namecal = $conf->global->$paramkey;
- $paramkey='AGENDA_EXT_COLOR'.$i;
- $colorcal = $conf->global->$paramkey;
- if ($url && $namecal) $listofextcals[]=array('src'=>$url,'name'=>$namecal,'color'=>$colorcal);
- }
-}
-
if (count($listofextcals))
{
require_once(DOL_DOCUMENT_ROOT."/comm/action/class/ical.class.php");
@@ -768,7 +770,7 @@ if (empty($action) || $action == 'show_month') // View by month
{
$style='cal_other_month';
echo '
| ';
//$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
- $i=0;
+ $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
+ $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
foreach ($eventarray as $daykey => $notused)
{
@@ -966,21 +967,22 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
{
foreach ($eventarray[$daykey] as $index => $event)
{
- if ($i < $maxPrint || $maxPrint == 0)
+ 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 ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) { $colorindex=1; $cssclass='family_mytasks'; }
- if ($event->type_code == 'ICALEVENT') { $color=$event->icalcolor; $cssclass=($event->icalname?'family_'.dol_string_nospecial($event->icalname):'family_other'); }
- if ($event->type_code == 'BIRTHDAY') { $colorindex=2; $cssclass='family_birthday'; }
+ if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) { $nummytasks++; $colorindex=1; $cssclass='family_mytasks'; }
+ else if ($event->type_code == 'ICALEVENT') { $numical++; $numicals[dol_string_nospecial($event->icalname)]++; $color=$event->icalcolor; $cssclass=($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) $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]);
- //print "x".$color;
+ $cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
// Show rect of event
- print ' ';
- print '
';
print $langs->trans("Type");
print ' | ';
- print $htmlactions->select_type_actions(GETPOST('actioncode'), "actioncode");
+ print $formactions->select_type_actions(GETPOST('actioncode'), "actioncode");
print ' | '; print img_picto($langs->trans("ViewList"),'object_list').' '; print ''; + + // Legend + if ($conf->use_javascript_ajax && is_array($showextcals)) + { + print ' ';
+ print ''."\n";
+ print ' | ';
+ }
+
print '';
}
print '
| |||||