# Suite 330, Boston, MA 02111-1307 USA
use strict;
-use C4::Auth;
use CGI;
-use C4::Context;
-use HTML::Template;
-use C4::Search;
+use C4::Auth;
use C4::Output;
+use C4::Context;
+use C4::Branch; # GetBranches
use C4::Koha;
-use C4::Interface::CGI::Output;
-use C4::Circulation::Circ2;
+use C4::Circulation;
+use C4::Members;
use Date::Manip;
=head1 NAME
=head1 DESCRIPTION
-
-=over2
+=over 2
=cut
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {editcatalogue => 1},
+ flagsrequired => {reports => 1},
debug => 1,
});
-$template->param(do_it => $do_it);
+$template->param(do_it => $do_it,
+ intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ );
if ($do_it) {
# Displaying results
my $results = calculate($limit, $column, \@filters);
} else {
# Printing to a csv file
print $input->header(-type => 'application/vnd.sun.xml.calc',
+ -encoding => 'utf-8',
-attachment=>"$basename.csv",
-filename=>"$basename.csv" );
my $cols = @$results[0]->{loopcol};
-values => \@dels,
-size => 1,
-multiple => 0 );
+ #branch
+ my $branches = GetBranches;
+ my @branchloop;
+ foreach my $thisbranch (keys %$branches) {
+# my $selected = 1 if $thisbranch eq $branch;
+ my %row =(value => $thisbranch,
+# selected => $selected,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ );
+ push @branchloop, \%row;
+ }
+
+ #doctype
+ my $itemtypes = GetItemTypes;
+ my @itemtypeloop;
+ foreach my $thisitemtype (keys %$itemtypes) {
+# my $selected = 1 if $thisbranch eq $branch;
+ my %row =(value => $thisitemtype,
+# selected => $selected,
+ description => $itemtypes->{$thisitemtype}->{'description'},
+ );
+ push @itemtypeloop, \%row;
+ }
+
+ #borcat
+ my ($codes,$labels) = GetborCatFromCatType(undef,undef);
+ my @borcatloop;
+ foreach my $thisborcat (sort keys %$labels) {
+ # my $selected = 1 if $thisbranch eq $branch;
+ my %row =(value => $thisborcat,
+ # selected => $selected,
+ description => $labels->{$thisborcat},
+ );
+ push @borcatloop, \%row;
+ }
+ #Day
+ #Month
$template->param(
CGIextChoice => $CGIextChoice,
- CGIsepChoice => $CGIsepChoice
+ CGIsepChoice => $CGIsepChoice,
+ branchloop =>\@branchloop,
+ itemtypeloop =>\@itemtypeloop,
+ borcatloop =>\@borcatloop,
);
output_html_with_http_headers $input, $cookie, $template->output;
}
while (my ($celvalue) = $sth2->fetchrow) {
my %cell;
- $cell{coltitle} = $celvalue;
+ $cell{'coltitle'} = ($celvalue?$celvalue:"NULL");
push @loopcol, \%cell;
}
# warn "fin des titres colonnes";
$strcalc .= " group by borrowers.borrowernumber";
$strcalc .= ", $colfield" if ($column);
- $strcalc .= " order by ";
- $strcalc .= "$colfield, " if ($colfield);
- $strcalc .= "RANK DESC ";
- my $max;
- if (@loopcol) {
- $max = $line*@loopcol;
- } else { $max=$line;}
- $strcalc .= " LIMIT 0,$max";
+ $strcalc .= " order by RANK DESC";
+ $strcalc .= ",$colfield " if ($colfield);
+# my $max;
+# if (@loopcol) {
+# $max = $line*@loopcol;
+# } else { $max=$line;}
+# $strcalc .= " LIMIT 0,$max";
warn "SQL :". $strcalc;
my $dbcalc = $dbh->prepare($strcalc);
$dbcalc->execute;
# warn "filling table";
my $previous_col;
- my $i=1;
+ my %indice;
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $id, $col )=@data;
$col = "zzEMPTY" if ($col eq undef);
- $i=1 if (($previous_col) and not($col eq $previous_col));
- $table[$i]->{$col}->{'name'}=$row;
- $table[$i]->{$col}->{'count'}=$rank;
- $table[$i]->{$col}->{'link'}=$id;
- warn " ".$i." ".$col. " ".$row;
- $i++;
- $previous_col=$col;
+ $indice{$col}=1 if (not($indice{$col}));
+ $table[$indice{$col}]->{$col}->{'name'}=$row;
+ $table[$indice{$col}]->{$col}->{'count'}=$rank;
+ $table[$indice{$col}]->{$col}->{'link'}=$id;
+# warn " ".$i." ".$col. " ".$row;
+ $indice{$col}++;
}
push @loopcol,{coltitle => "Global"} if not($column);
for ($i=1; $i<=$line;$i++) {
my @loopcell;
warn " $i";
- #@loopcol ensures the order for columns is common with column titles
+ #@loborrowersopcol ensures the order for columns is common with column titles
# and the number matches the number of columns
my $colcount=0;
foreach my $col ( @loopcol ) {
return \@mainloop;
}
-1;
\ No newline at end of file
+1;