Skip to content

Commit

Permalink
Improving top lists display
Browse files Browse the repository at this point in the history
  • Loading branch information
hdl committed Mar 29, 2005
1 parent 20137af commit 15dde75
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 44 deletions.
21 changes: 19 additions & 2 deletions koha-tmpl/intranet-tmpl/default/en/reports/bor_issues_top.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<div id="mainbloc" >

<!-- TMPL_IF NAME="do_it" -->
<script language="JavaScript" type="text/javascript">
function Dopop(link) {
newin=window.open(link,'width=500,height=400,toolbar=false,scrollbars=yes');
}
</script>
<!-- TMPL_LOOP NAME="mainloop" -->
<h1 class="reports">Koha : Top <!-- TMPL_VAR NAME="limit"--> List borrowers for Issues </h1>
<!-- TMPL_IF NAME="loopfilter"-->
Expand All @@ -11,11 +16,18 @@
<!-- /TMPL_LOOP -->
<!-- /TMPL_IF NAME="loopfilter"-->
<br>
<table>
<table border="1">
<tr >
<th class="reports">Rank/Borrowers</th>
<!-- TMPL_LOOP NAME="loopcol" -->
<th class="reports"><!-- TMPL_VAR NAME="coltitle" --></th>
<th class="reports" colspan="2"><!-- TMPL_VAR NAME="coltitle" --></th>
<!-- /TMPL_LOOP -->
</tr>
<tr >
<th class="reports">&nbsp;</th>
<!-- TMPL_LOOP NAME="loopcol" -->
<th class="reports">Borrower</th>
<th class="reports">Issues count</th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_LOOP NAME="looprow" -->
Expand All @@ -24,7 +36,12 @@
<!-- TMPL_VAR NAME="rowtitle" --></td>
<!-- TMPL_LOOP NAME="loopcell" -->
<!-- TMPL_IF NAME="hilighted" --><td class="hilighted"><!-- TMPL_ELSE --><td ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="reference" --><a href="javascript:Dopop('../members/moremember.pl?bornum=<!-- TMPL_VAR NAME="reference" -->')" ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="value" --><!-- TMPL_VAR NAME="value" --><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="reference" --></a><!-- /TMPL_IF -->
</td>
<!-- TMPL_IF NAME="hilighted" --><td class="hilighted"><!-- TMPL_ELSE --><td ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="count" --><!-- TMPL_VAR NAME="count" --><!-- /TMPL_IF -->
</td>
<!-- /TMPL_LOOP -->
</tr>
Expand Down
27 changes: 22 additions & 5 deletions koha-tmpl/intranet-tmpl/default/en/reports/cat_issues_top.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<div id="mainbloc" >

<!-- TMPL_IF NAME="do_it" -->
<script language="JavaScript" type="text/javascript">
function Dopop(link) {
newin=window.open(link,'width=500,height=400,toolbar=false,scrollbars=yes');
}
</script>
<!-- TMPL_LOOP NAME="mainloop" -->
<h1 class="reports">Koha : Top <!-- TMPL_VAR NAME="limit"--> List On Catalogue Issues </h1>
<!-- TMPL_IF NAME="loopfilter"-->
Expand All @@ -11,11 +16,18 @@
<!-- /TMPL_LOOP -->
<!-- /TMPL_IF NAME="loopfilter"-->
<br>
<table>
<table border="1">
<tr >
<th class="reports">Rank/biblioitemnumber</th>
<th class="reports">Rank/Biblioitemnumbers</th>
<!-- TMPL_LOOP NAME="loopcol" -->
<th class="reports"><!-- TMPL_VAR NAME="coltitle" --></th>
<th class="reports" colspan="2"><!-- TMPL_VAR NAME="coltitle" --></th>
<!-- /TMPL_LOOP -->
</tr>
<tr >
<th class="reports">&nbsp;</th>
<!-- TMPL_LOOP NAME="loopcol" -->
<th class="reports">Item</th>
<th class="reports">Issues count</th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_LOOP NAME="looprow" -->
Expand All @@ -24,7 +36,12 @@
<!-- TMPL_VAR NAME="rowtitle" --></td>
<!-- TMPL_LOOP NAME="loopcell" -->
<!-- TMPL_IF NAME="hilighted" --><td class="hilighted"><!-- TMPL_ELSE --><td ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="reference" --><a href="javascript:Dopop('../MARCdetail.pl?bib=<!-- TMPL_VAR NAME="reference" -->')" ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="value" --><!-- TMPL_VAR NAME="value" --><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="reference" --></a><!-- /TMPL_IF -->
</td>
<!-- TMPL_IF NAME="hilighted" --><td class="hilighted"><!-- TMPL_ELSE --><td ><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="count" --><!-- TMPL_VAR NAME="count" --><!-- /TMPL_IF -->
</td>
<!-- /TMPL_LOOP -->
</tr>
Expand All @@ -51,10 +68,10 @@
<option value ="10">10</option>
<option value ="15">15</option>
<option value ="20">20</option>
<!-- <option value ="25">25</option>
<option value ="25">25</option>
<option value ="40">40</option>
<option value ="50">50</option>
<option value ="100">100</option>-->
<option value ="100">100</option>
</select>
</td>
<td>
Expand Down
40 changes: 20 additions & 20 deletions reports/bor_issues_top.pl
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,11 @@ sub calculate {
warn "". $strsth2;

my $sth2 = $dbh->prepare( $strsth2 );
if (( @colfilter ) and ($colfilter[1])){
$sth2->execute("'".$colfilter[0]."'","'".$colfilter[1]."'");
} elsif ($colfilter[0]) {
$sth2->execute($colfilter[0]);
} else {
$sth2->execute;
}

$sth2->execute;

while (my ($celvalue) = $sth2->fetchrow) {
my %cell;
# my %ft;
# warn "coltitle :".$celvalue;
$cell{coltitle} = $celvalue;
# $ft{totalcol} = 0;
push @loopcol, \%cell;
}
# warn "fin des titres colonnes";
Expand All @@ -270,7 +260,7 @@ sub calculate {
for (my $i=1;$i<=$line;$i++) {
foreach my $col ( @loopcol ) {
# warn " init table : $row->{rowtitle} / $col->{coltitle} ";
$table[$i]->{($col->{coltitle})?$col->{coltitle}:"total"}=0;
$table[$i]->{($col->{coltitle})?$col->{coltitle}:"total"}->{'name'}=0;
}
}

Expand All @@ -279,9 +269,9 @@ sub calculate {
my $strcalc ;

# Processing average loanperiods
$strcalc .= "SELECT CONCAT( borrowers.surname , \"\\t\",borrowers.firstname, \"\\t\", borrowers.cardnumber) , COUNT(*) AS RANK";
$strcalc .= "SELECT CONCAT(borrowers.surname , \"\\t\",borrowers.firstname), COUNT(*) AS RANK, borrowers.borrowernumber AS ID";
$strcalc .= " , $colfield " if ($colfield);
$strcalc .= " FROM `issues`,borrowers,biblioitems LEFT JOIN items ON (biblioitems.biblioitemnumber=items.biblioitemnumber) LEFT JOIN issuingrules ON (issuingrules.branchcode=issues.branchcode AND issuingrules.itemtype=biblioitems.itemtype AND issuingrules.categorycode=borrowers.categorycode) WHERE issues.itemnumber=items.itemnumber AND issues.borrowernumber=borrowers.borrowernumber and returndate is not null";
$strcalc .= " FROM `issues`,borrowers,biblioitems LEFT JOIN items ON (biblioitems.biblioitemnumber=items.biblioitemnumber) WHERE issues.itemnumber=items.itemnumber AND issues.borrowernumber=borrowers.borrowernumber and returndate is not null";

@$filters[0]=~ s/\*/%/g if (@$filters[0]);
$strcalc .= " AND issues.timestamp > '" . @$filters[0] ."'" if ( @$filters[0] );
Expand Down Expand Up @@ -322,10 +312,12 @@ sub calculate {
my $previous_col;
my $i=1;
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $col )=@data;
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}=$row;
$table[$i]->{$col}->{'name'}=$row;
$table[$i]->{$col}->{'count'}=$rank;
$table[$i]->{$col}->{'link'}=$id;
warn " ".$i." ".$col. " ".$row;
$i++;
$previous_col=$col;
Expand All @@ -334,19 +326,27 @@ sub calculate {
push @loopcol,{coltitle => "Global"} if not($column);

for ($i=1; $i<=$line;$i++) {
warn " ".$i;
my @loopcell;
warn " $i";
#@loopcol 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 ) {
# warn " colonne :$col->{coltitle}";
my $value;
my $count=0;
my $link;
if (@loopcol){
$value =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}};
$value =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'name'};
$count =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'count'};
$link =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'link'};
} else {
$value =$table[$i]->{"zzEMPTY"};
$value =$table[$i]->{"zzEMPTY"}->{'name'};
$count =$table[$i]->{"zzEMPTY"}->{'count'};
$link =$table[$i]->{"zzEMPTY"}->{'link'};
}
push @loopcell, {value => $value} ;
# warn " ".$i ." value:$value count:$count reference:$link";
push @loopcell, {value => $value, count =>$count, reference => $link} ;
}
push @looprow,{ 'rowtitle' => $i ,
'loopcell' => \@loopcell,
Expand Down
37 changes: 20 additions & 17 deletions reports/cat_issues_top.pl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ sub calculate {
for (my $i=1;$i<=$line;$i++) {
foreach my $col ( @loopcol ) {
# warn " init table : $row->{rowtitle} / $col->{coltitle} ";
$table[$i]->{($col->{coltitle})?$col->{coltitle}:"total"}=0;
$table[$i]->{($col->{coltitle})?$col->{coltitle}:"total"}->{'name'}=0;
}
}

Expand All @@ -280,9 +280,9 @@ sub calculate {
my $strcalc ;

# Processing average loanperiods
$strcalc .= "SELECT CONCAT( biblioitems.biblioitemnumber) , COUNT(*) AS RANK";
$strcalc .= "SELECT biblio.title, COUNT(*) AS RANK, biblio.biblionumber AS ID";
$strcalc .= " , $colfield " if ($colfield);
$strcalc .= " FROM `issues`,borrowers,biblioitems LEFT JOIN items ON (biblioitems.biblioitemnumber=items.biblioitemnumber) LEFT JOIN issuingrules ON (issuingrules.branchcode=issues.branchcode AND issuingrules.itemtype=biblioitems.itemtype AND issuingrules.categorycode=borrowers.categorycode) WHERE issues.itemnumber=items.itemnumber AND issues.borrowernumber=borrowers.borrowernumber and returndate is not null";
$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[0]=~ s/\*/%/g if (@$filters[0]);
$strcalc .= " AND issues.timestamp > '" . @$filters[0] ."'" if ( @$filters[0] );
Expand Down Expand Up @@ -323,38 +323,41 @@ sub calculate {
my $previous_col;
my $i=1;
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $col )=@data;
# warn "filling table $row / $col / $issuedate / $returndate /$weight";
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}=$row;
$table[$i]->{$col}->{'name'}=(($row eq "") or ($row eq undef))?"Title":$row;
$table[$i]->{$col}->{'count'}=$rank;
$table[$i]->{$col}->{'link'}=$id;
# warn " ".$i." ".$col. " ".$row;
$i++;
$previous_col=$col;
# $table{$row}->{totalrow}+=$weight*$loanlength;
}

push @loopcol,{coltitle => "Global"} if not ($column);
push @loopcol,{coltitle => "Global"} if not($column);

for ($i=1; $i<=$line;$i++) {
warn " ".$i;
my @loopcell;
warn " $i";
#@loopcol 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 ) {
# warn " colonne :$col->{coltitle}";
my $value;
my $count=0;
my $link;
if (@loopcol){
#warn " test ".(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle};
$value =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}};
$value =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'name'};
$count =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'count'};
$link =$table[$i]->{(($col->{coltitle} eq "NULL") or ($col->{coltitle} eq "Global"))?"zzEMPTY":$col->{coltitle}}->{'link'};
} else {
$value =$table[$i]->{"zzEMPTY"};
$value =$table[$i]->{"zzEMPTY"}->{'name'};
$count =$table[$i]->{"zzEMPTY"}->{'count'};
$link =$table[$i]->{"zzEMPTY"}->{'link'};
}
# $table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} = $value;
#$table{$row}->{totalrow}+=$value;
#warn "row : $row col:$col $cnttable{$row}->{(($col->{coltitle} eq \"NULL\")or ($col->{coltitle} eq \"\"))?\"zzEMPTY\":$col->{coltitle}}";
# $colcount+=$cnttable{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}};
push @loopcell, {value => $value} ;
# warn " ".$i ." value:$value count:$count reference:$link";
push @loopcell, {value => $value, count =>$count, reference => $link} ;
}
#warn "row : $row colcount:$colcount";
#my $total = $table[$i]->{totalrow}/$colcount if ($colcount>0);
Expand Down

0 comments on commit 15dde75

Please sign in to comment.