Browse Source

bugs fixing on catalogue stats reporting

3.0.x
hdl 18 years ago
parent
commit
6fea10ed0f
  1. 173
      koha-tmpl/intranet-tmpl/default/en/reports/catalogue_stats.tmpl
  2. 139
      reports/catalogue_stats.pl

173
koha-tmpl/intranet-tmpl/default/en/reports/catalogue_stats.tmpl

@ -7,9 +7,10 @@
<!-- TMPL_IF NAME="loopfilter"-->
<p>Filtered on</p>
<!-- TMPL_LOOP NAME="loopfilter" -->
<p><!-- TMPL_IF NAME="err" --> <font color="red"> <b><!--/TMPL_IF --><label> <!-- TMPL_VAR NAME="crit"--> =</label><!-- TMPL_VAR NAME="filter"--><!-- TMPL_IF NAME="err" --> </font color="red"> </b><!--/TMPL_IF --></p>
<p><!-- TMPL_IF NAME="err" --> <font color="red"> <b><!--/TMPL_IF --><label class="label100"> <!-- TMPL_VAR NAME="crit"--> =</label><!-- TMPL_VAR NAME="filter"--><!-- TMPL_IF NAME="err" --> </font> </b><!--/TMPL_IF --></p>
<!-- /TMPL_LOOP -->
<!-- /TMPL_IF NAME="loopfilter"-->
<br>
<table>
<tr >
<th class="reports"><!-- TMPL_VAR name="line" --> / <!-- TMPL_VAR name="column" --></th>
@ -49,104 +50,108 @@
<table>
<thead>
<tr>
<th class="reports">Title</th>
<th class="reports"><div class="label100">Title</div></th>
<th class="reports">Row</th>
<th class="reports">Column</th>
<th class="reports">Filter</th>
</tr>
</thead>
<tbody>
<tr class="hilighted">
<td>Dewey Classification</td>
<td align="center"><input type="radio" name="Line" value="dewey"></td>
<td align="center"><input type="radio" name="Column" value="dewey"></td>
<td > From <!-- TMPL_VAR NAME="CGIFromDeweyClass" --> To <!-- TMPL_VAR NAME="CGIToDeweyClass" --></td>
</tr>
<tr class="hilighted">
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="deweydigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
digits
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Library Of Congress Classification</td>
<td align="center"><input type="radio" name="Line" value="lccn"></td>
<td align="center"><input type="radio" name="Column" value="lccn"></td>
<td > From <!-- TMPL_VAR NAME="CGIFromLoCClass" --> To <!-- TMPL_VAR NAME="CGIToLoCClass" --></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="lccndigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
characters
</td>
<td>&nbsp;</td>
</tr>
<tr class="hilighted">
<td>
Cote
</td>
<td align="center"><input type="radio" name="Line" value="items.itemcolnumber"></td>
<td align="center"><input type="radio" name="Column" value="items.itemcolnumber"></td>
<td>From <!-- TMPL_VAR NAME="CGIFromCoteClass" --> To <!-- TMPL_VAR NAME="CGIToCoteClass" --></td>
</tr>
<tr class="hilighted">
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="cotedigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
characters
</td>
<td>&nbsp;</td>
</tr>
<!-- TMPL_IF Name="hasdewey" -->
<tr class="hilighted">
<td>Dewey Classification</td>
<td align="center"><input type="radio" name="Line" value="dewey"></td>
<td align="center"><input type="radio" name="Column" value="dewey"></td>
<td > From <!-- TMPL_VAR NAME="CGIFromDeweyClass" --> To <!-- TMPL_VAR NAME="CGIToDeweyClass" --></td>
</tr>
<tr class="hilighted">
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="deweydigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
digits
</td>
<td>&nbsp;</td>
</tr>
<!-- /TMPL_IF -->
<!-- TMPL_IF Name="haslccn" -->
<!--TMPL_IF Name="hlghtlccn"--><tr class="hilighted"> <!--TMPL_ELSE --><tr><!--/TMPL_IF-->
<td>LoC Classification</td>
<td align="center"><input type="radio" name="Line" value="lccn"></td>
<td align="center"><input type="radio" name="Column" value="lccn"></td>
<td > From <!-- TMPL_VAR NAME="CGIFromLoCClass" --> To <!-- TMPL_VAR NAME="CGIToLoCClass" --></td>
</tr>
<!--TMPL_IF Name="hlghtlccn"--><tr class="hilighted"> <!--TMPL_ELSE --><tr><!--/TMPL_IF-->
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="lccndigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
characters
</td>
<td>&nbsp;</td>
</tr>
<!-- /TMPL_IF -->
<!-- TMPL_IF Name="hascote" -->
<!--TMPL_IF Name="hlghtcote"--><tr class="hilighted"> <!--TMPL_ELSE --><tr><!--/TMPL_IF-->
<td>Callnumber</td>
<td align="center"><input type="radio" name="Line" value="items.itemcallnumber"></td>
<td align="center"><input type="radio" name="Column" value="items.itemcallnumber"></td>
<td>From <!-- TMPL_VAR NAME="CGIFromCoteClass" --> To <!-- TMPL_VAR NAME="CGIToCoteClass" --></td>
</tr>
<!--TMPL_IF Name="hlghtcote"--><tr class="hilighted"> <!--TMPL_ELSE --><tr><!--/TMPL_IF-->
<td>&nbsp;</td>
<td align="center" colspan="2"><select name="cotedigits">
<option value=""> </option>
<option value ="1">1</option>
<option value ="2">2</option>
<option value ="3">3</option>
<option value ="4">4</option>
<option value ="5">5</option>
</select>
characters
</td>
<td>&nbsp;</td>
</tr>
<!-- /TMPL_IF -->
<tr>
<td>Document Type</td>
<td align="center"><input type="radio" name="Line" value="itemtype"></td>
<td align="center"><input type="radio" name="Column" value="itemtype"></td>
<td ><!-- TMPL_VAR NAME="CGIItemType" --></td>
<td>Document Type</td>
<td align="center"><input type="radio" name="Line" value="itemtype"></td>
<td align="center"><input type="radio" name="Column" value="itemtype"></td>
<td ><!-- TMPL_VAR NAME="CGIItemType" --></td>
</tr>
<tr class="hilighted" >
<td>Publisher</td>
<td align="center"><input type="radio" name="Line" value="publishercode"></td>
<td align="center"><input type="radio" name="Column" value="publishercode"></td>
<td><!-- TMPL_VAR NAME="CGIPublisher" --></td>
<td>Publisher</td>
<td align="center"><input type="radio" name="Line" value="publishercode"></td>
<td align="center"><input type="radio" name="Column" value="publishercode"></td>
<td><!-- TMPL_VAR NAME="CGIPublisher" --></td>
</tr>
<tr>
<td>Publication Year</td>
<td align="center"><input type="radio" name="Line" value="publicationyear"></td>
<td align="center"><input type="radio" name="Column" value="publicationyear"></td>
<td>From <!-- TMPL_VAR NAME="CGIFromPublicationYear" --> To <!-- TMPL_VAR NAME="CGIToPublicationYear" --></td>
<td>Publication Year</td>
<td align="center"><input type="radio" name="Line" value="publicationyear"></td>
<td align="center"><input type="radio" name="Column" value="publicationyear"></td>
<td>From <input type="text" name="Filter" > To <input type="text" name="Filter" ></td>
</tr>
<tr class="hilighted" >
<td>Home Branch</td>
<td align="center"><input type="radio" name="Line" value="items.homebranch"></td>
<td align="center"><input type="radio" name="Column" value="items.homebranch"></td>
<td><!-- TMPL_VAR NAME="CGIBranch" --></td>
<td>Home Branch</td>
<td align="center"><input type="radio" name="Line" value="items.homebranch"></td>
<td align="center"><input type="radio" name="Column" value="items.homebranch"></td>
<td><!-- TMPL_VAR NAME="CGIBranch" --></td>
</tr>
<tr>
<td>Location</td>
<td align="center"><input type="radio" name="Line" value="items.location"></td>
<td align="center"><input type="radio" name="Column" value="items.location"></td>
<td><!-- TMPL_VAR NAME="CGILocation" --> </td>
<td>Location</td>
<td align="center"><input type="radio" name="Line" value="items.location"></td>
<td align="center"><input type="radio" name="Column" value="items.location"></td>
<td><!-- TMPL_VAR NAME="CGILocation" --> </td>
</tr>
</tbody>
</table>

139
reports/catalogue_stats.pl

@ -105,9 +105,11 @@ if ($do_it) {
my $req;
$req = $dbh->prepare("select distinctrow left(dewey,3) from biblioitems");
$req->execute;
my $hasdewey=1;
my @select;
push @select,"";
while (my ($value) =$req->fetchrow) {
$hasdewey =1 if (($value) and (! $hasdewey));
push @select, $value;
}
my $CGIdewey=CGI::scrolling_list( -name => 'Filter',
@ -120,7 +122,11 @@ if ($do_it) {
$req->execute;
undef @select;
push @select,"";
my $haslccn=1;
my $hlghtlccn;
while (my ($value) =$req->fetchrow) {
$hlghtlccn = !($hasdewey);
$haslccn =1 if (($value) and (! $haslccn));
push @select, $value;
}
my $CGIlccn=CGI::scrolling_list( -name => 'Filter',
@ -129,11 +135,15 @@ if ($do_it) {
-size => 1,
-multiple => 0 );
$req = $dbh->prepare("select distinctrow left(itemcolnumber,5) from items");
$req = $dbh->prepare("select distinctrow left(itemcallnumber,5) from items");
$req->execute;
undef @select;
push @select,"";
my $hascote=1;
my $hlghtcote;
while (my ($value) =$req->fetchrow) {
$hascote =1 if (($value) and (! $hascote));
$hlghtcote = (($hasdewey) and ($haslccn)) or (!($hasdewey) and !($haslccn));
push @select, $value;
}
my $CGIcote=CGI::scrolling_list( -name => 'Filter',
@ -225,10 +235,15 @@ if ($do_it) {
-size => 1,
-multiple => 0 );
$template->param(CGIFromDeweyClass => $CGIdewey,
$template->param(hasdewey=>$hasdewey,
CGIFromDeweyClass => $CGIdewey,
CGIToDeweyClass => $CGIdewey,
haslccn=> $haslccn,
hlghtlccn => $hlghtlccn,
CGIFromLoCClass => $CGIlccn,
CGIToLoCClass => $CGIlccn,
hascote=> $hascote,
hlghtcote => $hlghtcote,
CGIFromCoteClass => $CGIcote,
CGIToCoteClass => $CGIcote,
CGIItemType => $CGIitemtype,
@ -269,54 +284,54 @@ sub calculate {
$cell{err} = 1 if (@$filters[$i]<@$filters[$i-1]) ;
}
$cell{filter} .= @$filters[$i];
$cell{crit} .="Dewey Classification From :" if ($i==0);
$cell{crit} .="Dewey Classification To :" if ($i==1);
$cell{crit} .="Lccn Classification From :" if ($i==2);
$cell{crit} .="Lccn Classification To :" if ($i==3);
$cell{crit} .="Cote Classification From :" if ($i==4);
$cell{crit} .="Cote Classification To :" if ($i==5);
$cell{crit} .="Document type :" if ($i==6);
$cell{crit} .="Publisher :" if ($i==7);
$cell{crit} .="Publication year From :" if ($i==8);
$cell{crit} .="Publication year To :" if ($i==9);
$cell{crit} .="Dewey Classification From" if ($i==0);
$cell{crit} .="Dewey Classification To" if ($i==1);
$cell{crit} .="Lccn Classification From" if ($i==2);
$cell{crit} .="Lccn Classification To" if ($i==3);
$cell{crit} .="Cote Classification From" if ($i==4);
$cell{crit} .="Cote Classification To" if ($i==5);
$cell{crit} .="Document type" if ($i==6);
$cell{crit} .="Publisher" if ($i==7);
$cell{crit} .="Publication year From" if ($i==8);
$cell{crit} .="Publication year To" if ($i==9);
$cell{crit} .="Branch :" if ($i==10);
$cell{crit} .="Location:" if ($i==11);
push @loopfilter, \%cell;
}
}
my $linefilter = "";
my @linefilter;
# warn "filtres ".@filters[0];
# warn "filtres ".@filters[1];
# warn "filtres ".@filters[2];
# warn "filtres ".@filters[3];
$linefilter = @$filters[0] if ($line =~ /dewey/ ) ;
$linefilter = @$filters[1] if ($line =~ /dewey/ ) ;
$linefilter = @$filters[2] if ($line =~ /lccn/ ) ;
$linefilter = @$filters[3] if ($line =~ /lccn/ ) ;
$linefilter = @$filters[4] if ($line =~ /itemcolnumber/ ) ;
$linefilter = @$filters[5] if ($line =~ /itemcolnumber/ ) ;
$linefilter = @$filters[6] if ($line =~ /itemtype/ ) ;
$linefilter = @$filters[7] if ($line =~ /publishercode/ ) ;
$linefilter = @$filters[8] if ($line =~ /publicationyear/ ) ;
$linefilter = @$filters[9] if ($line =~ /publicationyear/ ) ;
$linefilter = @$filters[10] if ($line =~ /items.homebranch/ ) ;
$linefilter = @$filters[11] if ($line =~ /items.location/ ) ;
$linefilter[0] = @$filters[0] if ($line =~ /dewey/ ) ;
$linefilter[1] = @$filters[1] if ($line =~ /dewey/ ) ;
$linefilter[0] = @$filters[2] if ($line =~ /lccn/ ) ;
$linefilter[1] = @$filters[3] if ($line =~ /lccn/ ) ;
$linefilter[0] = @$filters[4] if ($line =~ /items.itemcallnumber/ ) ;
$linefilter[1] = @$filters[5] if ($line =~ /items.itemcallnumber/ ) ;
@linefilter[0] = @$filters[6] if ($line =~ /itemtype/ ) ;
@linefilter[0] = @$filters[7] if ($line =~ /publishercode/ ) ;
$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.location/ ) ;
#
my $colfilter = "";
$colfilter = @$filters[0] if ($column =~ /dewey/ ) ;
$colfilter = @$filters[1] if ($column =~ /dewey/ ) ;
$colfilter = @$filters[2] if ($column =~ /lccn/ ) ;
$colfilter = @$filters[3] if ($column =~ /lccn/ ) ;
$colfilter = @$filters[4] if ($column =~ /itemcolnumber/ ) ;
$colfilter = @$filters[5] if ($column =~ /itemcolnumber/ ) ;
$colfilter = @$filters[6] if ($column =~ /itemtype/ ) ;
$colfilter = @$filters[7] if ($column =~ /publishercode/ ) ;
$colfilter = @$filters[8] if ($column =~ /publicationyear/ ) ;
$colfilter = @$filters[9] if ($column =~ /publicationyear/ ) ;
$colfilter = @$filters[10] if ($column =~ /items.homebranch/ ) ;
$colfilter = @$filters[11] if ($column =~ /items.location/ ) ;
my @colfilter ;
$colfilter[0] = @$filters[0] if ($column =~ /dewey/ ) ;
$colfilter[1] = @$filters[1] if ($column =~ /dewey/ ) ;
$colfilter[0] = @$filters[2] if ($column =~ /lccn/ ) ;
$colfilter[1] = @$filters[3] if ($column =~ /lccn/ ) ;
$colfilter[0] = @$filters[4] if ($column =~ /itemcallnumber/ ) ;
$colfilter[1] = @$filters[5] if ($column =~ /itemcallnumber/ ) ;
@colfilter[0] = @$filters[6] if ($column =~ /itemtype/ ) ;
@colfilter[0] = @$filters[7] if ($column =~ /publishercode/ ) ;
$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.location/ ) ;
# 1st, loop rows.
my $linefield;
@ -324,7 +339,7 @@ sub calculate {
$linefield .="left($line,$deweydigits)";
} elsif (($line=~/lccn/) and ($lccndigits)) {
$linefield .="left($line,$lccndigits)";
} elsif (($line=~/itemcolnumber/) and ($cotedigits)) {
} elsif (($line=~/items.itemcallnumber/) and ($cotedigits)) {
$linefield .="left($line,$cotedigits)";
}else {
$linefield .= $line;
@ -333,16 +348,23 @@ sub calculate {
my $strsth;
$strsth .= "select distinctrow $linefield from biblioitems, items where (items.biblioitemnumber = biblioitems.biblioitemnumber) and $line is not null ";
$linefilter =~ s/\*/%/g;
if ( $linefilter ) {
$strsth .= " and $linefield LIKE ? " ;
if ( @linefilter ) {
if ($linefilter[1]){
$strsth .= " and $line >= ? " ;
$strsth .= " and $line <= ? " ;
} elsif ($linefilter[0]) {
$linefilter[0] =~ s/\*/%/g;
$strsth .= " and $line LIKE ? " ;
}
}
$strsth .=" order by $linefield";
warn "". $strsth;
my $sth = $dbh->prepare( $strsth );
if ( $linefilter ) {
$sth->execute($linefilter);
if (( @linefilter ) and ($linefilter[1])){
$sth->execute($linefilter[0],$linefilter[1]);
} elsif ($linefilter[0]) {
$sth->execute($linefilter[0]);
} else {
$sth->execute;
}
@ -363,23 +385,27 @@ sub calculate {
$colfield .="left($column,$deweydigits)";
}elsif (($column=~/lccn/) and ($lccndigits)) {
$colfield .="left($column,$lccndigits)";
}elsif (($column=~/itemcolnumber/) and ($cotedigits)) {
}elsif (($column=~/itemcallnumber/) and ($cotedigits)) {
$colfield .="left($column,$cotedigits)";
}else {
$colfield .= $column;
}
my $strsth2;
$colfilter =~ s/\*/%/g;
$strsth2 .= "select distinctrow $colfield from biblioitems, items where (items.biblioitemnumber = biblioitems.biblioitemnumber) and $column is not null ";
if ( $colfilter ) {
$strsth2 .= " and $colfield LIKE ? ";
if (( @colfilter ) and ($colfilter[1])) {
$strsth2 .= " and $column> ? and $column< ?";
}elsif ($colfilter[0]){
$colfilter[0] =~ s/\*/%/g;
$strsth2 .= " and $column LIKE ? ";
}
$strsth2 .= " order by $colfield";
warn "". $strsth2;
my $sth2 = $dbh->prepare( $strsth2 );
if ($colfilter) {
$sth2->execute($colfilter);
if ((@colfilter) and ($colfilter[1])) {
$sth2->execute($colfilter[0],$colfilter[1]);
} elsif ($colfilter[0]){
$sth2->execute($colfilter[0]);
} else {
$sth2->execute;
}
@ -418,9 +444,9 @@ sub calculate {
@$filters[3]=~ s/\*/%/g if (@$filters[3]);
$strcalc .= " AND lccn <" . @$filters[3] ."" if ( @$filters[3] );
@$filters[4]=~ s/\*/%/g if (@$filters[4]);
$strcalc .= " AND items.itemcolnumber >" . @$filters[4] ."" if ( @$filters[4] );
$strcalc .= " AND items.itemcallnumber >" . @$filters[4] ."" if ( @$filters[4] );
@$filters[5]=~ s/\*/%/g if (@$filters[5]);
$strcalc .= " AND items.itemcolnumber <" . @$filters[5] ."" if ( @$filters[5] );
$strcalc .= " AND items.itemcallnumber <" . @$filters[5] ."" if ( @$filters[5] );
@$filters[6]=~ s/\*/%/g if (@$filters[6]);
$strcalc .= " AND biblioitems.itemtype like '" . @$filters[6] ."'" if ( @$filters[6] );
@$filters[7]=~ s/\*/%/g if (@$filters[7]);
@ -437,9 +463,9 @@ sub calculate {
warn "". $strcalc;
my $dbcalc = $dbh->prepare($strcalc);
$dbcalc->execute;
# warn "filling table";
warn "filling table";
while (my ($row, $col, $value) = $dbcalc->fetchrow) {
# warn "filling table $row / $col / $value ";
warn "filling table $row / $col / $value ";
$table{$row}->{$col}=$value;
$table{$row}->{totalrow}+=$value;
$grantotal += $value;
@ -459,11 +485,14 @@ sub calculate {
$hilighted = -$hilighted;
}
warn "footer processing";
foreach my $col ( @loopcol ) {
my $total=0;
foreach my $row ( @loopline ) {
foreach my $row ( @looprow ) {
$total += $table{$row->{rowtitle}}->{$col->{coltitle}};
warn "value added ".$table{$row->{rowtitle}}->{$col->{coltitle}}. "for line ".$row->{rowtitle};
}
warn "summ for column ".$col->{coltitle}." = ".$total;
push @loopfooter, {'totalcol' => $total};
}

Loading…
Cancel
Save