[Koha-cvs] koha/intranet/cgi-bin circ/branchreserves.pl ci... [rel_TG]

Tumer Garip tgarip at neu.edu.tr
Sat Mar 10 12:54:17 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_TG
Changes by:	Tumer Garip <tgarip1957>	07/03/10 11:54:16

Added files:
	intranet/cgi-bin/circ: branchreserves.pl branchtransfers.pl 
	                       circulation.pl currenttransfers.pl 
	                       renewscript.pl rescirculation.pl 
	                       resreturns.pl returns.pl 
	                       selectbranchprinter.pl 
	                       waitingreservestransfers.pl 
Removed files:
	intranet/cgi-bin: get-imdb.php 

Log message:
	

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/branchreserves.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/branchtransfers.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/circulation.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/currenttransfers.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/renewscript.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/rescirculation.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/resreturns.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/returns.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/selectbranchprinter.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/circ/waitingreservestransfers.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/get-imdb.php?cvsroot=koha&only_with_tag=rel_TG&r1=1.1.2.1&r2=0

Patches:
Index: circ/branchreserves.pl
===================================================================
RCS file: circ/branchreserves.pl
diff -N circ/branchreserves.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/branchreserves.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,136 @@
+#!/usr/bin/perl
+
+# $Id: branchreserves.pl,v 1.1.2.1 2007/03/10 11:54:16 tgarip1957 Exp $
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use C4::Context;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Circulation::Circ2;
+use C4::Reserves2;
+use C4::Search;
+use C4::Koha;
+
+my $input = new CGI;
+
+my $item=$input->param('itemnumber');
+my $borrowernumber=$input->param('borrowernumber');
+my $fbr=$input->param('fbr');
+my $tbr=$input->param('tbr');
+
+my $cancel;
+
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+
+my ($template, $loggedinuser, $cookie)
+      = get_template_and_user({template_name => "circ/branchreserves.tmpl",
+	                                 query => $input,
+	                                 type => "intranet",
+	                                 authnotrequired => 0,
+	                                 flagsrequired => {borrowers => 1},
+	                                 debug => 1,
+	                                 });
+
+my $default = C4::Context->userenv->{'branch'};
+my $dbh=C4::Context->dbh;
+my $todaysdate = get_today();
+
+
+# if we have a return from the form we launch the subroutine CancelReserve
+	if ($item){
+		my $messages;
+		my $nextreservinfo;
+		my %env;
+		my $waiting;
+		($messages,$nextreservinfo) = GlobalCancel($item,$borrowernumber);
+# 		if we have a result 
+		if ($nextreservinfo){
+			my $borrowerinfo = getpatroninformation(\%env,$nextreservinfo);
+			my $iteminfo = C4::Circulation::Circ2::getiteminformation(\%env,$item);
+			if ($messages->{'transfert'}){
+			my $branchname = getbranchname($messages->{'transfert'});
+				$template->param(
+					messagetransfert => $messages->{'transfert'},
+					branchname 	=> $branchname,
+				);
+			}
+			if ($messages->{'waiting'}){
+			$waiting = 1;
+			}
+
+				$template->param(
+					message			=> 1,
+					nextreservnumber  =>  $nextreservinfo,
+					nextreservsurname => $borrowerinfo->{'surname'},
+					nextreservfirstname => $borrowerinfo->{'firstname'},
+					nextreservitem		=> $item,
+					nextreservtitle		=> $iteminfo->{'title'},
+					waiting 		=> $waiting
+				);
+			}
+# 		if the document is not in his homebranch location and there is not reservation after, we transfer it
+		if (($fbr ne $tbr) and (not $nextreservinfo)){
+			C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr);
+			C4::Circulation::Circ2::itemseen($dbh,$itm);
+		}
+	}
+	
+my @reservloop;
+my @getreserves = GetReservesForBranch($default);
+foreach my $num (@getreserves) {
+	my %getreserv;
+	my %env;
+	my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
+	my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'});
+	my $itemtypeinfo = getitemtypeinfo($gettitle->{'ctype'});
+	$getreserv{'waitingdate'} = format_date($num->{'waitingdate'});
+	my $calcDate=DateCalc($num->{'waitingdate'},"+".C4::Context->preference('ReservesMaxPickUpDelay')."  days");
+	my $warning=Date_Cmp(ParseDate("today"),$calcDate);
+	if ($warning>0){
+		$getreserv{'messcompa'} = 1;
+	}
+	$getreserv{'title'} = $gettitle->{'title'};
+	$getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
+	$getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
+	$getreserv{'barcode'} = $gettitle->{'barcode'};
+	$getreserv{'itemtype'} = $itemtypeinfo->{'description'};
+	$getreserv{'homebranch'} = $gettitle->{'homebranch'};
+	$getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
+	if ($gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'}){
+		$getreserv{'dotransfer'} = 1;
+		}
+	$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
+	$getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
+	$getreserv{'borrowername'} = $getborrower->{'surname'};
+	$getreserv{'borrowerfirstname'} =  $getborrower->{'firstname'} ;
+	if ($getborrower->{'emailaddress'}){
+		$getreserv{'borrowermail'} =  $getborrower->{'emailaddress'} ;
+	}
+	$getreserv{'borrowerphone'} = $getborrower->{'phone'};
+	push(@reservloop, \%getreserv);
+}
+
+	$template->param( reserveloop       => \@reservloop,
+			show_date	=> format_date($todaysdate),	
+			 );
+	
+output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file

Index: circ/branchtransfers.pl
===================================================================
RCS file: circ/branchtransfers.pl
diff -N circ/branchtransfers.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/branchtransfers.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,283 @@
+#!/usr/bin/perl
+# WARNING: This file uses 4-character tabs!
+
+#written 11/3/2002 by Finlay
+#script to execute branch transfers of books
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ2;
+use C4::Reserves2;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+use C4::Members;
+###############################################
+# constants
+
+my %env;
+my $linecolor1='#ffffcc';
+my $linecolor2='white';
+
+my $branches = GetBranches();
+my $printers = getprinters(\%env);
+
+
+###############################################
+#  Getting state
+
+my $query=new CGI;
+
+
+my $branch = getbranch($query, $branches);
+my $printer = getprinter($query, $printers);
+
+my $genbrname = $branches->{$branch}->{'branchname'} ;
+my $genprname = $printers->{$printer}->{'printername'};
+
+my $messages;
+my $found;
+my $reserved;
+my $waiting;
+my $reqmessage;
+my $cancelled;
+my $setwaiting;
+my $reqbrchname;
+my $user=$query->param('loggedinuser');
+my $request=$query->param('request');
+my $borrnum = $query->param('borrowernumber');
+
+my $tobranchcd=$query->param('tobranchcd');
+my $frbranchcd='';
+my $dbh=C4::Context->dbh;
+############
+# Deal with the requests....
+if ($request eq "KillWaiting") {
+    my $item = $query->param('itemnumber');
+    CancelReserve(0, $item, $borrnum);
+	$cancelled = 1;
+	$reqmessage =1;
+}
+
+my $ignoreRs = 0;
+if ($request eq "SetWaiting") {
+    my $item = $query->param('itemnumber');
+    $tobranchcd = ReserveWaiting($item, $borrnum);
+	$reqbrchname = $branches->{$tobranchcd}->{'branchname'};
+    $ignoreRs = 1;
+	$setwaiting = 1;
+	$reqmessage =1;
+}
+if ($request eq 'KillReserved'){
+    my $biblio = $query->param('biblionumber');
+    CancelReserve($biblio, 0, $borrnum);
+	$cancelled = 1;
+	$reqmessage =1;
+}
+
+
+
+# set up the branchselect options....
+my @branchoptionloop;
+foreach my $br (keys %$branches) {
+    #(next) unless $branches->{$br}->{'CU'}; #FIXME disabled to fix bug 202
+    my %branch;
+    $branch{selected}=($br eq $tobranchcd);
+	$branch{code}=$br;
+	$branch{name}=$branches->{$br}->{'branchname'};
+	push (@branchoptionloop, \%branch);
+}
+
+
+# collect the stack of books already transfered so they can printed...
+my @trsfitemloop;
+my %transfereditems;
+my %frbranchcds;
+my %tobranchcds;
+my $color=$linecolor2;
+
+my $barcode = $query->param('barcode');
+if ($barcode) {
+	my $transfered;
+	my $iteminformation;
+	($transfered, $messages, $iteminformation)
+			= transferbook($tobranchcd, $barcode, $ignoreRs,$user);
+	$found = $messages->{'ResFound'};
+	if ($transfered) {
+		my %item;
+		my $frbranchcd = $iteminformation->{'holdingbranch'};
+		if (not ($found)) {
+			($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
+			$item{'color'}=$color;
+			$item{'biblionumber'}=$iteminformation->{'biblionumber'};
+			$item{'title'}=$iteminformation->{'title'};
+			$item{'author'}=$iteminformation->{'author'};
+			$item{'itemtype'}=$iteminformation->{'ctype'};
+			$item{'frbrname'}=$branches->{$frbranchcd}->{'branchname'};
+			$item{'tobrname'}=$branches->{$tobranchcd}->{'branchname'};
+		}
+		$item{counter}=0;
+		$item{barcode}=$barcode;
+		$item{frombrcd}=$frbranchcd;
+		$item{tobrcd}=$tobranchcd;
+##########
+#Are these lines still useful ???
+		$transfereditems{0}=$barcode;
+		$frbranchcds{0}=$frbranchcd;
+		$tobranchcds{0}=$tobranchcd;
+##########
+		push (@trsfitemloop, \%item);
+	}
+}
+
+foreach ($query->param){
+	(next) unless (/bc-(\d*)/);
+	my $counter=$1;
+	my %item;
+	my $bc=$query->param("bc-$counter");
+	my $frbcd=$query->param("fb-$counter");
+	my $tobcd=$query->param("tb-$counter");
+	$counter++;
+	$item{counter}=$counter;
+	$item{barcode}=$bc;
+	$item{frombrcd}=$frbcd;
+	$item{tobrcd}=$tobcd;
+	my ($iteminformation) = getiteminformation(\%env, 0, $bc);
+	($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
+	$item{'color'}=$color;
+	$item{'biblionumber'}=$iteminformation->{'biblionumber'};
+	$item{'title'}=$iteminformation->{'title'};
+	$item{'author'}=$iteminformation->{'author'};
+	$item{'itemtype'}=$iteminformation->{'ctype'};
+	$item{'frbrname'}=$branches->{$frbcd}->{'branchname'};
+	$item{'tobrname'}=$branches->{$tobcd}->{'branchname'};
+##########
+#Are these lines still useful ???
+	$transfereditems{$counter}=$bc;
+	$frbranchcds{$counter}=$frbcd;
+	$tobranchcds{$counter}=$tobcd;
+#########
+	push (@trsfitemloop, \%item);
+}
+
+
+my $name;
+my $bornum;
+my $borcnum;
+my $itemnumber;
+my $biblionum;
+my $branchname;
+
+
+#####################
+
+if ($found) {
+    my $res = $messages->{'ResFound'};
+	$branchname = $branches->{$res->{'branchcode'}}->{'branchname'};
+	my ($borr) = getpatroninformation(\%env, $res->{'borrowernumber'}, 0);
+	$name = name($borr);
+	$bornum = $borr->{'borrowernumber'}; #Hopefully, borr->{borrowernumber}=res->{borrowernumber}
+	$borcnum = $borr->{'cardnumber'};
+	$itemnumber = $res->{'itemnumber'};
+
+	if ($res->{'ResFound'} eq "Waiting") {
+		$waiting = 1;
+	}
+	if ($res->{'ResFound'} eq "Reserved") {
+		$reserved = 1;
+		$biblionum = $res->{'biblionumber'};
+	}
+}
+
+#####################
+
+my @errmsgloop;
+foreach my $code (keys %$messages) {
+	my %err;
+    $err{errbadcode} = ($code eq 'BadBarcode');
+	if ($code eq 'BadBarcode') {
+		$err{msg}=$messages->{'BadBarcode'};
+	}
+
+    $err{errispermanent} = ($code eq 'IsPermanent');
+    if ($code eq 'IsPermanent'){
+		$err{msg} = $branches->{$messages->{'IsPermanent'}}->{'branchname'};
+		# Here, msg contains the branchname
+		# Not so satisfied with this... But should work
+    }
+    $err{errdesteqholding} = ($code eq 'DestinationEqualsHolding');
+
+	$err{errwasreturned} = ($code eq 'WasReturned');
+	if ($code eq 'WasReturned') {
+		my ($borrowerinfo) = getpatroninformation(\%env, $messages->{'WasReturned'}, 0);
+		$name =name($borrowerinfo);
+		$bornum =$borrowerinfo->{'borrowernumber'};
+		$borcnum =$borrowerinfo->{'cardnumber'};
+    }
+    if ($code eq 'WasTransfered'){
+# Put code here if you want to notify the user that item was transfered...
+    }
+	push (@errmsgloop, \%err);
+}
+
+
+#######################################################################################
+# Make the page .....
+my ($template, $borrowernumber, $cookie)
+    = get_template_and_user({template_name => "circ/branchtransfers.tmpl",
+							query => $query,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {editcatalogue => 1},
+                         });
+$template->param(	genbrname => $genbrname,
+								genprname => $genprname,
+								branch => $branch,
+								printer => $printer,
+								found => $found,
+								reserved => $reserved,
+								waiting => $waiting,
+								name => $name,
+								bornum => $bornum,
+								borcnum => $borcnum,
+								branchname => $branchname,
+								itemnumber => $itemnumber,
+								barcode => $barcode,
+								biblionumber => $biblionum,
+								tobranchcd => $tobranchcd,
+								reqmessage => $reqmessage,
+								cancelled => $cancelled,
+								setwaiting => $setwaiting,
+								trsfitemloop => \@trsfitemloop,
+								branchoptionloop => \@branchoptionloop,
+								errmsgloop => \@errmsgloop
+							);
+output_html_with_http_headers $query, $cookie, $template->output;
+
+
+sub name {
+	my ($borinfo) = @_;
+	return $borinfo->{'surname'}." ".$borinfo->{'title'}." ".$borinfo->{'firstname'};
+}
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: circ/circulation.pl
===================================================================
RCS file: circ/circulation.pl
diff -N circ/circulation.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/circulation.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,486 @@
+#!/usr/bin/perl
+
+# Please use 8-character tabs for this file (indents are every 4 characters)
+
+#written 8/5/2002 by Finlay
+#script to execute issuing of books
+# New functions (renew etc.) added 07-08-2005 Tumer Garip tgarip at neu.edu.tr
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ2;
+use C4::Search;
+use C4::Output;
+use C4::Print;
+
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+
+use C4::Date;
+use C4::Context;
+use C4::Members;
+# PARAMETERS READING
+#
+my $query=new CGI;
+
+my ($template, $loggedinuser, $cookie) = get_template_and_user
+    ({
+	template_name	=> 'circ/circulation.tmpl',
+	query		=> $query,
+	type		=> "intranet",
+	authnotrequired	=> 0,
+	flagsrequired	=> { circulate => 1 },
+    });
+my $branches = GetBranches();
+my $printers = getprinters();
+#my $branch = getbranch($query, $branches);
+my $branch=C4::Context->preference("defaultBranch");
+my $printer = getprinter($query, $printers);
+
+my $findborrower = $query->param('findborrower');
+
+$findborrower =~ s|,| |g;
+$findborrower =~ s|'| |g;
+my $borrowernumber = $query->param('borrnumber');
+
+my $print=$query->param('print');
+my $barcode = $query->param('barcode');
+my $year=$query->param('year');
+my $month=$query->param('month');
+my $day=$query->param('day');
+my $stickyduedate=$query->param('stickyduedate');
+my $issueconfirmed = $query->param('issueconfirmed');
+my $cancelreserve = $query->param('cancelreserve');
+my %error;
+my  $errorflag=$query->param('error');
+## The following er
+if ( $errorflag gt "1"){
+%error=(TOO_EARLY=>{1},) if ($errorflag eq "2");
+%error=(NO_MORE_RENEWALS=>{1},) if ($errorflag eq "3");
+%error=(RESERVE_FOUND=>{1},) if ($errorflag eq "4");
+}elsif ( $errorflag eq "1"){
+%error=(SUCCESFULL_RENEW=>{1},)
+}
+#set up cookie.....
+my $branchcookie;
+my $printercookie;
+#if ($query->param('setcookies')) {
+#	$branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
+#	$printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
+#}
+
+my %env; # FIXME env is used as an "environment" variable. Could be dropped probably...
+
+$env{'branchcode'}=$branch;
+$env{'printer'}=$printer;
+$env{'queue'}=$printer;
+
+
+my $todaysdate =get_today();
+
+
+# check and see if we should print
+ if ($barcode eq ''  && $print eq 'maybe'){
+ 	$print = 'yes';
+ }
+ if ($print eq 'yes' && $borrowernumber ne ''){
+ 	printslip(\%env,$borrowernumber);
+ 	$query->param('borrnumber','');
+ 	$borrowernumber='';
+ }
+
+#
+# STEP 2 : FIND BORROWER
+# if there is a list of find borrowers....
+#
+my $borrowerslist;
+my $message;
+if ($findborrower) {
+	my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'cardnumber','web');
+	my @borrowers=@$borrowers;
+	if ($#borrowers == -1) {
+		$query->param('findborrower', '');
+		$message =  "'$findborrower'";
+	} elsif ($#borrowers == 0) {
+		$query->param('borrnumber', $borrowers[0]->{'borrowernumber'});
+		$query->param('barcode','');
+		$borrowernumber=$borrowers[0]->{'borrowernumber'};
+	} else {
+		$borrowerslist = \@borrowers;
+	}
+}
+
+# get the borrower information.....
+my $borrower;
+my $bornum=$query->param('bornum');
+if ($bornum){
+$borrowernumber=$bornum;
+}
+my $issues;
+if ($borrowernumber) {
+	$borrower = getpatroninformation(\%env,$borrowernumber,0);
+	my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
+	my ($resod,$resissue,$fines,$resfine)=borrdata3(\%env,$borrowernumber);
+
+	$template->param(overduecount => $od,resoverdue=>$resod,resissuecount=>$resissue,resfine=>$resfine,
+							issuecount => $issue,
+							finetotal => $fines);
+$issues=$issue;
+my $picture;
+ my $htdocs = C4::Context->config('opacdir');
+
+$picture =$htdocs. "/htdocs/uploaded-files/users-photo/".$borrower->{'cardnumber'}.".jpg";
+ if (-e $picture)
+{ 
+   $template->param(borrowerphoto => "http://library.neu.edu.tr/uploaded-files/users-photo/".$borrower->{'cardnumber'}.".jpg");
+ }else{
+$picture = "http://cc.neu.edu.tr/stdpictures/".$borrower->{'cardnumber'}.".jpg";
+  $template->param(borrowerphoto => $picture);
+}
+}
+
+#
+# STEP 3 : ISSUING
+#
+#Try to  issue
+
+
+if ($barcode) {
+
+	$barcode = cuecatbarcodedecode($barcode);
+	my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
+	if ($issueconfirmed) {
+		issuebook(\%env, $borrower, $barcode, $datedue,$cancelreserve);
+		my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
+
+
+	$template->param(overduecount => $od,
+							issuecount => $issue,
+							finetotal => $fines);	
+
+	} else {
+		my ($error, $question) = canbookbeissued(\%env, $borrower, $barcode, $year, $month, $day) unless %error;
+		$error=\%error if %error;
+
+		my $noerror=1;
+		my $noquestion = 1;
+		foreach my $impossible (keys %$error) {
+			$template->param($impossible => $$error{$impossible},
+							IMPOSSIBLE => 1) unless ($impossible eq 'SUCCESFULL_RENEW');
+			$noerror = 0;
+		}
+		foreach my $needsconfirmation (keys %$question) {
+			$template->param($needsconfirmation => $$question{$needsconfirmation},
+							NEEDSCONFIRMATION => 1);
+			$noquestion = 0;
+		}
+		$template->param(day => $day,
+						month => $month,
+						year => $year);
+		if ($noerror && ($noquestion || $issueconfirmed)) {
+
+			issuebook(\%env, $borrower, $barcode, $datedue);
+		my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
+	
+
+	$template->param(overduecount => $od,
+							issuecount => $issue,
+							finetotal => $fines);
+		}
+	}
+
+}
+
+
+
+
+##################################################################################
+# BUILD HTML
+
+# make the issued books table.....
+my $todaysissues='';
+my $previssues='';
+my @realtodayissues;
+my @realprevissues;
+#my @renewissues;
+my $allowborrow;
+if ($borrower) {
+
+# get each issue of the borrower & separate them in todayissues & previous issues
+	my @todaysissues;
+	my @previousissues;
+	my $issueslist = getissues($borrower);
+	# split in 2 arrays for today & previous
+	foreach my $it (keys %$issueslist) {
+		my $issuedate = $issueslist->{$it}->{'issue_date'};
+#		$issuedate = substr($issuedate, 0, 10);
+	
+		if ($todaysdate eq $issuedate) {
+			push @todaysissues, $issueslist->{$it};
+		} else { 
+			push @previousissues, $issueslist->{$it};
+		}
+    }
+
+
+	my $od; # overdues
+	my $i = 0;
+	my $togglecolor;
+	# parses today & build Template array
+	foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}} @todaysissues){
+		my $dd = $book->{'date_due'};
+		my $datedue = $book->{'date_due'};
+
+		$dd=format_date($dd);
+#		$datedue=~s/-//g;
+		if ($datedue lt $todaysdate) {
+			$od = 1;
+		} else {
+			$od=0;
+		}
+		$book->{'od'}=$od;
+		$book->{'dd'}=$dd;
+		
+		if ($togglecolor) {
+			$togglecolor=0;
+		} else {
+			$togglecolor=1;
+		}
+		$book->{'tcolor'}=$togglecolor;
+		if ($book->{'author'} eq ''){
+			$book->{'author'}=' ';
+		}    
+		push @realtodayissues,$book;
+	$i++;
+	}
+
+
+
+	# parses previous & build Template array
+	$i=0;
+    foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}} @previousissues){
+		my $dd = $book->{'date_due'};
+		my $datedue = $book->{'date_due'};
+		$dd=format_date($dd);
+		my $pcolor = '';
+		my $od = '';
+#		$datedue=~s/-//g;
+		if ($datedue lt $todaysdate) {
+		
+			$od = 1;
+		} else {
+			$od = 0;
+		}
+	
+		if ($togglecolor) {
+			$togglecolor=0;
+		} else {
+			$togglecolor=1;
+		}
+	$book->{'tcolor'}=$togglecolor;
+		$book->{'dd'}=$dd; 
+		$book->{'od'}=$od;
+		#$book->{'tcolor'}=$pcolor;
+		if ($book->{'author'} eq ''){
+			$book->{'author'}=' ';
+		}    
+
+		push @realprevissues,$book;
+	$i++;
+	}
+
+}#borrower
+
+
+my @values;
+my %labels;
+my $CGIselectborrower;
+if ($borrowerslist) {
+	foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowerslist){
+		push @values,$_->{'borrowernumber'};
+		$labels{$_->{'borrowernumber'}} ="$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ...  $_->{'streetaddress'} ";
+	}
+	$CGIselectborrower=CGI::scrolling_list( -name     => 'borrnumber',
+				-values   => \@values,
+				-labels   => \%labels,
+				-size     => 7,
+				-multiple => 0 );
+}
+#title
+
+my ($patrontable, $flaginfotable) = patrontable($borrower);
+my $amountold=$borrower->{flags}->{'CHARGES'}->{'message'};
+my @temp=split(/\$/,$amountold);
+$amountold=$temp[1];
+$template->param( today=>format_date($todaysdate),
+		findborrower => $findborrower,
+		borrower => $borrower,
+		borrowernumber => $borrowernumber,
+		branch => $branch,
+		printer => $printer,
+		branchname => $branches->{$branch}->{'branchname'},
+		printername => $printers->{$printer}->{'printername'},
+		firstname => $borrower->{'firstname'},
+		surname => $borrower->{'surname'},
+		categorycode => getborrowercategory($borrower->{'categorycode'}),
+		streetaddress => $borrower->{'streetaddress'},
+		emailaddress => $borrower->{'emailaddress'},
+		borrowernotes => $borrower->{'borrowernotes'},
+		city => $borrower->{'city'},
+		phone => $borrower->{'phone'},
+		cardnumber => $borrower->{'cardnumber'},
+		amountold => $amountold,
+		barcode => $barcode,
+		stickyduedate => $stickyduedate,
+		message => $message,
+		CGIselectborrower => $CGIselectborrower,
+		todayissues => \@realtodayissues,
+		previssues => \@realprevissues,
+		
+	);
+# set return date if stickyduedate
+if ($stickyduedate) {
+	my $t_year = "year".$year;
+	my $t_month = "month".$month;
+	my $t_day = "day".$day;
+	$template->param(
+		$t_year => 1,
+		$t_month => 1,
+		$t_day => 1,
+	);
+}
+
+
+if ($branchcookie) {
+    $cookie=[$cookie, $branchcookie, $printercookie];
+}
+
+output_html_with_http_headers $query, $cookie, $template->output;
+
+####################################################################
+# Extra subroutines,,,
+
+sub patrontable {
+    my ($borrower) = @_;
+    my $flags = $borrower->{'flags'};
+    my $flaginfotable='';
+    my $flaginfotext;
+    #my $flaginfotext='';
+    my $flag;
+    my $color='';
+    foreach $flag (sort keys %$flags) {
+#    	my @itemswaiting='';
+	$flags->{$flag}->{'message'}=~s/\n/<br>/g;
+	if ($flags->{$flag}->{'noissues'}) {
+		$template->param(
+			flagged => 1,
+			noissues => 'true',
+			 );
+		if ($flag eq 'GNA'){
+			$template->param(
+				gna => 'true'
+				);
+			}
+		if ($flag eq 'LOST'){
+			$template->param(
+				lost => 'true'
+			);
+			}
+		if ($flag eq 'DBARRED'){
+			$template->param(
+				dbarred => 'true'
+			);
+			}
+		if ($flag eq 'CHARGES') {
+			$template->param(
+				charges => 'true',
+				chargesmsg => $flags->{'CHARGES'}->{'message'}
+				 );
+		}
+	} else {
+		 if ($flag eq 'CHARGES') {
+			$template->param(
+				charges => 'true',
+				flagged => 1,
+				chargesmsg => $flags->{'CHARGES'}->{'message'}
+			 );
+		}
+	    	if ($flag eq 'WAITING') {
+			my $items=$flags->{$flag}->{'itemlist'};
+		        my @itemswaiting;
+			foreach my $item (@$items) {
+			my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
+			$iteminformation->{'branchname'} = $branches->{$iteminformation->{'holdingbranch'}}->{'branchname'};
+			push @itemswaiting, $iteminformation;
+			}
+			$template->param(
+				flagged => 1,
+				waiting => 'true',
+				waitingmsg => $flags->{'WAITING'}->{'message'},
+				itemswaiting => \@itemswaiting,
+				 );
+		}
+		if ($flag eq 'ODUES') {
+			$template->param(
+				odues => 'true',
+				flagged => 1,
+				oduesmsg => $flags->{'ODUES'}->{'message'}
+				 );
+
+			my $items=$flags->{$flag}->{'itemlist'};
+			{
+			    my @itemswaiting;
+			foreach my $item (@$items) {
+				my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
+				push @itemswaiting, $iteminformation;
+			}
+			}
+			if ($query->param('module') ne 'returns'){
+				$template->param( nonreturns => 'true' );
+			}
+		}
+		if ($flag eq 'NOTES') {
+			$template->param(
+				notes => 'true',
+				flagged => 1,
+				notesmsg => $flags->{'NOTES'}->{'message'}
+				 );
+		}
+	}
+    }
+    return($patrontable, $flaginfotext);
+}
+
+sub cuecatbarcodedecode {
+    my ($barcode) = @_;
+    chomp($barcode);
+    my @fields = split(/\./,$barcode);
+    my @results = map(decode($_), @fields[1..$#fields]);
+    if ($#results == 2){
+  	return $results[2];
+    } else {
+	return $barcode;
+    }
+}
+
+# Local Variables:
+# tab-width: 8
+# End:

Index: circ/currenttransfers.pl
===================================================================
RCS file: circ/currenttransfers.pl
diff -N circ/currenttransfers.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/currenttransfers.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,123 @@
+#!/usr/bin/perl
+
+# $Id: currenttransfers.pl,v 1.1.2.1 2007/03/10 11:54:16 tgarip1957 Exp $
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use C4::Context;
+use C4::Interface::CGI::Output;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Circulation::Circ2;
+use C4::Date;
+use C4::Koha;
+use C4::Search;
+use C4::Reserves2;
+
+my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+my $itemnumber = $input->param('itemnumber');
+# if we have a resturn of the form to delete the transfer, we launch the subrroutine
+if ($itemnumber){
+	C4::Circulation::Circ2::DeleteTransfer($itemnumber);
+}
+
+my ($template, $loggedinuser, $cookie)
+      = get_template_and_user({template_name => "circ/currenttransfers.tmpl",
+	                                 query => $input,
+	                                 type => "intranet",
+	                                 authnotrequired => 0,
+	                                 flagsrequired => {borrowers => 1},
+	                                 debug => 1,
+	                                 });
+
+
+# set the userenv branch
+my $default = C4::Context->userenv->{'branch'};
+
+
+
+my $todaysdate = get_today();
+
+# get the all the branches for reference
+my $branches = GetBranches();
+my @branchesloop;
+foreach my $br (keys %$branches) {
+	my @transferloop;
+	my %branchloop;
+	$branchloop{'branchname'} = $branches->{$br}->{'branchname'};
+	$branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
+	# # # # # # # # # # # # # # # # # # # # # # 
+	my @gettransfers = GetTransfersFromBib($branches->{$br}->{'branchcode'},$default);
+		if (@gettransfers){
+		foreach my $num (@gettransfers) {
+			my %getransf;
+			my %env;
+			my $calcDate=DATE_Add($num->{'datesent'},C4::Context->preference('TransfersMaxDaysWarning'));
+			my $warning=DATE_Diff($todaysdate,$calcDate);
+			if ($warning>0){
+				$getransf{'messcompa'} = 1;
+			}
+			my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
+			my $itemtypeinfo = getitemtypeinfo($gettitle->{'ctype'});
+			
+				$getransf{'title'} = $gettitle->{'title'};
+				$getransf{'datetransfer'} = format_date($num->{'datesent'});
+				$getransf{'biblionumber'} = $gettitle->{'biblionumber'};
+				$getransf{'itemnumber'} = $gettitle->{'itemnumber'};
+				$getransf{'barcode'} = $gettitle->{'barcode'};
+				$getransf{'itemtype'} = $itemtypeinfo->{'description'};
+				$getransf{'homebranch'} = $gettitle->{'homebranch'};
+				$getransf{'holdingbranch'} = $gettitle->{'holdingbranch'};
+				$getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
+
+# 				we check if we have a reserv for this transfer
+				my @checkreserv = FastFindReserves($num->{'itemnumber'});
+				if (@checkreserv[0]){
+					my $getborrower = getpatroninformation (\%env,$checkreserv[1]);
+					$getransf{'borrowernum'} = $getborrower->{'borrowernumber'};
+					$getransf{'borrowername'} = $getborrower->{'surname'};
+					$getransf{'borrowerfirstname'} =  $getborrower->{'firstname'};
+						if ($getborrower->{'emailaddress'}){
+							$getransf{'borrowermail'} =  $getborrower->{'emailaddress'} ;
+						}
+					$getransf{'borrowerphone'} = $getborrower->{'phone'};	
+
+				}
+				push(@transferloop, \%getransf);
+			}
+# 		If we have a return of reservloop we put it in the branchloop sequence
+		$branchloop{'reserv'} = \@transferloop ;
+		}		
+	else {
+# 	if we don't have a retrun from reservestobranch we unset branchname and branchcode
+	$branchloop{'branchname'} = 0;
+	$branchloop{'branchcode'} = 0;
+	}
+push(@branchesloop, \%branchloop);
+}
+	$template->param( branchesloop  => \@branchesloop,
+			show_date	=> format_date($todaysdate)	
+			 );
+	
+output_html_with_http_headers $input, $cookie, $template->output;
+
+

Index: circ/renewscript.pl
===================================================================
RCS file: circ/renewscript.pl
diff -N circ/renewscript.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/renewscript.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+
+# $Id: renewscript.pl,v 1.1.2.1 2007/03/10 11:54:16 tgarip1957 Exp $
+
+#written 18/1/2000 by chris at katipo.co.nz
+#script to renew items from the web
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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::Circulation::Circ2;
+use C4::Date;
+use C4::Members;
+use C4::Log;
+use C4::Context;
+use C4::Auth;
+#get input
+my $input= new CGI;
+my $flagsrequired;
+# $flagsrequired->{circulation}=1;
+#my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
+
+my @names=$input->param();
+my $count=@names;
+my %data;
+my $dbh = C4::Context->dbh;
+for (my $i=0;$i<$count;$i++){
+  if ($names[$i] =~ /renew/){
+    my $temp=$names[$i];
+    $temp=~ s/renew_item_//;
+    $data{$temp}=$input->param($names[$i]);
+  }
+}
+my %env;
+my $barcode;
+my $destination = $input->param("destination");
+my $cardnumber = $input->param("cardnumber");
+my $bornum=$input->param("bornum");
+my $error;
+my $status=0;
+
+while ( my ($itemno, $value) = each %data) {
+
+   if ($value eq 'y'){
+my $iteminformation = getiteminformation($env, $itemno,0);
+$barcode=$iteminformation->{'barcode'};
+	 $status=renewstatus(\%env,$bornum,$itemno);
+	if ($status==1){
+     renewbook($env,$bornum,$itemno);	
+
+# logaction($loggedinuser,"circulation","renew",$barcode,$bornum) if (&logstatus);
+	}else{
+	last;
+	}   
+}
+}
+
+if($destination eq "circ" || $status>1){
+	print $input->redirect("/cgi-bin/koha/circ/circulation.pl?bornum=$bornum&error=$status&barcode=$barcode");
+} else {
+	print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$bornum");
+}
\ No newline at end of file

Index: circ/rescirculation.pl
===================================================================
RCS file: circ/rescirculation.pl
diff -N circ/rescirculation.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/rescirculation.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,465 @@
+#!/usr/bin/perl
+
+# Please use 8-character tabs for this file (indents are every 4 characters)
+
+#written 8/5/2002 by Finlay
+#script to execute issuing of books
+# New functions added 07-08-2005 Tumer Garip tgarip at neu.edu.tr
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ3;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+use C4::Date;
+use C4::Context;
+use C4::Members;
+use C4::Print;
+use C4::Log;
+#
+# PARAMETERS READING
+#
+my $query=new CGI;
+
+my ($template, $loggedinuser, $cookie) = get_template_and_user
+    ({
+	template_name	=> 'circ/rescirculation.tmpl',
+	query		=> $query,
+	type		=> "intranet",
+	authnotrequired	=> 0,
+	flagsrequired	=> { circulate => 1 },
+    });
+my $branches = GetBranches();
+my $printers = getprinters();
+my $branch=C4::Context->preference("defaultBranch");
+my $printer = getprinter($query, $printers);
+
+my $findborrower = $query->param('findborrower');
+$findborrower =~ s|,| |g;
+$findborrower =~ s|'| |g;
+my $borrowernumber = $query->param('borrnumber');
+
+my $print=$query->param('print');
+my $barcode = $query->param('barcode');
+my $year=$query->param('year');
+my $month=$query->param('month');
+my $day=$query->param('day');
+my $stickyduedate=$query->param('stickyduedate');
+my $issueconfirmed = $query->param('issueconfirmed');
+my $cancelreserve = $query->param('cancelreserve');
+
+my $renew=0;
+ 
+#set up cookie.....
+my $branchcookie;
+my $printercookie;
+#if ($query->param('setcookies')) {
+#	$branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
+#	$printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
+#}
+
+my %env; # FIXME env is used as an "environment" variable. Could be dropped probably...
+
+$env{'branchcode'}=$branch;
+$env{'printer'}=$printer;
+$env{'queue'}=$printer;
+
+my $todaysdate =get_today();
+
+
+# check and see if we should print
+ if ($barcode eq ''  && $print eq 'maybe'){
+ 	$print = 'yes';
+ }
+ if ($print eq 'yes' && $borrowernumber ne ''){
+ 	printslip(\%env,$borrowernumber);
+ 	$query->param('borrnumber','');
+ 	$borrowernumber='';
+ }
+
+#
+# STEP 2 : FIND BORROWER
+# if there is a list of find borrowers....
+#
+my $borrowerslist;
+my $message;
+if ($findborrower) {
+	my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'cardnumber','web');
+	my @borrowers=@$borrowers;
+	if ($#borrowers == -1) {
+		$query->param('findborrower', '');
+		$message =  "'$findborrower'";
+	} elsif ($#borrowers == 0) {
+		$query->param('borrnumber', $borrowers[0]->{'borrowernumber'});
+		$query->param('barcode','');
+		$borrowernumber=$borrowers[0]->{'borrowernumber'};
+	} else {
+		$borrowerslist = \@borrowers;
+	}
+}
+
+# get the borrower information.....
+my $borrower;
+my $bornum=$query->param('bornum');
+if ($bornum){
+$borrowernumber=$bornum;
+}
+
+if ($borrowernumber) {
+	$borrower = C4::Members::getpatroninformation(\%env,$borrowernumber,0);
+	my ($od,$issue,$fines,$resfine)=borrdata3(\%env,$borrowernumber);
+if ($resfine >0 || $fines) {
+$template->param(
+			flagged => 1,
+			noissues => 'true',
+			 );
+}
+	$template->param(overduecount => $od,
+							issuecount => $issue,
+							finetotal => $fines,
+							resfine => $resfine);
+my $picture;
+ my $htdocs = C4::Context->config('opacdir');
+
+$picture =$htdocs. "/htdocs/uploaded-files/users-photo/".$borrower->{'cardnumber'}.".jpg";
+ if (-e $picture)
+{ 
+
+   $template->param(borrowerphoto => "http://library.neu.edu.tr/uploaded-files/users-photo/".$borrower->{'cardnumber'}.".jpg");
+ }else{
+$picture = "http://cc.neu.edu.tr/stdpictures/".$borrower->{'cardnumber'}.".jpg";
+  $template->param(borrowerphoto => $picture);
+}
+}
+$renew=$query->param('renew');
+
+#
+# STEP 3 : ISSUING
+#
+#Try to issue
+
+if ($barcode) {
+
+	$barcode = cuecatbarcodedecode($barcode);
+#	my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
+	if ($issueconfirmed) {
+			issuebookr(\%env, $borrower, $barcode, $cancelreserve);
+my ($od,$issue,$fines,$resfine)=borrdata3(\%env,$borrowernumber);
+	$template->param(overduecount => $od,
+							issuecount => $issue,
+							finetotal => $fines,
+							resfine => $resfine);
+logaction($loggedinuser,"circulation","issue",$barcode,$borrowernumber) if (&logstatus);
+
+	} else {
+		my ($error, $question) = canbookbeissuedr(\%env, $borrower, $barcode, $year, $month, $day);
+		my $noerror=1;
+		my $noquestion = 1;
+		foreach my $impossible (keys %$error) {
+			$template->param($impossible => $$error{$impossible},
+							IMPOSSIBLE => 1);
+			$noerror = 0;
+		}
+		foreach my $needsconfirmation (keys %$question) {
+			$template->param($needsconfirmation => $$question{$needsconfirmation},
+							NEEDSCONFIRMATION => 1);
+			$noquestion = 0;
+		}
+		$template->param(day => $day,
+						month => $month,
+						year => $year);
+		if ($noerror && ($noquestion || $issueconfirmed)) {
+			issuebookr(\%env, $borrower, $barcode);
+		logaction($loggedinuser,"circulation","issue",$barcode,$borrowernumber) if (&logstatus);
+
+			my ($od,$issue,$fines,$resfine)=borrdata3(\%env,$borrowernumber);
+				$template->param(overduecount => $od,
+							issuecount => $issue,
+							finetotal => $fines,
+							resfine => $resfine);
+		}
+	}
+	}#barcode
+
+
+
+
+
+##################################################################################
+# BUILD HTML
+
+# make the issued books table.....
+my $todaysissues='';
+my $previssues='';
+my @realtodayissues;
+my @realprevissues;
+my $allowborrow;
+if ($borrower) {
+# get each issue of the borrower & separate them in todayissues & previous issues
+	my @todaysissues;
+	my @previousissues;
+	my $issueslist = getissuesr($borrower);
+	
+	# split in 2 arrays for today & previous
+	foreach my $it (keys %$issueslist) {
+		my $issuedate = $issueslist->{$it}->{'timestamp'};
+		$issuedate = substr($issuedate, 0, 10);
+#warn "$todaysdate,$issuedate";
+		if ($todaysdate == $issuedate) {
+			push @todaysissues, $issueslist->{$it};
+		} else {
+			push @previousissues, $issueslist->{$it};
+		}
+    }
+
+
+	my $od; # overdues
+	my $togglecolor;
+	# parses today & build Template array
+	foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}} @todaysissues){
+		my $dd = $book->{'duetime'};
+		my $overdue = $book->{'overdue'};
+#		$dd=format_date($dd);
+#		$datedue=~s/-//g;
+		if ($overdue) {
+			$od = 1;
+		} else {
+			$od=0;
+		}
+		$book->{'od'}=$od;
+		$book->{'dd'}=$dd;
+		
+		if ($togglecolor) {
+			$togglecolor=0;
+		} else {
+			$togglecolor=1;
+		}
+		$book->{'tcolor'}=$togglecolor;
+		if ($book->{'author'} eq ''){
+			$book->{'author'}=' ';
+		}    
+		push @realtodayissues,$book;
+	}
+
+	# parses previous & build Template array
+    foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}} @previousissues){
+		my $dd = $book->{'duedate'};
+		my $overdue = $book->{'overdue'};
+#		$dd=format_date($dd);
+		my $pcolor = '';
+		my $od = '';
+#		$datedue=~s/-//g;
+		if ($overdue) {
+			$od = 1;
+		} else {
+			$od = 0;
+		}
+		
+		if ($togglecolor) {
+			$togglecolor=0;
+		} else {
+			$togglecolor=1;
+		}
+		$book->{'dd'}=$dd; 
+		$book->{'od'}=$od;
+		$book->{'tcolor'}=$togglecolor;
+		if ($book->{'author'} eq ''){
+			$book->{'author'}=' ';
+		}    
+		push @realprevissues,$book
+	}
+}
+
+
+my @values;
+my %labels;
+my $CGIselectborrower;
+if ($borrowerslist) {
+	foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowerslist){
+		push @values,$_->{'borrowernumber'};
+		$labels{$_->{'borrowernumber'}} ="$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ...  $_->{'streetaddress'} ";
+	}
+	$CGIselectborrower=CGI::scrolling_list( -name     => 'borrnumber',
+				-values   => \@values,
+				-labels   => \%labels,
+				-size     => 7,
+				-multiple => 0 );
+}
+#title
+
+my ($patrontable, $flaginfotable) = patrontable($borrower);
+my $amountold=$borrower->{flags}->{'CHARGES'}->{'message'};
+my @temp=split(/\$/,$amountold);
+$amountold=$temp[1];
+$template->param( today=>format_date($todaysdate),
+		findborrower => $findborrower,
+		borrower => $borrower,
+		borrowernumber => $borrowernumber,
+		branch => $branch,
+		printer => $printer,
+		branchname => $branches->{$branch}->{'branchname'},
+		printername => $printers->{$printer}->{'printername'},
+		firstname => $borrower->{'firstname'},
+		surname => $borrower->{'surname'},
+		categorycode => getborrowercategory($borrower->{'categorycode'}),
+		streetaddress => $borrower->{'streetaddress'},
+		emailaddress => $borrower->{'emailaddress'},
+		borrowernotes => $borrower->{'borrowernotes'},
+		city => $borrower->{'city'},
+		phone => $borrower->{'phone'},
+		cardnumber => $borrower->{'cardnumber'},
+		amountold => $amountold,
+		barcode => $barcode,
+		renew=>$renew,
+		stickyduedate => $stickyduedate,
+		message => $message,
+		CGIselectborrower => $CGIselectborrower,
+		todayissues => \@realtodayissues,
+		previssues => \@realprevissues,
+	);
+# set return date if stickyduedate
+if ($stickyduedate) {
+	my $t_year = "year".$year;
+	my $t_month = "month".$month;
+	my $t_day = "day".$day;
+	$template->param(
+		$t_year => 1,
+		$t_month => 1,
+		$t_day => 1,
+	);
+}
+
+
+if ($branchcookie) {
+    $cookie=[$cookie, $branchcookie, $printercookie];
+}
+
+output_html_with_http_headers $query, $cookie, $template->output;
+
+####################################################################
+# Extra subroutines,,,
+
+sub patrontable {
+    my ($borrower) = @_;
+    my $flags = $borrower->{'flags'};
+    my $flaginfotable='';
+    my $flaginfotext;
+    #my $flaginfotext='';
+    my $flag;
+    my $color='';
+    foreach $flag (sort keys %$flags) {
+#    	my @itemswaiting='';
+	$flags->{$flag}->{'message'}=~s/\n/<br>/g;
+	if ($flags->{$flag}->{'noissues'}) {
+		$template->param(
+			flagged => 1,
+			noissues => 'true',
+			 );
+		if ($flag eq 'GNA'){
+			$template->param(
+				gna => 'true'
+				);
+			}
+		if ($flag eq 'LOST'){
+			$template->param(
+				lost => 'true'
+			);
+			}
+		if ($flag eq 'DBARRED'){
+			$template->param(
+				dbarred => 'true'
+			);
+			}
+		if ($flag eq 'CHARGES') {
+			$template->param(
+				charges => 'true',
+				chargesmsg => $flags->{'CHARGES'}->{'message'}
+				 );
+		}
+	} else {
+		 if ($flag eq 'CHARGES') {
+			$template->param(
+				charges => 'true',
+				flagged => 1,
+				chargesmsg => $flags->{'CHARGES'}->{'message'}
+			 );
+		}
+	    	if ($flag eq 'WAITING') {
+			my $items=$flags->{$flag}->{'itemlist'};
+		        my @itemswaiting;
+			foreach my $item (@$items) {
+			my ($iteminformation) = C4::Circulation::Circ2::getiteminformation(\%env, $item->{'itemnumber'}, 0);
+			$iteminformation->{'branchname'} = $branches->{$iteminformation->{'holdingbranch'}}->{'branchname'};
+			push @itemswaiting, $iteminformation;
+			}
+			$template->param(
+				flagged => 1,
+				waiting => 'true',
+				waitingmsg => $flags->{'WAITING'}->{'message'},
+				itemswaiting => \@itemswaiting,
+				 );
+		}
+		if ($flag eq 'ODUES') {
+			$template->param(
+				odues => 'true',
+				flagged => 1,
+				oduesmsg => $flags->{'ODUES'}->{'message'}
+				 );
+
+			my $items=$flags->{$flag}->{'itemlist'};
+			{
+			    my @itemswaiting;
+			foreach my $item (@$items) {
+				my ($iteminformation) = C4::Circulation::Circ2::getiteminformation(\%env, $item->{'itemnumber'}, 0);
+				push @itemswaiting, $iteminformation;
+			}
+			}
+			if ($query->param('module') ne 'returns'){
+				$template->param( nonreturns => 'true' );
+			}
+		}
+		if ($flag eq 'NOTES') {
+			$template->param(
+				notes => 'true',
+				flagged => 1,
+				notesmsg => $flags->{'NOTES'}->{'message'}
+				 );
+		}
+	}
+    }
+    return($patrontable, $flaginfotext);
+}
+
+sub cuecatbarcodedecode {
+    my ($barcode) = @_;
+    chomp($barcode);
+    my @fields = split(/\./,$barcode);
+    my @results = map(decode($_), @fields[1..$#fields]);
+    if ($#results == 2){
+  	return $results[2];
+    } else {
+	return $barcode;
+    }
+}
+
+# Local Variables:
+# tab-width: 8
+# End:

Index: circ/resreturns.pl
===================================================================
RCS file: circ/resreturns.pl
diff -N circ/resreturns.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/resreturns.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,480 @@
+#!/usr/bin/perl
+# WARNING: This file contains mixed-sized tabs! (some 4-character, some 8)
+# WARNING: Currently, 4-character tabs seem to be dominant
+# WARNING: But there are still lots of 8-character tabs
+
+#written 11/3/2002 by Finlay
+#script to execute returns of books
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ3;
+use C4::Search;
+use C4::Output;
+use C4::Print;
+use C4::Reserves2;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Log;
+use C4::Koha;
+use C4::Members;
+my $query = new CGI;
+
+#getting the template
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/resreturns.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 1 },
+    }
+);
+
+#####################
+#Global vars
+my %env;
+my $headerbackgroundcolor = '#99cc33';
+my $linecolor1            = '#ffffcc';
+my $linecolor2            = 'white';
+
+my $branches = GetBranches();
+my $printers = getprinters( \%env );
+
+# my $branch  = getbranch( $query,  $branches );
+my $printer = getprinter( $query, $printers );
+
+#
+# Some code to handle the error if there is no branch or printer setting.....
+#
+my $branch=C4::Context->preference("defaultBranch");
+$env{'branchcode'} = $branch;
+$env{'printer'}    = $printer;
+$env{'queue'}      = $printer;
+
+# Set up the item stack ....
+my %returneditems;
+my %riduedate;
+my %riborrowernumber;
+my @inputloop;
+foreach ( $query->param ) {
+    (next) unless (/ri-(\d*)/);
+    my %input;
+    my $counter = $1;
+    (next) if ( $counter > 20 );
+    my $barcode        = $query->param("ri-$counter");
+    my $duedate        = $query->param("dd-$counter");
+    my $borrowernumber = $query->param("bn-$counter");
+    $counter++;
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+
+    ######################
+    #Are these lines still useful ?
+    $returneditems{$counter}    = $barcode;
+    $riduedate{$counter}        = $duedate;
+    $riborrowernumber{$counter} = $borrowernumber;
+
+    #######################
+    $input{counter} = $counter;
+    $input{barcode} = $barcode;
+    $input{duedate} = $duedate;
+    $input{bornum}  = $borrowernumber;
+    push ( @inputloop, \%input );
+}
+
+############
+# Deal with the requests....
+if ( $query->param('resbarcode') ) {
+    my $item       = $query->param('itemnumber');
+    my $borrnum    = $query->param('borrowernumber');
+    my $resbarcode = $query->param('resbarcode');
+
+    # set to waiting....
+    my $iteminfo = C4::Circulation::Circ2::getiteminformation( \%env, $item );
+    my $tobranchcd = ReserveWaiting( $item, $borrnum );
+    my $branchname = $branches->{$tobranchcd}->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $borrnum, 0 );
+    my $borcnum = $borr->{'cardnumber'};
+    my $name    =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my $slip = $query->param('resslip');
+    printslip( \%env, $slip ); #removed by paul
+
+    if ( $tobranchcd ne $branch ) {
+        $template->param(
+            itemtitle  => $iteminfo->{'title'},
+            iteminfo   => $iteminfo->{'author'},
+            branchname => $branchname,
+            name       => $name,
+            bornum     => $borrnum,
+            borcnum    => $borcnum,
+            diffbranch => 1
+        );
+    }
+}
+
+my $iteminformation;
+my $borrower;
+my $returned = 0;
+my $messages;
+
+my $barcode = $query->param('barcode');
+
+# actually return book and prepare item table.....
+if ($barcode) {
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+    ( $returned, $messages, $iteminformation, $borrower ) =
+      returnbookr( $barcode, $branch );
+    if ($returned) {
+        $returneditems{0}    = $barcode;
+        $riborrowernumber{0} = $borrower->{'borrowernumber'};
+        $riduedate{0}        = $iteminformation->{'date_due'};
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = $riduedate{0};
+        $input{bornum}  = $riborrowernumber{0};
+        push ( @inputloop, \%input );
+logaction($loggedinuser,"circulation","return",$barcode,$borrower->{'borrowernumber'}) if (&logstatus);
+
+    }
+    elsif ( !$messages->{'BadBarcode'} ) {
+		if ( $messages->{'NotIssued'} ) {
+		my $dbh = C4::Context->dbh;
+		my $sth=$dbh->prepare("select date_due from issues where itemnumber=? and isnull(returndate)");
+		$sth->execute($iteminformation->{'itemnumber'});
+		my ($date_due) = $sth->fetchrow;
+		
+		$sth->finish;
+			if ($date_due){	
+			print $query->redirect("/cgi-bin/koha/circ/returns.pl?barcode=$barcode");
+			}
+		}
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = 0;
+
+        $returneditems{0} = $barcode;
+        $riduedate{0}     = 0;
+        if ( $messages->{'wthdrawn'} ) {
+            $input{withdrawn} = 1;
+            $input{bornum}    = "Item Cancelled";
+            $riborrowernumber{0} = 'Item Cancelled';
+        }
+        else {
+            $input{bornum} = "&nbsp;";
+            $riborrowernumber{0} = '&nbsp;';
+        }
+        push ( @inputloop, \%input );
+    }
+    $template->param(
+        returned  => $returned,
+        itemtitle => $iteminformation->{'title'},
+
+        #									itembc => $iteminformation->{'barcode'},
+        #									itemdatedue => $iteminformation->{'date_due'},
+        itemauthor => $iteminformation->{'author'}
+    );
+}
+$template->param( inputloop => \@inputloop );
+
+my $found    = 0;
+my $waiting  = 0;
+my $reserved = 0;
+
+if ( $messages->{'ResFound'} ) {
+    my $res        = $messages->{'ResFound'};
+    my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
+    my $name =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my ($iteminfo) = getiteminformation( \%env, 0, $barcode );
+
+    if ( $res->{'ResFound'} eq "Waiting" ) {
+        $template->param(
+            found         => 1,
+            name          => $name,
+            borfirstname  => $borr->{'firstname'},
+            borsurname    => $borr->{'surname'},
+            bortitle      => $borr->{'title'},
+            borphone      => $borr->{'phone'},
+            borstraddress => $borr->{'streetaddress'},
+            borcity       => $borr->{'city'},
+            borzip        => $borr->{'zipcode'},
+            bornum        => $res->{'borrowernumber'},
+            borcnum       => $borr->{'cardnumber'},
+            branchname  => $branches->{ $res->{'branchcode'} }->{'branchname'},
+            waiting     => 1,
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'ctype'},
+            itembiblionumber => $iteminfo->{'biblionumber'}
+        );
+
+    }
+    if ( $res->{'ResFound'} eq "Reserved" ) {
+        my @da         = localtime( time() );
+        my $todaysdate =
+          sprintf( "%0.2d", ( $da[3] + 1 ) ) . "/"
+          . sprintf( "%0.2d", ( $da[4] + 1 ) ) . "/"
+          . ( $da[5] + 1900 );
+        $template->param(
+            found       => 1,
+            branchname  => $branches->{ $res->{'branchcode'} }->{'branchname'},
+            reserved    => 1,
+            today       => $todaysdate,
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'ctype'},
+            itembiblionumber => $iteminfo->{'biblionumber'},
+            borsurname       => $borr->{'surname'},
+            bortitle         => $borr->{'title'},
+            borfirstname     => $borr->{'firstname'},
+            bornum           => $res->{'borrowernumber'},
+            borcnum          => $borr->{'cardnumber'},
+            borphone         => $borr->{'phone'},
+            borstraddress    => $borr->{'streetaddress'},
+            borsub           => $borr->{'suburb'},
+            borcity          => $borr->{'city'},
+            borzip           => $borr->{'zipcode'},
+            boremail         => $borr->{'emailadress'},
+            barcode          => $barcode
+        );
+    }
+}
+
+# Error Messages
+my @errmsgloop;
+foreach my $code ( keys %$messages ) {
+
+   #     warn $code;
+    my %err;
+    my $exit_required_p = 0;
+    if ( $code eq 'BadBarcode' ) {
+        $err{badbarcode} = 1;
+        $err{msg}        = $messages->{'BadBarcode'};
+    }
+    elsif ( $code eq 'NotIssued' ) {
+        $err{notissued} = 1;
+        $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+    }
+    elsif ( $code eq 'WasLost' ) {
+        $err{waslost} = 1;
+    }
+    elsif ( $code eq 'ResFound' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasReturned' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasTransfered' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'wthdrawn' ) {
+        $err{withdrawn} = 1;
+        $exit_required_p = 1;
+    }
+    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
+        if ( $messages->{'IsPermanent'} ne $branch ) {
+            $err{ispermanent} = 1;
+            $err{msg}         =
+              $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+        }
+    }
+    else {
+        die "Unknown error code $code";    # XXX
+    }
+    if (%err) {
+        push ( @errmsgloop, \%err );
+    }
+    last if $exit_required_p;
+}
+$template->param( errmsgloop => \@errmsgloop );
+
+# patrontable ....
+if ($borrower) {
+    my $flags = $borrower->{'flags'};
+    my $color = '';
+    my @flagloop;
+    my $flagset;
+    foreach my $flag ( sort keys %$flags ) {
+        my %flaginfo;
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        unless ($flagset) { $flagset = 1; }
+        $flaginfo{color}   = $color;
+        $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
+        $flaginfo{flag}    = $flag;
+        if ( $flag eq 'CHARGES' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{charges} = 1;
+	    $flaginfo{bornum} = $borrower->{borrowernumber};
+        }
+        elsif ( $flag eq 'WAITING' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{waiting} = 1;
+            my @waitingitemloop;
+            my $items = $flags->{$flag}->{'itemlist'};
+            foreach my $item (@$items) {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %waitingitem;
+                $waitingitem{biblionum} = $iteminformation->{'biblionumber'};
+                $waitingitem{barcode}   = $iteminformation->{'barcode'};
+                $waitingitem{title}     = $iteminformation->{'title'};
+                $waitingitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @waitingitemloop, \%waitingitem );
+            }
+            $flaginfo{itemloop} = \@waitingitemloop;
+        }
+        elsif ( $flag eq 'ODUES' ) {
+            my $items = $flags->{$flag}->{'itemlist'};
+            my @itemloop;
+            foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+                @$items )
+            {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %overdueitem;
+                $overdueitem{duedate}   = $item->{'date_due'};
+                $overdueitem{biblionum} = $iteminformation->{'biblionumber'};
+                $overdueitem{barcode}   = $iteminformation->{'barcode'};
+                $overdueitem{title}     = $iteminformation->{'title'};
+                $overdueitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @itemloop, \%overdueitem );
+            }
+            $flaginfo{itemloop} = \@itemloop;
+            $flaginfo{overdue}  = 1;
+        }
+        else {
+            $flaginfo{other} = 1;
+            $flaginfo{msg}   = $flags->{$flag}->{'message'};
+        }
+        push ( @flagloop, \%flaginfo );
+    }
+    $template->param(
+        flagset        => $flagset,
+        flagloop       => \@flagloop,
+        ribornum       => $borrower->{'borrowernumber'},
+        riborcnum      => $borrower->{'cardnumber'},
+        riborsurname   => $borrower->{'surname'},
+        ribortitle     => $borrower->{'title'},
+        riborfirstname => $borrower->{'firstname'}
+    );
+}
+
+my $color = '';
+
+#set up so only the last 8 returned items display (make for faster loading pages)
+my $count = 0;
+my @riloop;
+foreach ( sort { $a <=> $b } keys %returneditems ) {
+    my %ri;
+    if ( $count < 8 ) {
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        $ri{color} = $color;
+        my $barcode = $returneditems{$_};
+        my $duedate = $riduedate{$_};
+        my $overduetext;
+        my $borrowerinfo;
+        if ($duedate) {
+            my @tempdate = split ( /-/, $duedate );
+	    $ri{year}=$tempdate[0];
+	    $ri{month}=$tempdate[1];
+	    $ri{day}=$tempdate[2];
+            my $duedatenz  = "$tempdate[2]/$tempdate[1]/$tempdate[0]";
+            my @datearr    = localtime( time() );
+            my $todaysdate =
+              $datearr[5] . '-'
+              . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+              . sprintf( "%0.2d", $datearr[3] );
+	    $ri{duedate}=$duedate;
+            my ($borrower) =              getpatroninformation( \%env, $riborrowernumber{$_}, 0 );
+            $ri{bornum}       = $borrower->{'borrowernumber'};
+            $ri{borcnum}      = $borrower->{'cardnumber'};
+            $ri{borfirstname} = $borrower->{'firstname'};
+            $ri{borsurname}   = $borrower->{'surname'};
+            $ri{bortitle}     = $borrower->{'title'};
+        }
+        else {
+            $ri{bornum} = $riborrowernumber{$_};
+        }
+#        my %ri;
+        my ($iteminformation) =C4::Circulation::Circ2::getiteminformation( \%env, 0, $barcode );
+        $ri{color}            = $color;
+        $ri{itembiblionumber} = $iteminformation->{'biblionumber'};
+        $ri{itemtitle}        = $iteminformation->{'title'};
+        $ri{itemauthor}       = $iteminformation->{'author'};
+        $ri{itemtype}         = $iteminformation->{'ctype'};
+        $ri{barcode}          = $barcode;
+    }
+    else {
+        last;
+    }
+    $count++;
+    push ( @riloop, \%ri );
+}
+$template->param( riloop => \@riloop );
+
+$template->param(
+    genbrname  => $branches->{$branch}->{'branchname'},
+    genprname  => $printers->{$printer}->{'printername'},
+    branch     => $branch,
+    printer    => $printer,
+    errmsgloop => \@errmsgloop
+);
+
+# actually print the page!
+output_html_with_http_headers $query, $cookie, $template->output;
+
+sub cuecatbarcodedecode {
+    my ($barcode) = @_;
+    chomp($barcode);
+    my @fields = split ( /\./, $barcode );
+    my @results = map( decode($_), @fields[ 1 .. $#fields ] );
+    if ( $#results == 2 ) {
+        return $results[2];
+    }
+    else {
+        return $barcode;
+    }
+}
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: circ/returns.pl
===================================================================
RCS file: circ/returns.pl
diff -N circ/returns.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/returns.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,474 @@
+#!/usr/bin/perl
+# WARNING: This file contains mixed-sized tabs! (some 4-character, some 8)
+# WARNING: Currently, 4-character tabs seem to be dominant
+# WARNING: But there are still lots of 8-character tabs
+
+#written 11/3/2002 by Finlay
+#script to execute returns of books
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ2;
+use C4::Search;
+use C4::Output;
+use C4::Print;
+use C4::Reserves2;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+use C4::Members;
+use C4::Date;
+use C4::Log;
+my $query = new CGI;
+
+#getting the template
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/returns.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 1 },
+    }
+);
+
+#####################
+#Global vars
+my %env;
+my $headerbackgroundcolor = '#99cc33';
+my $linecolor1            = '#ffffcc';
+my $linecolor2            = 'white';
+my $todaysdate =get_today();
+my $branches = GetBranches();
+my $printers = getprinters( \%env );
+
+# my $branch  = getbranch( $query,  $branches );
+my $printer = getprinter( $query, $printers );
+
+#
+# Some code to handle the error if there is no branch or printer setting.....
+#
+my $branch=C4::Context->preference("defaultBranch");
+$env{'branchcode'} = $branch;
+$env{'printer'}    = $printer;
+$env{'queue'}      = $printer;
+
+# Set up the item stack ....
+my %returneditems;
+my %riduedate;
+my %riborrowernumber;
+my @inputloop;
+foreach ( $query->param ) {
+    (next) unless (/ri-(\d*)/);
+    my %input;
+    my $counter = $1;
+    (next) if ( $counter > 20 );
+    my $barcode        = $query->param("ri-$counter");
+    my $duedate        = $query->param("dd-$counter");
+    my $borrowernumber = $query->param("bn-$counter");
+    $counter++;
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+
+    ######################
+    #Are these lines still useful ?
+    $returneditems{$counter}    = $barcode;
+    $riduedate{$counter}        = $duedate;
+    $riborrowernumber{$counter} = $borrowernumber;
+
+    #######################
+    $input{counter} = $counter;
+    $input{barcode} = $barcode;
+    $input{duedate} = $duedate;
+    $input{bornum}  = $borrowernumber;
+    push ( @inputloop, \%input );
+}
+
+############
+my $item;
+# Deal with the requests....
+if ( $query->param('resbarcode') ) {
+    $item       = $query->param('itemnumber');
+    my $borrnum    = $query->param('borrowernumber');
+    my $resbarcode = $query->param('resbarcode');
+
+    # set to waiting....
+    my $iteminfo = getiteminformation( \%env, $item );
+    my $tobranchcd = ReserveWaiting( $item, $borrnum );
+    my $branchname = $branches->{$tobranchcd}->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $borrnum, 0 );
+    my $borcnum = $borr->{'cardnumber'};
+    my $name    =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my $slip = $query->param('resslip');
+    printslip( \%env, $slip ); #removed by paul
+
+    if ( $tobranchcd ne $branch ) {
+        $template->param(
+            itemtitle  => $iteminfo->{'title'},
+            iteminfo   => $iteminfo->{'author'},
+            branchname => $branchname,
+            name       => $name,
+            bornum     => $borrnum,
+            borcnum    => $borcnum,
+            diffbranch => 1
+        );
+    }
+}
+
+my $iteminformation;
+my $borrower;
+my $returned = 0;
+my $messages;
+my $barcode = $query->param('barcode');
+
+# actually return book and prepare item table.....
+if ($barcode) {
+
+    # decode cuecat
+    $barcode = cuecatbarcodedecode($barcode);
+    ( $returned, $messages, $iteminformation, $borrower ) =      returnbook( $barcode, $branch );
+    if ($returned) {
+        $returneditems{0}    = $barcode;
+        $riborrowernumber{0} = $borrower->{'borrowernumber'};
+        $riduedate{0}        = $iteminformation->{'date_due'};
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = $riduedate{0};
+        $input{bornum}  = $riborrowernumber{0};
+        push ( @inputloop, \%input );
+logaction($loggedinuser,"circulation","return",$barcode,$borrower->{'borrowernumber'}) if (&logstatus);
+
+    }
+    elsif ( !$messages->{'BadBarcode'} ) {
+		if ( $messages->{'NotIssued'} ) {
+		my $dbh = C4::Context->dbh;
+		my $sth=$dbh->prepare("select duetime from reserveissue where itemnumber=? and isnull(rettime)");
+		$sth->execute($iteminformation->{'itemnumber'});
+		my ($date_due) = $sth->fetchrow;
+		
+		$sth->finish;
+			if ($date_due){
+#				$messages->{'ReserveIssued'} =$barcode;			
+			print $query->redirect("/cgi-bin/koha/circ/resreturns.pl?barcode=$barcode");
+			}
+		}
+        my %input;
+        $input{counter} = 0;
+        $input{first}   = 1;
+        $input{barcode} = $barcode;
+        $input{duedate} = 0;
+
+        $returneditems{0} = $barcode;
+        $riduedate{0}     = 0;
+        if ( $messages->{'wthdrawn'} ) {
+            $input{withdrawn} = 1;
+            $input{bornum}    = "Item Cancelled";
+            $riborrowernumber{0} = 'Item Cancelled';
+        }
+        else {
+            $input{bornum} = "&nbsp;";
+            $riborrowernumber{0} = '&nbsp;';
+        }
+        push ( @inputloop, \%input );
+    }
+    $template->param(
+        returned  => $returned,
+        itemtitle => $iteminformation->{'title'},
+
+        #									itembc => $iteminformation->{'barcode'},
+        #									itemdatedue => $iteminformation->{'datedue'},
+        itemauthor => $iteminformation->{'author'}
+    );
+}
+$template->param( inputloop => \@inputloop );
+
+my $found    = 0;
+my $waiting  = 0;
+my $reserved = 0;
+
+if ( $messages->{'ResFound'} ) {
+    my $res        = $messages->{'ResFound'};
+    my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
+    my $name =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my ($iteminfo) = getiteminformation( \%env, 0, $barcode );
+
+    if ( $res->{'ResFound'} eq "Waiting" ) {
+        $template->param(
+            found         => 1,
+            name          => $name,
+            borfirstname  => $borr->{'firstname'},
+            borsurname    => $borr->{'surname'},
+            bortitle      => $borr->{'title'},
+            borphone      => $borr->{'phone'},
+            borstraddress => $borr->{'streetaddress'},
+            borcity       => $borr->{'city'},
+            borzip        => $borr->{'zipcode'},
+            bornum        => $res->{'borrowernumber'},
+            borcnum       => $borr->{'cardnumber'},
+            branchname  => $branches->{ $res->{'branchcode'} }->{'branchname'},
+            waiting     => 1,
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'ctype'},
+            itembiblionumber => $iteminfo->{'biblionumber'}
+        );
+
+    }
+    if ( $res->{'ResFound'} eq "Reserved" ) {
+      
+        $template->param(
+            found       => 1,
+            branchname  => $branches->{ $res->{'branchcode'} }->{'branchname'},
+            reserved    => 1,
+            today       =>format_date( $todaysdate),
+            itemnumber  => $res->{'itemnumber'},
+            itemtitle   => $iteminfo->{'title'},
+            itemauthor  => $iteminfo->{'author'},
+            itembarcode => $iteminfo->{'barcode'},
+            itemtype    => $iteminfo->{'ctype'},
+            itembiblionumber => $iteminfo->{'biblionumber'},
+            borsurname       => $borr->{'surname'},
+            bortitle         => $borr->{'title'},
+            borfirstname     => $borr->{'firstname'},
+            bornum           => $res->{'borrowernumber'},
+            borcnum          => $borr->{'cardnumber'},
+            borphone         => $borr->{'phone'},
+            borstraddress    => $borr->{'streetaddress'},
+            borsub           => $borr->{'suburb'},
+            borcity          => $borr->{'city'},
+            borzip           => $borr->{'zipcode'},
+            boremail         => $borr->{'emailadress'},
+            barcode          => $barcode
+        );
+    }
+}
+
+# Error Messages
+my @errmsgloop;
+foreach my $code ( keys %$messages ) {
+
+    #    warn $code;
+    my %err;
+    my $exit_required_p = 0;
+    if ( $code eq 'BadBarcode' ) {
+        $err{badbarcode} = 1;
+        $err{msg}        = $messages->{'BadBarcode'};
+    }
+    elsif ( $code eq 'NotIssued' ) {
+        $err{notissued} = 1;
+        $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+    }
+    elsif ( $code eq 'WasLost' ) {
+        $err{waslost} = 1;
+    }
+    elsif ( $code eq 'ResFound' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasReturned' ) {
+        ;    # FIXME... anything to do here?
+    }
+    elsif ( $code eq 'WasTransfered' ) {
+        ;    # FIXME... anything to do here?
+    }
+	elsif ( $code eq 'ReserveIssued' ) {
+        $err{reserveissued} = 1;
+    }
+    elsif ( $code eq 'wthdrawn' ) {
+        $err{withdrawn} = 1;
+        $exit_required_p = 1;
+    }
+    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
+        if ( $messages->{'IsPermanent'} ne $branch ) {
+            $err{ispermanent} = 1;
+            $err{msg}         =
+              $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+        }
+    }
+    else {
+        die "Unknown error code $code";    # XXX
+    }
+    if (%err) {
+        push ( @errmsgloop, \%err );
+    }
+    last if $exit_required_p;
+}
+$template->param( errmsgloop => \@errmsgloop );
+
+# patrontable ....
+if ($borrower) {
+    my $flags = $borrower->{'flags'};
+    my $color = '';
+    my @flagloop;
+    my $flagset;
+    foreach my $flag ( sort keys %$flags ) {
+        my %flaginfo;
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        unless ($flagset) { $flagset = 1; }
+        $flaginfo{color}   = $color;
+        $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
+        $flaginfo{flag}    = $flag;
+        if ( $flag eq 'CHARGES' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{charges} = 1;
+	    $flaginfo{bornum} = $borrower->{borrowernumber};
+        }
+        elsif ( $flag eq 'WAITING' ) {
+            $flaginfo{msg}     = $flag;
+            $flaginfo{waiting} = 1;
+            my @waitingitemloop;
+            my $items = $flags->{$flag}->{'itemlist'};
+            foreach my $item (@$items) {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %waitingitem;
+                $waitingitem{biblionum} = $iteminformation->{'biblionumber'};
+                $waitingitem{barcode}   = $iteminformation->{'barcode'};
+                $waitingitem{title}     = $iteminformation->{'title'};
+                $waitingitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @waitingitemloop, \%waitingitem );
+            }
+            $flaginfo{itemloop} = \@waitingitemloop;
+        }
+        elsif ( $flag eq 'ODUES' ) {
+            my $items = $flags->{$flag}->{'itemlist'};
+            my @itemloop;
+            foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+                @$items )
+            {
+                my ($iteminformation) =
+                  getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+                my %overdueitem;
+                $overdueitem{duedate}   = $item->{'date_due'};
+                $overdueitem{biblionum} = $iteminformation->{'biblionumber'};
+                $overdueitem{barcode}   = $iteminformation->{'barcode'};
+                $overdueitem{title}     = $iteminformation->{'title'};
+                $overdueitem{brname}    =
+                  $branches->{ $iteminformation->{'holdingbranch'} }->{
+                  'branchname'};
+                push ( @itemloop, \%overdueitem );
+            }
+            $flaginfo{itemloop} = \@itemloop;
+            $flaginfo{overdue}  = 1;
+        }
+        else {
+            $flaginfo{other} = 1;
+            $flaginfo{msg}   = $flags->{$flag}->{'message'};
+        }
+        push ( @flagloop, \%flaginfo );
+    }
+    $template->param(
+        flagset        => $flagset,
+        flagloop       => \@flagloop,
+        ribornum       => $borrower->{'borrowernumber'},
+        riborcnum      => $borrower->{'cardnumber'},
+        riborsurname   => $borrower->{'surname'},
+        ribortitle     => $borrower->{'title'},
+        riborfirstname => $borrower->{'firstname'}
+    );
+}
+
+my $color = '';
+
+#set up so only the last 8 returned items display (make for faster loading pages)
+my $count = 0;
+my @riloop;
+foreach ( sort { $a <=> $b } keys %returneditems ) {
+    my %ri;
+    if ( $count < 8 ) {
+        ( $color eq $linecolor1 ) 
+          ? ( $color = $linecolor2 )
+          : ( $color = $linecolor1 );
+        $ri{color} = $color;
+        my $barcode = $returneditems{$_};
+        my $duedate = $riduedate{$_};
+        my $overduetext;
+        my $borrowerinfo;
+        if ($duedate) {
+           
+           
+	    $ri{duedate}=format_date($duedate);
+            my ($borrower) =
+              getpatroninformation( \%env, $riborrowernumber{$_}, 0 );
+            $ri{bornum}       = $borrower->{'borrowernumber'};
+            $ri{borcnum}      = $borrower->{'cardnumber'};
+            $ri{borfirstname} = $borrower->{'firstname'};
+            $ri{borsurname}   = $borrower->{'surname'};
+            $ri{bortitle}     = $borrower->{'title'};
+        }
+        else {
+            $ri{bornum} = $riborrowernumber{$_};
+        }
+#        my %ri;
+        my ($iteminformation) = getiteminformation( \%env, 0, $barcode );
+        $ri{color}            = $color;
+        $ri{itembiblionumber} = $iteminformation->{'biblionumber'};
+        $ri{itemtitle}        = $iteminformation->{'title'};
+        $ri{itemauthor}       = $iteminformation->{'author'};
+        $ri{itemtype}         = $iteminformation->{'ctype'};
+        $ri{barcode}          = $barcode;
+    }
+    else {
+        last;
+    }
+    $count++;
+    push ( @riloop, \%ri );
+}
+$template->param( riloop => \@riloop );
+
+$template->param(
+    genbrname  => $branches->{$branch}->{'branchname'},
+    genprname  => $printers->{$printer}->{'printername'},
+    branch     => $branch,
+    printer    => $printer,
+    errmsgloop => \@errmsgloop
+);
+
+# actually print the page!
+output_html_with_http_headers $query, $cookie, $template->output;
+
+sub cuecatbarcodedecode {
+    my ($barcode) = @_;
+$barcode=~s/ //g;
+    chomp($barcode);
+    my @fields = split ( /\./, $barcode );
+    my @results = map( decode($_), @fields[ 1 .. $#fields ] );
+    if ( $#results == 2 ) {
+        return $results[2];
+    }
+    else {
+        return $barcode;
+    }
+}
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: circ/selectbranchprinter.pl
===================================================================
RCS file: circ/selectbranchprinter.pl
diff -N circ/selectbranchprinter.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/selectbranchprinter.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,145 @@
+#!/usr/bin/perl
+# WARNING: This file uses 4-character tabs!
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use CGI;
+use C4::Circulation::Circ2;
+use C4::Output;
+use C4::Auth;
+use C4::Print;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+
+
+# this is a reorganisation of circulationold.pl
+# dividing it up into three scripts......
+# this will be the first one that chooses branch and printer settings....
+
+#general design stuff...
+my $headerbackgroundcolor='#99cc33';
+my $circbackgroundcolor='#ffffcc';
+my $circbackgroundcolor='white';
+my $linecolor1='#ffffcc';
+my $linecolor2='white';
+my $backgroundimage="/images/background-mem.gif";
+
+# try to get the branch and printer settings from the http....
+my %env;
+my $query=new CGI;
+my $branches=GetBranches('IS');
+my $printers=getprinters(\%env);
+my $branch=$query->param('branch');
+my $printer=$query->param('printer');
+
+($branch) || ($branch=$query->cookie('branch'));
+($printer) || ($printer=$query->cookie('printer'));
+
+($branches->{$branch}) || ($branch=(keys %$branches)[0]);
+($printers->{$printer}) || ($printer=(keys %$printers)[0]);
+
+
+# is you force a selection....
+my $oldbranch = $branch;
+my $oldprinter = $printer;
+
+#$branch='';
+#$printer='';
+
+
+$env{'branchcode'}=$branch;
+$env{'printer'}=$printer;
+$env{'queue'}=$printer;
+
+# set up select options....
+my $branchcount=0;
+my $printercount=0;
+my @branchloop;
+foreach my $br (keys %$branches) {
+    next unless $br =~ /\S/;
+    #(next) unless ($branches->{$_}->{'IS'}); # FIXME disabled to fix bug 202
+    $branchcount++;
+	my %branch;
+	$branch{selected}=($br eq $oldbranch);
+	$branch{name}=$branches->{$br}->{'branchname'};
+	$branch{value}=$br;
+    push(@branchloop,\%branch);
+}
+my @printerloop;
+foreach (keys %$printers) {
+    (next) unless ($_);
+    $printercount++;
+	my %printer;
+	$printer{selected}=($_ eq $oldprinter);
+	$printer{name}=$printers->{$_}->{'printername'};
+	$printer{value}=$_;
+    push(@printerloop,\%printer);
+}
+
+# if there is only one....
+my $printername;
+my $branchname;
+
+my $oneprinter=($printercount==1) ;
+my $onebranch=($branchcount==1) ;
+if ($printercount==1) {
+    my ($tmpprinter)=keys %$printers;
+	$printername=$printers->{$tmpprinter}->{printername};
+}
+if ($branchcount==1) {
+    my ($tmpbranch)=keys %$branches;
+	$branchname=$branches->{$tmpbranch}->{branchname};
+}
+
+
+#############################################################################################
+# Start writing page....
+# set header with cookie....
+
+my ($template, $borrowernumber, $cookie)
+    = get_template_and_user({template_name => "circ/selectbranchprinter.tmpl",
+							query => $query,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {circulate => 1},
+                         });
+$template->param(headerbackgroundcolor => $headerbackgroundcolor,
+							backgroundimage => $backgroundimage,
+							oneprinter => $oneprinter,
+							onebranch => $onebranch,
+							printername => $printername,
+							branchname => $branchname,
+							printerloop => \@printerloop,
+							branchloop => \@branchloop,
+							intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+		IntranetNav => C4::Context->preference("IntranetNav"),
+							);
+
+my $branchcookie=$query->cookie(-name => 'branch', -value => "$branch", -expires => '+1y');
+my $printercookie=$query->cookie(-name => 'printer', -value => "$printer", -expires => '+1y');
+
+my $cookies=[$cookie,$branchcookie, $printercookie]; 
+output_html_with_http_headers $query, $cookies, $template->output;
+
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: circ/waitingreservestransfers.pl
===================================================================
RCS file: circ/waitingreservestransfers.pl
diff -N circ/waitingreservestransfers.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ circ/waitingreservestransfers.pl	10 Mar 2007 11:54:16 -0000	1.1.2.1
@@ -0,0 +1,124 @@
+#!/usr/bin/perl
+
+# $Id: waitingreservestransfers.pl,v 1.1.2.1 2007/03/10 11:54:16 tgarip1957 Exp $
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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;
+use C4::Context;
+use C4::Interface::CGI::Output;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Circulation::Circ2;
+use C4::Koha;
+use C4::Biblio;
+
+my $input = new CGI;
+
+my $theme = $input->param('theme'); # only used if allowthemeoverride is set
+
+my ($template, $loggedinuser, $cookie)
+      = get_template_and_user({template_name => "circ/waitingreservestransfers.tmpl",
+	                                 query => $input,
+	                                 type => "intranet",
+	                                 authnotrequired => 0,
+	                                 flagsrequired => {borrowers => 1},
+	                                 debug => 1,
+	                                 });
+
+
+# set the userenv branch
+my $default = C4::Context->userenv->{'branch'};
+
+
+my $todaysdate =get_today();
+
+my $item=$input->param('itemnumber');
+my $fbr=$input->param('fbr');
+my $tbr=$input->param('tbr');
+# If we have a return of the form dotransfer, we launch the subroutine dotransfer
+if ($item){
+	C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr);
+}
+
+# get the all the branches for reference
+my $branches = GetBranches();
+my @branchesloop;
+foreach my $br (keys %$branches) {
+	my @reservloop;
+	my %branchloop;
+	$branchloop{'branchname'} = $branches->{$br}->{'branchname'};
+	$branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
+	my @getreserves = GetReservesToBranch($branches->{$br}->{'branchcode'},$default);
+		if (@getreserves){
+		foreach my $num (@getreserves) {
+			my %getreserv;
+			my %env;
+			my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
+			my $itemtypeinfo = getitemtypeinfo($gettitle->{'itemtype'});
+			if ($gettitle->{'holdingbranch'} eq $default){
+				my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'});
+				$getreserv{'reservedate'} = format_date($num->{'reservedate'});
+				my $calcDate=DATE_Add($num->{'reservedate'},C4::Context->preference('TransfersMaxDaysWarning'));
+				my $warning=DATE_Diff($todaysdate,$calcDate);
+				if ($warning>0){
+					$getreserv{'messcompa'} = 1;
+				}
+				$getreserv{'title'} = $gettitle->{'title'};
+				$getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
+				$getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
+				$getreserv{'barcode'} = $gettitle->{'barcode'};
+				$getreserv{'itemtype'} = $itemtypeinfo->{'description'};
+				$getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
+				$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
+				$getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
+				$getreserv{'borrowername'} = $getborrower->{'surname'};
+				$getreserv{'borrowerfirstname'} =  $getborrower->{'firstname'} ;
+				if ($getborrower->{'emailaddress'}){
+					$getreserv{'borrowermail'} =  $getborrower->{'emailaddress'} ;
+				}
+				$getreserv{'borrowerphone'} = $getborrower->{'phone'};
+				push(@reservloop, \%getreserv);
+			}
+		}
+# 		If we have a return of reservloop we put it in the branchloop sequence
+		if (@reservloop){
+		$branchloop{'reserv'} = \@reservloop ;
+		}
+# 		else, we unset the value of the branchcode .
+		else{
+		$branchloop{'branchcode'} = 0;
+		}
+	}
+	else {
+# 	if we don't have a retrun from reservestobranch we unset branchname and branchcode
+	$branchloop{'branchname'} = 0;
+	$branchloop{'branchcode'} = 0;
+	}
+	push(@branchesloop, \%branchloop);
+}
+
+	$template->param( branchesloop  => \@branchesloop,
+			show_date	=> format_date($todaysdate)	
+			 );
+	
+	print "Content-Type: text/html\n\n", $template->output;
+
+
+

Index: get-imdb.php
===================================================================
RCS file: get-imdb.php
diff -N get-imdb.php
--- get-imdb.php	10 Mar 2007 01:06:21 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,98 +0,0 @@
-<?php
-/*
-* Example using "file_get_contents"
-* note: allow_url_fopen = On in your php.ini should be On
-* safemode off
-*/
-
-$website=$_GET['website'];
-$oldbiblionumber=$_GET['oldbiblionumber'];
-$websitesummary=$website."/plotsummary";
-$imdb_website_summary = file_get_contents("${websitesummary}"); //movie Summary
-
-$imdb_website = file_get_contents("${website}"); //movie PI
-
-$filename=substr($website,27,9).".xml";
-//include the parser-class
-require("classes/class.imdb_parser.php");
-
-//init the class
-$IMDB_Parser = new IMDB_Parser;
-
-// output movie-picture (html)
-print "<p>".$IMDB_Parser->getMoviePictureHtml($imdb_website)."</p>";
-
-// output movie-languages (array)
- $xml='<?xml version="1.0" encoding="UTF-8"?>';
-$xml=$xml.'<record>';
-$xml.="<leader>     naa a22     7ar4500</leader>";
-foreach($IMDB_Parser->getMovieLanguage($imdb_website) as $value)
-{
-   $xml=$xml.'<datafield tag="40"><subfield code="a">'.$value.'</subfield></datafield>';
-}
-// output movie-title 
-$title=$IMDB_Parser->getMovieTitle($imdb_website);
-$date=substr($title,strlen($title)-5,4);
-$title= '<datafield tag="245"><subfield code="a">'.substr($title,0,strlen($title)-6).'</subfield>';
-$xml=$xml.$title;
-// output movie-directed by
- $xml=$xml.'<subfield code="c">'.$IMDB_Parser->getMovieDirectedBy($imdb_website).'</subfield><subfield code="h">DVD</subfield></datafield>';
-// output movie-country (array)
-
-foreach($IMDB_Parser->getMovieCountry($imdb_website) as $value)
-{
-   $xml=$xml.'<datafield tag="260"><subfield code="a">'.$value.'</subfield><subfield code="c">'.$date.'</subfield></datafield>';
-}
-
-
-// output movie-tagline
-$xml=$xml.'<datafield tag="500"> <subfield code="a">'.$IMDB_Parser->getMovieTagline($imdb_website).'</subfield></datafield>';
-
-// output movie-plot
-$xml=$xml.'<datafield tag="520"> <subfield code="a">'.$IMDB_Parser->getMoviePlot($imdb_website).'</subfield></datafield>';
-// output movie-summary
-foreach($IMDB_Parser->getMovieSummary($imdb_website_summary) as $value)
-{
-$xml=$xml.'<datafield tag="520"> <subfield code="a">'.$value.'</subfield></datafield>';
-}
-// output movie-genres (array)
-
-foreach($IMDB_Parser->getMovieGenres($imdb_website) as $value)
-{
-   $xml=$xml.'<datafield tag="650"> <subfield code="a">'.$value.'</subfield></datafield>';
-}
-
-// output movie-actors (array)
-foreach($IMDB_Parser->getMovieActors($imdb_website) as $value)
-{
- $xml=$xml.'<datafield tag="700"><subfield code="a">'.$value.'</subfield></datafield>';
-}
-
-
-
-
-// output movie-color
-//print "<br />Color: ".$IMDB_Parser->getMovieColor($imdb_website);
-
-$xml=$xml.'<datafield tag="856"><subfield code="u">'.$website.'</subfield></datafield>';
-
-// output movie-picture path
- $xml=$xml.'<datafield tag="956"> <subfield code="u">'.$IMDB_Parser->getMoviePicture($imdb_website).'</subfield></datafield>';
-$xml=$xml.'</record>';
-
-$dvd=fopen('c:/webservices/koha/intranet/htdocs/uploaded-files/tmp-pdf/'.$filename,'w');
-fwrite($dvd,$xml);
-fclose($dvd);
-
-
-print  "<a href=\"javascript:Import()\">Get: $title</a>
-<script language=\"JavaScript\" type=\"text/javascript\">
-	function Import() {
-		opener.document.location=\"cataloguing/addbiblio.pl?z3950=1&DVDid=$filename&oldbiblionumber=$oldbiblionumber\";
-		self.close();
-		return false;
-	}
-</script>"
-;
-//header("Location: /cgi-bin/koha/mainpage.pl?xml=$xml");
-?>





More information about the Koha-cvs mailing list