<%args> $Queue => undef $Month => undef $Year => undef <%init> use Date::Calc qw( Days_in_Month); my $title = loc("Calendar Queues"); my $query = 'Status != "deleted" '; my ($from, $to); # Create the from and to dates from the month and year. # Put this in a sub somewhere? if ( $Year && $Month ){ $from = $Year . '-' . $Month . '-' . '01'; my $last_day = Days_in_Month($Year,$Month); $to = $Year . '-' . $Month . '-' . $last_day; } <& /Elements/Header, Title => $title &> <& /Tools/Calendar/Elements/Tabs, current_tab => 'Tools/Calendar/SelectCalendar.html', Title => $title &>
<%perl> if ($Queue && $from && $to) { # Queue might be an array. if ( ref $Queue eq 'ARRAY' ){ $query .= " AND ("; for my $queue ( @$Queue ){ $query .= " Queue = '$queue' OR"; } # Nibble off the last 'OR'. I know, it's ugly. chop $query; chop $query; $query .= ')'; } else{ $query .= " AND Queue = '$Queue'"; } $query .= " AND Due >= '" . $from . "'"; $query .= " AND Due <= '" . $to . "'"; % print "

$query"; <& /Tools/Calendar/Calendar, Query => $query, Month => $Month, Year => $Year &> %}


%#
%# Create sub to generate list of calendar queues and add it as a config item. %# Queue:
Select Queues:
ACS Calendar
ACS Calendar Network


Month: %# TODO: Make this dynamic somehow. Year: %# Select Date Range: %#
From: <& /Elements/SelectDate, Name => "From", Value => $ARGS{From}, Default => '' &> %#
To: <& /Elements/SelectDate, Name => "To", Value => $ARGS{To}, Default => '' &> <& /Elements/Submit&>