[Koha-cvs] koha/opac changelanguage.pl opac-ISBDdetail.pl ...

paul poulain paul at koha-fr.org
Fri Mar 9 16:12:55 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	paul poulain <tipaul>	07/03/09 15:12:54

Modified files:
	opac           : changelanguage.pl opac-ISBDdetail.pl 
	                 opac-MARCdetail.pl opac-account.pl 
	                 opac-addbookbybiblionumber.pl 
	                 opac-alert-subscribe.pl opac-basket.pl 
	                 opac-detail.pl opac-detailprint.pl 
	                 opac-dictionary.pl opac-logout.pl opac-main.pl 
	                 opac-passwd.pl opac-readingrecord.pl 
	                 opac-renew.pl opac-reserve.pl opac-review.pl 
	                 opac-search.pl opac-sendbasket.pl 
	                 opac-serial-issues.pl opac-shelves.pl 
	                 opac-showreviews.pl opac-suggestions.pl 
	                 opac-user.pl opac-userdetails.pl 
	                 opac-userupdate.pl 

Log message:
	rel_3_0 moved to HEAD

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/changelanguage.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-ISBDdetail.pl?cvsroot=koha&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-MARCdetail.pl?cvsroot=koha&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-account.pl?cvsroot=koha&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-addbookbybiblionumber.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-alert-subscribe.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-basket.pl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-detail.pl?cvsroot=koha&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-detailprint.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-dictionary.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-logout.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-main.pl?cvsroot=koha&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-passwd.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-readingrecord.pl?cvsroot=koha&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-renew.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-reserve.pl?cvsroot=koha&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-review.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-search.pl?cvsroot=koha&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-sendbasket.pl?cvsroot=koha&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-serial-issues.pl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-shelves.pl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-showreviews.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-suggestions.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-user.pl?cvsroot=koha&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-userdetails.pl?cvsroot=koha&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-userupdate.pl?cvsroot=koha&r1=1.14&r2=1.15

Patches:
Index: changelanguage.pl
===================================================================
RCS file: /sources/koha/koha/opac/changelanguage.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- changelanguage.pl	16 Aug 2004 12:49:42 -0000	1.1
+++ changelanguage.pl	9 Mar 2007 15:12:54 -0000	1.2
@@ -1,10 +1,25 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use C4::Output;
 use CGI;
 
-my $query=new CGI;
-my $language=$query->param('language');
-my $url=$query->referer();
+my $query    = new CGI;
+my $language = $query->param('language');
+my $url      = $query->referer();
 
-setlanguagecookie($query,$language,$url);
+setlanguagecookie( $query, $language, $url );

Index: opac-ISBDdetail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-ISBDdetail.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- opac-ISBDdetail.pl	11 Aug 2006 15:45:37 -0000	1.16
+++ opac-ISBDdetail.pl	9 Mar 2007 15:12:54 -0000	1.17
@@ -17,22 +17,20 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-ISBDdetail.pl,v 1.16 2006/08/11 15:45:37 toins Exp $
+# $Id: opac-ISBDdetail.pl,v 1.17 2007/03/09 15:12:54 tipaul Exp $
 
 =head1 NAME
 
-MARCdetail.pl : script to show a biblio in MARC format
+opac-ISBDdetail.pl : script to show a biblio in ISBD format
 
 
 =head1 DESCRIPTION
 
-This script needs a biblionumber in bib parameter (bibnumber
-from koha style DB.  Automaticaly maps to marc biblionumber).
+This script needs a biblionumber as parameter 
 
-It shows the biblio in a (nice) MARC format depending on MARC
-parameters tables.
+It shows the biblio
 
-The template is in <templates_dir>/catalogue/MARCdetail.tmpl.
+The template is in <templates_dir>/catalogue/ISBDdetail.tmpl.
 this template must be divided into 11 "tabs".
 
 The first 10 tabs present the biblio, the 11th one presents
@@ -44,7 +42,6 @@
 
 =cut
 
-
 use strict;
 require Exporter;
 use C4::Auth;
@@ -52,135 +49,183 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use CGI;
-use C4::Search;
 use MARC::Record;
 use C4::Biblio;
 use C4::Acquisition;
-use C4::Serials; #uses getsubscriptionfrom biblionumber
-use HTML::Template;
+use C4::Review;
+use C4::Serials;    # uses getsubscriptionfrom biblionumber
+use C4::Koha;       # use getitemtypeinfo
+use C4::Members;    # GetMember
 
-my $query=new CGI;
+my $query = new CGI;
 
-my $dbh=C4::Context->dbh;
+my $dbh = C4::Context->dbh;
 
-my $biblionumber=$query->param('bib');
-my $bibid = $query->param('bibid');
-$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
-$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
-my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
-my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
+my $biblionumber = $query->param('biblionumber');
+my $itemtype     = &MARCfind_frameworkcode($biblionumber);
+my $tagslib      = &MARCgettagslib( $dbh, 1, $itemtype );
 
-my $record =MARCgetbiblio($dbh,$bibid);
+my $record = GetMarcBiblio($biblionumber);
 
 #coping with subscriptions
 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
-my $dat = MARCmarc2koha($dbh,$record);
-my @subscriptions = GetSubscriptions($dat->{title},$dat->{issn},$biblionumber);
+my $dat                 = MARCmarc2koha( $dbh, $record );
+my @subscriptions       =
+  GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
 my @subs;
-foreach my $subscription (@subscriptions){
+foreach my $subscription (@subscriptions) {
 	my %cell;
-	$cell{subscriptionid}= $subscription->{subscriptionid};
-	$cell{subscriptionnotes}= $subscription->{notes};
+    $cell{subscriptionid}    = $subscription->{subscriptionid};
+    $cell{subscriptionnotes} = $subscription->{notes};
+
 	#get the three latest serials.
-	$cell{latestserials}=GetLatestSerials($subscription->{subscriptionid},3);
+    $cell{latestserials} =
+      GetLatestSerials( $subscription->{subscriptionid}, 3 );
 	push @subs, \%cell;
 }
 
 # open template
-my ($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "opac-ISBDdetail.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-ISBDdetail.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
 			     debug => 1,
-			     });
+    }
+);
 $template->param(
 				subscriptions => \@subs,
 				subscriptionsnumber => $subscriptionsnumber,
 );
 
 my $ISBD = C4::Context->preference('ISBD');
+
 # my @blocs = split /\@/,$ISBD;
 # my @fields = $record->fields();
 my $res;
+
 # foreach my $bloc (@blocs) {
 # 	$bloc =~ s/\n//g;
-	my $bloc = $ISBD;
-	my $blocres;
-	foreach my $isbdfield (split /#/,$bloc) {
-# 		$isbdfield= /(.?.?.?)/;
+my $bloc = $ISBD;
+my $blocres;
+foreach my $isbdfield ( split /#/, $bloc ) {
+
+    #         $isbdfield= /(.?.?.?)/;
 		$isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
-		my $fieldvalue=$1;
-		my $textbefore=$2;
-		my $analysestring=$3;
-		my $textafter=$4;
-# 		warn "==> $1 / $2 / $3 / $4";
-# 		my $fieldvalue=substr($isbdfield,0,3);
-		if ($fieldvalue>0) {
+    my $fieldvalue    = $1;
+    my $textbefore    = $2;
+    my $analysestring = $3;
+    my $textafter     = $4;
+
+    #         warn "==> $1 / $2 / $3 / $4";
+    #         my $fieldvalue=substr($isbdfield,0,3);
+    if ( $fieldvalue > 0 ) {
+
 	# 		warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
-# 			warn "FV : $fieldvalue";
-			my $hasputtextbefore=0;
-			foreach my $field ($record->field($fieldvalue)) {
+        #             warn "FV : $fieldvalue";
+        my $hasputtextbefore = 0;
+        foreach my $field ( $record->field($fieldvalue) ) {
 				my $calculated = $analysestring;
 				my $tag = $field->tag();
-				if ($tag<10) {
-				} else {
+            if ( $tag < 10 ) {
+            }
+            else {
 					my @subf = $field->subfields;
-					for my $i (0..$#subf) {
+                for my $i ( 0 .. $#subf ) {
 						my $subfieldcode = $subf[$i][0];
-						my $subfieldvalue = get_authorised_value_desc($tag, $subf[$i][0], $subf[$i][1], '', $dbh);
-						my $tagsubf = $tag.$subfieldcode;
-						$calculated =~ s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
+                    my $subfieldvalue =
+                      GetAuthorisedValueDesc( $tag, $subf[$i][0],
+                        $subf[$i][1], '', $tagslib );
+                    my $tagsubf = $tag . $subfieldcode;
+                    $calculated =~
+s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
 					}
+
 					# field builded, store the result
-					if ($calculated && !$hasputtextbefore) { # put textbefore if not done
-						$blocres .=$textbefore;
-						$hasputtextbefore=1
+                if ( $calculated && !$hasputtextbefore )
+                {    # put textbefore if not done
+                    $blocres .= $textbefore;
+                    $hasputtextbefore = 1;
 					}
+
 					# remove punctuation at start
 					$calculated =~ s/^( |;|:|\.|-)*//g;
-					$blocres.=$calculated;
+                $blocres .= $calculated;
 				}
 			}
-			$blocres .=$textafter if $hasputtextbefore;
-		} else {
-			$blocres.=$isbdfield;
+        $blocres .= $textafter if $hasputtextbefore;
 		}
+    else {
+        $blocres .= $isbdfield;
 	}
-	$res.=$blocres;
+}
+$res .= $blocres;
+
 # }
 $res =~ s/\{(.*?)\}//g;
 $res =~ s/\\n/\n/g;
 $res =~ s/\n/<br\/>/g;
+
 # remove empty ()
 $res =~ s/\(\)//g;
-$template->param(ISBD => $res,
-				biblionumber => $biblionumber);
 
-output_html_with_http_headers $query, $cookie, $template->output;
+my $reviews = getreviews( $biblionumber, 1 );
+foreach ( @$reviews ) {
+    my $borrower_number_review = $_->{borrowernumber};
+    my $borrowerData           = GetMember('',$borrower_number_review);
+    # setting some borrower info into this hash
+    $_->{title}     = $borrowerData->{'title'};
+    $_->{surname}   = $borrowerData->{'surname'};
+    $_->{firstname} = $borrowerData->{'firstname'};
+}
 
-sub get_authorised_value_desc ($$$$$) {
-   my($tag, $subfield, $value, $framework, $dbh) = @_;
 
-   #---- branch
-    if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
-       return getbranchname($value);
-    }
+$template->param(
+    ISBD         => $res,
+    biblionumber => $biblionumber,
+    reviews             => $reviews,
+);
 
-   #---- itemtypes
-   if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
-       return ItemType($value);
+## Amazon.com stuff
+#not used unless preference set
+if ( C4::Context->preference("AmazonContent") == 1 ) {
+    use C4::Amazon;
+    $dat->{'amazonisbn'} = $dat->{'isbn'};
+    $dat->{'amazonisbn'} =~ s|-||g;
+
+    $template->param( amazonisbn => $dat->{amazonisbn} );
+
+    my $amazon_details = &get_amazon_details( $dat->{amazonisbn} );
+
+    foreach my $result ( @{ $amazon_details->{Details} } ) {
+        $template->param( item_description => $result->{ProductDescription} );
+        $template->param( image            => $result->{ImageUrlMedium} );
+        $template->param( list_price       => $result->{ListPrice} );
+        $template->param( amazon_url       => $result->{url} );
+    }
+
+    my @products;
+    my @reviews;
+    for my $details ( @{ $amazon_details->{Details} } ) {
+        next unless $details->{SimilarProducts};
+        for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
+            push @products, +{ Product => $product };
+        }
+        next unless $details->{Reviews};
+        for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
+            $template->param( rating => $product * 20 );
+        }
+        for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
+            push @reviews,
+              +{
+                Summary => $reviews->{Summary},
+                Comment => $reviews->{Comment},
+              };
     }
-
-   #---- "true" authorized value
-   my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
-
-   if ($category ne "") {
-       my $sth = $dbh->prepare("select lib from authorised_values where category = ? and authorised_value = ?");
-       $sth->execute($category, $value);
-       my $data = $sth->fetchrow_hashref;
-       return $data->{'lib'};
-   } else {
-       return $value; # if nothing is found return the original value
    }
+    $template->param( SIMILAR_PRODUCTS => \@products );
+    $template->param( AMAZONREVIEWS    => \@reviews );
 }
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: opac-MARCdetail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-MARCdetail.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- opac-MARCdetail.pl	11 Aug 2006 15:45:37 -0000	1.14
+++ opac-MARCdetail.pl	9 Mar 2007 15:12:54 -0000	1.15
@@ -26,8 +26,7 @@
 
 =head1 DESCRIPTION
 
-This script needs a biblionumber in bib parameter (bibnumber
-from koha style DB.  Automaticaly maps to marc biblionumber).
+This script needs a biblionumber as  parameter
 
 It shows the biblio in a (nice) MARC format depending on MARC
 parameters tables.
@@ -38,13 +37,8 @@
 The first 10 tabs present the biblio, the 11th one presents
 the items attached to the biblio
 
-=head1 FUNCTIONS
-
-=over 2
-
 =cut
 
-
 use strict;
 require Exporter;
 use C4::Auth;
@@ -52,196 +46,235 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use CGI;
-use C4::Search;
 use MARC::Record;
 use C4::Biblio;
 use C4::Acquisition;
-use HTML::Template;
+use C4::Koha;
 
-my $query=new CGI;
+my $query = new CGI;
 
-my $dbh=C4::Context->dbh;
+my $dbh = C4::Context->dbh;
 
-my $biblionumber=$query->param('bib');
-my $bibid = $query->param('bibid');
-$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
-$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
-my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
-my $tagslib = &MARCgettagslib($dbh,0,$itemtype);
+my $biblionumber = $query->param('biblionumber');
+my $itemtype     = &MARCfind_frameworkcode($biblionumber);
+my $tagslib      = &MARCgettagslib( $dbh, 0, $itemtype );
+
+my $record = GetMarcBiblio($biblionumber);
 
-my $record =MARCgetbiblio($dbh,$bibid);
 # open template
-my ($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "opac-MARCdetail.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-MARCdetail.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
 			     debug => 1,
-			     });
+    }
+);
+# adding the $RequestOnOpac param
+my $RequestOnOpac;
+if (C4::Context->preference("RequestOnOpac")) {
+	$RequestOnOpac = 1;
+}
 
 # fill arrays
-my @loop_data =();
+my @loop_data = ();
 my $tag;
+
 # loop through each tab 0 through 9
-for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
-# loop through each tag
-	my @loop_data =();
+for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) {
+
+    # loop through each tag
+    my @loop_data = ();
 	my @subfields_data;
+
 	# deal with leader
-	unless ($tagslib->{'000'}->{'@'}->{tab}  ne $tabloop  or $tagslib->{'000'}->{'@'}->{hidden}>0) {
+    unless ( $tagslib->{'000'}->{'@'}->{tab} ne $tabloop
+        or $tagslib->{'000'}->{'@'}->{hidden} > 0 )
+    {
 		my %subfield_data;
-		$subfield_data{marc_lib}=$tagslib->{'000'}->{'@'}->{lib};
-		$subfield_data{marc_value}=$record->leader();
-		$subfield_data{marc_subfield}='@';
-		$subfield_data{marc_tag}='000';
-		push(@subfields_data, \%subfield_data);
+        $subfield_data{marc_lib}      = $tagslib->{'000'}->{'@'}->{lib};
+        $subfield_data{marc_value}    = $record->leader();
+        $subfield_data{marc_subfield} = '@';
+        $subfield_data{marc_tag}      = '000';
+        push( @subfields_data, \%subfield_data );
 		my %tag_data;
-			$tag_data{tag}='000 -'. $tagslib->{'000'}->{lib};
+        $tag_data{tag} = '000 -' . $tagslib->{'000'}->{lib};
 		my @tmp = @subfields_data;
 		$tag_data{subfield} = \@tmp;
-		push (@loop_data, \%tag_data);
+        push( @loop_data, \%tag_data );
 		undef @subfields_data;
 	}
 	my @fields = $record->fields();
-	for (my $x_i=0;$x_i<=$#fields;$x_i++) {
+    for ( my $x_i = 0 ; $x_i <= $#fields ; $x_i++ ) {
+
 		# if tag <10, there's no subfield, use the "@" trick
-		if ($fields[$x_i]->tag()<10) {
-			next if ($tagslib->{$fields[$x_i]->tag()}->{'@'}->{tab}  ne $tabloop);
-			next if ($tagslib->{$fields[$x_i]->tag()}->{'@'}->{hidden}>0);
+        if ( $fields[$x_i]->tag() < 10 ) {
+            next
+              if (
+                $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{tab} ne $tabloop );
+            next if ( $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{hidden} > 0 );
 			my %subfield_data;
-			$subfield_data{marc_lib}=$tagslib->{$fields[$x_i]->tag()}->{'@'}->{lib};
-			$subfield_data{marc_value}=$fields[$x_i]->data();
-			$subfield_data{marc_subfield}='@';
-			$subfield_data{marc_tag}=$fields[$x_i]->tag();
-			push(@subfields_data, \%subfield_data);
-		} else {
-			my @subf=$fields[$x_i]->subfields;
+            $subfield_data{marc_lib} =
+              $tagslib->{ $fields[$x_i]->tag() }->{'@'}->{lib};
+            $subfield_data{marc_value}    = $fields[$x_i]->data();
+            $subfield_data{marc_subfield} = '@';
+            $subfield_data{marc_tag}      = $fields[$x_i]->tag();
+            push( @subfields_data, \%subfield_data );
+        }
+        else {
+            my @subf = $fields[$x_i]->subfields;
+
 	# loop through each subfield
-			for my $i (0..$#subf) {
+            for my $i ( 0 .. $#subf ) {
 				$subf[$i][0] = "@" unless $subf[$i][0];
-				next if ($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{tab}  ne $tabloop);
-				next if ($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{hidden}>0);
+                next
+                  if (
+                    $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{tab}
+                    ne $tabloop );
+                next
+                  if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
+                    ->{hidden} > 0 );
 				my %subfield_data;
-				$subfield_data{marc_lib}=$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{lib};
-				$subfield_data{link}=$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{link};
+                $subfield_data{marc_lib} =
+                  $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{lib};
+                $subfield_data{link} =
+                  $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }->{link};
 				$subf[$i][1] =~ s/\n/<br\/>/g;
-				if ($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{isurl}) {
-					$subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
-				} elsif ($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{kohafield} eq "biblioitems.isbn") {
+                if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
+                    ->{isurl} )
+                {
+                    $subfield_data{marc_value} =
+                      "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
+                }
+                elsif ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
+                    ->{kohafield} eq "biblioitems.isbn" )
+                {
+
 #					warn " tag : ".$tagslib->{$fields[$x_i]->tag()}." subfield :".$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}. "ISBN : ".$subf[$i][1]."PosttraitementISBN :".DisplayISBN($subf[$i][1]);
-					$subfield_data{marc_value}=DisplayISBN($subf[$i][1]);
-				} else {
-					if ($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{authtypecode}) {
-						$subfield_data{authority}=$fields[$x_i]->subfield(9);
+                    $subfield_data{marc_value} = DisplayISBN( $subf[$i][1] );
+                }
+                else {
+                    if ( $tagslib->{ $fields[$x_i]->tag() }->{ $subf[$i][0] }
+                        ->{authtypecode} )
+                    {
+                        $subfield_data{authority} = $fields[$x_i]->subfield(9);
 					}
-					$subfield_data{marc_value}=get_authorised_value_desc($fields[$x_i]->tag(), $subf[$i][0], $subf[$i][1], '', $dbh);
+                    $subfield_data{marc_value} =
+                      GetAuthorisedValueDesc( $fields[$x_i]->tag(),
+                        $subf[$i][0], $subf[$i][1], '', $tagslib );
 				}
-				$subfield_data{marc_subfield}=$subf[$i][0];
-				$subfield_data{marc_tag}=$fields[$x_i]->tag();
-				push(@subfields_data, \%subfield_data);
+                $subfield_data{marc_subfield} = $subf[$i][0];
+                $subfield_data{marc_tag}      = $fields[$x_i]->tag();
+                push( @subfields_data, \%subfield_data );
 			}
 		}
-		if ($#subfields_data>=0) {
+        if ( $#subfields_data >= 0 ) {
 			my %tag_data;
-			if (($fields[$x_i]->tag() eq $fields[$x_i-1]->tag()) && (C4::Context->preference('LabelMARCView') eq 'economical')) {
-				$tag_data{tag}="";
-			} else {
-				if (C4::Context->preference('hide_marc')) {
-					$tag_data{tag}=$tagslib->{$fields[$x_i]->tag()}->{lib};
-				} else {
-					$tag_data{tag}=$fields[$x_i]->tag().' -'. $tagslib->{$fields[$x_i]->tag()}->{lib};
+            if (   ( $fields[$x_i]->tag() eq $fields[ $x_i - 1 ]->tag() )
+                && ( C4::Context->preference('LabelMARCView') eq 'economical' )
+              )
+            {
+                $tag_data{tag} = "";
+            }
+            else {
+                if ( C4::Context->preference('hide_marc') ) {
+                    $tag_data{tag} = $tagslib->{ $fields[$x_i]->tag() }->{lib};
+                }
+                else {
+                    $tag_data{tag} =
+                        $fields[$x_i]->tag() . ' -'
+                      . $tagslib->{ $fields[$x_i]->tag() }->{lib};
 				}
 			}
 			my @tmp = @subfields_data;
 			$tag_data{subfield} = \@tmp;
-			push (@loop_data, \%tag_data);
+            push( @loop_data, \%tag_data );
 			undef @subfields_data;
 		}
 	}
-	$template->param($tabloop."XX" =>\@loop_data);
+    $template->param( $tabloop . "XX" => \@loop_data );
 }
+
+
 # now, build item tab !
 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
 # loop through each tag
 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
 # then construct template.
 my @fields = $record->fields();
-my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
+my %witness
+  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
 my @big_array;
 foreach my $field (@fields) {
-	next if ($field->tag()<10);
-	my @subf=$field->subfields;
+    next if ( $field->tag() < 10 );
+    my @subf = $field->subfields;
 	my %this_row;
-# loop through each subfield
-	for my $i (0..$#subf) {
-		next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  ne 10);
-		$witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
-        if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
-            $this_row{$subf[$i][0]}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
-        } elsif ($tagslib->{$field->tag()}->{$subf[$i][0]}->{kohafield} eq "biblioitems.isbn") {
-            $this_row{$subf[$i][0]}=DisplayISBN($subf[$i][1]);
-        } else {
-            $this_row{$subf[$i][0]}=get_authorised_value_desc($field->tag(), $subf[$i][0], $subf[$i][1], '', $dbh);
+
+    # loop through each subfield
+    for my $i ( 0 .. $#subf ) {
+        next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{tab} ne 10 );
+        $witness{ $subf[$i][0] } =
+          $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
+        if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl} ) {
+            $this_row{ $subf[$i][0] } =
+              "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
+        }
+        elsif ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq
+            "biblioitems.isbn" )
+        {
+            $this_row{ $subf[$i][0] } = DisplayISBN( $subf[$i][1] );
+        }
+        else {
+            $this_row{ $subf[$i][0] } =
+              GetAuthorisedValueDesc( $field->tag(), $subf[$i][0],
+                $subf[$i][1], '', $tagslib );
         }
 	}
 	if (%this_row) {
-		push(@big_array, \%this_row);
+        push( @big_array, \%this_row );
 	}
 }
-my ($holdingbrtagf,$holdingbrtagsubf) = &MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$itemtype);
- at big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
+my ( $holdingbrtagf, $holdingbrtagsubf ) =
+  &MARCfind_marc_from_kohafield( $dbh, "items.holdingbranch", $itemtype );
+ at big_array =
+  sort { $a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf} } @big_array;
+
 #fill big_row with missing datas
-foreach my $subfield_code  (keys(%witness)) {
-	for (my $i=0;$i<=$#big_array;$i++) {
-		$big_array[$i]{$subfield_code}="&nbsp;" unless ($big_array[$i]{$subfield_code});
+foreach my $subfield_code ( keys(%witness) ) {
+    for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
+        $big_array[$i]{$subfield_code} = "&nbsp;"
+          unless ( $big_array[$i]{$subfield_code} );
 	}
 }
+
 # now, construct template !
 my @item_value_loop;
 my @header_value_loop;
-for (my $i=0;$i<=$#big_array; $i++) {
+for ( my $i = 0 ; $i <= $#big_array ; $i++ ) {
 	my $items_data;
-	foreach my $subfield_code (keys(%witness)) {
-		$items_data .="<td>".$big_array[$i]{$subfield_code}."</td>";
+    foreach my $subfield_code ( keys(%witness) ) {
+        $items_data .= "<td>" . $big_array[$i]{$subfield_code} . "</td>";
 	}
 	my %row_data;
 	$row_data{item_value} = $items_data;
-	push(@item_value_loop,\%row_data);
+    push( @item_value_loop, \%row_data );
 }
-foreach my $subfield_code (keys(%witness)) {
+
+foreach my $subfield_code ( keys(%witness) ) {
 	my %header_value;
 	$header_value{header_value} = $witness{$subfield_code};
-	push(@header_value_loop, \%header_value);
+    push( @header_value_loop, \%header_value );
 }
 
-$template->param(item_loop => \@item_value_loop,
+if(C4::Context->preference("ISBD")) {
+	$template->param(ISBD => 1);
+}
+
+$template->param(
+    item_loop        => \@item_value_loop,
 				item_header_loop => \@header_value_loop,
-				biblionumber => $biblionumber
+    biblionumber     => $biblionumber,
 );
-output_html_with_http_headers $query, $cookie, $template->output;
-
-sub get_authorised_value_desc ($$$$$) {
-   my($tag, $subfield, $value, $framework, $dbh) = @_;
 
-   #---- branch
-    if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
-#       return getbranchdetail($value)->{branchname};
-    }
-
-   #---- itemtypes
-   if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
-#       return ItemType($value);
-    }
-
-   #---- "true" authorized value
-   my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
-
-   if ($category ne "") {
-       my $sth = $dbh->prepare("select lib from authorised_values where category = ? and authorised_value = ?");
-       $sth->execute($category, $value);
-       my $data = $sth->fetchrow_hashref;
-       return $data->{'lib'};
-   } else {
-       return $value; # if nothing is found return the original value
-   }
-}
+output_html_with_http_headers $query, $cookie, $template->output;

Index: opac-account.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-account.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- opac-account.pl	21 May 2006 02:08:34 -0000	1.11
+++ opac-account.pl	9 Mar 2007 15:12:54 -0000	1.12
@@ -1,5 +1,20 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 # wrriten 15/10/2002 by finlay at katipo.oc.nz
 # script to display borrowers account details in the opac
 
@@ -10,42 +25,46 @@
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
+
 use C4::Date;
 
 my $query = new CGI;
-my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "opac-account.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-account.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
 my @bordat;
 $bordat[0] = $borr;
 
 $template->param( BORROWER_INFO => \@bordat );
 
-
 #get account details
-my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
+my ( $numaccts, $accts, $total ) = getboracctrecord( undef, $borr );
 
-for (my $i=0;$i<$numaccts;$i++){
-	$accts->[$i]{'date'} = format_date($accts->[$i]{'date'});
-    $accts->[$i]{'amount'} = sprintf("%.2f", $accts->[$i]{'amount'});
-	if($accts->[$i]{'amount'} >= 0){
+for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
+    $accts->[$i]{'date'} = format_date( $accts->[$i]{'date'} );
+    $accts->[$i]{'amount'} = sprintf( "%.2f", $accts->[$i]{'amount'} );
+    if ( $accts->[$i]{'amount'} >= 0 ) {
 		$accts->[$i]{'amountcredit'} = 1;
 	}
-    $accts->[$i]{'amountoutstanding'} =sprintf("%.2f", $accts->[$i]{'amountoutstanding'});
-	if($accts->[$i]{'amountoutstanding'} >= 0){
+    $accts->[$i]{'amountoutstanding'} =
+      sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} );
+    if ( $accts->[$i]{'amountoutstanding'} >= 0 ) {
 		$accts->[$i]{'amountoutstandingcredit'} = 1;
 	}
-    if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
+    if (   $accts->[$i]{'accounttype'} ne 'F'
+        && $accts->[$i]{'accounttype'} ne 'FU' )
+    {
 	$accts->[$i]{'print_title'};
     }
 }
@@ -58,12 +77,10 @@
     $num++;
 }
 
-
-$template->param( ACCOUNT_LINES => $accts,
+$template->param (
+    ACCOUNT_LINES => $accts,
+    total => sprintf( "%.2f", $total )
 );
 
-$template->param( total => sprintf("%.2f",$total) );
-
-#$template->param(loggeninuser => $loggedinuser);
 output_html_with_http_headers $query, $cookie, $template->output;
 

Index: opac-addbookbybiblionumber.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- opac-addbookbybiblionumber.pl	4 Jul 2006 14:36:52 -0000	1.5
+++ opac-addbookbybiblionumber.pl	9 Mar 2007 15:12:54 -0000	1.6
@@ -1,8 +1,9 @@
 #!/usr/bin/perl
+
 #script to provide bookshelf management
 # WARNING: This file uses 4-character tabs!
 #
-# $Header: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v 1.5 2006/07/04 14:36:52 toins Exp $
+# $Header: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v 1.6 2007/03/09 15:12:54 tipaul Exp $
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -22,7 +23,6 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
-use C4::Search;
 use C4::Biblio;
 use CGI;
 use C4::Output;
@@ -30,99 +30,89 @@
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
-my $env;
 my $query = new CGI;
 my $biblionumber = $query->param('biblionumber');
 my $shelfnumber = $query->param('shelfnumber');
 my $newbookshelf = $query->param('newbookshelf');
 my $category = $query->param('category');
 
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "opac-addbookbybiblionumber.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-addbookbybiblionumber.tmpl",
 							query => $query,
 							type => "opac",
 							authnotrequired => 1,
-						});
+    }
+);
 
-my $x; # for trash
-($x,$x,$shelfnumber) = AddShelf('',$newbookshelf,$loggedinuser,$category) if $newbookshelf;
+$shelfnumber = AddShelf( '', $newbookshelf, $loggedinuser, $category ) if $newbookshelf;
 
-if ($shelfnumber) {
-	&AddToShelfFromBiblio($env, $biblionumber, $shelfnumber);
-	print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
-	exit;
-} else {
+# to know if we had to add more than one biblio.
+my $multiple = 0;
+$multiple = 1 if $biblionumber =~ /^(\d*\/)*$/;
 
-	my  ( $bibliocount, @biblios )  = getbiblio($biblionumber);
 
-	my ($shelflist) = GetShelfList($loggedinuser,3);
+if ($shelfnumber) {
+
+    if ($multiple){
+        foreach (split /\//,$biblionumber){
+            &AddToShelfFromBiblio($_,$shelfnumber);
+        }
+    }
+    else {
+        &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
+    }
+    print $query->header;
+    print "<html><body onload=\"window.close();\"></body></html>";
+    exit;
+}
+else {
+    my ($shelflist) = GetShelves( $loggedinuser, 3 );
 	my @shelvesloop;
 	my %shelvesloop;
-	foreach my $element (sort keys %$shelflist) {
-			push (@shelvesloop, $element);
+    foreach my $element ( sort keys %$shelflist ) {
+        push( @shelvesloop, $element );
 			$shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
 	}
 
 	my $CGIbookshelves;
-	if (@shelvesloop > 0){
-	$CGIbookshelves=CGI::scrolling_list( -name     => 'shelfnumber',
+    if ( @shelvesloop > 0 ) {
+        $CGIbookshelves = CGI::scrolling_list (
+            -name     => 'shelfnumber',
 				-values   => \@shelvesloop,
 				-labels   => \%shelvesloop,
 				-size     => 1,
-	 			-tabindex=>'',
-				-multiple => 0 );
+            -tabindex => '',
+            -multiple => 0
+        );
+    }
+
+    if ( $multiple ) {
+        my @biblios;
+        foreach (split /\//,$biblionumber){
+            my $data = GetBiblioData($_);
+            push @biblios,$data;
+        }
+        $template->param (
+            multiple => 1,
+            biblionumber => $biblionumber,
+            total    => scalar @biblios,
+            biblios  => \@biblios,
+        );
+    }
+    else { # just one to add.
+        my $data = GetBiblioData( $biblionumber );
+        $template->param (
+            biblionumber => $biblionumber,
+            title        => $data->{'title'},
+            author       => $data->{'author'},
+        );
 	 }
 
-	$template->param(biblionumber => $biblionumber,
-				title => $biblios[0]->{'title'},
-				author => $biblios[0]->{'author'},
+    $template->param (
 				CGIbookshelves => $CGIbookshelves,
-				LibraryName => C4::Context->preference("LibraryName"),
-				suggestion => C4::Context->preference("suggestion"),
-				virtualshelves => C4::Context->preference("virtualshelves"),
-				OpacNav => C4::Context->preference("OpacNav"),
-				opaccredits => C4::Context->preference("opaccredits"),
-				opacsmallimage => C4::Context->preference("opacsmallimage"),
-				opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
-				opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
 	);
 
 	output_html_with_http_headers $query, $cookie, $template->output;
 }
-# $Log: opac-addbookbybiblionumber.pl,v $
-# Revision 1.5  2006/07/04 14:36:52  toins
-# Head & rel_2_2 merged
-#
-# Revision 1.4  2006/05/21 02:10:32  kados
-# syncing dev-week and HEAD
-#
-# Revision 1.1.2.6  2006/04/27 16:23:34  oleonard
-# Hiding option to add to existing virtual shelves if there are no existing virtual shelves (thanks Chris!)
-#
-# Revision 1.1.2.5  2006/03/01 22:33:25  oleonard
-# Enabling several new system preferences: opacreadinghistory, opaccolorstylesheet, opaclanguagesdisplay, opaclayoutstylesheet, opacsmallimage
-#
-# Revision 1.1.2.4  2006/02/04 16:47:21  kados
-# Adding support for opaccredits to opac scripts
-#
-# Revision 1.1.2.3  2006/02/03 21:03:57  kados
-# Updating script for new system preference: OpacNav
-# ----------------------------------------------------------------------
-#
-# Revision 1.1.2.2  2005/03/25 17:04:27  tipaul
-# adding virtual shelves & suggestions button to the top
-#
-# Revision 1.1.2.1  2005/03/10 08:44:43  tipaul
-# bugfix in baskets :
-# * The user does not need to have to have librarian rights to use virtual shelves
-# * error when adding a biblio to an existing basket
-#
-# Revision 1.1  2005/01/03 11:09:59  tipaul
-# *** empty log message ***
-#
-
-# Local Variables:
-# tab-width: 4
-# End:

Index: opac-alert-subscribe.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-alert-subscribe.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- opac-alert-subscribe.pl	7 Jul 2006 09:00:12 -0000	1.2
+++ opac-alert-subscribe.pl	9 Mar 2007 15:12:54 -0000	1.3
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-alert-subscribe.pl,v 1.2 2006/07/07 09:00:12 toins Exp $
+# $Id: opac-alert-subscribe.pl,v 1.3 2007/03/09 15:12:54 tipaul Exp $
 
 use strict;
 use CGI;
@@ -29,53 +29,61 @@
 use C4::Koha;
 use C4::Letters;
 use C4::Serials;
-# use C4::Search;
-use HTML::Template;
+
 
 my $query = new CGI;
 my $op = $query->param('op');
 my $dbh = C4::Context->dbh;
 
 my $sth;
-my ($template, $loggedinuser, $cookie);
+my ( $template, $loggedinuser, $cookie );
 my $externalid = $query->param('externalid');
 my $alerttype = $query->param('alerttype');
 my $biblionumber = $query->param('biblionumber');
 
-($template, $loggedinuser, $cookie)
-	= get_template_and_user({template_name => "opac-alert-subscribe.tmpl",
+( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-alert-subscribe.tmpl",
 				query => $query,
 				type => "opac",
 				authnotrequired => 1,
 				debug => 1,
-				});
+    }
+);
 
-if ($op eq 'alert_confirmed') {
-	addalert($loggedinuser,$alerttype,$externalid);
-	if ($alerttype eq 'issue') {
-		print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
+if ( $op eq 'alert_confirmed' ) {
+    addalert( $loggedinuser, $alerttype, $externalid );
+    if ( $alerttype eq 'issue' ) {
+        print $query->redirect(
+            "opac-serial-issues.pl?biblionumber=$biblionumber");
 		exit;
 	}
-} elsif ($op eq 'cancel_confirmed') {
-	my $alerts =getalert($loggedinuser,$alerttype,$externalid);
-	foreach (@$alerts) { # we are supposed to have only 1 result, but just in case...
-		delalert($_->{alertid});
+}
+elsif ( $op eq 'cancel_confirmed' ) {
+    my $alerts = getalert( $loggedinuser, $alerttype, $externalid );
+    foreach (@$alerts)
+    {    # we are supposed to have only 1 result, but just in case...
+        delalert( $_->{alertid} );
 	}
-	if ($alerttype eq 'issue') {
-		print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber");
+    if ( $alerttype eq 'issue' ) {
+        print $query->redirect(
+            "opac-serial-issues.pl?biblionumber=$biblionumber");
 		exit;
 	}
 
-} else {
-	if ($alerttype eq 'issue') { # alert for subscription issues
+}
+else {
+    if ( $alerttype eq 'issue' ) {    # alert for subscription issues
 		my $subscription = &GetSubscription($externalid);
-		$template->param("typeissue$op" => 1,
+        $template->param(
+            "typeissue$op" => 1,
 						bibliotitle => $subscription->{bibliotitle},
 						notes => $subscription->{notes},
 						externalid => $externalid,
 						biblionumber => $biblionumber,
 						);
-	} else {
+    }
+    else {
 	}
 	
 }

Index: opac-basket.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-basket.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- opac-basket.pl	21 May 2006 02:11:29 -0000	1.8
+++ opac-basket.pl	9 Mar 2007 15:12:54 -0000	1.9
@@ -1,65 +1,92 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: opac-basket.pl,v 1.9 2007/03/09 15:12:54 tipaul Exp $
+
 use strict;
 require Exporter;
 use CGI;
 use C4::Biblio;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
-my $query=new CGI;
+my $query = new CGI;
 
-my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "opac-basket.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
+    {
+        template_name   => "opac-basket.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
-			     flagsrequired => {borrow => 1},
-			 });
-
+        flagsrequired   => { borrow => 1 },
+    }
+);
 
-my $bib_list=$query->param('bib_list');
-my $print_basket=$query->param('print');
+my $bib_list     = $query->param('bib_list');
+my $print_basket = $query->param('print');
 my $verbose = $query->param('verbose');
 
-if($verbose) { $template->param(verbose => 1); }
-if ($print_basket) { $template->param(print_basket => 1); }
+if ($verbose)      { $template->param( verbose      => 1 ); }
+if ($print_basket) { $template->param( print_basket => 1 ); }
 
-my @bibs = split(/\//, $bib_list);
+my @bibs = split( /\//, $bib_list );
 my @results;
 
 my $num = 1;
-foreach my $biblionumber (@bibs) {
-	$template->param(biblionumber => $biblionumber);
+my $marcflavour = C4::Context->preference('marcflavour');
+foreach my $biblionumber ( @bibs ) {
+    $template->param( biblionumber => $biblionumber );
+
+    my $dat              = &GetBiblioData($biblionumber);
+    my $record           = &GetMarcBiblio($biblionumber);
+    my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
+    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
+    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
+    my @items            = &GetItemsInfo( $biblionumber, 'opac' );
 
-	my $dat                                   = &bibdata($biblionumber);
-	my ($authorcount, $addauthor)             = &addauthor($biblionumber);
-	my @items                                 = &ItemInfo(undef, $biblionumber, 'opac');
-
-	$dat->{'additional'}=$addauthor->[0]->{'author'};
-	for (my $i = 1; $i < $authorcount; $i++) {
-			$dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
-	} # for
-	if($num % 2 == 1){
+    if ( $num % 2 == 1 ) {
 		$dat->{'even'} = 1;
 	}
+
 	$num++;
-	$dat->{'biblionumber'} = $biblionumber;
+    $dat->{biblionumber} = $biblionumber;
 	$dat->{ITEM_RESULTS} = \@items;
-	if (C4::Context->preference("BiblioDefaultView") eq "normal") {
+    $dat->{MARCNOTES}      = $marcnotesarray;
+    $dat->{MARCSUBJCTS}    = $marcsubjctsarray;
+    $dat->{MARCAUTHORS}    = $marcauthorsarray;
+
+    if ( C4::Context->preference("BiblioDefaultView") eq "normal" ) {
 	     $dat->{dest} = "opac-detail.pl";
-	} elsif (C4::Context->preference("BiblioDefaultView") eq "marc") {
-	     $dat->{dest} ="opac-MARCdetail.pl";
-	} else {
+    }
+    elsif ( C4::Context->preference("BiblioDefaultView") eq "marc" ) {
+        $dat->{dest} = "opac-MARCdetail.pl";
+    }
+    else {
 	     $dat->{dest} = "opac-ISBDdetail.pl";
 	}
-	push (@results, $dat);
+    push( @results, $dat );
 }
 
-my $resultsarray=\@results;
+my $resultsarray = \@results;
+
 # my $itemsarray=\@items;
 
-$template->param(BIBLIO_RESULTS => $resultsarray,
+$template->param(
+    BIBLIO_RESULTS => $resultsarray,
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;

Index: opac-detail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-detail.pl,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- opac-detail.pl	11 Aug 2006 16:08:28 -0000	1.32
+++ opac-detail.pl	9 Mar 2007 15:12:54 -0000	1.33
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-detail.pl,v 1.32 2006/08/11 16:08:28 toins Exp $
+# $Id: opac-detail.pl,v 1.33 2007/03/09 15:12:54 tipaul Exp $
 
 use strict;
 require Exporter;
@@ -25,11 +25,12 @@
 use C4::Auth;
 use C4::Serials;    #uses getsubscriptionfrom biblionumber
 use C4::Interface::CGI::Output;
-use HTML::Template;
 use C4::Biblio;
-use C4::Search;
 use C4::Amazon;
 use C4::Review;
+use C4::Serials;
+use C4::Members;
+
 
 my $query = new CGI;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@@ -42,16 +43,12 @@
     }
 );
 
-my $biblionumber = $query->param('bib');
+my $biblionumber = $query->param('biblionumber') || $query->param('bib');
 $template->param( biblionumber => $biblionumber );
 
 # change back when ive fixed request.pl
-my @items = &ItemInfo( undef, $biblionumber, 'opac' );
-my $dat = &bibdata($biblionumber);
-my ( $authorcount,        $addauthor )      = &addauthor($biblionumber);
-my ( $webbiblioitemcount, @webbiblioitems ) = &getwebbiblioitems($biblionumber);
-my ( $websitecount,       @websites )       = &getwebsites($biblionumber);
-
+my @items = &GetItemsInfo( $biblionumber, 'opac' );
+my $dat = &GetBiblioData($biblionumber);
 #coping with subscriptions
 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
 my @subscriptions       =
@@ -69,109 +66,66 @@
 }
 
 $dat->{'count'} = @items;
-my @author;
-if ( $dat->{'author'} ) {
-    my %authorpush;
-    $authorpush{author} = $dat->{'author'};
-    push @author, \%authorpush;
-}
-$dat->{'additional'} = $addauthor->[0]->{'author'};
-if ( $dat->{'additional'} ) {
-    my %authorpush;
-    $authorpush{author} = $addauthor->[0]->{'author'};
-    push @author, \%authorpush;
-}
-my @title;
-foreach my $word ( split( " ", $dat->{'title'} ) ) {
-    unless ( length($word) == 4 ) {
-        $word =~ s/\%//g;
-    }
-    unless ( C4::Context->stopwords->{ uc($word) } or length($word) == 1 ) {
-        my %titlepush;
-        $titlepush{title} = $word;
-        push @title, \%titlepush;
-    }    #it's NOT a stopword => use it. Otherwise, ignore
-}
-
-for ( my $i = 1 ; $i < $authorcount ; $i++ ) {
-    $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
-
-    my %authorpush;
-    $authorpush{author} = $addauthor->[$i]->{'author'};
-    push @author, \%authorpush;
-}    # for
+
+#adding RequestOnOpac filter to allow or not the display of plce reserve button
+# FIXME - use me or delete me.
+my $RequestOnOpac;
+if (C4::Context->preference("RequestOnOpac")) {
+	$RequestOnOpac = 1;
+}
 
 my $norequests = 1;
 foreach my $itm (@items) {
     $norequests = 0
       unless ( ( $itm->{'wthdrawn'} )
         || ( $itm->{'itemlost'} )
-        || ( $itm->{'notforloan'} )
         || ( $itm->{'itemnotforloan'} )
         || ( !$itm->{'itemnumber'} ) );
     $itm->{ $itm->{'publictype'} } = 1;
 }
 
-$template->param( norequests => $norequests );
+$template->param( norequests => $norequests, );
 
 ## get notes and subjects from MARC record
-my $marc    = C4::Context->preference("marc");
-my @results = ( $dat, );
-if ( C4::Boolean::true_p($marc) ) {
     my $dbh = C4::Context->dbh;
-    my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber( $dbh, $biblionumber );
     my $marcflavour = C4::Context->preference("marcflavour");
-    my $marcnotesarray = &getMARCnotes( $dbh, $bibid, $marcflavour );
-    $results[0]->{MARCNOTES} = $marcnotesarray;
-    my $marcsubjctsarray = &getMARCsubjects( $dbh, $bibid, $marcflavour );
-    $results[0]->{MARCSUBJCTS} = $marcsubjctsarray;
-
-    # 	$template->param(MARCNOTES => $marcnotesarray);
-    # 	$template->param(MARCSUBJCTS => $marcsubjctsarray);
-}
-
-# get the number of reviews
-my $reviewcount = numberofreviews($biblionumber);
-$dat->{'reviews'} = $reviewcount;
+    my $record           = GetMarcBiblio($biblionumber);
+    my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
+    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
+    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
+	my $marcseriesarray  = GetMarcSeries($record,$marcflavour);
+
+    $template->param(
+        MARCNOTES   => $marcnotesarray,
+        MARCSUBJCTS => $marcsubjctsarray,
+        MARCAUTHORS => $marcauthorsarray,
+		MARCSERIES  => $marcseriesarray
+    );
 
 my @results      = ( $dat, );
-my $resultsarray = \@results;
-my $itemsarray   = \@items;
-my $webarray     = \@webbiblioitems;
-my $sitearray    = \@websites;
-my $titlewords   = \@title;
-my $authorwords  = \@author;
-
-#coping with subscriptions
-my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
-my @subscriptions       =
-  GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
-my @subs;
-foreach my $subscription (@subscriptions) {
-    warn "subsid :" . $subscription->{subscriptionid};
-    my %cell;
-    $cell{subscriptionid}    = $subscription->{subscriptionid};
-    $cell{subscriptionnotes} = $subscription->{notes};
+foreach ( keys %{$dat} ) {
+    $template->param( "$_" => $dat->{$_} . "" );
+}
 
-    #get the three latest serials.
-    $cell{latestserials} =
-      GetLatestSerials( $subscription->{subscriptionid}, 3 );
-    push @subs, \%cell;
+my $reviews = getreviews( $biblionumber, 1 );
+foreach ( @$reviews ) {
+    my $borrower_number_review = $_->{borrowernumber};
+    my $borrowerData           = GetMember('',$borrower_number_review);
+    # setting some borrower info into this hash
+    $_->{title}     = $borrowerData->{'title'};
+    $_->{surname}   = $borrowerData->{'surname'};
+    $_->{firstname} = $borrowerData->{'firstname'};
 }
 
 $template->param(
-    BIBLIO_RESULTS      => $resultsarray,
-    ITEM_RESULTS        => $itemsarray,
-    WEB_RESULTS         => $webarray,
-    SITE_RESULTS        => $sitearray,
+    ITEM_RESULTS        => \@items,
+    subscriptionsnumber => $subscriptionsnumber,
+    biblionumber        => $biblionumber,
+    subscriptions       => \@subs,
     subscriptionsnumber => $subscriptionsnumber,
-    LibraryName         => C4::Context->preference("LibraryName"),
-    suggestion          => C4::Context->preference("suggestion"),
-    virtualshelves      => C4::Context->preference("virtualshelves"),
-    titlewords          => $titlewords,
-    authorwords         => $authorwords,
-    reviewson           => C4::Context->preference("marc"),
+    reviews             => $reviews
 );
+
 ## Amazon.com stuff
 #not used unless preference set
 if ( C4::Context->preference("AmazonContent") == 1 ) {
@@ -210,6 +164,6 @@
         }
     }
     $template->param( SIMILAR_PRODUCTS => \@products );
-    $template->param( REVIEWS          => \@reviews );
+    $template->param( AMAZONREVIEWS    => \@reviews );
 }
 output_html_with_http_headers $query, $cookie, $template->output;

Index: opac-detailprint.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-detailprint.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- opac-detailprint.pl	22 Sep 2005 10:01:46 -0000	1.3
+++ opac-detailprint.pl	9 Mar 2007 15:12:54 -0000	1.4
@@ -18,7 +18,6 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-use HTML::Template;
 use strict;
 require Exporter;
 use C4::Context;
@@ -29,76 +28,73 @@
 use C4::Interface::CGI::Output;
 use C4::Date;
 
-my $query=new CGI;
-my $type=$query->param('type');
-($type) || ($type='intra');
+my $query = new CGI;
+my $type  = $query->param('type');
+($type) || ( $type = 'intra' );
 
-my $biblionumber=$query->param('bib');
+my $biblionumber = $query->param('biblionumber');
 
 # change back when ive fixed request.pl
-my @items = ItemInfo(undef, $biblionumber, $type);
+my @items      = GetItemInfosOf($biblionumber);
 my $norequests = 1;
 foreach my $itm (@items) {
      $norequests = 0 unless $itm->{'notforloan'};
 }
 
+my $dat       = GetBiblioData($biblionumber);
+my $record    = GetMarcBiblio($biblionumber);
+my $addauthor =
+  GetMarcAuthors( $record, C4::Context->preference("marcflavour") );
+my $authorcount = scalar @$addauthor;
 
-
-my $dat=bibdata($biblionumber);
-my ($authorcount, $addauthor)= &getaddauthor($biblionumber);
-my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
-my ($websitecount, @websites)             = &getwebsites($biblionumber);
-
-$dat->{'count'}=@items;
+$dat->{'count'}      = @items;
 $dat->{'norequests'} = $norequests;
 
-$dat->{'additional'}=$addauthor->[0]->{'author'};
-for (my $i = 1; $i < $authorcount; $i++) {
-        $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
+$dat->{'additional'} = "";
+foreach (@$addauthor) {
+    $dat->{'additional'} .= "|" . $_->{'value'};
 } # for
 
 my @results;
 
-$results[0]=$dat;
+$results[0] = $dat;
 
-my $resultsarray=\@results;
-my $itemsarray=\@items;
-my $webarray=\@webbiblioitems;
-my $sitearray=\@websites;
+my $resultsarray = \@results;
+my $itemsarray   = \@items;
 
-my $startfrom=$query->param('startfrom');
-($startfrom) || ($startfrom=0);
+my $startfrom = $query->param('startfrom');
+($startfrom) || ( $startfrom = 0 );
 
-my ($template, $loggedinuser, $cookie) = get_template_and_user({
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
 	template_name   => ('opac-detailprint.tmpl'),
 	query           => $query,
 	type            => "opac",
 	authnotrequired => 1,
-    });
+    }
+);
 
-my $count=1;
+my $count = 1;
 
 # now to get the items into a hash we can use and whack that thru
 
-
-my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
-my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
-$template->param(startfrom => $startfrom+1,
-						endat => $startfrom+20,
+my $nextstartfrom =
+  ( $startfrom + 20 < $count - 20 ) ? ( $startfrom + 20 ) : ( $count - 20 );
+my $prevstartfrom = ( $startfrom - 20 > 0 ) ? ( $startfrom - 20 ) : (0);
+$template->param(
+    startfrom      => $startfrom + 1,
+    endat          => $startfrom + 20,
 						numrecords => $count,
 						nextstartfrom => $nextstartfrom,
 						prevstartfrom => $prevstartfrom,
 						BIBLIO_RESULTS => $resultsarray,
 						ITEM_RESULTS => $itemsarray,
-						WEB_RESULTS => $webarray,
-						SITE_RESULTS => $sitearray,
 						loggedinuser => $loggedinuser,
 						biblionumber => $biblionumber,
-						);
+);
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
-
 # Local Variables:
 # tab-width: 8
 # End:

Index: opac-dictionary.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-dictionary.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- opac-dictionary.pl	11 Aug 2006 16:08:28 -0000	1.4
+++ opac-dictionary.pl	9 Mar 2007 15:12:54 -0000	1.5
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-
 # Copyright 2000-2002 Katipo Communications
 #
 # This file is part of Koha.
@@ -27,7 +26,7 @@
 use C4::AuthoritiesMarc;
 use C4::Context;
 use C4::Biblio;
-use HTML::Template;
+
 
 =head1 NAME
 
@@ -48,95 +47,120 @@
 =cut
 
 my $input = new CGI;
-my $field =$input->param('marclist');
+my $field = $input->param('marclist');
+
 #warn "field :$field";
-my ($tablename, $kohafield)=split /./,$field;
+my ( $tablename, $kohafield ) = split /./, $field;
+
 #my $tablename=$input->param('tablename');
-$tablename="biblio" unless ($tablename);
+$tablename = "biblio" unless ($tablename);
+
 #my $kohafield = $input->param('kohafield');
 my @search = $input->param('search');
+
 # warn " ".$search[0];
 my $index = $input->param('index');
+
 # warn " index: ".$index;
-my $op=$input->param('op');
-if (($search[0]) and not ($op eq 'do_search')){
-	$op='do_search';
+my $op = $input->param('op');
+if ( ( $search[0] ) and not( $op eq 'do_search' ) ) {
+    $op = 'do_search';
 }
 my $script_name = 'opac-dictionary.pl';
 my $query;
-my $type=$input->param('type');
+my $type = $input->param('type');
+
 #warn " ".$type;
 
 my $dbh = C4::Context->dbh;
-my ($template, $loggedinuser, $cookie);
+my ( $template, $loggedinuser, $cookie );
 
 my $env;
 
-my $startfrom=$input->param('startfrom');
-$startfrom=0 if(!defined $startfrom);
+my $startfrom = $input->param('startfrom');
+$startfrom = 0 if ( !defined $startfrom );
 my $searchdesc;
 my $resultsperpage;
 
 #warn "Starting process";
 
-if ($op eq "do_search") {
+if ( $op eq "do_search" ) {
+
 	#
 	# searching in biblio
 	#
-	my $sth=$dbh->prepare("Select distinct tagfield,tagsubfield from marc_subfield_structure where kohafield = ?");
+    my $sth =
+      $dbh->prepare(
+"Select distinct tagfield,tagsubfield from marc_subfield_structure where kohafield = ?"
+      );
 	$sth->execute("$field");
-	my (@tags, @and_or, @operator, @excluding, at value);
+    my ( @tags, @and_or, @operator, @excluding, @value );
 	
- 	while ((my $tagfield,my $tagsubfield,my $liblibrarian) = $sth->fetchrow) {
+    while ( ( my $tagfield, my $tagsubfield, my $liblibrarian ) =
+        $sth->fetchrow )
+    {
  		push @tags, $dbh->quote("$tagfield$tagsubfield");
  	}
 
-	$resultsperpage= $input->param('resultsperpage');
-	$resultsperpage = 19 if(!defined $resultsperpage);
+    $resultsperpage = $input->param('resultsperpage');
+    $resultsperpage = 19 if ( !defined $resultsperpage );
 	my $orderby = $input->param('orderby');
 
-	findseealso($dbh,\@tags);
+    findseealso( $dbh, \@tags );
 
 	my @results, my $total;
-	my $strsth="select distinct subfieldvalue, count(marc_subfield_table.bibid) from marc_subfield_table,marc_word where marc_word.word like ? and marc_subfield_table.bibid=marc_word.bibid and marc_subfield_table.tagorder=marc_word.tagorder and marc_word.tagsubfield in ";
-	my $listtags="(";
-	foreach my $tag (@tags){
-		$listtags .= $tag .",";
-	}
-	$listtags =~s/,$/)/;
-	$strsth .= $listtags." and marc_word.tagsubfield=concat(marc_subfield_table.tag,marc_subfield_table.subfieldcode) group by subfieldvalue ";
-# 	warn "search in biblio : ".$strsth;
-	my $value = uc($search[0]);
-	$value=~s/\*/%/g;
-	$value.= "%" if not($value=~m/%/);
-# 	warn " texte : ".$value;
+    my $strsth =
+"select distinct subfieldvalue, count(marc_subfield_table.bibid) from marc_subfield_table,marc_word where marc_word.word like ? and marc_subfield_table.bibid=marc_word.bibid and marc_subfield_table.tagorder=marc_word.tagorder and marc_word.tagsubfield in ";
+    my $listtags = "(";
+    foreach my $tag (@tags) {
+        $listtags .= $tag . ",";
+    }
+    $listtags =~ s/,$/)/;
+    $strsth .= $listtags
+      . " and marc_word.tagsubfield=concat(marc_subfield_table.tag,marc_subfield_table.subfieldcode) group by subfieldvalue ";
+
+    #     warn "search in biblio : ".$strsth;
+    my $value = uc( $search[0] );
+    $value =~ s/\*/%/g;
+    $value .= "%" if not( $value =~ m/%/ );
+
+    #     warn " texte : ".$value;
 
-	$sth=$dbh->prepare($strsth);
+    $sth = $dbh->prepare($strsth);
 	$sth->execute($value);
-	my $total;
 	my @catresults;
-	while (my ($value,$ctresults)=$sth->fetchrow) {
-# 		warn "countresults : ".$ctresults;
-		push @catresults,{value=> $value, 
-						  even=>($total-$startfrom*$resultsperpage)%2,
-						  count=>$ctresults
-						  } if (($total>=$startfrom*$resultsperpage) and ($total<($startfrom+1)*$resultsperpage));
+    while ( my ( $value, $ctresults ) = $sth->fetchrow ) {
+
+        #         warn "countresults : ".$ctresults;
+        push @catresults,
+          {
+            value => $value,
+            even  => ( $total - $startfrom * $resultsperpage ) % 2,
+            count => $ctresults
+          }
+          if (  ( $total >= $startfrom * $resultsperpage )
+            and ( $total < ( $startfrom + 1 ) * $resultsperpage ) );
 		$total++;
 	}
 	
-
-	my $strsth="Select distinct authtypecode from marc_subfield_structure where (";
-	foreach my $listtags (@tags){
-		my @taglist=split /,/,$listtags;
-		foreach my $curtag (@taglist){
-			$strsth.="(tagfield='".substr($curtag,1,3)."' AND tagsubfield='".substr($curtag,4,1)."') OR";
+    $strsth =
+      "Select distinct authtypecode from marc_subfield_structure where (";
+    foreach my $listtags (@tags) {
+        my @taglist = split /,/, $listtags;
+        foreach my $curtag (@taglist) {
+            $strsth .=
+                "(tagfield='"
+              . substr( $curtag, 1, 3 )
+              . "' AND tagsubfield='"
+              . substr( $curtag, 4, 1 ) . "') OR";
 		}
 	}
 	
-	$strsth=~s/ OR$/)/;
-	my $strsth = $strsth." and authtypecode is not NULL";
-# 	warn $strsth;
-	my $sth=$dbh->prepare($strsth);
+    $strsth =~ s/ OR$/)/;
+    $strsth = $strsth . " and authtypecode is not NULL";
+
+    #     warn $strsth;
+    $sth = $dbh->prepare($strsth);
 	$sth->execute;
 	
 	#
@@ -144,105 +168,121 @@
 	#
 	my @authresults;
 	my $authnbresults;
-	while ((my $authtypecode) = $sth->fetchrow) {
-		my ($curauthresults,$nbresults) = authoritysearch($dbh,[''],[''],[''],['contains'],
-														\@search,$startfrom*$resultsperpage, $resultsperpage,$authtypecode);
+    while ( ( my $authtypecode ) = $sth->fetchrow ) {
+        my ( $curauthresults, $nbresults ) =
+          authoritysearch( $dbh, [''], [''], [''], ['contains'], \@search,
+            $startfrom * $resultsperpage,
+            $resultsperpage, $authtypecode );
 		push @authresults, @$curauthresults;
-		$authnbresults+=$nbresults;
-#		warn "auth : $authtypecode nbauthresults : $nbresults";
+        $authnbresults += $nbresults;
+
+        #        warn "auth : $authtypecode nbauthresults : $nbresults";
 	}
 	
 	# 
 	# OK, filling the template with authorities & biblio entries found.
 	#
-	($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "opac-dictionary.tmpl",
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-dictionary.tmpl",
 				query => $input,
 				type => 'opac',
 				authnotrequired => 1,
 				debug => 1,
-				});
+        }
+    );
 
 	# multi page display gestion
-	my $displaynext=0;
-	my $displayprev=$startfrom;
-	if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
+    my $displaynext = 0;
+    my $displayprev = $startfrom;
+    if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
 		$displaynext = 1;
 	}
 
 	my @field_data = ();
 
-	for(my $i = 0 ; $i <= $#tags ; $i++) {
-		push @field_data, { term => "marclist", val=>$tags[$i] };
-		push @field_data, { term => "and_or", val=>$and_or[$i] };
-		push @field_data, { term => "excluding", val=>$excluding[$i] };
-		push @field_data, { term => "operator", val=>$operator[$i] };
-		push @field_data, { term => "value", val=>$value[$i] };
+    for ( my $i = 0 ; $i <= $#tags ; $i++ ) {
+        push @field_data, { term => "marclist",  val => $tags[$i] };
+        push @field_data, { term => "and_or",    val => $and_or[$i] };
+        push @field_data, { term => "excluding", val => $excluding[$i] };
+        push @field_data, { term => "operator",  val => $operator[$i] };
+        push @field_data, { term => "value",     val => $value[$i] };
 	}
 
 	my @numbers = ();
 
-	if ($total>$resultsperpage) {
-		for (my $i=1; $i<$total/$resultsperpage+1; $i++) {
-			if ($i<16) {
-	    		my $highlight=0;
-	    		($startfrom==($i-1)) && ($highlight=1);
-	    		push @numbers, { number => $i,
-					highlight => $highlight ,
-					searchdata=> \@field_data,
-					startfrom => ($i-1)};
+    if ( $total > $resultsperpage ) {
+        for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
+            if ( $i < 16 ) {
+                my $highlight = 0;
+                ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
+                push @numbers,
+                  {
+                    number     => $i,
+                    highlight  => $highlight,
+                    searchdata => \@field_data,
+                    startfrom  => ( $i - 1 )
+                  };
 			}
     	}
 	}
 
-	my $from = $startfrom*$resultsperpage+1;
+    my $from = $startfrom * $resultsperpage + 1;
 	my $to;
 
- 	if($total < (($startfrom+1)*$resultsperpage))
-	{
+    if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
 		$to = $total;
-	} else {
-		$to = (($startfrom+1)*$resultsperpage);
 	}
-	$template->param(anindex => $input->param('index'),
+    else {
+        $to = ( ( $startfrom + 1 ) * $resultsperpage );
+    }
+    $template->param(
+        anindex              => $input->param('index'),
 	opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
         opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
 	);
-	$template->param(result => \@results,
-					 catresult=> \@catresults,
+    $template->param(
+        result         => \@results,
+        catresult      => \@catresults,
 						search => $search[0],
-						marclist =>$field,
+        marclist       => $field,
 						authresult => \@authresults,
 						nbresults => $authnbresults,
-						startfrom=> $startfrom,
-						displaynext=> $displaynext,
-						displayprev=> $displayprev,
+        startfrom      => $startfrom,
+        displaynext    => $displaynext,
+        displayprev    => $displayprev,
 						resultsperpage => $resultsperpage,
-						startfromnext => $startfrom+1,
-						startfromprev => $startfrom-1,
-						searchdata=>\@field_data,
-						total=>$total,
-						from=>$from,
-						to=>$to,
-						numbers=>\@numbers,
+        startfromnext  => $startfrom + 1,
+        startfromprev  => $startfrom - 1,
+        searchdata     => \@field_data,
+        total          => $total,
+        from           => $from,
+        to             => $to,
+        numbers        => \@numbers,
 						MARC_ON => C4::Context->preference("marc"),
 						);
 
- } else {
- 	($template, $loggedinuser, $cookie)
- 		= get_template_and_user({template_name => "opac-dictionary.tmpl",
+}
+else {
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-dictionary.tmpl",
  				query => $input,
  				type => 'opac',
 				authnotrequired => 1,
  				debug => 1,
- 				});
-#warn "type : $type";
- 
  }
-$template->param(search => $search[0],
-					marclist =>$field,
-					type=>$type,
-					anindex => $input->param('index'));
+    );
+
+    #warn "type : $type";
+
+}
+$template->param(
+    search   => $search[0],
+    marclist => $field,
+    type     => $type,
+    anindex  => $input->param('index')
+);
 
 # Print the page
 output_html_with_http_headers $input, $cookie, $template->output;

Index: opac-logout.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-logout.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- opac-logout.pl	20 Dec 2002 13:59:07 -0000	1.5
+++ opac-logout.pl	9 Mar 2007 15:12:54 -0000	1.6
@@ -1,86 +1,58 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use CGI;
 use C4::Context;
 use C4::Output;
-use HTML::Template;
-
-my $query=new CGI;
-
-my $sessionID=$query->cookie('sessionID');
-
-
-if ($ENV{'REMOTE_USER'}) {
-    print $query->header();
-    print startpage();
-    print startmenu('catalogue');
-    print qq|
-<h1>Logout Feature Not Available</h1>
-Your Koha server is configured to use a type of authentication called "Basic
-Authentication" instead of using a cookies-based authentication system.  With
-Basic Authentication, the only way to logout of Koha is by exiting your
-browser.
-|;
-    print endmenu('catalogue');
-    print endpage();
-    exit;
-}
-
-my $sessions;
-open (S, "/tmp/sessions");
-	# FIXME - Come up with a better logging mechanism
-while (my ($sid, $u, $lasttime) = split(/:/, <S>)) {
-    chomp $lasttime;
-    (next) unless ($sid);
-    (next) if ($sid eq $sessionID);
-    $sessions->{$sid}->{'userid'}=$u;
-    $sessions->{$sid}->{'lasttime'}=$lasttime;
-}
-open (S, ">/tmp/sessions");
-foreach (keys %$sessions) {
-    my $userid=$sessions->{$_}->{'userid'};
-    my $lasttime=$sessions->{$_}->{'lasttime'};
-    print S "$_:$userid:$lasttime\n";
-}
 
+my $query = new CGI;
+my $sessionID = $query->cookie('sessionID');
 my $dbh = C4::Context->dbh;
 
 # Check that this is the ip that created the session before deleting it
-
-my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
+my $sth = $dbh->prepare("select userid,ip from sessions where sessionID=?");
 $sth->execute($sessionID);
-my ($userid, $ip);
-if ($sth->rows) {
-    ($userid,$ip) = $sth->fetchrow;
-    if ($ip ne $ENV{'REMOTE_ADDR'}) {
+my ( $userid, $ip );
+if ( $sth->rows ) {
+    ( $userid, $ip ) = $sth->fetchrow;
+    if ( $ip ne $ENV{'REMOTE_ADDR'} ) {
+
        # attempt to logout from a different ip than cookie was created at
        exit;
     }
 }
 
-my $sth=$dbh->prepare("delete from sessions where sessionID=?");
+$sth = $dbh->prepare("delete from sessions where sessionID=?");
 $sth->execute($sessionID);
 open L, ">>/tmp/sessionlog";
-my $time=localtime(time());
-printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, $time;
+my $time = localtime( time() );
+printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip,
+  $time;
 close L;
 
-my $cookie=$query->cookie(-name => 'sessionID',
+my $cookie = $query->cookie(
+    -name    => 'sessionID',
 			  -value => '',
-			  -expires => '+1y');
+    -expires => '+1y'
+);
 
 # Should redirect to opac home page after logging out
 
 print $query->redirect("/cgi-bin/koha/opac-main.pl");
 
 exit;
-if ($sessionID) {
-    print "Logged out of $sessionID<br>\n";
-    print "<a href=shelves.pl>Login</a>";
-} else {
-    print "Not logged in.<br>\n";
-    print "<a href=shelves.pl>Login</a>";
-}
-
-
 

Index: opac-main.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-main.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- opac-main.pl	4 Jul 2006 14:36:52 -0000	1.23
+++ opac-main.pl	9 Mar 2007 15:12:54 -0000	1.24
@@ -1,111 +1,108 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: opac-main.pl,v 1.24 2007/03/09 15:12:54 tipaul Exp $
+
 use strict;
 require Exporter;
 use CGI;
-use HTML::Template;
-
-use C4::Context;
 use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
 use C4::BookShelves;
-use C4::Koha;
-use C4::Members;
+use C4::Languages;           # getTranslatedLanguages
+use C4::Branch;         # GetBranches
+use C4::Members;        # GetMember
+use C4::NewsChannels;   # get_opac_news
+use C4::Acquisition;    # GetRecentAcqui
 
 my $input = new CGI;
-my $kohaVersion = C4::Context->config("kohaversion");
 my $dbh = C4::Context->dbh;
-my $query="Select itemtype,description from itemtypes order by description";
-my $sth=$dbh->prepare($query);
-$sth->execute;
-my  @itemtypeloop;
-my %itemtypes;
-while (my ($value,$lib) = $sth->fetchrow_array) {
-	my %row =(	value => $value,
-				description => $lib,
-			);
-	push @itemtypeloop, \%row;
-}
-$sth->finish;
+
+my $limit = $input->param('recentacqui');
 
 my @branches;
 my @select_branch;
 my %select_branches;
-my $branches = getallbranches();
+my $branches = GetBranches();
 my @branchloop;
-foreach my $thisbranch (keys %$branches) {
-        my $selected = 1 if (C4::Context->userenv && ($thisbranch eq C4::Context->userenv->{branch}));
-        my %row =(value => $thisbranch,
+foreach my $thisbranch ( keys %$branches ) {
+    my $selected = 1
+      if ( C4::Context->userenv
+        && ( $thisbranch eq C4::Context->userenv->{branch} ) );
+    my %row = (
+        value      => $thisbranch,
                                 selected => $selected,
                                 branchname => $branches->{$thisbranch}->{'branchname'},
                         );
         push @branchloop, \%row;
 }
-
-my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "opac-main.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-main.tmpl",
 			     type => "opac",
 			     query => $input,
 			     authnotrequired => 1,
-			     flagsrequired => {borrow => 1},
-			 });
-my $borrower = getmember('',$borrowernumber);
-my @options;
-my $counter=0;
-foreach my $language (getalllanguages()) {
-	next if $language eq 'images';
-	next if $language eq 'CVS';
-	next if $language=~ /png$/;
-	next if $language=~ /css$/;
-	my $selected='0';
-#                            next if $currently_selected_languages->{$language};
-	push @options, { language => $language, counter => $counter };
-	$counter++;
-}
-my $languages_count = @options;
-if($languages_count > 1){
-		$template->param(languages => \@options);
-}
-
-my $branchinfo = getbranchinfo();
-my @loop_data =();
-foreach my $branch (@$branchinfo) {
-        my %row =();
-        $row{'branch_name'} = $branch->{'branchname'};
-        $row{'branch_hours'} = $branch->{'branchhours'};
-        $row{'branch_hours'} =~ s^\n^<br />^g;
-        push (@loop_data, \%row);
+        flagsrequired   => { borrow => 1 },
     }
+);
 
-sub getbranchinfo {
-        my $dbh = C4::Context->dbh;
-        my $sth;
-        $sth = $dbh->prepare("Select * from branches order by branchcode");
-        $sth->execute();
-    
-        my @results;
-        while(my $data = $sth->fetchrow_hashref) {
-	            push(@results, $data);
-	        }
-        $sth->finish;
-        return \@results;
+if($limit) {
+    my $recentacquiloop = GetRecentAcqui($limit);
+    warn Data::Dumper::Dumper($recentacquiloop);
+    $template->param(
+        recentacquiloop => $recentacquiloop,
+    );
+}
+
+my $borrower = GetMember( '', $borrowernumber );
+my @languages;
+my $counter = 0;
+my $langavail = getTranslatedLanguages('opac');
+foreach my $language ( @$langavail ) {
+    #   next if $currently_selected_languages->{$language};
+	#   FIXME: could incorporate language_name and language_locale_name for better display
+    push @languages, { language => $language->{'language_code'}, counter => $counter };
+    $counter++;
 }
 
+# Template params
+if ( $counter > 1 ) {
+    $template->param(languages => \@languages) if C4::Context->preference('opaclanguagesdisplay');
+}
 
-$template->param(		suggestion => C4::Context->preference("suggestion"),
-				virtualshelves => C4::Context->preference("virtualshelves"),
+$template->param(
+    branchloop           => \@branchloop,
 				textmessaging => $borrower->{textmessaging},
-				opaclargeimage => C4::Context->preference("opaclargeimage"),
-				LibraryName => C4::Context->preference("LibraryName"),
-				OpacNav => C4::Context->preference("OpacNav"),
-				opaccredits => C4::Context->preference("opaccredits"),
-				opacreadinghistory => C4::Context->preference("opacreadinghistory"),
-				opacsmallimage => C4::Context->preference("opacsmallimage"),
-				opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
-				opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
-				opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"),
-                                branches => \@loop_data,
+    opaclanguagesdisplay => 0,
+);
+
+# display news
+# use cookie setting for language, bug default to syspref if it's not set
+my $news_lang = $input->cookie('KohaOpacLanguage') || C4::Context->preference('opaclanguages');
+my  $all_koha_news  = &GetNewsToDisplay( $news_lang );
+my $koha_news_count = scalar @$all_koha_news;
+
+$template->param(
+    koha_news       => $all_koha_news,
+    koha_news_count => $koha_news_count
 );
 
-$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
+$template->param(
+    'Disable_Dictionary' => C4::Context->preference("Disable_Dictionary") )
+  if ( C4::Context->preference("Disable_Dictionary") );
 
 output_html_with_http_headers $input, $cookie, $template->output;

Index: opac-passwd.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-passwd.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- opac-passwd.pl	4 Jul 2006 14:36:52 -0000	1.3
+++ opac-passwd.pl	9 Mar 2007 15:12:54 -0000	1.4
@@ -26,67 +26,79 @@
 use C4::Context;
 use Digest::MD5 qw(md5_base64);
 use C4::Circulation::Circ2;
-use HTML::Template;
+
 use C4::Interface::CGI::Output;
 
 my $query = new CGI;
 my $dbh = C4::Context->dbh;
 
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-passwd.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-passwd.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
-
-if ( $query->param('Oldkey') && $query->param('Newkey') && $query->param('Confirm') ){
-	if ( goodkey($dbh,$borrowernumber, $query->param('Oldkey')) ){
-		if ( $query->param('Newkey') eq $query->param('Confirm') &&
-			length($query->param('Confirm')) > 5 ){ # Record password
-			my $clave = md5_base64($query->param('Newkey'));
-			$sth->execute($clave,$borrowernumber);
-			$template->param('password_updated' => '1');
-			$template->param('borrowernumber' => $borrowernumber);
-		}elsif ( $query->param('Newkey') ne $query->param('Confirm') ){
-			$template->param('Ask_data' => '1');
-			$template->param('Error_messages' => '1');
-			$template->param('PassMismatch' => '1');
-		}elsif (length($query->param('Confirm')) <= 5 ){
-			$template->param('Ask_data' => '1');
-			$template->param('Error_messages' => '1');
-			$template->param('ShortPass' => '1');
-		}else{
-			$template->param('Error_messages' => '1');
-		} 
-	}else{
-		$template->param('Ask_data' => '1');
-		$template->param('Error_messages' => '1');
-		$template->param('WrongPass' => '1');
-	}
-}else {
-# Called Empty, Ask for data.
-	$template->param('Ask_data' => '1');
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
+my $sth =
+  $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
+
+if (   $query->param('Oldkey')
+    && $query->param('Newkey')
+    && $query->param('Confirm') )
+{
+    if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) {
+        if ( $query->param('Newkey') eq $query->param('Confirm')
+            && length( $query->param('Confirm') ) > 5 )
+        {    # Record password
+            my $clave = md5_base64( $query->param('Newkey') );
+            $sth->execute( $clave, $borrowernumber );
+            $template->param( 'password_updated' => '1' );
+            $template->param( 'borrowernumber'   => $borrowernumber );
+        }
+        elsif ( $query->param('Newkey') ne $query->param('Confirm') ) {
+            $template->param( 'Ask_data'       => '1' );
+            $template->param( 'Error_messages' => '1' );
+            $template->param( 'PassMismatch'   => '1' );
+        }
+        elsif ( length( $query->param('Confirm') ) <= 5 ) {
+            $template->param( 'Ask_data'       => '1' );
+            $template->param( 'Error_messages' => '1' );
+            $template->param( 'ShortPass'      => '1' );
+        }
+        else {
+            $template->param( 'Error_messages' => '1' );
+        }
+    }
+    else {
+        $template->param( 'Ask_data'       => '1' );
+        $template->param( 'Error_messages' => '1' );
+        $template->param( 'WrongPass'      => '1' );
+    }
 }
+else {
 
-$template->param(LibraryName => C4::Context->preference("LibraryName"),
-);
+    # Called Empty, Ask for data.
+    $template->param( 'Ask_data' => '1' );
+}
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
-
 sub goodkey {
-my ($dbh, $borrowernumber, $key) = @_;
+    my ( $dbh, $borrowernumber, $key ) = @_;
 
-	my $sth=$dbh->prepare("SELECT password FROM borrowers WHERE borrowernumber=?");
+    my $sth =
+      $dbh->prepare("SELECT password FROM borrowers WHERE borrowernumber=?");
 	$sth->execute($borrowernumber);
-	if ($sth->rows){
+    if ( $sth->rows ) {
 		my ($md5password) = $sth->fetchrow;
-		if (md5_base64($key) eq $md5password) { return 1; } else { return 0; }
-	}else{ return 0; }
+        if ( md5_base64($key) eq $md5password ) { return 1; }
+        else { return 0; }
+    }
+    else { return 0; }
 }

Index: opac-readingrecord.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-readingrecord.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- opac-readingrecord.pl	21 May 2006 01:50:51 -0000	1.10
+++ opac-readingrecord.pl	9 Mar 2007 15:12:54 -0000	1.11
@@ -1,4 +1,22 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: opac-readingrecord.pl,v 1.11 2007/03/09 15:12:54 tipaul Exp $
+
 use strict;
 require Exporter;
 use CGI;
@@ -8,48 +26,50 @@
 use C4::Circulation::Circ2;
 use C4::Date;
 use C4::Members;
-use HTML::Template;
+
 use C4::Interface::CGI::Output;
 
 my $query = new CGI;
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-readingrecord.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-readingrecord.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
 $template->param($borr);
 
 # get the record
-my $order=$query->param('order');
-my $order2=$order;
-if ($order2 eq ''){
-  $order2="date_due desc";
-  $template->param(orderbydate => 1);
+my $order  = $query->param('order');
+my $order2 = $order;
+if ( $order2 eq '' ) {
+    $order2 = "date_due desc";
+    $template->param( orderbydate => 1 );
 }
 
-if($order2 eq 'title'){
-	$template->param(orderbytitle => 1);
-	}
+if ( $order2 eq 'title' ) {
+    $template->param( orderbytitle => 1 );
+}
 
-if($order2 eq 'author'){
-	$template->param(orderbyauthor => 1);
+if ( $order2 eq 'author' ) {
+    $template->param( orderbyauthor => 1 );
 }
 
-my $limit=$query->param('limit');
-if ($limit eq 'full'){
-  $limit=0;
-} else {
-  $limit=50;
+my $limit = $query->param('limit');
+if ( $limit eq 'full' ) {
+    $limit = 0;
 }
-my ($count,$issues)=allissues($borrowernumber,$order2,$limit);
+else {
+    $limit = 50;
+}
+my ( $count, $issues ) = allissues( $borrowernumber, $order2, $limit );
 
 # add the row parity
 #my $num = 0;
@@ -61,28 +81,28 @@
 
 my @loop_reading;
 
-for (my $i=0;$i<$count;$i++){
+for ( my $i = 0 ; $i < $count ; $i++ ) {
  	my %line;
-	if($i%2){
+    if ( $i % 2 ) {
 		$line{'toggle'} = 1;
 	}
-	$line{biblionumber}=$issues->[$i]->{'biblionumber'};
-	$line{title}=$issues->[$i]->{'title'};
-	$line{author}=$issues->[$i]->{'author'};
+    $line{biblionumber}   = $issues->[$i]->{'biblionumber'};
+    $line{title}          = $issues->[$i]->{'title'};
+    $line{author}         = $issues->[$i]->{'author'};
 	$line{classification} = $issues->[$i]->{'classification'};
-	$line{date_due}=format_date($issues->[$i]->{'date_due'});
-	$line{returndate}=format_date($issues->[$i]->{'returndate'});
-	$line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
+    $line{date_due}       = format_date( $issues->[$i]->{'date_due'} );
+    $line{returndate}     = format_date( $issues->[$i]->{'returndate'} );
+    $line{volumeddesc}    = $issues->[$i]->{'volumeddesc'};
 	$line{counter} = $i + 1;
-	push(@loop_reading,\%line);
+    push( @loop_reading, \%line );
 }
 
-$template->param(count => $count,
+$template->param(
+    count          => $count,
 				READING_RECORD => \@loop_reading,
 				limit => $limit,
-				showfulllink => ($count > 50),		
+    showfulllink   => ( $count > 50 ),
 );
 
-
 output_html_with_http_headers $query, $cookie, $template->output;
 

Index: opac-renew.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-renew.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- opac-renew.pl	4 May 2004 15:46:58 -0000	1.3
+++ opac-renew.pl	9 Mar 2007 15:12:54 -0000	1.4
@@ -10,16 +10,14 @@
 my $query = new CGI;
 
 my $itemnumber = $query->param('item');
-my $borrowernumber = $query->param("bornum");
-
-
+my $borrowernumber = $query->param("borrowernumber");
 
 my %env;
-my $status = renewstatus(\%env,$borrowernumber,$itemnumber);
-if ($status == 1){
-    renewbook(\%env,$borrowernumber,$itemnumber);
+my $status = renewstatus( \%env, $borrowernumber, $itemnumber );
+if ( $status == 1 ) {
+    renewbook( \%env, $borrowernumber, $itemnumber );
 }
 
-if ($query->param('from') eq 'opac_user') {
+if ( $query->param('from') eq 'opac_user' ) {
     print $query->redirect("/cgi-bin/koha/opac-user.pl");
 }

Index: opac-reserve.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-reserve.pl,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- opac-reserve.pl	21 Jul 2006 09:51:42 -0000	1.29
+++ opac-reserve.pl	9 Mar 2007 15:12:54 -0000	1.30
@@ -1,77 +1,90 @@
 #!/usr/bin/perl
-# NOTE: This file uses standard 8-character tabs
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
 require Exporter;
 use CGI;
-
 use C4::Biblio;
 use C4::Auth;         # checkauth, getborrowernumber.
 use C4::Koha;
 use C4::Circulation::Circ2;
 use C4::Reserves2;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 use C4::Date;
 use C4::Context;
+use C4::Branch; # GetBranches
 
 my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
 
 my $query = new CGI;
-my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "opac-reserve.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-reserve.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-# my @bordat;
-# $bordat[0] = $borr;
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
 # get biblionumber.....
-my $biblionumber = $query->param('bib');
+my $biblionumber = $query->param('biblionumber');
 
-my $bibdata = bibdata($biblionumber);
- $template->param($bibdata);
- $template->param(biblionumber => $biblionumber);
+my $bibdata = GetBiblioData($biblionumber);
+$template->param($bibdata);
+$template->param( biblionumber => $biblionumber );
 
 # get the rank number....
-my ($rank,$reserves) = FindReserves($biblionumber,'');
-$template->param(reservecount => $rank);
+my ( $rank, $reserves ) = FindReserves( $biblionumber, '' );
+$template->param( reservecount => $rank );
 
 foreach my $res (@$reserves) {
-    if ($res->{'found'} eq 'W') {
+    if ( $res->{'found'} eq 'W' ) {
 	$rank--;
     }
 }
 
 $rank++;
-$template->param(rank => $rank);
+$template->param( rank => $rank );
 
 # pass the pickup branch along....
 my $branch = $query->param('branch');
-$template->param(branch => $branch);
+$template->param( branch => $branch );
 
 my $branches = GetBranches();
+
 # make sure it's a real branch
-if (!$branches->{$branch}) {
-$branch='';
+if ( !$branches->{$branch} ) {
+    $branch = '';
 }
-$template->param(branchname => $branches->{$branch}->{'branchname'});
+$template->param( branchname => $branches->{$branch}->{'branchname'} );
 
 # make branch selection options...
-#my $branchoptions = '';
 my @branches;
 my @select_branch;
 my %select_branches;
 
 my @CGIbranchlooparray;
 
-foreach my $branch (keys %$branches) {
+foreach my $branch ( keys %$branches ) {
 	if ($branch) {
 		my %line;
 		$line{branch} = $branches->{$branch}->{'branchname'};
@@ -79,32 +92,36 @@
 		push @CGIbranchlooparray, \%line;
 	}
 }
- at CGIbranchlooparray = sort {$a->{branch} cmp $b->{branch}} @CGIbranchlooparray;
+ at CGIbranchlooparray =
+  sort { $a->{branch} cmp $b->{branch} } @CGIbranchlooparray;
 my $CGIbranchloop = \@CGIbranchlooparray;
-$template->param( CGIbranch => $CGIbranchloop);
+$template->param( CGIbranch => $CGIbranchloop );
 
 #### THIS IS A BIT OF A HACK BECAUSE THE BIBLIOITEMS DATA IS A LITTLE MESSED UP!
 # get the itemtype data....
-my @items = ItemInfo(undef, $biblionumber, 'opac');
+my @items = GetItemInfosOf($biblionumber);
 
 #######################################################
 # old version, add so that old templates still work
 my %types_old;
 foreach my $itm (@items) {
     my $ity = $itm->{'itemtype'};
-    unless ($types_old {$ity}) {
+    unless ( $types_old{$ity} ) {
 	$types_old{$ity}->{'itemtype'} = $ity;
-	$types_old{$ity}->{'branchinfo'}->{$itm->{'branchcode'}} = 1;
+        $types_old{$ity}->{'branchinfo'}->{ $itm->{'branchcode'} } = 1;
 	$types_old{$ity}->{'description'} = $itm->{'description'};
-    } else {
-	$types_old{$ity}->{'branchinfo'}->{$itm->{'branchcode'}} ++;
+    }
+    else {
+        $types_old{$ity}->{'branchinfo'}->{ $itm->{'branchcode'} }++;
     }
 }
 
-foreach my $type (values %types_old) {
+foreach my $type ( values %types_old ) {
     my $copies = "";
-    foreach my $bc (keys %{$type->{'branchinfo'}}) {
-	$copies .= $branches->{$bc}->{'branchname'}."(".$type->{'branchinfo'}->{$bc}.")";
+    foreach my $bc ( keys %{ $type->{'branchinfo'} } ) {
+        $copies .=
+            $branches->{$bc}->{'branchname'} . "("
+          . $type->{'branchinfo'}->{$bc} . ")";
     }
     $type->{'copies'} = $copies;
 }
@@ -120,63 +137,66 @@
 }
 @items = @temp;
 my $itemcount = @items;
-$template->param(itemcount => $itemcount);
+$template->param( itemcount => $itemcount );
 
 my %types;
 my %itemtypes;
 my @duedates;
 foreach my $itm (@items) {
-    push @duedates, {date_due => format_date($itm->{'date_due'})} if defined $itm->{'date_due'};
-    $itm->{$itm->{'publictype'}} = 1;
+    push @duedates, { date_due => format_date( $itm->{'date_due'} ) }
+      if defined $itm->{'date_due'};
+    $itm->{ $itm->{'publictype'} } = 1;
+
     # FIXME CalcReserveFee is supposed to be internal-use-only
-    my $fee  = CalcReserveFee(undef, $borrowernumber, $itm->{'biblionumber'},'a',($itm->{'biblioitemnumber'}));
+    my $fee = CalcReserveFee( undef, $borrowernumber, $itm->{'biblionumber'},
+        'a', ( $itm->{'biblioitemnumber'} ) );
     $fee = sprintf "%.02f", $fee;
     $itm->{'reservefee'} = $fee;
     my $pty = $itm->{'publictype'};
-    $itemtypes{$itm->{'itemtype'}} = $itm;
-    unless ($types {$pty}) {
+    $itemtypes{ $itm->{'itemtype'} } = $itm;
+    unless ( $types{$pty} ) {
 	$types{$pty}->{'count'} = 1;
-	$types{$pty}->{$itm->{'itemtype'}} = 1;
-	push @{$types{$pty}->{'items'}}, $itm;
-    } else {
-	unless ($types{$pty}->{$itm->{'itemtype'}}) {
+        $types{$pty}->{ $itm->{'itemtype'} } = 1;
+        push @{ $types{$pty}->{'items'} }, $itm;
+    }
+    else {
+        unless ( $types{$pty}->{ $itm->{'itemtype'} } ) {
 	    $types{$pty}->{'count'}++;
-	    $types{$pty}->{$itm->{'itemtype'}} = 1;
-	    push @{$types{$pty}->{'items'}}, $itm;
+            $types{$pty}->{ $itm->{'itemtype'} } = 1;
+            push @{ $types{$pty}->{'items'} }, $itm;
 	}
     }
 }
 
-
-$template->param(ITEMS => \@duedates);
+$template->param( ITEMS => \@duedates );
 
 my $width = keys %types;
-my @publictypes = sort {$b->{'count'} <=> $a->{'count'}} values %types;
+my @publictypes = sort { $b->{'count'} <=> $a->{'count'} } values %types;
 my $typecount;
 foreach my $pt (@publictypes) {
     $typecount += $pt->{'count'};
 }
-$template->param(onlyone => 1) if $typecount == 1;
+$template->param( onlyone => 1 ) if $typecount == 1;
 
 my @typerows;
-for (my $rownum=0;$rownum<$publictypes[0]->{'count'} ;$rownum++) {
+for ( my $rownum = 0 ; $rownum < $publictypes[0]->{'count'} ; $rownum++ ) {
     my @row;
     foreach my $pty (@publictypes) {
-	my @items = @{$pty->{'items'}};
+        my @items = @{ $pty->{'items'} };
 	push @row, $items[$rownum] if defined $items[$rownum];
     }
     my $last = @row;
-    $row[$last-1]->{'last'} =1 if $last == $width;
-    my $fill = ($width - $last)*2;
+    $row[ $last - 1 ]->{'last'} = 1 if $last == $width;
+    my $fill = ( $width - $last ) * 2;
     $fill-- if $fill;
-    push @typerows, {ROW => \@row, fill => $fill};
+    push @typerows, { ROW => \@row, fill => $fill };
 }
-$template->param(TYPE_ROWS => \@typerows);
-$width = 2*$width -1;
-$template->param(totalwidth => 2*$width-1,
-);
+$template->param( TYPE_ROWS => \@typerows );
+$width = 2 * $width - 1;
+$template->param( totalwidth => 2 * $width - 1, );
+
+if ( $query->param('item_types_selected') ) {
 
-if ($query->param('item_types_selected')) {
 	# this is what happens after the itemtypes have been selected. Stage 2
 	my @itemtypes = $query->param('itemtype');
 	my $fee = 0;
@@ -187,99 +207,115 @@
 		$newtypes{$itmtype} = $itemtypes{$itmtype};
 		}
 		my @types = values %newtypes;
-		$template->param(TYPES => \@types);
+        $template->param( TYPES => \@types );
 		foreach my $type (@itemtypes) {
 		my @reqbibs;
 		foreach my $item (@items) {
-			if ($item->{'itemtype'} eq $type) {
+                if ( $item->{'itemtype'} eq $type ) {
 			push @reqbibs, $item->{'biblioitemnumber'};
 			}
 		}
-		$fee += CalcReserveFee(undef,$borrowernumber,$biblionumber,'o',\@reqbibs);
+            $fee +=
+              CalcReserveFee( undef, $borrowernumber, $biblionumber, 'o',
+                \@reqbibs );
 		}
 		$proceed = 1;
-	} elsif ($query->param('all')) {
-		$template->param(all => 1);
-		$fee = 1;
+    }
+    elsif ( $query->param('all') ) {
+        $template->param( all => 1 );
+        # No idea why fee would be set to 1 ... it's supposed to be a monetary value, not a flag
+		# -- JF
+		#$fee = 1;
 		$proceed = 1;
 	}
-	if ($proceed && $branch) {
+    if ( $proceed && $branch ) {
 		$fee = sprintf "%.02f", $fee;
-		$template->param(fee => $fee,istherefee => $fee>0?1:0);
-		$template->param(item_types_selected => 1);
-		warn "Branch is ==$branch==";
-		$template->param(no_branch_selected => 1) unless ($branch!='');
-	} else {
-		$template->param(message => 1);
-		$template->param(no_items_selected => 1) unless ($proceed);
-		$template->param(no_branch_selected => 1) unless ($branch);
-		warn "Branch is ==$branch==";
+		if ($fee > 1) {
+        $template->param( fee => $fee, istherefee => $fee > 0 ? 1 : 0 );
+		}
+        $template->param( item_types_selected => 1 );
+        $template->param( no_branch_selected => 1 ) unless ( $branch != '' );
 	}
-} elsif ($query->param('place_reserve')) {
+    else {
+        $template->param( message            => 1 );
+        $template->param( no_items_selected  => 1 ) unless ($proceed);
+        $template->param( no_branch_selected => 1 ) unless ($branch);
+    }
+}
+elsif ( $query->param('place_reserve') ) {
+
 	# here we actually do the reserveration. Stage 3.
 	my $title = $bibdata->{'title'};
 	my @itemtypes = $query->param('itemtype');
 	foreach my $type (@itemtypes) {
 		my @reqbibs;
 		foreach my $item (@items) {
-		if ($item->{'itemtype'} eq $type) {
+            if ( $item->{'itemtype'} eq $type ) {
 			push @reqbibs, $item->{'biblioitemnumber'};
 		}
 		}
-		CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'o',\@reqbibs,$rank,'',$title);
+        CreateReserve( undef, $branch, $borrowernumber, $biblionumber, 'o',
+            \@reqbibs, $rank, '', $title );
 	}
-	if ($query->param('all')) {
-		CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'a', undef, $rank,'',$title);
+    if ( $query->param('all') ) {
+        CreateReserve( undef, $branch, $borrowernumber, $biblionumber, 'a',
+            undef, $rank, '', $title );
 	}
 	print $query->redirect("/cgi-bin/koha/opac-user.pl");
-} else {
+}
+else {
+
 	# Here we check that the borrower can actually make reserves Stage 1.
 	my $noreserves = 0;
 	my $maxoutstanding = C4::Context->preference("maxoutstanding");
-	$template->param(noreserve => 1) unless $maxoutstanding;
-	if ($borr->{'amountoutstanding'} > $maxoutstanding) {
+    $template->param( noreserve => 1 ) unless $maxoutstanding;
+    if ( $borr->{'amountoutstanding'} > $maxoutstanding ) {
 		my $amount = sprintf "\$%.02f", $borr->{'amountoutstanding'};
-		$template->param(message => 1);
+        $template->param( message => 1 );
 		$noreserves = 1;
-		$template->param(too_much_oweing => $amount);
+        $template->param( too_much_oweing => $amount );
 	}
-	if ($borr->{gonenoaddress} eq 1) {
+    if ( $borr->{gonenoaddress} eq 1 ) {
 		$noreserves = 1;
-		$template->param(message => 1,
-						GNA => 1);
+        $template->param(
+            message => 1,
+            GNA     => 1
+        );
 	}
-	if ($borr->{lost} eq 1) {
+    if ( $borr->{lost} eq 1 ) {
 		$noreserves = 1;
-		$template->param(message => 1,
-						lost => 1);
+        $template->param(
+            message => 1,
+            lost    => 1
+        );
 	}
-	if ($borr->{debarred} eq 1) {
+    if ( $borr->{debarred} eq 1 ) {
 		$noreserves = 1;
-		$template->param(message => 1,
-						debarred => 1);
-	}
-	my ($resnum, $reserves) = FindReserves('', $borrowernumber);
-	$template->param(RESERVES => $reserves);
-	if ($resnum >= $MAXIMUM_NUMBER_OF_RESERVES) {
-		$template->param(message => 1);
+        $template->param(
+            message  => 1,
+            debarred => 1
+        );
+    }
+    my ( $resnum, $reserves ) = FindReserves( '', $borrowernumber );
+    $template->param( RESERVES => $reserves );
+    if ( $resnum >= $MAXIMUM_NUMBER_OF_RESERVES ) {
+        $template->param( message => 1 );
 		$noreserves = 1;
-		$template->param(too_many_reserves => $resnum);
+        $template->param( too_many_reserves => $resnum );
 	}
 	foreach my $res (@$reserves) {
-		if ($res->{'biblionumber'} == $biblionumber) {
-		$template->param(message => 1);
+        if ( $res->{'biblionumber'} == $biblionumber ) {
+            $template->param( message => 1 );
 		$noreserves = 1;
-		$template->param(already_reserved => 1);
+            $template->param( already_reserved => 1 );
 		}
 	}
 	unless ($noreserves) {
-		$template->param(TYPES => \@types_old);
-		$template->param(select_item_types => 1);
+        $template->param( TYPES             => \@types_old );
+        $template->param( select_item_types => 1 );
 	}
 }
 
-# check that you can actually make the reserve.
-
 output_html_with_http_headers $query, $cookie, $template->output;
 
 # Local Variables:

Index: opac-review.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-review.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- opac-review.pl	17 Jun 2006 03:18:32 -0000	1.2
+++ opac-review.pl	9 Mar 2007 15:12:54 -0000	1.3
@@ -20,10 +20,8 @@
 use strict;
 require Exporter;
 use CGI;
-
 use C4::Auth;
 use C4::Koha;
-use HTML::Template;
 use C4::Interface::CGI::Output;
 use C4::Circulation::Circ2;
 use C4::Review;
@@ -38,17 +36,11 @@
         template_name   => "opac-review.tmpl",
         query           => $query,
         type            => "opac",
-        authnotrequired => 0,
-        flagsrequired   => { borrow => 1 },
-        debug           => 1,
+        authnotrequired => 1,
     }
 );
 
-# get borrower information ....
-# my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-# $template->param($borr);
-
-my $biblio = bibdata( $biblionumber, 'opac' );
+my $biblio = GetBiblioData( $biblionumber, 'opac' );
 
 my $savedreview = getreview( $biblionumber, $borrowernumber );
 if ( $type eq 'save' ) {
@@ -69,7 +61,7 @@
     'borrowernumber' => $borrowernumber,
     'type'           => $type,
     'review'         => $reviewdata,
-    'title'          => $biblio->{'title'}
+    'title'          => $biblio->{'title'},
 );
 
 # get the record

Index: opac-search.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-search.pl,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- opac-search.pl	21 Jul 2006 09:51:42 -0000	1.38
+++ opac-search.pl	9 Mar 2007 15:12:54 -0000	1.39
@@ -1,450 +1,618 @@
 #!/usr/bin/perl
-use strict;
-require Exporter;
 
-use C4::Auth;
-use C4::Interface::CGI::Output;
+# Script to perform searching
+# For documentation try 'perldoc /path/to/search'
+#
+# $Header: /sources/koha/koha/opac/opac-search.pl,v 1.39 2007/03/09 15:12:54 tipaul Exp $
+#
+# Copyright 2006 LibLime
+#
+# This file is part of Koha
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+=head1 NAME
+
+search - a search script for finding records in a Koha system (Version 2.4)
+
+=head1 OVERVIEW
+
+This script contains a demonstration of a new search API for Koha 2.4. It is
+designed to be simple to use and configure, yet capable of performing feats
+like stemming, field weighting, relevance ranking, support for multiple 
+query language formats (CCL, CQL, PQF), full or nearly full support for the
+bib1 attribute set, extended attribute sets defined in Zebra profiles, access
+to the full range of Z39.50 query options, federated searches on Z39.50
+targets, etc.
+
+I believe the API as represented in this script is mostly sound, even if the
+individual functions in Search.pm and Koha.pm need to be cleaned up. Of course,
+you are free to disagree :-)
+
+I will attempt to describe what is happening at each part of this script.
+-- JF
+
+=head2 INTRO
+
+This script performs two functions:
+
+=over 
+
+=item 1. interacts with Koha to retrieve and display the results of a search
+
+=item 2. loads the advanced search page
+
+=back
+
+These two functions share many of the same variables and modules, so the first
+task is to load what they have in common and determine which template to use.
+Once determined, proceed to only load the variables and procedures necessary
+for that function.
+
+=head2 THE ADVANCED SEARCH PAGE
+
+If we're loading the advanced search page this script will call a number of
+display* routines which populate objects that are sent to the template for 
+display of things like search indexes, languages, search limits, branches,
+etc. These are not stored in the template for two reasons:
+
+=over
+
+=item 1. Efficiency - we have more control over objects inside the script, and it's possible to not duplicate things like indexes (if the search indexes were stored in the template they would need to be repeated)
+
+=item 2. Customization - if these elements were moved to the sql database it would allow a simple librarian to determine which fields to display on the page without editing any html (also how the fields should behave when being searched).
+
+=back
+
+However, they create one problem : the strings aren't translated. I have an idea
+for how to do this that I will purusue soon.
+
+=head2 PERFORMING A SEARCH
+
+If we're performing a search, this script  performs three primary
+operations:
+
+=over 
+
+=item 1. builds query strings (yes, plural)
+
+=item 2. perform the search and return the results array
+
+=item 3. build the HTML for output to the template
+
+=back
+
+There are several additional secondary functions performed that I will
+not cover in detail.
+
+=head3 1. Building Query Strings
+    
+There are several types of queries needed in the process of search and retrieve:
+
+=over
+
+=item 1 Koha query - the query that is passed to Zebra
+
+This is the most complex query that needs to be built.The original design goal was to use a custom CCL2PQF query parser to translate an incoming CCL query into a multi-leaf query to pass to Zebra. It needs to be multi-leaf to allow field weighting, koha-specific relevance ranking, and stemming. When I have a chance I'll try to flesh out this section to better explain.
+
+This query incorporates query profiles that aren't compatible with non-Zebra Z39.50 targets to acomplish the field weighting and relevance ranking.
+
+=item 2 Federated query - the query that is passed to other Z39.50 targets
+
+This query is just the user's query expressed in CCL CQL, or PQF for passing to a non-zebra Z39.50 target (one that doesn't support the extended profile that Zebra does).
+
+=item 3 Search description - passed to the template / saved for future refinements of the query (by user)
+
+This is a simple string that completely expresses the query in a way that can be parsed by Koha for future refinements of the query or as a part of a history feature. It differs from the human search description in several ways:
+
+1. it does not contain commas or = signs
+2. 
+
+=item 4 Human search description - what the user sees in the search_desc area
+
+This is a simple string nearly identical to the Search description, but more human readable. It will contain = signs or commas, etc.
+
+=back
+
+=head3 2. Perform the Search
+
+This section takes the query strings and performs searches on the named servers, including the Koha Zebra server, stores the results in a deeply nested object, builds 'faceted results', and returns these objects.
+
+=head3 3. Build HTML
+
+The final major section of this script takes the objects collected thusfar and builds the HTML for output to the template and user.
+
+=head3 Additional Notes
+
+Not yet completed...
+
+=cut
+
+use strict;    # always use
+
+#use warnings;        # use only for development
+
+## STEP 1. Load things that are used in both search page and
+# results page and decide which template to load, operations
+# to perform, etc.
+## load Koha modules
 use C4::Context;
-use CGI;
-use C4::Database;
-use HTML::Template;
-use C4::SearchMarc;
-use C4::Acquisition;
-use C4::Biblio;
+use C4::Interface::CGI::Output;
+use C4::Auth;
+use C4::Search;
+use C4::Languages; # getAllLanguages
 use C4::Koha;
+use C4::Branch; # GetBranches
+use POSIX qw(ceil floor);
 
-my @spsuggest; # the array for holding suggestions
-my $suggest;   # a flag to be set (if there are suggestions it's 1)
-my $firstbiblionumber; # needed for directly sending user to first item
-# use C4::Search;
-my $totalresults;
-
-my $itemtypelist;
-my $brancheslist;
-my $categorylist;
-my $subcategorylist;
-my $mediatypelist;
-# added by Gavin 
-my $totalresults;
-
-my $dbh=C4::Context->dbh;
-my $sth=$dbh->prepare("select description,itemtype from itemtypes order by description");
-$sth->execute;
-while (my ($description,$itemtype) = $sth->fetchrow) {
-    $itemtypelist.="<option value=\"$itemtype\">$description</option>\n";
-}
-my $sth=$dbh->prepare("select description,subcategorycode from subcategorytable order by description");
-$sth->execute;
-while (my ($description,$subcategorycode) = $sth->fetchrow) {
-    $subcategorylist.="<option value=\"$subcategorycode\">$description</option>\n";
-}
-my $sth=$dbh->prepare("select description,mediatypecode from mediatypetable order by description");
-$sth->execute;
-while (my ($description,$mediatypecode) = $sth->fetchrow) {
-    $mediatypelist.="<option value=\"$mediatypecode\">$description</option>\n";
-}
-my $sth=$dbh->prepare("select description,categorycode from categorytable order by description");
-$sth->execute;
-while (my ($description,$categorycode) = $sth->fetchrow) {
-    $categorylist .= '<input type="radio" name="categorylist" value="'.$categorycode.'">'.$description.'<br>';
+# create a new CGI object
+# not sure undef_params option is working, need to test
+use CGI qw('-no_undef_params');
+my $cgi = new CGI;
+
+my ( $template, $borrowernumber, $cookie );
+
+# decide which template to use
+my $template_name;
+my @params = $cgi->param("limit");
+if ( ( @params > 1 ) || ( $cgi->param("q") ) ) {
+
+    $template_name = 'opac-results.tmpl';
 }
-my $sth=$dbh->prepare("select branchname,branchcode from branches order by branchname");
-$sth->execute;
+else {
 
-while (my ($branchname,$branchcode) = $sth->fetchrow) {
-    $brancheslist.="<option value=\"$branchcode\">$branchname</option>\n";
+    $template_name = 'opac-advsearch.tmpl';
 }
-my $query = new CGI;
-my $op = $query->param("op");
-my $type=$query->param('type');
-my $avail=$query->param('avail');
-my $itemtypesstring=$query->param("itemtypesstring");
-$itemtypesstring =~s/"//g;
-my @itemtypes = split ( /\|/, $itemtypesstring);
-my $branchesstring=$query->param("branchesstring");
-$branchesstring =~s/"//g;
-my @branches = split (/\|/, $branchesstring);
-
-my $startfrom=$query->param('startfrom');
-$startfrom=0 if(!defined $startfrom);
-my ($template, $loggedinuser, $cookie);
-my $resultsperpage;
-my $searchdesc;
-
-if ($op eq "do_search") {
-	my @marclist = $query->param('marclist');
-	my @and_or = $query->param('and_or');
-	my @excluding = $query->param('excluding');
-	my @operator = $query->param('operator');
-	my @value = $query->param('value');
-	my $orderby = $query->param('orderby');
-	my $desc_or_asc = $query->param('desc_or_asc');
-	my $exactsearch = $query->param('exact');
-	for (my $i=0;$i<=$#marclist;$i++) {
-		if ($searchdesc) { # don't put the and_or on the 1st search term
-			$searchdesc .= $and_or[$i].$excluding[$i]." ".($marclist[$i]?$marclist[$i]:"*").$operator[$i].$value[$i] if ($value[$i]);
-		} else {
-			$searchdesc = $excluding[$i].($marclist[$i]?$marclist[$i]:"*").$operator[$i].$value[$i] if ($value[$i]);
-			if ($marclist[$i] eq "biblioitems.isbn") {
-				$value[$i] =~ s/-//g;
-			}
-		}
-	}
-  if ($itemtypesstring ne ''){
-    $searchdesc .= 'filtered by itemtypes ';
-    $searchdesc .= join(" ", at itemtypes)
-  }
-
-  if ($branchesstring ne ''){
-    $searchdesc .= ' in branches ';
-    $searchdesc .= join(" ", at branches)
-  }
-  if ($avail ne ''){
-    $searchdesc .= '. Only available items shown.'
-  }
-	$resultsperpage= $query->param('resultsperpage');
-	$resultsperpage = 19 if(!defined $resultsperpage);
-	
-	if ($exactsearch) {
-		foreach (@operator) {
-			$_='=';
-		}
-	}
-	# builds tag and subfield arrays
-	my @tags;
-
-	foreach my $marc (@marclist) {
-		if ($marc) {
-			my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc,'');
-			if ($tag) {
-				push @tags,$dbh->quote("$tag$subfield");
-			} else {
-				push @tags, $dbh->quote(substr($marc,0,4));
-			}
-		} else {
-			push @tags, "";
-		}
-	}
-	findseealso($dbh,\@tags);
-    my $sqlstring;
-    my $extratables;
-    if ($itemtypesstring ne ''){
-        $sqlstring = 'and (biblioitems.itemtype IN (';
-        my $itemtypeloop=0;
-        foreach my $itemtype (@itemtypes){
-            if ($itemtype ne ''){
-                if ($itemtypeloop != 0){
-                    $sqlstring .=','
-                }
-                $sqlstring .= '"'.$itemtype.'"';
-                $itemtypeloop++;
-            }
-        }
-        $sqlstring .= '))'
-    }
-    if ($branchesstring ne ''){
-        $sqlstring .= 'and biblio.biblionumber=items.biblionumber and (items.holdingbranch IN (';
-        my $branchesloop=0;
-        $extratables = ',items';
-        foreach my $branch (@branches){
-            if ($branch ne ''){
-                if ($branchesloop != 0){
-                    $sqlstring .=','
-                }
-                $sqlstring .= '"'.$branch.'"';
-                $branchesloop++;
-            }
-        }
-        $sqlstring .= '))'
-    }
-  if ($avail){
-  	$extratables .= ',items,issues,reserves';
-    $sqlstring .= "and biblioitems.biblioitemnumber=items.biblioitemnumber and items.itemnumber !=issues.itemnumber and biblio.biblionumber !=reserves.biblionumber and (items.itemlost IS NULL or items.itemlost = 0) and (items.notforloan IS NULL or items.notforloan =0) and (items.wthdrawn IS NULL or items.wthdrawn =0) ";
-  }
-	my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
-										\@excluding, \@operator, \@value,
-										$startfrom*$resultsperpage, $resultsperpage,$orderby,$desc_or_asc);
-	if ($total ==1) {
-	if (C4::Context->preference("BiblioDefaultView") eq "normal") {
-	     print $query->redirect("/cgi-bin/koha/opac-detail.pl?bib=".@$results[0]->{biblionumber});
-	} elsif (C4::Context->preference("BiblioDefaultView") eq "marc") {
-	     print $query->redirect("/cgi-bin/koha/opac-MARCdetail.pl?bib=".@$results[0]->{biblionumber});
-	} else {
-	     print $query->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?bib=".@$results[0]->{biblionumber});
-	}
-	exit;
-	}
-	($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "opac-searchresults.tmpl",
-				query => $query,
-				type => 'opac',
+
+# load the template
+( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => $template_name,
+        query           => $cgi,
+        type            => "opac",
 				authnotrequired => 1,
-				debug => 1,
-				});
+    }
+);
 
-	# multi page display gestion
-	my $displaynext=0;
-	my $displayprev=$startfrom;
-	if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
-		$displaynext = 1;
-	}
-
-	my @field_data = ();
-
-### Added by JF
-## This next does a number of things:
-# 1. It allows you to track all the searches made for stats, etc.
-# 2. It fixes the 'searchdesc' variable problem by introducing
-#         a. 'searchterms' which comes out as 'Keyword: neal stephenson'
-#         b. 'phraseorterm' which comes out as 'neal stephenson'
-#      both of these are useful for differen purposes ... I use searchterms
-#      for display purposes and phraseorterm for passing the search terms
-#      to an external source through a url (like a database search)
-# 3. It provides the variables necessary for the spellchecking (look below for
-#      how this is done
-# 4.
- 
-$totalresults = $total;
-
-## This formats the 'search results' string and populates
-## the 'OPLIN' variable as well as the 'spellcheck' variable
-## with appropriate values based on the user's search input
-
-my $searchterms; #returned in place of searchdesc for 'results for search'
-                 # as a string (can format if need be)
-
-my @spphrases;
-my $phraseorterm;
-my %searchtypehash = ( # used only for the searchterms string formation
-                        # and for spellcheck string
-        '0' => 'keyword',
-        '1' => 'title',
-        '2' => 'author',
-        '3' => 'subject',
-        '4' => 'series',
-        '5' => 'format',
+=head1 BUGS and FIXMEs
+
+There are many, most are documented in the code. The one that
+isn't fully documented, but referred to is the need for a full
+query parser.
+
+=cut
+
+## URI Re-Writing
+# FIXME: URI re-writing should be tested more carefully and may better
+# handled by mod_rewrite or something else. The code below almost works,
+# but doesn't quite handle limits correctly when they are the only
+# param passed -- I'll work on this soon -- JF
+#my $rewrite_flag;
+#my $uri = $cgi->url(-base => 1);
+#my $relative_url = $cgi->url(-relative=>1);
+#$uri.="/".$relative_url."?";
+#warn "URI:$uri";
+#my @cgi_params_list = $cgi->param();
+#my $url_params = $cgi->Vars;
+
+#for my $each_param_set (@cgi_params_list) {
+#    $uri.= join "",  map "\&$each_param_set=".$_, split("\0",$url_params->{$each_param_set}) if $url_params->{$each_param_set};
+#}
+#warn "New URI:$uri";
+# Only re-write a URI if there are params or if it already hasn't been re-written
+#unless (($cgi->param('r')) || (!$cgi->param()) ) {
+#    print $cgi->redirect(     -uri=>$uri."&r=1",
+#                            -cookie => $cookie);
+#    exit;
+#}
+
+# load the branches
+my $branches = GetBranches();
+my @branch_loop;
+for my $branch_hash ( keys %$branches ) {
+    push @branch_loop,
+      {
+        value      => "branch: $branch_hash",
+        branchname => $branches->{$branch_hash}->{'branchname'},
+      };
+}
+$template->param( branchloop => \@branch_loop, );
+
+# load the itemtypes (Called Collection Codes in the template -- used for circ rules )
+my $itemtypes = GetItemTypes;
+my @itemtypesloop;
+my $selected = 1;
+my $cnt;
+my $imgdir = getitemtypeimagesrc();
+foreach my $thisitemtype ( sort keys %$itemtypes ) {
+    my %row = (
+        number   => $cnt++,
+        imageurl => $imgdir . "/" . $itemtypes->{$thisitemtype}->{'imageurl'},
+        code     => $thisitemtype,
+        selected => $selected,
+        description => $itemtypes->{$thisitemtype}->{'description'},
+        count5      => $cnt % 5,
         );
+    $selected = 0 if ($selected);
+    push @itemtypesloop, \%row;
+}
+$template->param( itemtypeloop => \@itemtypesloop );
 
-my @searchterm = $query->param('value');
+# # load the itypes (Called item types in the template -- just authorized values for searching)
+# my ($itypecount, at itype_loop) = GetCcodes();
+# $template->param(itypeloop=>\@itype_loop,);
+
+# load the languages ( for switching from one template to another )
+# my @languages_options = displayLanguages($cgi);
+# my $languages_count = @languages_options;
+# if($languages_count > 1){
+#         $template->param(languages => \@languages_options);
+# }
+
+# The following should only be loaded if we're bringing up the advanced search template
+if ( $template_name eq "opac-advsearch.tmpl" ) {
+
+    # load the servers (used for searching -- to do federated searching, etc.)
+    my $primary_servers_loop;    # = displayPrimaryServers();
+    $template->param( outer_servers_loop => $primary_servers_loop, );
+
+    my $secondary_servers_loop;    # = displaySecondaryServers();
+    $template->param( outer_sup_servers_loop => $secondary_servers_loop, );
+
+    # load the limit types (icon-based limits in advanced search page)
+    my $outer_limit_types_loop = displayLimitTypes();
+    $template->param( outer_limit_types_loop => $outer_limit_types_loop, );
+
+    # load the search indexes (what a user can choose to search by)
+    my $indexes = displayIndexes();
+
+    # determine what to display next to the search boxes (ie, boolean option
+    # shouldn't appear on the first one, scan indexes should, adding a new
+    # box should only appear on the last, etc.
+    # FIXME: this stuff should be cleaned up a bit and the html should be turned
+    # into flags for the template -- I'll work on that soon -- JF
+    my @search_boxes_array;
+    my $search_boxes_count = 1;    # should be a syspref
+    for ( my $i = 0 ; $i <= $search_boxes_count ; $i++ ) {
+        my $this_index = [@$indexes];   # clone the data, not just the reference
+             #@$this_index[$i]->{selected} = "selected";
+        if ( $i == 0 ) {
+            push @search_boxes_array,
+              {
+                indexes            => $this_index,
+                search_boxes_label => "<span class='labels'>Search for:</span>",
+                scan_index         =>
+"<input type='checkbox' name='scan' id='scan' value='1'/><label for='scan'>Scan Indexes</label>",
+              };
 
-for (my $i=0; $i <= $#searchterm; $i++) {
-        my $searchtype = $searchtypehash{$i};
-        push @spphrases, $searchterm[$i];
-        if ($searchterms) { #don't put and in again
-                if ($searchterm[$i]) {
-                $phraseorterm.=$searchterm[$i];
-                $searchterms.=" AND ".$searchtype." : \'".$searchterm[$i]."\'";
-                }
-        } else {
-                if ($searchterm[$i]) {
-                $phraseorterm.=$searchterm[$i];
-                $searchterms.=$searchtype.": \'".$searchterm[$i]."\'";
                 }
+        elsif ( $i == $search_boxes_count ) {
+            push @search_boxes_array,
+              {
+                indexes      => $indexes,
+                left_content =>
+" <select name='op'><option value='and' selected='selected'>and</option><option value='or'>or</option><option value='not'>not</option></select>",
+                add_field => "1"
+              };
         }
-}
+        else {
+            push @search_boxes_array,
+              {
+                indexes      => $indexes,
+                left_content =>
+" <select name='op'><option value='and' selected='selected'>and</option><option value='or'>or</option><option value='not'>not</option></select>",
+              };
+        }
+    }
+    $template->param(
+        uc( C4::Context->preference("marcflavour") ) => 1,
+        search_boxes_loop                            => \@search_boxes_array
+    );
 
-# Spellchecck stuff ... needs to use above scheme but must change
-# cgi script first
-my $phrases = $query->param('value');
-#my $searchterms = $query->param('value');
-# warn "here is searchterms:".$searchterms;
-
-# FIXME: should be obvious ;-)
-#foreach my $phrases (@spphrases) {
-$phrases =~ s/(\.|\?|\:|\!|\'|,|\-|\"|\(|\)|\[|\]|\{|\})/ /g;
-$phrases =~ s/(\Athe |\Aa |\Aan |)//g;
-my $spchkphraseorterm = $phraseorterm;
-        $spchkphraseorterm =~ tr/A-Z/a-z/;
-        $spchkphraseorterm =~ s/(\.|\?|\:|\!|\'|,|\-|\"|\(|\)|\[|\]|\{|\})/ /g;
-        $spchkphraseorterm =~s/(\Aand-or |\Aand\/or |\Aanon |\Aan |\Aa |\Abut |\Aby |\Ade |\Ader |\Adr |\Adu|et |\Afor |\Afrom |\Ain |\Ainto |\Ait |\Amy |\Anot |\Aon |\Aor |\Aper |\Apt |\Aspp |\Ato |\Avs |\Awith |\Athe )/ /g;
-        $spchkphraseorterm =~s/( and-or | and\/or | anon | an | a | but | by | de | der | dr | du|et | for | from | in | into | it | my | not | on | or | per | pt | spp | to | vs | with | the )/ /g;
- 
-        $spchkphraseorterm =~s/  / /g;
-my $resultcount = $total;
-my $ipaddress = $query->remote_host();
-#
+    # load the language limits (for search)
+    my $languages_limit_loop = getAllLanguages();
+    $template->param( search_languages_loop => $languages_limit_loop, );
+
+    # load the subtype limits
+    my $outer_subtype_limits_loop = displaySubtypesLimit();
+    $template->param( outer_subtype_limits_loop => $outer_subtype_limits_loop,
+    );
 
-if (
-#need to create a table to record the search info
-#...FIXME: add the script name that creates the table
-# 
-my $dbhpop=DBI->connect("DBI:mysql:demosuggest:localhost","auth","YourPass")) {
+    my $expanded_options;
+    if ( C4::Context->preference("expandedSearchOption") ) {
+        $expanded_options = C4::Context->preference("expandedSearchOption");
+    }
+    else {
+        $expanded_options = $cgi->param('expanded_options');
+    }
 
-# insert the search info query
-my $insertpop = "INSERT INTO phrase_log(phr_phrase,phr_resultcount,phr_ip) VALUES(?,?,?)";
+    $template->param( expanded_options => $expanded_options );
 
-# grab spelling suggestions query
-my $getsugg = "SELECT display FROM spellcheck WHERE strcmp(soundex(suggestion), soundex(?)) = 0 order by soundex(suggestion) limit 0,5";
+    # load the sort_by options for the template
+    my $sort_by      = $cgi->param('sort_by');
+    my $sort_by_loop = displaySortby($sort_by);
+    $template->param(
+        sort_by_loop => $sort_by_loop,
+        OpacCloud            => C4::Context->preference("OpacCloud"),
+        OpacTopissue         => C4::Context->preference("OpacTopissue"),
+        OpacAuthorities      => C4::Context->preference("OpacAuthorities"),
+     );
 
-#get spelling suggestions when there are no results
-if ($resultcount eq 0) {
-        my $sthgetsugg=$dbhpop->prepare($getsugg);
-        $sthgetsugg->execute($spchkphraseorterm);
-        while (my ($spsuggestion)=$sthgetsugg->fetchrow_array) {
-#               warn "==>$spsuggestion";
-                #push @spsuggest, +{ spsuggestion => $spsuggestion };
-                my %line;
-                $line{spsuggestion} = $spsuggestion;
-                push @spsuggest,\%line;
-                $suggest = 1;
-        }
-#       warn "==>".$#spsuggest;
-        $sthgetsugg->finish;
+    output_html_with_http_headers $cgi, $cookie, $template->output;
+    exit;
 }
-# end of spelling suggestions
 
-my $sthpop=$dbhpop->prepare($insertpop);
+### OK, if we're this far, we're performing an actual search
+
+# Fetch the paramater list as a hash in scalar context:
+#  * returns paramater list as tied hash ref
+#  * we can edit the values by changing the key
+#  * multivalued CGI paramaters are returned as a packaged string separated by "\0" (null)
+my $params = $cgi->Vars;
+
+# Params that can have more than one value
+# sort by is used to sort the query
+my @sort_by;
+ at sort_by = split( "\0", $params->{'sort_by'} ) if $params->{'sort_by'};
+
+# load the sort_by options for the template
+my $sort_by      = $params->{'sort_by'};
+my $sort_by_loop = displaySortby($sort_by);
+$template->param( sort_by_loop => $sort_by_loop );
 
-#$sthpop->execute($phrases,$resultcount,$ipaddress);
-$sthpop->finish;
-}
-#
-### end of tracking stuff  --  jmf at kados dot org
-#
-$template->param(suggest => $suggest );
-$template->param( SPELL_SUGGEST => \@spsuggest );
-$template->param( searchterms => $searchterms );
-$template->param( phraseorterm => $phraseorterm );
-#warn "here's the search terms: ".$searchterms;
 #
-### end of spelling suggestions
-### /Added by JF
+# Use the servers defined, or just search our local catalog(default)
+my @servers;
+ at servers = split( "\0", $params->{'server'} ) if $params->{'server'};
+unless (@servers) {
+
+    #FIXME: this should be handled using Context.pm
+    @servers = ("biblioserver");
+
+    # @servers = C4::Context->config("biblioserver");
+}
+
+# operators include boolean and proximity operators and are used
+# to evaluate multiple operands
+my @operators;
+ at operators = split( "\0", $params->{'op'} ) if $params->{'op'};
+
+# indexes are query qualifiers, like 'title', 'author', etc. They
+# can be simple or complex
+my @indexes;
+ at indexes = split( "\0", $params->{'idx'} ) if $params->{'idx'};
+
+# an operand can be a single term, a phrase, or a complete ccl query
+my @operands;
+ at operands = split( "\0", $params->{'q'} ) if $params->{'q'};
+
+# limits are use to limit to results to a pre-defined category such as branch or language
+my @limits;
+ at limits = split( "\0", $params->{'limit'} ) if $params->{'limit'};
+
+my $available;
+foreach my $limit (@limits) {
+    if ( $limit =~ /available/ ) {
+        $available = 1;
+    }
+}
+$template->param( available => $available );
+push @limits, map "yr:" . $_, split( "\0", $params->{'limit-yr'} )
+  if $params->{'limit-yr'};
+
+# Params that can only have one value
+my $query            = $params->{'q'};
+my $scan             = $params->{'scan'};
+my $results_per_page = $params->{'count'} || 20;
+my $offset           = $params->{'offset'} || 0;
+my $hits;
+my $expanded_facet = $params->{'expand'};
+
+# Define some global variables
+my $error;          # used for error handling
+my $search_desc;    # the query expressed in terms that humans understand
+my $koha_query
+  ; # the query expressed in terms that zoom understands with field weighting and stemming
+my $federated_query;
+my $query_type
+  ; # usually not needed, but can be used to trigger ccl, cql, or pqf queries if set
+my @results;
+## I. BUILD THE QUERY
+( $error, $search_desc, $koha_query, $federated_query, $query_type ) =
+  buildQuery( $query, \@operators, \@operands, \@indexes, \@limits );
+
+# warn "query : $koha_query";
+## II. DO THE SEARCH AND GET THE RESULTS
+my $total;    # the total results for the whole set
+my $facets
+  ; # this object stores the faceted results that display on the left-hand of the results page
+my @results_array;
+my $results_hashref;
+
+eval {
+
+    ( $error, $results_hashref, $facets ) = getRecords(
+        $koha_query,     $federated_query,  \@sort_by,
+        \@servers,       $results_per_page, $offset,
+        $expanded_facet, $branches,         $query_type,
+        $scan
+    );
 
-	for(my $i = 0 ; $i <= $#marclist ; $i++)
-	{
-		push @field_data, { term => "marclist", val=>$marclist[$i] };
-		push @field_data, { term => "and_or", val=>$and_or[$i] };
-		push @field_data, { term => "excluding", val=>$excluding[$i] };
-		push @field_data, { term => "operator", val=>$operator[$i] };
-		push @field_data, { term => "value", val=>$value[$i] };
-	}
-	push @field_data, {term => "desc_or_asc", val => $desc_or_asc} if $desc_or_asc;
-	push @field_data, {term => "orderby", val => $orderby} if $orderby;
-	my @numbers = ();
+};
+if ( $@ || $error ) {
+    $template->param( query_error => $error . $@ );
+
+    #     warn "error: ".$error.$@;
+    output_html_with_http_headers $cgi, $cookie, $template->output;
+    exit;
+}
 
-	if ($total>$resultsperpage)
+# At this point, each server has given us a result set
+# now we build that set for template display
+my @sup_results_array;
+for ( my $i = 0 ; $i <= @servers ; $i++ ) {
+    my $server = $servers[$i];
+    if ( $server =~ /biblioserver/ ) {  # this is the local bibliographic server
+        $hits = $results_hashref->{$server}->{"hits"};
+        my @newresults =
+          searchResults( $search_desc, $hits, $results_per_page, $offset,
+            @{ $results_hashref->{$server}->{"RECORDS"} } );
+        $total = $total + $results_hashref->{$server}->{"hits"};
+        if ($hits) {
+            $template->param( total            => $hits );
+            $template->param( searchdesc       => $search_desc );
+            $template->param( results_per_page => $results_per_page );
+            $template->param( SEARCH_RESULTS   => \@newresults );
+
+            my @page_numbers;
+            my $pages               = ceil( $hits / $results_per_page );
+            my $current_page_number = 1;
+            $current_page_number = ( $offset / $results_per_page + 1 )
+              if $offset;
+            my $previous_page_offset = $offset - $results_per_page
+              unless ( $offset - $results_per_page < 0 );
+            my $next_page_offset = $offset + $results_per_page;
+            for ( $i = 1 ; $i <= $pages ; $i++ ) {
+                my $this_offset =
+                  ( ( $i * $results_per_page ) - $results_per_page );
+                my $this_page_number = $i;
+                my $highlight        = 1
+                  if ( $this_page_number == $current_page_number );
+                push @page_numbers,
 	{
-		for (my $i=1; $i<$total/$resultsperpage+1; $i++)
+                    offset    => $this_offset,
+                    pg        => $this_page_number,
+                    highlight => $highlight,
+                    sort_by   => join " ",
+                    @sort_by
+                  };
+            }
+            $template->param(
+                PAGE_NUMBERS         => \@page_numbers,
+                previous_page_offset => $previous_page_offset,
+                next_page_offset     => $next_page_offset
+            ) unless $pages < 2;
+        }
+    }    # end of the if local
+    else {
+
+        # check if it's a z3950 or opensearch source
+        my $zed3950 = 0;    # FIXME :: Hardcoded value.
+        if ($zed3950) {
+            my @inner_sup_results_array;
+            for my $sup_record ( @{ $results_hashref->{$server}->{"RECORDS"} } )
 		{
-			if ($i<16)
+                my $marc_record_object =
+                  MARC::Record->new_from_usmarc($sup_record);
+                my $control_number =
+                  $marc_record_object->field('010')->subfield('a')
+                  if $marc_record_object->field('010');
+                $control_number =~ s/^ //g;
+                my $link =
+                    "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?SAB1="
+                  . $control_number
+                  . "&BOOL1=all+of+these&FLD1=LC+Control+Number+LCCN+%28K010%29+%28K010%29&GRP1=AND+with+next+set&SAB2=&BOOL2=all+of+these&FLD2=Keyword+Anywhere+%28GKEY%29+%28GKEY%29&PID=6211&SEQ=20060816121838&CNT=25&HIST=1";
+                my $title = $marc_record_object->title();
+                push @inner_sup_results_array,
 			{
-	    		my $highlight=0;
-	    		($startfrom==($i-1)) && ($highlight=1);
-	    		push @numbers, { number => $i,
-					highlight => $highlight ,
-					searchdata=> \@field_data,
-					startfrom => ($i-1)};
+                    'title' => $title,
+                    'link'  => $link,
+                  };
 			}
+            my $servername = $server;
+            push @sup_results_array,
+              {
+                servername             => $servername,
+                inner_sup_results_loop => \@inner_sup_results_array
+              };
+            $template->param( outer_sup_results_loop => \@sup_results_array );
     	}
 	}
 
-	my $from = $startfrom*$resultsperpage+1;
-	my $to;
-
- 	if($total < (($startfrom+1)*$resultsperpage))
-	{
-		$to = $total;
-	} else {
-		$to = (($startfrom+1)*$resultsperpage);
-	}
-	my $defaultview = 'BiblioDefaultView'.C4::Context->preference('BiblioDefaultView');
-	$template->param(results => $results,
-							startfrom=> $startfrom,
-							displaynext=> $displaynext,
-							displayprev=> $displayprev,
-							resultsperpage => $resultsperpage,
-							orderby => $orderby,
-							startfromnext => $startfrom+1,
-							startfromprev => $startfrom-1,
-							searchdata=>\@field_data,
-							total=>$total,
-							from=>$from,
-							to=>$to,
-							numbers=>\@numbers,
-							searchdesc=> $searchdesc,
-							$defaultview => 1,
-							suggestion => C4::Context->preference("suggestion"),
-							virtualshelves => C4::Context->preference("virtualshelves"),
-							);
-
-} else {
-	($template, $loggedinuser, $cookie)
-		= get_template_and_user({template_name => "opac-search.tmpl",
-					query => $query,
-					type => "opac",
-					authnotrequired => 1,
-				});
-	
-	
-	my $query="Select itemtype,description from itemtypes order by description";
-	my $sth=$dbh->prepare($query);
-	$sth->execute;
-	my  @itemtypeloop;
-	my %itemtypes;
-	while (my ($value,$lib) = $sth->fetchrow_array) {
-		my %row =(	value => $value,
-					description => $lib,
-				);
-		push @itemtypeloop, \%row;
+}    #/end of the for loop
+
+#$template->param(FEDERATED_RESULTS => \@results_array);
+# adding the $RequestOnOpac param
+my $RequestOnOpac;
+if (C4::Context->preference("RequestOnOpac")) {
+	$RequestOnOpac = 1;
+}
+
+$template->param(
+
+    #classlist => $classlist,
+    total                => $total,
+    searchdesc           => $search_desc,
+    opacfacets           => 1,
+    facets_loop          => $facets,
+    "BiblioDefaultView"
+      . C4::Context->preference("BiblioDefaultView") => 1,
+    scan_use     => $scan,
+    search_error => $error,
+    RequestOnOpac	 => $RequestOnOpac,
+);
+## Now let's find out if we have any supplemental data to show the user
+#  and in the meantime, save the current query for statistical purposes, etc.
+my $koha_spsuggest;   # a flag to tell if we've got suggestions coming from Koha
+my @koha_spsuggest
+  ;    # place we store the suggestions to be returned to the template as LOOP
+my $phrases = $search_desc;
+my $ipaddress;
+
+if ( C4::Context->preference("kohaspsuggest") ) {
+    eval {
+        my $koha_spsuggest_dbh;
+
+        # FIXME: this needs to be moved to Context.pm
+        eval {
+            $koha_spsuggest_dbh =
+              DBI->connect( "DBI:mysql:suggest:66.213.78.76",
+                "auth", "Free2cirC" );
+        };
+        if ($@) {
+            warn "can't connect to spsuggest db";
+        }
+        else {
+            my $koha_spsuggest_insert =
+"INSERT INTO phrase_log(phr_phrase,phr_resultcount,phr_ip) VALUES(?,?,?)";
+            my $koha_spsuggest_query =
+"SELECT display FROM distincts WHERE strcmp(soundex(suggestion), soundex(?)) = 0 order by soundex(suggestion) limit 0,5";
+            my $koha_spsuggest_sth =
+              $koha_spsuggest_dbh->prepare($koha_spsuggest_query);
+            $koha_spsuggest_sth->execute($phrases);
+            while ( my $spsuggestion = $koha_spsuggest_sth->fetchrow_array ) {
+                $spsuggestion =~ s/(:|\/)//g;
+                my %line;
+                $line{spsuggestion} = $spsuggestion;
+                push @koha_spsuggest, \%line;
+                $koha_spsuggest = 1;
 	}
-	$sth->finish;
-
-	my @oldbranches;
-	my @oldselect_branch;
-	my %oldselect_branches;
- 	my ($oldcount2, at oldbranches)=branches();
-	push @oldselect_branch, "";
-	$oldselect_branches{''} = "";
-	for (my $i=0;$i<$oldcount2;$i++){
-		push @oldselect_branch, $oldbranches[$i]->{'branchcode'};#
-		$oldselect_branches{$oldbranches[$i]->{'branchcode'}} = $oldbranches[$i]->{'branchname'};
-	}
-	my $CGIbranch=CGI::scrolling_list( -name     => 'value',
-				-values   => \@oldselect_branch,
-				-labels   => \%oldselect_branches,
-				-size     => 1,
-				-multiple => 0 );
-	$sth->finish;
-	my @select_branch;
-	my %select_branches;
-	my $branches=GetBranches();
-	push @select_branch, "";
-	$select_branches{''} = "";
-        foreach my $branch ( keys %$branches ){
-		push @select_branch, $branches->{$branch}->{'branchcode'};
-		$select_branches{$branches->{$branch}->{'branchcode'}} = $branches->{$branch}->{'branchname'};
-	}
-	my $CGIbranch=CGI::scrolling_list( -name     => 'value',
-				-values   => \@select_branch,
-				-labels   => \%select_branches,
-				-size     => 1,
-				-multiple => 0 );
-	$sth->finish;
     
-	$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
-	$template->param(
+            # Now save the current query
+            $koha_spsuggest_sth =
+              $koha_spsuggest_dbh->prepare($koha_spsuggest_insert);
 	    
-# CHRIS : Whats this? 	    
-#	    classlist => $classlist,
-					CGIbranch => $CGIbranch,
-					suggestion => C4::Context->preference("suggestion"),
-					virtualshelves => C4::Context->preference("virtualshelves"),
-					LibraryName => C4::Context->preference("LibraryName"),
-					OpacNav => C4::Context->preference("OpacNav"),
-					opaccredits => C4::Context->preference("opaccredits"),
-					AmazonContent => C4::Context->preference("AmazonContent"),
-				opacsmallimage => C4::Context->preference("opacsmallimage"),
-				opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
-				opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
-	);
-}
-# ADDED BY JF
-if ($totalresults == 1){
-    # if its a barcode search by definition we will only have one result.
-    # And if we have a result
-    # lets jump straight to the detail.pl page
-    print $query->redirect("/cgi-bin/koha/opac-detail.pl?bib=$firstbiblionumber");
-}
-else {
-  output_html_with_http_headers $query, $cookie, $template->output;
+           #$koha_spsuggest_sth->execute($phrases,$results_per_page,$ipaddress);
+            $koha_spsuggest_sth->finish;
+            $template->param( koha_spsuggest => $koha_spsuggest ) unless $hits;
+            $template->param( SPELL_SUGGEST => \@koha_spsuggest, );
+        }
+    };
+    if ($@) {
+        warn "Kohaspsuggest failure:" . $@;
+    }
 }
+
+# VI. BUILD THE TEMPLATE
+output_html_with_http_headers $cgi, $cookie, $template->output;

Index: opac-sendbasket.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-sendbasket.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- opac-sendbasket.pl	26 Oct 2005 09:13:11 -0000	1.10
+++ opac-sendbasket.pl	9 Mar 2007 15:12:54 -0000	1.11
@@ -1,109 +1,136 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
 require Exporter;
 use CGI;
 use Mail::Sendmail;
 use MIME::QuotedPrint;
 use MIME::Base64;
-
-use C4::Search;
 use C4::Biblio;
 use C4::Auth;
 use C4::Interface::CGI::Output;
 use C4::Biblio;
-use HTML::Template;
 
 my $query = new CGI;
 
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-sendbasketform.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
+    {
+        template_name   => "opac-sendbasketform.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
-			     flagsrequired => {borrow => 1},
-			 });
+        flagsrequired   => { borrow => 1 },
+    }
+);
 
-my $bib_list=$query->param('bib_list');
-my $email_add=$query->param('email_add');
-my $email_sender=$query->param('email_sender');
-my $dbh=C4::Context->dbh;
-my $sth;
-$sth=$dbh->prepare("select bibid from marc_biblio where biblionumber=? order by bibid");
+my $bib_list     = $query->param('bib_list');
+my $email_add    = $query->param('email_add');
+my $email_sender = $query->param('email_sender');
 
+my $dbh          = C4::Context->dbh;
 
-if ($email_add) {
+if ( $email_add ) {
 	my $email_from = C4::Context->preference('KohaAdminEmailAddress');
+    my $comment    = $query->param('comment');
+    my %mail = (
+        To   => $email_add,
+        From => $email_from
+    );
 
-	my %mail = (	 To      => $email_add,
-						 From    => $email_from);
-
-	my ($template2, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-sendbasket.tmpl",
+    my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-sendbasket.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
-			     flagsrequired => {borrow => 1},
-			 });
+            flagsrequired   => { borrow => 1 },
+        }
+    );
 
-	my @bibs = split(/\//, $bib_list);
+    my @bibs = split( /\//, $bib_list );
 	my @results;
 	my $iso2709;
+    my $marcflavour = C4::Context->preference('marcflavour');
 	foreach my $biblionumber (@bibs) {
-		$template2->param(biblionumber => $biblionumber);
-
-		my $dat = &bibdata($biblionumber);
-		my ($authorcount, $addauthor) = &addauthor($biblionumber);
-		my @items                     = &ItemInfo(undef, $biblionumber, 'opac');
-
-		$dat->{'additional'}=$addauthor->[0]->{'author'};
-		for (my $i = 1; $i < $authorcount; $i++) {
-			$dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
-		}
+        $template2->param( biblionumber => $biblionumber );
 
+        my $dat              = GetBiblioData($biblionumber);
+        my $record           = GetMarcBiblio($biblionumber);
+        my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
+        my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
+        my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
+
+        my @items = &GetItemsInfo( $biblionumber, 'opac' );
+
+        $dat->{MARCNOTES}      = $marcnotesarray;
+        $dat->{MARCSUBJCTS}    = $marcsubjctsarray;
+        $dat->{MARCAUTHORS}    = $marcauthorsarray;
 		$dat->{'biblionumber'} = $biblionumber;
 		$dat->{ITEM_RESULTS} = \@items;
-		$sth->execute($biblionumber);
-		my ($bibid) = $sth->fetchrow;
-		my $record = MARCgetbiblio($dbh,$bibid);
+
 		$iso2709 .= $record->as_usmarc();
 
-		push (@results, $dat);
+        push( @results, $dat );
 	}
 
-	my $resultsarray=\@results;
-	$template2->param(BIBLIO_RESULTS => $resultsarray,
-					email_sender => $email_sender);
+    my $resultsarray = \@results;
+    $template2->param(
+        BIBLIO_RESULTS => $resultsarray,
+        email_sender   => $email_sender,
+        comment        => $comment
+    );
 
 	# Getting template result
 	my $template_res = $template2->output();
 	my $body;
 
 	# Analysing information and getting mail properties
-	if ($template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s) { $mail{'subject'} = $1; }
+    if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
+        $mail{'subject'} = $1;
+    }
 	else { $mail{'subject'} = "no subject"; }
 
 	my $email_header = "";
-	if ($template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s) { $email_header = $1; }
+    if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
+        $email_header = $1;
+    }
 
 	my $email_file = "basket.txt";
-	if ($template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s) { $email_file = $1; }
+    if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
+        $email_file = $1;
+    }
 
-	if ($template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s) { $body = $1; }
+    if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) { $body = $1; }
 
 	my $boundary = "====" . time() . "====";
-# 	$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
-# 
-# 	$email_header = encode_qp($email_header);
-# 
-# 	$boundary = "--".$boundary;
-# 
-# 	# Writing mail
-# 	$mail{body} =
+
+    #     $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
+    #
+    #     $email_header = encode_qp($email_header);
+    #
+    #     $boundary = "--".$boundary;
+    #
+    #     # Writing mail
+    #     $mail{body} =
 	$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
 	my $isofile = encode_base64($iso2709);
-	$boundary = '--'.$boundary;
-	$mail{body} = 
-<<END_OF_BODY;
+    $boundary = '--' . $boundary;
+    $mail{body} = <<END_OF_BODY;
 $boundary
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
@@ -119,19 +146,22 @@
 END_OF_BODY
 
 	# Sending mail
-	if (sendmail %mail) {
+    if ( sendmail %mail ) {
 	# do something if it works....
-		$template->param(SENT => "1");
-		$template->param(email_add => $email_add);
-	} else {
+        $template->param( SENT      => "1" );
+    }
+    else {
 		# do something if it doesnt work....
 		warn "Error sending mail: $Mail::Sendmail::error \n";
+        $template->param( error => 1 );
 	}
+    $template->param( email_add => $email_add );
 	output_html_with_http_headers $query, $cookie, $template->output;
 }
 else {
-	$template->param(bib_list => $bib_list);
-	$template->param(url => "/cgi-bin/koha/opac-sendbasket.pl",
+    $template->param( bib_list => $bib_list );
+    $template->param(
+        url            => "/cgi-bin/koha/opac-sendbasket.pl",
 	suggestion => C4::Context->preference("suggestion"),
 	virtualshelves => C4::Context->preference("virtualshelves"),
 	);

Index: opac-serial-issues.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-serial-issues.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- opac-serial-issues.pl	12 Jul 2006 17:20:36 -0000	1.8
+++ opac-serial-issues.pl	9 Mar 2007 15:12:54 -0000	1.9
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-serial-issues.pl,v 1.8 2006/07/12 17:20:36 toins Exp $
+# $Id: opac-serial-issues.pl,v 1.9 2007/03/09 15:12:54 tipaul Exp $
 
 use strict;
 use CGI;
@@ -29,7 +29,7 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use HTML::Template;
+
 
 my $query = new CGI;
 my $op = $query->param('op');
@@ -38,23 +38,26 @@
 $selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
 
 my $sth;
+
 # my $id;
-my ($template, $loggedinuser, $cookie);
+my ( $template, $loggedinuser, $cookie );
 my $biblionumber = $query->param('biblionumber');
-if ($selectview eq "full"){
+if ( $selectview eq "full" ) {
 	my $subscriptions = GetFullSubscriptionsFromBiblionumber($biblionumber);
 	
 	my $title = $subscriptions->[0]{bibliotitle};
-	my $yearmin=$subscriptions->[0]{year};
-	my $yearmax=$subscriptions->[scalar(@$subscriptions)-1]{year};
+    my $yearmin = $subscriptions->[0]{year};
+    my $yearmax = $subscriptions->[ scalar(@$subscriptions) - 1 ]{year};
 
-	($template, $loggedinuser, $cookie)
-	= get_template_and_user({template_name => "opac-full-serial-issues.tmpl",
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-full-serial-issues.tmpl",
 					query => $query,
 					type => "opac",
 					authnotrequired => 1,
 					debug => 1,
-					});
+        }
+    );
 	
 	# replace CR by <br> in librarian note
 	# $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
@@ -63,22 +66,25 @@
 		biblionumber => $query->param('biblionumber'),
 		years => $subscriptions,
 		yearmin => $yearmin,
-		yearmax =>$yearmax,
+        yearmax        => $yearmax,
 		bibliotitle => $title,
 		suggestion => C4::Context->preference("suggestion"),
 		virtualshelves => C4::Context->preference("virtualshelves"),
 		);
 
-} else {
+}
+else {
 	my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
 	
-	($template, $loggedinuser, $cookie)
-	= get_template_and_user({template_name => "opac-serial-issues.tmpl",
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-serial-issues.tmpl",
 					query => $query,
 					type => "opac",
 					authnotrequired => 1,
 					debug => 1,
-					});
+        }
+    );
 	
 	# replace CR by <br> in librarian note
 	# $subscription->{opacnote} =~ s/\n/\<br\/\>/g;

Index: opac-shelves.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-shelves.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- opac-shelves.pl	21 May 2006 02:30:17 -0000	1.8
+++ opac-shelves.pl	9 Mar 2007 15:12:54 -0000	1.9
@@ -1,9 +1,5 @@
 #!/usr/bin/perl
-#script to provide bookshelf management
-# WARNING: This file uses 4-character tabs!
-#
-# $Header: /sources/koha/koha/opac/opac-shelves.pl,v 1.8 2006/05/21 02:30:17 kados Exp $
-#
+
 # Copyright 2000-2002 Katipo Communications
 #
 # This file is part of Koha.
@@ -21,268 +17,252 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# $Id: opac-shelves.pl,v 1.9 2007/03/09 15:12:54 tipaul Exp $
+
+=head1 NAME
+
+    opac-shelves.pl
+
+=head1 DESCRIPTION
+
+    this script is used to script to provide bookshelf management
+
+=head1 CGI PARAMETERS
+
+=over 4
+
+=item C<modifyshelfcontents>
+
+    if this script has to modify the shelve content.
+
+=item C<shelfnumber>
+
+    to know on which shelve this script has to work.
+
+=item C<addbarcode>
+
+=item C<op>
+
+    op can be equals to:
+        * modifsave to save change on the shelves
+        * modif to change the template to allow to modify the shelves.
+
+=item C<viewshelf>
+
+    to load the template with 'viewshelves param' which allow to read the shelves information.
+
+=item C<shelves>
+
+    if equals to 1. then call the function shelves which add
+    or delete a shelf.
+
+=item C<addshelf>
+
+    if the param shelves = 1 then addshelf must be equals to the name of the shelf to add.
+
+=back
+
+=cut
+
 use strict;
-use C4::Search;
 use CGI;
 use C4::Output;
 use C4::BookShelves;
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
-my $env;
 my $query = new CGI;
 
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "opac-shelves.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-shelves.tmpl",
 							query => $query,
 							type => "opac",
 							authnotrequired => 1,
-						});
+    }
+);
 
-if ($query->param('modifyshelfcontents')) {
-	my $shelfnumber=$query->param('shelfnumber');
-	my $barcode=$query->param('addbarcode');
-	my ($item) = getiteminformation($env, 0, $barcode);
-	if (ShelfPossibleAction($loggedinuser,$shelfnumber,'manage')) {
-		AddToShelf($env, $item->{'itemnumber'}, $shelfnumber);
-		foreach ($query->param) {
-			if (/REM-(\d*)/) {
-				my $itemnumber=$1;
-				RemoveFromShelf($env, $itemnumber, $shelfnumber);
+if ( $query->param('modifyshelfcontents') ) {
+    my $shelfnumber = $query->param('viewshelf');
+    my $barcode     = $query->param('addbarcode');
+    my ($item) = getiteminformation( 0, $barcode );
+    if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
+        AddToShelf( $item->{'itemnumber'}, $shelfnumber );
+        foreach ( $query->param ) {
+            if (/MOD-(\d*)/) {
+                my $itemnumber = $1;
+                if ( $query->param('remove') eq "on" ) {
+                    DelFromShelf( $itemnumber, $shelfnumber );
+                }
 			}
 		}
 	}
 }
-my ($shelflist) = GetShelfList($loggedinuser,2);
 
-$template->param({	loggedinuser => $loggedinuser,
-				});
+# getting the Shelves list
+my $shelflist = GetShelves( $loggedinuser, 2 );
+$template->param( { loggedinuser => $loggedinuser } );
+my $op = $query->param('op');
+
 SWITCH: {
-	if ($query->param('op') eq 'modifsave') {
-		ModifShelf($query->param('shelfnumber'),$query->param('shelfname'),$loggedinuser,$query->param('category'));
+    if ( $op && ( $op eq 'modifsave' ) ) {
+        ModShelf(
+            $query->param('shelfnumber'), $query->param('shelfname'),
+            $loggedinuser,                $query->param('category')
+        );
 		last SWITCH;
 	}
-	if ($query->param('op') eq 'modif') {
-		my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($query->param('shelf'));
-		$template->param(edit => 1,
+    if ( $op && ( $op eq 'modif' ) ) {
+        my ( $shelfnumber, $shelfname, $owner, $category ) =
+          GetShelf( $query->param('shelf') );
+        $template->param(
+            edit                => 1,
 						shelfnumber => $shelfnumber,
 						shelfname => $shelfname,
-						"category$category" => 1);
-# 		editshelf($query->param('shelf'));
+            "category$category" => 1
+        );
+
+        #         editshelf($query->param('shelf'));
 		last SWITCH;
 	}
-	if ($query->param('viewshelf')) {
-		viewshelf($query->param('viewshelf'));
-		last SWITCH;
+    if ( $query->param('viewshelf') ) {
+        #check that the user can view the shelf
+        my $shelfnumber = $query->param('viewshelf');
+        if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
+            my $items = GetShelfContents($shelfnumber);
+            $template->param(
+                shelfname   => $shelflist->{$shelfnumber}->{'shelfname'},
+                shelfnumber => $shelfnumber,
+                viewshelf   => $query->param('viewshelf'),
+                manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
+                itemsloop   => $items,
+            );
 	}
-	if ($query->param('shelves')) {
-		shelves();
 		last SWITCH;
 	}
-}
-
-($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added
-
-my $color='';
-my @shelvesloop;
-foreach my $element (sort keys %$shelflist) {
-		my %line;
-		($color eq 0) ? ($color=1) : ($color=0);
-		$line{'color'}= $color;
-		$line{'shelf'}=$element;
-		$line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
-		$line{"category".$shelflist->{$element}->{'category'}} = 1;
-		$line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
-		$line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
-		$line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
-		$line{'firstname'}=$shelflist->{$element}->{'firstname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
-		$line{'surname'}=$shelflist->{$element}->{'surname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
-;
-		push (@shelvesloop, \%line);
-}
-$template->param(shelvesloop => \@shelvesloop);
-
-output_html_with_http_headers $query, $cookie, $template->output;
+    if ( $query->param('shelves') ) {
+        if ( my $newshelf = $query->param('addshelf') ) {
+            my $shelfnumber = AddShelf(
+                $newshelf,
+                $query->param('owner'),
+                $query->param('category')
+            );
 
-# sub editshelf {
-# 	my ($shelfnumber) = @_;
-# 	my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber);
-# 	$template->param(edit => 1,
-# 					shelfnumber => $shelfnumber,
-# 					shelfname => $shelfname,
-# 					"category$category" => 1);
-# }
-sub shelves {
-	if (my $newshelf=$query->param('addshelf')) {
-		my ($status, $string) = AddShelf($env,$newshelf,$query->param('owner'),$query->param('category'));
-		if ($status) {
-			$template->param(status1 => $status, string1 => $string);
+            if ( $shelfnumber == -1 ) {    #shelf already exists.
+                $template->param(
+                    {
+                        shelfnumber => $shelfnumber,
+                        already     => 1
+                    }
+                );
 		}
 	}
 	my @paramsloop;
-	foreach ($query->param()) {
+    foreach ( $query->param() ) {
 		my %line;
 		if (/DEL-(\d+)/) {
-			my $delshelf=$1;
-			my ($status, $string) = RemoveShelf($env,$delshelf);
+            my $delshelf = $1;
+            my ( $status, $count ) = DelShelf($delshelf);
 			if ($status) {
-				$line{'status'}=$status;
-				$line{'string'} = $string;
+                $line{'status'} = $status;
+                $line{'count'}  = $count;
 			}
 		}
+
 		#if the shelf is not deleted, %line points on null
-		push(@paramsloop,\%line);
+        push( @paramsloop, \%line );
 	}
-	$template->param(paramsloop => \@paramsloop);
-	my ($shelflist) = GetShelfList($loggedinuser,2);
-	my $color='';
+    $template->param( paramsloop => \@paramsloop );
+    my ($shelflist) = GetShelves( $loggedinuser, 2 );
+    my $color = '';
 	my @shelvesloop;
-	foreach my $element (sort keys %$shelflist) {
+    foreach my $element ( sort keys %$shelflist ) {
 		my %line;
-		($color eq 0) ? ($color=1) : ($color=0);
-		$line{'color'}=$color;
-		$line{'shelf'}=$element;
-		$line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
-		$line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
-		push(@shelvesloop, \%line);
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $line{'toggle'}         = $color;
+        $line{'shelf'}          = $element;
+        $line{'shelfname'}      = $shelflist->{$element}->{'shelfname'};
+        $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+        push( @shelvesloop, \%line );
 	}
-	$template->param(shelvesloop=>\@shelvesloop,
+    $template->param(
+        shelvesloop => \@shelvesloop,
 							shelves => 1,
 						);
+        last SWITCH;
+    }
 }
 
-sub viewshelf {
-	my $shelfnumber=shift;
-	#check that the user can view the shelf
-	return unless (ShelfPossibleAction($loggedinuser,$shelfnumber,'view'));
-	my ($itemlist) = GetShelfContents($env, $shelfnumber);
-	my $item='';
-	my $color='';
-	my @itemsloop;
-	foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
+($shelflist) =
+  GetShelves( $loggedinuser, 2 )
+  ;    # rebuild shelflist in case a shelf has been added
+
+my $color = '';
+my @shelvesloop;
+foreach my $element ( sort keys %$shelflist ) {
 		my %line;
-		($color eq 0) ? ($color=1) : ($color=0);
-		$line{'color'}=$color;
-		$line{'itemnumber'}=$item->{'itemnumber'};
-		$line{'barcode'}=$item->{'barcode'};
-		$line{'title'}=$item->{'title'};
-		$line{'author'}=$item->{'author'};
-		$line{'classification'}=$item->{'classification'};		
-		$line{'itemtype'}=$item->{'itemtype'};		
-		$line{biblionumber} = $item->{biblionumber};
-		push(@itemsloop, \%line);
+    ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+    $line{'toggle'}    = $color;
+        $line{'shelf'}     = $element;
+        $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
+        $line{ "category" . $shelflist->{$element}->{'category'} } = 1;
+        $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
+        $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+        $line{'canmanage'}      =
+          ShelfPossibleAction( $loggedinuser, $element, 'manage' );
+        $line{'firstname'} = $shelflist->{$element}->{'firstname'}
+          unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+        $line{'surname'} = $shelflist->{$element}->{'surname'}
+          unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+        push( @shelvesloop, \%line );
 	}
-	$template->param(	itemsloop => \@itemsloop,
-						shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
-						shelfnumber => $shelfnumber,
-						viewshelf => $query->param('viewshelf'),
-						manageshelf => &ShelfPossibleAction($loggedinuser,$shelfnumber,'manage'),
-					);
-}
+
+$template->param(
+    shelvesloop             => \@shelvesloop,
+    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
+
+
 
 #
 # $Log: opac-shelves.pl,v $
-# Revision 1.8  2006/05/21 02:30:17  kados
-# syncing dev-week and HEAD
+# Revision 1.9  2007/03/09 15:12:54  tipaul
+# rel_3_0 moved to HEAD
 #
-# Revision 1.7  2005/05/04 09:02:38  tipaul
-# synch'ing 2.2 and head
+# Revision 1.8.2.12  2007/01/15 17:19:30  toins
+# enable to add checked items to a shelf.
+# Some display enhancements.
 #
-# Revision 1.3.2.4  2005/03/25 17:04:28  tipaul
-# adding virtual shelves & suggestions button to the top
+# Revision 1.8.2.11  2007/01/10 10:52:58  toins
+# adding syspref directly to Auth.pm instead of to the template.
 #
-# Revision 1.3.2.3  2005/01/27 17:18:28  oleonard
-# Taking table cell background color information out of the script and moving it into the template (requires update to opac-shelves.tmpl)
+# Revision 1.8.2.10  2007/01/10 10:12:48  toins
+# Adding OpacTopissue, OpacCloud, OpacAuthorithies to the template->param.
+# + Some cleanup.
 #
-# Revision 1.3.2.2  2005/01/11 20:18:29  oleonard
-# Adding call number and item type to list of returned variables
+# Revision 1.8.2.9  2006/12/15 17:43:24  toins
+# sync with intranet.
 #
-# Revision 1.3.2.1  2005/01/11 16:33:57  tipaul
-# fix for http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=811 :
-# The OPAC requires uses to log in to view virtual shelves, and it requires a user
-# with librarian privileges.  Virtual shelves should be viewable by all users,
-# logged in or not, and editable by all logged-in users in good standing.
+# Revision 1.8.2.8  2006/12/14 17:59:17  toins
+# add the link to "BiblioDefaultView systempref" and not to opac-detail.pl
 #
-# Revision 1.3  2005/01/03 11:09:34  tipaul
-# synch'ing virtual shelves management in opac with the librarian one, that has more features
+# Revision 1.8.2.7  2006/12/14 17:22:55  toins
+# bookshelves work perfectly with mod_perl and are cleaned.
 #
-# Revision 1.5  2004/12/16 11:30:57  tipaul
-# adding bookshelf features :
-# * create bookshelf on the fly
-# * modify a bookshelf name & status
+# Revision 1.8.2.6  2006/12/14 16:04:25  toins
+# sync with intranet.
 #
-# Revision 1.4  2004/12/15 17:28:23  tipaul
-# adding bookshelf features :
-# * create bookshelf on the fly
-# * modify a bookshelf (this being not finished, will commit the rest soon)
+# Revision 1.8.2.5  2006/12/11 17:10:06  toins
+# fixing some bugs on bookshelves.
 #
-# Revision 1.3  2004/12/02 16:38:50  tipaul
-# improvement in book shelves
+# Revision 1.8.2.4  2006/12/07 15:42:15  toins
+# synching opac & intranet.
+# fix some broken link & bugs.
+# removing warn compilation.
 #
-# Revision 1.2  2004/11/19 16:31:30  tipaul
-# bugfix for bookshelves not in official CVS
+# Revision 1.8.2.3  2006/11/30 18:23:51  toins
+# theses scripts don't need to use C4::Search.
 #
-# Revision 1.1.2.1  2004/03/10 15:08:18  tipaul
-# modifying shelves : introducing category of shelf : private, public, free for all
-#
-# Revision 1.13  2004/02/11 08:35:31  tipaul
-# synch'ing 2.0.0 branch and head
-#
-# Revision 1.12.2.1  2004/02/06 14:22:19  tipaul
-# fixing bugs in bookshelves management.
-#
-# Revision 1.12  2003/02/05 10:04:14  acli
-# Worked around weirdness with HTML::Template; without the {}, it complains
-# of being passed an odd number of arguments even though we are not
-#
-# Revision 1.11  2003/02/05 09:23:03  acli
-# Fixed a few minor errors to make it run
-# Noted correct tab size
-#
-# Revision 1.10  2003/02/02 07:18:37  acli
-# Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
-#
-# Create output_html_with_http_headers function to contain the "print $query
-# ->header(-type => guesstype...),..." call. This is in preparation for
-# non-HTML output (e.g., text/xml) and charset conversion before output in
-# the future.
-#
-# Created C4/Interface/CGI/Template.pm to hold convenience functions specific
-# to the CGI interface using HTML::Template
-#
-# Modified moremembers.pl to make the "sex" field localizable for languages
-# where M and F doesn't make sense
-#
-# Revision 1.9  2002/12/19 18:55:40  hdl
-# Templating reservereport et shelves.
-#
-# Revision 1.9  2002/08/14 18:12:51  hdl
-# Templating files
-#
-# Revision 1.8  2002/08/14 18:12:51  tonnesen
-# Added copyright statement to all .pl and .pm files
-#
-# Revision 1.7  2002/07/05 05:03:37  tonnesen
-# Minor changes to authentication routines.
-#
-# Revision 1.5  2002/07/04 19:42:48  tonnesen
-# Minor changes
-#
-# Revision 1.4  2002/07/04 19:21:29  tonnesen
-# Beginning of authentication api.  Applied to shelves.pl for now as a test case.
-#
-# Revision 1.2.2.1  2002/06/26 20:28:15  tonnesen
-# Some udpates that I made here locally a while ago.  Still won't be useful, but
-# should be functional
-#
-#
-#
-
-
-
-
-# Local Variables:
-# tab-width: 4
-# End:

Index: opac-showreviews.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-showreviews.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- opac-showreviews.pl	17 Jun 2006 03:50:50 -0000	1.2
+++ opac-showreviews.pl	9 Mar 2007 15:12:54 -0000	1.3
@@ -1,13 +1,26 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
 require Exporter;
 use CGI;
-
 use C4::Auth;
 use C4::Koha;
-use HTML::Template;
 use C4::Interface::CGI::Output;
-use C4::Search;
 use C4::Circulation::Circ2;
 use C4::Review;
 use C4::Biblio;
@@ -15,20 +28,25 @@
 my $query = new CGI;
 my $biblionumber = $query->param('biblionumber');
 
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-showreviews.tmpl",
+my ( $template, $borrowernumber, $cookie ) = &get_template_and_user(
+    {
+        template_name   => "opac-showreviews.tmpl",
 			     query => $query,
 			     type => "opac",
-			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
-			     debug => 1,
-			     });
-
-my $biblio=bibdata($biblionumber,'opac');
-my $reviews=getreviews($biblionumber,1);
-
-$template->param('reviews' => $reviews,
-'title' => $biblio->{'title'});
+        authnotrequired => 1,
+    }
+);
+
+my $biblio  = GetBiblioData( $biblionumber,'opac' );
+my $reviews = getreviews( $biblionumber, 1 );
+
+$template->param(
+    reviews => $reviews,
+    title   => $biblio->{'title'},
+    OpacCloud            => C4::Context->preference("OpacCloud"),
+    OpacTopissue         => C4::Context->preference("OpacTopissue"),
+    OpacAuthorities      => C4::Context->preference("OpacAuthorities"),
+);
 
 output_html_with_http_headers $query, $cookie, $template->output;
 

Index: opac-suggestions.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-suggestions.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- opac-suggestions.pl	7 Jul 2006 09:01:03 -0000	1.6
+++ opac-suggestions.pl	9 Mar 2007 15:12:54 -0000	1.7
@@ -1,9 +1,23 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
 require Exporter;
 use CGI;
-use HTML::Template;
-
 use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
 use C4::Suggestions;
@@ -12,7 +26,7 @@
 my $title = $input->param('title');
 my $author = $input->param('author');
 my $note = $input->param('note');
-my $copyrightdate =$input->param('copyrightdate');
+my $copyrightdate   = $input->param('copyrightdate');
 my $publishercode = $input->param('publishercode');
 my $volumedesc = $input->param('volumedesc');
 my $publicationyear = $input->param('publicationyear');
@@ -23,53 +37,66 @@
 my $op = $input->param('op');
 $op = 'else' unless $op;
 
-my ($template, $borrowernumber, $cookie);
+my ( $template, $borrowernumber, $cookie );
 
 my $dbh = C4::Context->dbh;
 
-if (C4::Context->preference("AnonSuggestions")) {
-	($template, $borrowernumber, $cookie)
-		= get_template_and_user({template_name => "opac-suggestions.tmpl",
+if ( C4::Context->preference("AnonSuggestions") ) {
+    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-suggestions.tmpl",
 								query => $input,
 								type => "opac",
 								authnotrequired => 1,
-							});
-if (!$borrowernumber) {
+        }
+    );
+    if ( !$borrowernumber ) {
 	$borrowernumber = C4::Context->preference("AnonSuggestions");
+    }
 }
-} else {
-	($template, $borrowernumber, $cookie)
-		= get_template_and_user({template_name => "opac-suggestions.tmpl",
+else {
+    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-suggestions.tmpl",
 								query => $input,
 								type => "opac",
 								authnotrequired => 1,
-			 });
+        }
+    );
 }
 
-if ($op eq "add_confirm") {
-	&NewSuggestion($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn,'');
+if ( $op eq "add_confirm" ) {
+    &NewSuggestion(
+        $borrowernumber, $title,         $author,     $publishercode,
+        $note,           $copyrightdate, $volumedesc, $publicationyear,
+        $place,          $isbn,          ''
+    );
+
 	# empty fields, to avoid filter in "SearchSuggestion"
-	$title='';
-	$author='';
-	$publishercode='';
-	$copyrightdate ='';
+    $title           = '';
+    $author          = '';
+    $publishercode   = '';
+    $copyrightdate   = '';
 	$volumedesc = '';
 	$publicationyear = '';
 	$place = '';
 	$isbn = '';
-	$op='else';
+    $op              = 'else';
 }
 
-if ($op eq "delete_confirm") {
+if ( $op eq "delete_confirm" ) {
 	my @delete_field = $input->param("delete_field");
 	foreach my $delete_field (@delete_field) {
-		&DelSuggestion($borrowernumber,$delete_field);
+        &DelSuggestion( $borrowernumber, $delete_field );
 	}
-	$op='else';
+    $op = 'else';
 }
 
-my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
-$template->param(suggestions_loop => $suggestions_loop,
+my $suggestions_loop =
+  &SearchSuggestion( $borrowernumber, $author, $title, $publishercode, $status,
+    $suggestedbyme );
+$template->param(
+    suggestions_loop => $suggestions_loop,
 				title => $title,
 				author => $author,
 				publishercode => $publishercode,
@@ -77,4 +104,5 @@
 				suggestedbyme => $suggestedbyme,
 				"op_$op" => 1,
 );
+
 output_html_with_http_headers $input, $cookie, $template->output;

Index: opac-user.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-user.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- opac-user.pl	21 Jul 2006 09:51:42 -0000	1.23
+++ opac-user.pl	9 Mar 2007 15:12:54 -0000	1.24
@@ -1,4 +1,22 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: opac-user.pl,v 1.24 2007/03/09 15:12:54 tipaul Exp $
+
 use strict;
 require Exporter;
 use CGI;
@@ -9,41 +27,44 @@
 use C4::Reserves2;
 use C4::Members;
 use C4::Interface::CGI::Output;
-use HTML::Template;
+use C4::Biblio;
 use C4::Date;
 use C4::Letters;
+use C4::Branch; # GetBranches
 
 my $query = new CGI;
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-user.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-user.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
-$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
-$borr->{'expiry'}       = format_date($borr->{'expiry'});
-$borr->{'dateofbirth'}  = format_date($borr->{'dateofbirth'});
-$borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
+$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
+$borr->{'expiry'}       = format_date( $borr->{'expiry'} );
+$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
+$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
 
-if($borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'}){
-	$borr->{'flagged'} =1;
+if ( $borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'} ) {
+    $borr->{'flagged'} = 1;
 }
 
-if ($borr->{'amountoutstanding'} > 5) {
+if ( $borr->{'amountoutstanding'} > 5 ) {
     $borr->{'amountoverfive'} = 1;
 }
-if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
+if ( 5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
     $borr->{'amountoverzero'} = 1;
 }
-if ($borr->{'amountoutstanding'} < 0) {
+if ( $borr->{'amountoutstanding'} < 0 ) {
     $borr->{'amountlessthanzero'} = 1;
-    $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
+    $borr->{'amountoutstanding'} = -1 * ( $borr->{'amountoutstanding'} );
 }
 
 $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
@@ -51,8 +72,8 @@
 my @bordat;
 $bordat[0] = $borr;
 
-$template->param(BORROWER_INFO => \@bordat);
-$template->param(borrowernumber => $borrowernumber);
+$template->param( BORROWER_INFO  => \@bordat );
+$template->param( borrowernumber => $borrowernumber );
 
 #get issued items ....
 my $issues = getissues($borr);
@@ -61,22 +82,26 @@
 my $overdues_count = 0;
 my @overdues;
 my @issuedat;
-foreach my $key (keys %$issues) {
+my $imgdir = getitemtypeimagesrc();
+my $itemtypes = GetItemTypes();
+foreach my $key ( keys %$issues ) {
     my $issue = $issues->{$key};
-    $issue->{'date_due'}  = format_date($issue->{'date_due'});
+    $issue->{'date_due'} = format_date( $issue->{'date_due'} );
 
     # check for reserves
-    my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
-    if ($restype) {
+    my ( $restype, $res ) = CheckReserves( $issue->{'itemnumber'} );
+    if ( $restype ) {
 	$issue->{'reserved'} = 1;
     }
 
-    my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
+    my ( $numaccts, $accts, $total ) = getboracctrecord( undef, $borr );
     my $charges = 0;
     foreach my $ac (@$accts) {
-	if ($ac->{'itemnumber'} == $issue->{'itemnumber'}) {
-	    $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'F'; 
-	    $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'L';
+        if ( $ac->{'itemnumber'} == $issue->{'itemnumber'} ) {
+            $charges += $ac->{'amountoutstanding'}
+              if $ac->{'accounttype'} eq 'F';
+            $charges += $ac->{'amountoutstanding'}
+              if $ac->{'accounttype'} eq 'L';
 	} 
     }
     $issue->{'charges'} = $charges;
@@ -88,69 +113,81 @@
 
     # check if item is renewable
     my %env;
-    my $status = renewstatus(\%env,$borrowernumber, $issue->{'itemnumber'});
+    my $status = renewstatus( \%env, $borrowernumber, $issue->{'itemnumber'} );
 
     $issue->{'status'} = $status;
 
-    if ($issue->{'overdue'}) {
+    if ( $issue->{'overdue'} ) {
 	push @overdues, $issue;
 	$overdues_count++;
 	$issue->{'overdue'} = 1;
-    } else {
+    }
+    else {
 	$issue->{'issued'} = 1;
     }
+    # imageurl:
+    my $itemtype = $issue->{'itemtype'};
+    if ( $itemtype ) {
+        $issue->{'imageurl'}    = $imgdir."/".$itemtypes->{$itemtype}->{'imageurl'};
+        $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
+    }
     push @issuedat, $issue;
     $count++;
 }
 
-$template->param(ISSUES => \@issuedat);
-$template->param(issues_count => $count);
+$template->param( ISSUES       => \@issuedat );
+$template->param( issues_count => $count );
 
-$template->param(OVERDUES => \@overdues);
-$template->param(overdues_count => $overdues_count);
+$template->param( OVERDUES       => \@overdues );
+$template->param( overdues_count => $overdues_count );
 
 my $branches = GetBranches();
 
 # now the reserved items....
-my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
+my ( $rcount, $reserves ) = FindReserves( undef, $borrowernumber );
 foreach my $res (@$reserves) {
-    $res->{'reservedate'}  = format_date($res->{'reservedate'});
+    $res->{'reservedate'} = format_date( $res->{'reservedate'} );
     my $publictype = $res->{'publictype'};
     $res->{$publictype} = 1;
     $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
-    $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
+    $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
+    my $biblioData = GetBiblioData($res->{'biblionumber'});
+    $res->{'reserves_title'} = $biblioData->{'title'};
 }
 
-$template->param(RESERVES => $reserves);
-$template->param(reserves_count => $rcount);
+$template->param( RESERVES       => $reserves );
+$template->param( reserves_count => $rcount );
 
 my @waiting;
 my $wcount = 0;
 foreach my $res (@$reserves) {
-    if ($res->{'itemnumber'}) {
-	my $item = getiteminformation('',$res->{'itemnumber'},'');
-	$res->{'holdingbranch'} = $branches->{$item->{'holdingbranch'}}->{'branchname'};
-	$res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
-	if($res->{'holdingbranch'} eq $res->{'branch'}){
+    if ( $res->{'itemnumber'} ) {
+        my $item = getiteminformation( $res->{'itemnumber'}, '' );
+        $res->{'holdingbranch'} =
+          $branches->{ $item->{'holdingbranch'} }->{'branchname'};
+        $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
+        if ( $res->{'holdingbranch'} eq $res->{'branch'} ) {
 			$res->{'atdestination'} = 1;
 		}
+        my $biblioData = GetBiblioData($res->{'biblionumber'});
+        $res->{'waiting_title'} = $biblioData->{'title'};
 	push @waiting, $res;
 	$wcount++;
     }
 }
-$template->param(WAITING => \@waiting);
+
+$template->param( WAITING => \@waiting );
 
 # current alert subscriptions
-warn " B : $borrowernumber";
 my $alerts = getalert($borrowernumber);
-foreach (@$alerts) {
-	$_->{$_->{type}}=1;
-	$_->{relatedto} = findrelatedto($_->{type},$_->{externalid});
+foreach ( @$alerts ) {
+    $_->{ $_->{type} } = 1;
+    $_->{relatedto} = findrelatedto( $_->{type}, $_->{externalid} );
 }
 
-$template->param(waiting_count => $wcount,
+$template->param(
+    waiting_count      => $wcount,
 				textmessaging => $borr->{textmessaging},
-				OpacPasswordChange => C4::Context->preference("OpacPasswordChange"),
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;

Index: opac-userdetails.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-userdetails.pl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- opac-userdetails.pl	11 Aug 2006 09:14:01 -0000	1.12
+++ opac-userdetails.pl	9 Mar 2007 15:12:54 -0000	1.13
@@ -17,42 +17,38 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-
 use strict;
-require Exporter;
 use CGI;
 
 use C4::Auth;
 use C4::Koha;
 use C4::Circulation::Circ2;
-use C4::Search;
-use HTML::Template;
+
 use C4::Interface::CGI::Output;
 use C4::Date;
 use C4::Members;
 
 my $query = new CGI;
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-userdetails.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-userdetails.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-
-$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
-$borr->{'expiry'}       = format_date($borr->{'expiry'});
-$borr->{'dateofbirth'}  = format_date($borr->{'dateofbirth'});
-$borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
+$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
+$borr->{'dateexpiry'}       = format_date( $borr->{'dateexpiry'} );
+$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
+$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
 
 $template->param($borr);
-$template->param(LibraryName => C4::Context->preference("LibraryName"),
-);
 
 output_html_with_http_headers $query, $cookie, $template->output;
 

Index: opac-userupdate.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-userupdate.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- opac-userupdate.pl	11 Aug 2006 15:59:14 -0000	1.14
+++ opac-userupdate.pl	9 Mar 2007 15:12:54 -0000	1.15
@@ -17,7 +17,6 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-
 use strict;
 require Exporter;
 use CGI;
@@ -28,48 +27,58 @@
 use C4::Koha;
 use C4::Circulation::Circ2;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 use C4::Date;
 use C4::Members;
 
 my $query = new CGI;
 
-my ($template, $borrowernumber, $cookie) 
-    = get_template_and_user({template_name => "opac-userupdate.tmpl",
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-userupdate.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 0,
-			     flagsrequired => {borrow => 1},
+        flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+    }
+);
 
 # get borrower information ....
-my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
-
+my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber );
 
 # handle the new information....
 # collect the form values and send an email.
-my @fields = ('title', 'surname', 'firstname', 'phone', 'faxnumber', 'streetaddress', 'emailaddress', 'city');
+my @fields = (
+    'title',     'surname',       'firstname',    'phone',
+    'fax', 'streetaddress', 'emailaddress', 'city','phonepro',
+);
 my $update;
-my $updateemailaddress= C4::Context->preference('KohaAdminEmailAddress');
-if ($updateemailaddress eq '') {
-    warn "KohaAdminEmailAddress system preference not set.  Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
-    my($template) = get_template_and_user({template_name => "kohaerror.tmpl",
+my $updateemailaddress = C4::Context->preference('KohaAdminEmailAddress');
+if ( $updateemailaddress eq '' ) {
+    warn
+"KohaAdminEmailAddress system preference not set.  Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
+    my ($template) = get_template_and_user(
+        {
+            template_name   => "kohaerror.tmpl",
 			     query => $query,
 			     type => "opac",
 			     authnotrequired => 1,
-			     flagsrequired => {borrow => 1},
+            flagsrequired   => { borrow => 1 },
 			     debug => 1,
-			     });
+        }
+    );
 
-    $template->param(errormessage => 'KohaAdminEmailAddress system preference
-    is not set.  Please visit the library to update your user record');
+    $template->param(
+        errormessage => 'KohaAdminEmailAddress system preference
+    is not set.  Please visit the library to update your user record'
+    );
 
     output_html_with_http_headers $query, $cookie, $template->output;
     exit;
 }
 
-if ($query->{'title'}) {
+if ( $query->{'title'} ) {
+
     # get all the fields:
     my $message = <<"EOF";
 Borrower $borr->{'cardnumber'}
@@ -77,37 +86,42 @@
 has requested to change her/his personal details.
 Please check these new details and make the changes:
 EOF
-    foreach my $field (@fields){
+    foreach my $field (@fields) {
 	my $newfield = $query->param($field);
 	$message .= "$field : $borr->{$field}  -->  $newfield\n";
     }
     $message .= "\n\nThanks,\nKoha\n\n";
-    my %mail = ( To      => $updateemailaddress ,
-		 From    => $updateemailaddress ,
+    my %mail = (
+        To      => $updateemailaddress,
+        From    => $updateemailaddress,
 		 Subject => "User Request for update of Record.",
-		 Message => $message );
-    if (sendmail %mail) {
-# do something if it works....
+        Message => $message
+    );
+
+    if ( sendmail %mail ) {
+
+        # do something if it works....
 	warn "Mail sent ok\n";
 	print $query->redirect('/cgi-bin/koha/opac-user.pl');
 	exit;
-    } else {
-# do something if it doesnt work....
+    }
+    else {
+
+        # do something if it doesnt work....
         warn "Error sending mail: $Mail::Sendmail::error \n";
     }
 }
 
-
-$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
-$borr->{'expiry'}       = format_date($borr->{'expiry'});
-$borr->{'dateofbirth'}  = format_date($borr->{'dateofbirth'});
-$borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
-
+$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
+$borr->{'expiry'}       = format_date( $borr->{'expiry'} );
+$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
+$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
 
 my @bordat;
 $bordat[0] = $borr;
 
-$template->param(BORROWER_INFO => \@bordat,
+$template->param( 
+    BORROWER_INFO => \@bordat
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;





More information about the Koha-cvs mailing list