Improving top lists display
authorhdl <hdl>
Tue, 29 Mar 2005 17:20:03 +0000 (17:20 +0000)
committerhdl <hdl>
Tue, 29 Mar 2005 17:20:03 +0000 (17:20 +0000)
koha-tmpl/intranet-tmpl/default/en/reports/bor_issues_top.tmpl
koha-tmpl/intranet-tmpl/default/en/reports/cat_issues_top.tmpl
reports/bor_issues_top.pl
reports/cat_issues_top.pl

index 2b279c0..fc5a382 100644 (file)
@@ -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"-->
                        <!-- /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" -->
                                                <!-- 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>
index 4c2bd17..4df22ad 100644 (file)
@@ -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"-->
                        <!-- /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" -->
                                                <!-- 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>
                                                <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>
index 3883908..317822a 100755 (executable)
@@ -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";
@@ -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;
                }
        }
 
@@ -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] );
@@ -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;
@@ -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,
index 3e08f68..0a2d940 100755 (executable)
@@ -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;
                }
        }
 
@@ -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] );
@@ -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);