use C4::Interface::CGI::Output;
use C4::Circulation::Circ2;
use Date::Manip;
+use C4::Members;
=head1 NAME
flagsrequired => {editcatalogue => 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);
-values => \@dels,
-size => 1,
-multiple => 0 );
+ #branch
+ my $branches = getallbranches;
+ 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) = borrowercategories;
+ 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;
- # my %ft;
- # warn "coltitle :".$celvalue;
- $cell{coltitle} = $celvalue;
- # $ft{totalcol} = 0;
+ $cell{coltitle} = ($celvalue?$celvalue:"NULL");
push @loopcol, \%cell;
}
# warn "fin des titres colonnes";
my $strcalc ;
# Processing average loanperiods
- $strcalc .= "SELECT biblio.title, COUNT(*) AS RANK, biblio.biblionumber AS ID";
+ $strcalc .= "SELECT DISTINCT biblio.title, COUNT(biblio.biblionumber) AS RANK, biblio.biblionumber AS ID";
$strcalc .= " , $colfield " if ($colfield);
$strcalc .= " FROM `issues`,borrowers,(items LEFT JOIN biblioitems ON biblioitems.biblioitemnumber=items.biblioitemnumber) LEFT JOIN biblio ON (biblio.biblionumber=items.biblionumber) WHERE issues.itemnumber=items.itemnumber AND issues.borrowernumber=borrowers.borrowernumber and returndate is not null";
@$filters[9]=~ s/\*/%/g if (@$filters[9]);
$strcalc .= " AND year(issues.timestamp) like '" . @$filters[9] ."'" if ( @$filters[9] );
- $strcalc .= " group by borrowers.borrowernumber";
+ $strcalc .= " group by biblio.biblionumber";
$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;
+ $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;
- $i++;
- $previous_col=$col;
+ $indice{$col}++;
}
push @loopcol,{coltitle => "Global"} if not($column);
return \@mainloop;
}
-1;
\ No newline at end of file
+1;