[Koha-cvs] koha koha-tmpl/intranet-tmpl/prog/en/reports/is...

paul poulain paul at koha-fr.org
Wed Apr 18 16:19:53 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	paul poulain <tipaul>	07/04/18 14:19:53

Modified files:
	koha-tmpl/intranet-tmpl/prog/en/reports: issues_stats.tmpl 
	reports        : catalogue_stats.pl issues_stats.pl 

Log message:
	improving issues_stats by adding location & itemcallnumber filters

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/reports/issues_stats.tmpl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/reports/catalogue_stats.pl?cvsroot=koha&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/koha/reports/issues_stats.pl?cvsroot=koha&r1=1.16&r2=1.17

Patches:
Index: koha-tmpl/intranet-tmpl/prog/en/reports/issues_stats.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/reports/issues_stats.tmpl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- koha-tmpl/intranet-tmpl/prog/en/reports/issues_stats.tmpl	11 Mar 2007 21:08:14 -0000	1.3
+++ koha-tmpl/intranet-tmpl/prog/en/reports/issues_stats.tmpl	18 Apr 2007 14:19:52 -0000	1.4
@@ -14,12 +14,14 @@
 <!-- TMPL_IF NAME="do_it" -->
 	<!-- TMPL_LOOP NAME="mainloop" -->
 		<h1>Issues statistics </h1>
-		<!-- TMPL_IF NAME="loopfilter"-->
+        <!-- TMPL_IF NAME="loopfilter" -->
 			<p>Filtered on</p>
+            <ul>
 			<!-- TMPL_LOOP NAME="loopfilter" -->
-					<p><!-- TMPL_IF NAME="err" -->  <!--/TMPL_IF --> <!-- TMPL_VAR NAME="crit"--> =<!-- TMPL_VAR NAME="filter"--><!-- TMPL_IF NAME="err" -->  <!--/TMPL_IF --></p>
+                <li><!-- TMPL_IF NAME="err" -->  <!--/TMPL_IF --> <!-- TMPL_VAR NAME="crit"--> <!-- TMPL_VAR NAME="filter"--><!-- TMPL_IF NAME="err" -->  <!--/TMPL_IF --></li>
 			<!-- /TMPL_LOOP -->
-		<!-- /TMPL_IF NAME="loopfilter"-->
+            </ul>
+        <!-- /TMPL_IF -->
 		
 		<table> 
 			<tr >
@@ -44,7 +46,7 @@
 							<!-- TMPL_VAR NAME="totalrow" -->
 						</td>
 					</tr>
-				<!-- /TMPL_LOOP NAME="looprow" -->
+                        <!-- /TMPL_LOOP -->
 				<tr >
 					<th>TOTAL</th>
 					<!-- TMPL_LOOP NAME="loopfooter" -->
@@ -91,7 +93,6 @@
 											return false;
 										}
 									}
-					
 									Calendar.setup(
 										{
 											inputField : "from",
@@ -144,7 +145,6 @@
 					<option value ="2">Month</option>
 					<option value ="3">Year</option>
 					</select>
-					
 				</td>
 				<td>
 					Select Day : <select name="PeriodDaySel">
@@ -192,9 +192,21 @@
 				<td><input type="radio" name="Column" value="branch" /></td>
 				<td><!-- TMPL_VAR NAME="CGIBranch" --></td>
 			</tr>
+        <tr>
+            <td>Location</td>
+            <td><input type="radio" name="Line" value="location" /></td>
+            <td><input type="radio" name="Column" value="location" /></td>
+            <td><!-- TMPL_VAR NAME="CGILocation" --></td>
+        </tr>
+        <tr>
+            <td>Item Callnumber</td>
+            <td></td>
+            <td></td>
+            <td>From <input type="text" name="Filter" size="10"/> (included) to <input type="text" name="Filter" size="10" /> (excluded) </td>
+        </tr>
 			<!-- TMPL_IF Name="hassort1" -->
 				<tr class="hilighted"> 
-					<td>Sort1</td>
+                    <td>Borrower sort1</td>
 					<td><input type="radio" name="Line" value="borrowers.sort1" /></td>
 					<td><input type="radio" name="Column" value="borrowers.sort1" /></td>
 					<td><!-- TMPL_VAR NAME="CGISort1" --> </td>
@@ -202,7 +214,7 @@
 			<!-- /TMPL_IF -->
 			<!-- TMPL_IF Name="hassort2" -->
 				<!-- TMPL_IF Name="HglghtSort2"--><tr class="hilighted"> <!-- TMPL_ELSE --><tr><!--/TMPL_IF --> 
-					<td>Sort2</td>
+                <td>Borrower sort2</td>
 					<td><input type="radio" name="Line" value="borrowers.sort2" /></td>
 					<td><input type="radio" name="Column" value="borrowers.sort2" /></td>
 					<td><!-- TMPL_VAR NAME="CGISort2" --> </td>
@@ -211,21 +223,15 @@
 			<tr></tr>
 		</tbody>
 	</table>
-	
-	
 		<h3> Cell value </h3>
 			<p><input type="radio" name="Cellvalue" value="1" checked="checked" /> Count issues </p>
 			<p><input type="radio" name="Cellvalue" value="3" /> Circulation rate </p>
-	
-	
 		<h3> Output </h3>
 		<input type="radio" checked name="output" value="screen" /> To screen into the browser
-		
 		<input type="radio" name="output" value="file"> To file <input type="text" name="basename" value="Export" /> into an application  
 		<!-- TMPL_VAR NAME="CGIextChoice" -->
 		<!-- TMPL_VAR NAME="CGIsepChoice" -->
 	</p>
-	
 	<p>
 	<input type="submit" value="OK" />
 	<input type="hidden" name="report_name" value="<!--TMPL_VAR NAME="report_name" -->" />

Index: reports/catalogue_stats.pl
===================================================================
RCS file: /sources/koha/koha/reports/catalogue_stats.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- reports/catalogue_stats.pl	4 Apr 2007 16:46:23 -0000	1.20
+++ reports/catalogue_stats.pl	18 Apr 2007 14:19:52 -0000	1.21
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: catalogue_stats.pl,v 1.20 2007/04/04 16:46:23 tipaul Exp $
+# $Id: catalogue_stats.pl,v 1.21 2007/04/18 14:19:52 tipaul Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -174,7 +174,7 @@
 #	warn "highlightLOC ".$hglghtLOC;
 	
 	
-	$req = $dbh->prepare("select distinctrow itemtype from biblioitems order by itemtype");
+	$req = $dbh->prepare("select itemtype from itemtypes order by itemtype");
 	$req->execute;
 	undef @select;
 	push @select,"";
@@ -216,12 +216,15 @@
 				-size     => 1,
 				-multiple => 0 );
 	
-	$req = $dbh->prepare("select distinctrow holdingbranch from items order by holdingbranch");
+	$req = $dbh->prepare("select distinctrow location from items order by location");
 	$req->execute;
 	undef @select;
 	push @select,"";
+	while (my ($value) =$req->fetchrow) {
+		push @select, $value;
+	}
 	my $CGIlocation=CGI::scrolling_list( -name     => 'Filter',
-				-id => 'holdingbranch',
+				-id => 'location',
 				-values   => \@select,
 				-size     => 1,
 				-multiple => 0 );
@@ -333,7 +336,7 @@
  	$linefilter[0] = @$filters[8] if ($line =~ /publicationyear/ ) ;
  	$linefilter[1] = @$filters[9] if ($line =~ /publicationyear/ ) ;
  	@linefilter[0] = @$filters[10] if ($line =~ /items.homebranch/ ) ;
- 	@linefilter[0] = @$filters[11] if ($line =~ /items.holdingbranch/ ) ;
+ 	@linefilter[0] = @$filters[11] if ($line =~ /items.location/ ) ;
 # 
  	my @colfilter ;
  	$colfilter[0] = @$filters[0] if ($column =~ /dewey/ )  ;
@@ -347,7 +350,7 @@
  	$colfilter[0] = @$filters[8] if ($column =~ /publicationyear/ ) ;
  	$colfilter[1] = @$filters[9] if ($column =~ /publicationyear/ ) ;
  	@colfilter[0] = @$filters[10] if ($column =~ /items.homebranch/ ) ;
- 	@colfilter[0] = @$filters[11] if ($column =~ /items.holdingbranch/ ) ;
+ 	@colfilter[0] = @$filters[11] if ($column =~ /items.location/ ) ;
 
 # 1st, loop rows.
 	my $linefield;
@@ -506,7 +509,7 @@
 	}
 	if (@$filters[11]){
 		@$filters[11]=~ s/\*/%/g;
-		$strcalc .= " AND items.holdingbranch like '" . @$filters[11] ."'" if ( @$filters[11] );
+		$strcalc .= " AND items.location like '" . @$filters[11] ."'" if ( @$filters[11] );
 	}
 	
 	$strcalc .= " group by $linefield, $colfield order by $linefield,$colfield";

Index: reports/issues_stats.pl
===================================================================
RCS file: /sources/koha/koha/reports/issues_stats.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- reports/issues_stats.pl	4 Apr 2007 16:46:23 -0000	1.16
+++ reports/issues_stats.pl	18 Apr 2007 14:19:52 -0000	1.17
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: issues_stats.pl,v 1.16 2007/04/04 16:46:23 tipaul Exp $
+# $Id: issues_stats.pl,v 1.17 2007/04/18 14:19:52 tipaul Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -201,11 +201,21 @@
 				-values   => \@select,
 				-size     => 1,
 				-multiple => 0 );
-	
+    # location list
+    $req = $dbh->prepare("select distinctrow location from items order by location");
+    $req->execute;
+    undef @select;
+    push @select,"";
+    while (my ($value) =$req->fetchrow) {
+        push @select, $value;
+    }
+    my $CGIlocation=CGI::scrolling_list( -name     => 'Filter',
+                            -id => 'location',
+                            -values   => \@select,
+                            -size     => 1,
+                            -multiple => 0 );
+    # various
 	my @mime = ( C4::Context->preference("MIME") );
-#	foreach my $mime (@mime){
-#		warn "".$mime;
-#	}
 	
 	my $CGIextChoice=CGI::scrolling_list(
 				-name     => 'MIME',
@@ -232,9 +242,10 @@
 					CGISort1 => $CGISort1,
 					CGISort2 => $CGISort2,
 					CGIextChoice => $CGIextChoice,
-					CGIsepChoice => $CGIsepChoice
+        CGIsepChoice => $CGIsepChoice,
+        CGILocation => $CGIlocation,
 					);
-output_html_with_http_headers $input, $cookie, $template->output;
+    output_html_with_http_headers $input, $cookie, $template->output;
 }
 
 
@@ -256,7 +267,7 @@
 # Checking filters
 #
 	my @loopfilter;
-	for (my $i=0;$i<=6;$i++) {
+        for (my $i=0;$i<=9;$i++) {
 		my %cell;
 		if ( @$filters[$i] ) {
 			if (($i==1) and (@$filters[$i-1])) {
@@ -265,11 +276,15 @@
 			$cell{filter} .= @$filters[$i];
 			$cell{crit} .="Period From" if ($i==0);
 			$cell{crit} .="Period To" if ($i==1);
-			$cell{crit} .="Borrower Cat" if ($i==2);
-			$cell{crit} .="Doc Type" if ($i==3);
-			$cell{crit} .="Branch" if ($i==4);
-			$cell{crit} .="Sort1" if ($i==5);
-			$cell{crit} .="Sort2" if ($i==6);
+                        $cell{crit} .="Borrower Cat=" if ($i==2);
+                        $cell{crit} .="Doc Type=" if ($i==3);
+                        $cell{crit} .="Branch=" if ($i==4);
+                        $cell{crit} .="Location=" if ($i==5);
+                        $cell{crit} .="Item callnumber>=" if ($i==6);
+                        $cell{crit} .="Item callnumber<" if ($i==7);
+                        $cell{crit} .="sort1=" if ($i==8);
+                        $cell{crit} .="sort2=" if ($i==9);
+
 			push @loopfilter, \%cell;
 		}
 	}
@@ -290,21 +305,19 @@
  	$linefilter[0] = @$filters[2] if ($line =~ /category/ )  ;
  	$linefilter[0] = @$filters[3] if ($line =~ /itemtype/ )  ;
  	$linefilter[0] = @$filters[4] if ($line =~ /branch/ )  ;
-# 	$linefilter[0] = @$filters[11] if ($line =~ /sort2/ ) ;
- 	$linefilter[0] = @$filters[5] if ($line =~ /sort1/ ) ;
- 	$linefilter[0] = @$filters[6] if ($line =~ /sort2/ ) ;
-#warn "filtre lignes".$linefilter[0]." ".$linefilter[1];
-# 
+        $linefilter[0] = @$filters[5] if ($line =~ /location/ ) ;
+        $linefilter[0] = @$filters[6] if ($line =~ /sort1/ ) ;
+        $linefilter[0] = @$filters[7] if ($line =~ /sort2/ ) ;
+
  	my @colfilter ;
  	$colfilter[0] = @$filters[0] if ($column =~ /datetime/) ;
  	$colfilter[1] = @$filters[1] if ($column =~ /datetime/) ;
  	$colfilter[0] = @$filters[2] if ($column =~ /category/) ;
  	$colfilter[0] = @$filters[3] if ($column =~ /itemtype/) ;
  	$colfilter[0] = @$filters[4] if ($column =~ /branch/ )  ;
- 	$colfilter[0] = @$filters[5] if ($column =~ /sort1/  )  ;
- 	$colfilter[0] = @$filters[6] if ($column =~ /sort2/  )  ;
-#warn "filtre col ".$colfilter[0]." ".$colfilter[1];
-                                              
+        $colfilter[0] = @$filters[5] if ($column =~ /location/  )  ;
+        $colfilter[0] = @$filters[6] if ($column =~ /sort1/  )  ;
+        $colfilter[0] = @$filters[7] if ($column =~ /sort2/  )  ;
 # 1st, loop rows.                             
 	my $linefield;                               
 	if (($line =~/datetime/) and ($dsp == 1)) {
@@ -463,8 +476,11 @@
 		my ($bookcount) = $rqbookcount->fetchrow;
 		$strcalc .= "100*(COUNT(DISTINCT issues.itemnumber))/ $bookcount " ;
 	}
-	$strcalc .= "FROM statistics,borrowers where (statistics.borrowernumber=borrowers.borrowernumber) ";
+        $strcalc .= "FROM statistics ";
+        $strcalc .= "LEFT JOIN borrowers ON statistics.borrowernumber=borrowers.borrowernumber ";
+        $strcalc .= "LEFT JOIN items ON statistics.itemnumber=items.itemnumber " if @$filters[5] or @$filters[6];
 
+        $strcalc .= "WHERE 1=1 ";
 	@$filters[0]=~ s/\*/%/g if (@$filters[0]);
 	$strcalc .= " AND statistics.datetime > '" . @$filters[0] ."'" if ( @$filters[0] );
 	@$filters[1]=~ s/\*/%/g if (@$filters[1]);
@@ -476,9 +492,15 @@
 	@$filters[4]=~ s/\*/%/g if (@$filters[4]);
 	$strcalc .= " AND statistics.branch like '" . @$filters[4] ."'" if ( @$filters[4] );
 	@$filters[5]=~ s/\*/%/g if (@$filters[5]);
-	$strcalc .= " AND borrowers.sort1 like '" . @$filters[5] ."'" if ( @$filters[5] );
+        $strcalc .= " AND items.location like '" . @$filters[5] ."'" if ( @$filters[5] );
 	@$filters[6]=~ s/\*/%/g if (@$filters[6]);
-	$strcalc .= " AND borrowers.sort2 like '" . @$filters[6] ."'" if ( @$filters[6] );
+        $strcalc .= " AND items.itemcallnumber >='" . @$filters[6] ."'" if ( @$filters[6] );
+        @$filters[7]=~ s/\*/%/g if (@$filters[7]);
+        $strcalc .= " AND items.itemcallnumber <'" . @$filters[7] ."'" if ( @$filters[7] );
+        @$filters[8]=~ s/\*/%/g if (@$filters[8]);
+        $strcalc .= " AND borrowers.sort1 like '" . @$filters[8] ."'" if ( @$filters[8] );
+        @$filters[9]=~ s/\*/%/g if (@$filters[9]);
+        $strcalc .= " AND borrowers.sort2 like '" . @$filters[9] ."'" if ( @$filters[9] );
 	$strcalc .= " AND dayname(datetime) like '" . $daysel ."'" if ( $daysel );
 	$strcalc .= " AND monthname(datetime) like '" . $monthsel ."'" if ( $monthsel );
 	$strcalc .= " AND statistics.type like '" . $type ."'" if ( $type );





More information about the Koha-cvs mailing list