[Koha-cvs] koha/circ branchreserves.pl branchtransfers.pl ...
paul poulain
paul at koha-fr.org
Fri Mar 9 15:34:32 CET 2007
CVSROOT: /sources/koha
Module name: koha
Changes by: paul poulain <tipaul> 07/03/09 14:34:32
Modified files:
circ : branchreserves.pl branchtransfers.pl
circulation.pl currenttransfers.pl reserve.pl
returns.pl selectbranchprinter.pl
waitingreservestransfers.pl
Log message:
rel_3_0 moved to HEAD
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchreserves.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchtransfers.pl?cvsroot=koha&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/koha/circ/circulation.pl?cvsroot=koha&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/koha/circ/currenttransfers.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/circ/reserve.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/circ/returns.pl?cvsroot=koha&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/koha/circ/selectbranchprinter.pl?cvsroot=koha&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/koha/circ/waitingreservestransfers.pl?cvsroot=koha&r1=1.5&r2=1.6
Patches:
Index: branchreserves.pl
===================================================================
RCS file: /sources/koha/koha/circ/branchreserves.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- branchreserves.pl 15 Nov 2006 01:41:51 -0000 1.3
+++ branchreserves.pl 9 Mar 2007 14:34:31 -0000 1.4
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: branchreserves.pl,v 1.3 2006/11/15 01:41:51 tgarip1957 Exp $
+# $Id: branchreserves.pl,v 1.4 2007/03/09 14:34:31 tipaul Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -21,59 +21,72 @@
use strict;
use C4::Context;
+use C4::Output;
use CGI;
+use C4::Branch; # GetBranchName
use C4::Auth;
use C4::Date;
use C4::Circulation::Circ2;
+
+use Date::Calc qw(
+ Today
+ Add_Delta_YM
+ Date_to_Days
+);
use C4::Reserves2;
-use C4::Search;
use C4::Koha;
+use C4::Interface::CGI::Output;
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 $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",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/branchreserves.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {borrowers => 1},
+ flagsrequired => { circulate => 1 },
debug => 1,
- });
+ }
+);
my $default = C4::Context->userenv->{'branch'};
-my $dbh=C4::Context->dbh;
-my $todaysdate = get_today();
+my @datearr = localtime( time() );
+my $todaysdate =
+ ( 1900 + $datearr[5] ) . '-'
+ . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+ . sprintf( "%0.2d", $datearr[3] );
# if we have a return from the form we launch the subroutine CancelReserve
- if ($item){
+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'});
+ ( $messages, $nextreservinfo ) = GlobalCancel( $item, $borrowernumber );
+
+ # if we have a result
+ if ($nextreservinfo) {
+ my $borrowerinfo = getpatroninformation( \%env, $nextreservinfo );
+ my $iteminfo = C4::Circulation::Circ2::getiteminformation($item);
+ if ( $messages->{'transfert'} ) {
+ my $branchname = GetBranchName( $messages->{'transfert'} );
$template->param(
messagetransfert => $messages->{'transfert'},
branchname => $branchname,
);
}
- if ($messages->{'waiting'}){
+ if ( $messages->{'waiting'} ) {
$waiting = 1;
}
@@ -87,25 +100,36 @@
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);
- }
+ if ( ( $fbr ne $tbr ) and ( not $nextreservinfo ) ) {
+ C4::Circulation::Circ2::dotransfer( $item, $fbr, $tbr );
}
+}
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->{'itemtype'});
- $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){
+ my $gettitle = getiteminformation( $num->{'itemnumber'} );
+ my $getborrower = getpatroninformation( \%env, $num->{'borrowernumber'} );
+ my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
+ $getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} );
+
+ next unless $num->{'waitingdate'} ne '0000-00-00';
+ my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/,
+ $num->{'waitingdate'};
+ ( $waiting_year, $waiting_month, $waiting_day ) =
+ Add_Delta_YM( $waiting_year, $waiting_month, $waiting_day,
+ C4::Context->preference('ReservesMaxPickUpDelay'), 0 );
+ my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day );
+ my $today = Date_to_Days(&Today);
+ my $warning = ( $today > $calcDate );
+
+ if ( $warning > 0 ) {
$getreserv{'messcompa'} = 1;
}
$getreserv{'title'} = $gettitle->{'title'};
@@ -115,22 +139,23 @@
$getreserv{'itemtype'} = $itemtypeinfo->{'description'};
$getreserv{'homebranch'} = $gettitle->{'homebranch'};
$getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
- if ($gettitle->{'homebranch'} ne $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{'borrowerfirstname'} = $getborrower->{'firstname'};
+ if ( $getborrower->{'emailaddress'} ) {
+ $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
}
$getreserv{'borrowerphone'} = $getborrower->{'phone'};
- push(@reservloop, \%getreserv);
+ push( @reservloop, \%getreserv );
}
- $template->param( reserveloop => \@reservloop,
+$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: branchtransfers.pl
===================================================================
RCS file: /sources/koha/koha/circ/branchtransfers.pl,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- branchtransfers.pl 15 Nov 2006 01:41:51 -0000 1.26
+++ branchtransfers.pl 9 Mar 2007 14:34:31 -0000 1.27
@@ -4,7 +4,6 @@
#written 11/3/2002 by Finlay
#script to execute branch transfers of books
-
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@@ -25,32 +24,29 @@
use strict;
use CGI;
use C4::Circulation::Circ2;
+use C4::Output;
use C4::Reserves2;
use C4::Auth;
use C4::Interface::CGI::Output;
+use C4::Branch; # GetBranches
use C4::Koha;
-use C4::Members;
+
###############################################
# constants
my %env;
-my $linecolor1='#ffffcc';
-my $linecolor2='white';
-
-my $branches = GetBranches();
-my $printers = getprinters(\%env);
-
+my $branches = GetBranches;
+my $printers = GetPrinters( \%env );
###############################################
# Getting state
-my $query=new CGI;
+my $query = new CGI;
+my $branch = GetBranch( $query, $branches );
+my $printer = GetPrinter( $query, $printers );
-my $branch = getbranch($query, $branches);
-my $printer = getprinter($query, $printers);
-
-my $genbrname = $branches->{$branch}->{'branchname'} ;
+my $genbrname = $branches->{$branch}->{'branchname'};
my $genprname = $printers->{$printer}->{'printername'};
my $messages;
@@ -61,147 +57,161 @@
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;
+my $allmessages;
+
+my $request = $query->param('request');
+my $borrowernumber = $query->param('borrowernumber');
+
+my $tobranchcd = $query->param('tobranchcd');
+my $frbranchcd = '';
+
############
# Deal with the requests....
-if ($request eq "KillWaiting") {
+if ( $request eq "KillWaiting" ) {
my $item = $query->param('itemnumber');
- CancelReserve(0, $item, $borrnum);
+
+ CancelReserve( 0, $item, $borrowernumber );
$cancelled = 1;
- $reqmessage =1;
+ $reqmessage = 1;
+ $allmessages = 1;
}
my $ignoreRs = 0;
-if ($request eq "SetWaiting") {
+if ( $request eq "SetWaiting" ) {
my $item = $query->param('itemnumber');
- $tobranchcd = ReserveWaiting($item, $borrnum);
+ $tobranchcd = ReserveWaiting( $item, $borrowernumber );
$reqbrchname = $branches->{$tobranchcd}->{'branchname'};
$ignoreRs = 1;
$setwaiting = 1;
- $reqmessage =1;
+ $reqmessage = 1;
+ $allmessages = 1;
}
-if ($request eq 'KillReserved'){
+if ( $request eq 'KillReserved' ) {
my $biblio = $query->param('biblionumber');
- CancelReserve($biblio, 0, $borrnum);
+ CancelReserve( $biblio, 0, $borrowernumber );
$cancelled = 1;
- $reqmessage =1;
+ $reqmessage = 1;
+ $allmessages = 1;
}
-
-
# set up the branchselect options....
my @branchoptionloop;
-foreach my $br (keys %$branches) {
+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);
+ $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 $transfered;
my $barcode = $query->param('barcode');
if ($barcode) {
- my $transfered;
+
my $iteminformation;
- ($transfered, $messages, $iteminformation)
- = transferbook($tobranchcd, $barcode, $ignoreRs,$user);
+ ( $transfered, $messages, $iteminformation ) =
+ transferbook( $tobranchcd, $barcode, $ignoreRs );
$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->{'itemtype'};
- $item{'frbrname'}=$branches->{$frbranchcd}->{'branchname'};
- $item{'tobrname'}=$branches->{$tobranchcd}->{'branchname'};
+ my $frbranchcd = $iteminformation->{'frbranchcd'};
+ if ( not($found) ) {
+ $item{'biblionumber'} = $iteminformation->{'biblionumber'};
+ $item{'title'} = $iteminformation->{'title'};
+ $item{'author'} = $iteminformation->{'author'};
+ $item{'itemtype'} = $iteminformation->{'itemtype'};
+ $item{'ccode'} = $iteminformation->{'ccode'};
+ $item{'frbrname'} = $branches->{$frbranchcd}->{'branchname'};
+ $item{'tobrname'} = $branches->{$tobranchcd}->{'branchname'};
}
- $item{counter}=0;
- $item{barcode}=$barcode;
- $item{frombrcd}=$frbranchcd;
- $item{tobrcd}=$tobranchcd;
+ $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;
+ #Are these lines still useful ???
+ $transfereditems{0} = $barcode;
+ $frbranchcds{0} = $frbranchcd;
+ $tobranchcds{0} = $tobranchcd;
##########
- push (@trsfitemloop, \%item);
+ push( @trsfitemloop, \%item );
}
}
-foreach ($query->param){
+foreach ( $query->param ) {
(next) unless (/bc-(\d*)/);
- my $counter=$1;
+ my $counter = $1;
my %item;
- my $bc=$query->param("bc-$counter");
- my $frbcd=$query->param("fb-$counter");
- my $tobcd=$query->param("tb-$counter");
+ 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->{'itemtype'};
- $item{'frbrname'}=$branches->{$frbcd}->{'branchname'};
- $item{'tobrname'}=$branches->{$tobcd}->{'branchname'};
+ $item{counter} = $counter;
+ $item{barcode} = $bc;
+ $item{frombrcd} = $frbcd;
+ $item{tobrcd} = $tobcd;
+ my ($iteminformation) = getiteminformation( 0, $bc );
+ $item{'biblionumber'} = $iteminformation->{'biblionumber'};
+ $item{'title'} = $iteminformation->{'title'};
+ $item{'author'} = $iteminformation->{'author'};
+ $item{'itemtype'} = $iteminformation->{'itemtype'};
+ $item{'ccode'} = $iteminformation->{'ccode'};
+ $item{'frbrname'} = $branches->{$frbcd}->{'branchname'};
+ $item{'tobrname'} = $branches->{$tobcd}->{'branchname'};
##########
-#Are these lines still useful ???
- $transfereditems{$counter}=$bc;
- $frbranchcds{$counter}=$frbcd;
- $tobranchcds{$counter}=$tobcd;
+ #Are these lines still useful ???
+ $transfereditems{$counter} = $bc;
+ $frbranchcds{$counter} = $frbcd;
+ $tobranchcds{$counter} = $tobcd;
#########
- push (@trsfitemloop, \%item);
+ push( @trsfitemloop, \%item );
}
-
-my $name;
-my $bornum;
+my $title;
+my $surname;
+my $firstname;
+my $borphone;
+my $borstraddress;
+my $borcity;
+my $borzip;
+my $boremail;
my $borcnum;
my $itemnumber;
my $biblionum;
my $branchname;
-
+my $wastransferred;
#####################
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}
+ $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
+ my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
+ $title = $borr->{'title'};
+ $surname = $borr->{'surname'};
+ $firstname = $borr->{'firstname'};
+ $borrowernumber = $borr->{'borrowernumber'};
+ $borphone = $borr->{'phone'};
+ $borstraddress = $borr->{'streetaddress'};
+ $borcity = $borr->{'city'};
+ $borzip = $borr->{'zipcode'};
+ $boremail = $borr->{'emailadress'};
+
+ #Hopefully, borr->{borrowernumber}=res->{borrowernumber}
$borcnum = $borr->{'cardnumber'};
$itemnumber = $res->{'itemnumber'};
- if ($res->{'ResFound'} eq "Waiting") {
+ if ( $res->{'ResFound'} eq "Waiting" ) {
$waiting = 1;
}
- if ($res->{'ResFound'} eq "Reserved") {
+ if ( $res->{'ResFound'} eq "Reserved" ) {
$reserved = 1;
$biblionum = $res->{'biblionumber'};
}
@@ -210,53 +220,77 @@
#####################
my @errmsgloop;
-foreach my $code (keys %$messages) {
+foreach my $code ( keys %$messages ) {
my %err;
- $err{errbadcode} = ($code eq 'BadBarcode');
- if ($code eq 'BadBarcode') {
- $err{msg}=$messages->{'BadBarcode'};
+
+ if ( $code eq 'BadBarcode' ) {
+ $err{msg} = $messages->{'BadBarcode'};
+ $err{errbadcode} = 1;
+ $allmessages = 1;
}
- $err{errispermanent} = ($code eq 'IsPermanent');
- if ($code eq 'IsPermanent'){
- $err{msg} = $branches->{$messages->{'IsPermanent'}}->{'branchname'};
+ if ( $code eq 'IsPermanent' ) {
+ $err{errispermanent} = 1;
+ $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+
# Here, msg contains the branchname
# Not so satisfied with this... But should work
+ $allmessages = 1;
}
- $err{errdesteqholding} = ($code eq 'DestinationEqualsHolding');
+ $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...
+ if ( $code eq 'WasReturned' ) {
+ $err{errwasreturned} = 1;
+ $allmessages = 1;
+ my ($borrowerinfo) =
+ getpatroninformation( \%env, $messages->{'WasReturned'}, 0 );
+ $title = $borrowerinfo->{'title'};
+ $surname = $borrowerinfo->{'surname'};
+ $firstname = $borrowerinfo->{'firstname'};
+ $borrowernumber = $borrowerinfo->{'borrowernumber'};
+ $borcnum = $borrowerinfo->{'cardnumber'};
}
- push (@errmsgloop, \%err);
-}
+ # if ($code eq 'WasTransfered'){
+ # Put code here if you want to notify the user that item was transfered...
+ # $wastransferred = 1;
+ # }
+ push( @errmsgloop, \%err );
+}
#######################################################################################
# Make the page .....
-my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "circ/branchtransfers.tmpl",
+my ( $template, $cookie );
+( $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,
+ flagsrequired => { circulate => 1 },
+ }
+);
+if ($allmessages) {
+ $template->param( allmessages => 1 );
+}
+
+$template->param(
+ genbrname => $genbrname,
genprname => $genprname,
branch => $branch,
printer => $printer,
found => $found,
reserved => $reserved,
waiting => $waiting,
- name => $name,
- bornum => $bornum,
+ title => $title,
+ surname => $surname,
+ firstname => $firstname,
+ borphone => $borphone,
+ borstraddress => $borstraddress,
+ borcity => $borcity,
+ borzip => $borzip,
+ boremail => $boremail,
+ borrowernumber => $borrowernumber,
borcnum => $borcnum,
branchname => $branchname,
itemnumber => $itemnumber,
@@ -266,16 +300,22 @@
reqmessage => $reqmessage,
cancelled => $cancelled,
setwaiting => $setwaiting,
+ wastransferred => $wastransferred,
trsfitemloop => \@trsfitemloop,
branchoptionloop => \@branchoptionloop,
- errmsgloop => \@errmsgloop
- );
+ errmsgloop => \@errmsgloop,
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
output_html_with_http_headers $query, $cookie, $template->output;
-
sub name {
my ($borinfo) = @_;
- return $borinfo->{'surname'}." ".$borinfo->{'title'}." ".$borinfo->{'firstname'};
+ return $borinfo->{'surname'} . " "
+ . $borinfo->{'title'} . " "
+ . $borinfo->{'firstname'};
}
# Local Variables:
Index: circulation.pl
===================================================================
RCS file: /sources/koha/koha/circ/circulation.pl,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- circulation.pl 15 Nov 2006 01:41:51 -0000 1.99
+++ circulation.pl 9 Mar 2007 14:34:32 -0000 1.100
@@ -2,9 +2,8 @@
# 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
+# written 8/5/2002 by Finlay
+# script to execute issuing of books
# Copyright 2000-2002 Katipo Communications
#
@@ -26,86 +25,121 @@
use strict;
use CGI;
use C4::Circulation::Circ2;
-use C4::Search;
+use C4::Members;
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;
+use C4::Branch; # GetBranches
+use C4::Koha; # GetPrinter
+use Date::Calc qw(
+ Today
+ Today_and_Now
+ Add_Delta_YM
+ Add_Delta_Days
+ Date_to_Days
+);
+
+use C4::Biblio;
+use C4::Reserves2;
+use C4::Circulation::Date;
+#
# PARAMETERS READING
#
-my $query=new CGI;
+my $query = new CGI;
-my ($template, $loggedinuser, $cookie) = get_template_and_user
- ({
+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 $printers = GetPrinters();
+my $printer = GetPrinter($query, $printers);
my $findborrower = $query->param('findborrower');
$findborrower =~ s|,| |g;
$findborrower =~ s|'| |g;
-my $borrowernumber = $query->param('borrnumber');
+my $borrowernumber = $query->param('borrowernumber');
+
+# new op dev the branch and the printer are now defined by the userenv
+my $branch = C4::Context->userenv->{'branch'};
+my $printer = C4::Context->userenv->{'branchprinter'};
+
+# If Autolocated is not activated, we show the Circulation Parameters to chage settings of librarian
+ if (C4::Context->preference("AutoLocation") ne 1)
+ {
+ $template->param(
+ ManualLocation => 1,
+ );
+ }
-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 $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},)
-}
+my $organisation = $query->param('organisations');
+my $print = $query->param('print');
+
#set up cookie.....
-my $branchcookie;
-my $printercookie;
-#if ($query->param('setcookies')) {
+# 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...
+my %env
+ ; # FIXME env is used as an "environment" variable. Could be dropped probably...
-$env{'branchcode'}=$branch;
-$env{'printer'}=$printer;
-$env{'queue'}=$printer;
+#
+$env{'branchcode'} = $branch;
+$env{'printer'} = $printer;
+$env{'organisation'} = $organisation;
+
+# $env{'queue'}=$printer;
+
+my @datearr = localtime( time() );
+
+# FIXME - Could just use POSIX::strftime("%Y%m%d", localtime);
+my $todaysdate =
+ ( 1900 + $datearr[5] )
+ . sprintf( "%0.2d", ( $datearr[4] + 1 ) )
+ . sprintf( "%0.2d", ( $datearr[3] ) );
+# check and see if we should print
+if ( $barcode eq '' && $print eq 'maybe' ) {
+ $print = 'yes';
+}
-my $todaysdate =get_today();
+my $inprocess = $query->param('inprocess');
+if ( $barcode eq '' ) {
+ $inprocess = '';
+}
+else {
+}
+if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
+ $template->param(
+ PAYCHARGES => 'yes',
+ borrowernumber => $borrowernumber
+ );
+}
-# 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='';
- }
+if ( $print eq 'yes' && $borrowernumber ne '' ) {
+ printslip( \%env, $borrowernumber );
+ $query->param( 'borrowernumber', '' );
+ $borrowernumber = '';
+}
#
# STEP 2 : FIND BORROWER
@@ -114,350 +148,513 @@
my $borrowerslist;
my $message;
if ($findborrower) {
- my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'cardnumber','web');
- my @borrowers=@$borrowers;
- if ($#borrowers == -1) {
- $query->param('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 {
+ }
+ elsif ( $#borrowers == 0 ) {
+ $query->param( 'borrowernumber', $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;
+my @lines;
+
if ($borrowernumber) {
- $borrower = getpatroninformation(\%env,$borrowernumber,0);
- my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
-my $warning;
-
- $template->param(overduecount => $od,
- issuecount => $issue.$warning,
- 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);
-}
+ $borrower = getpatroninformation( \%env, $borrowernumber, 0 );
+ my ( $od, $issue, $fines ) = borrdata2( \%env, $borrowernumber );
+
+ # Warningdate is the date that the warning starts appearing
+ my ( $today_year, $today_month, $today_day ) = Today();
+ my ( $warning_year, $warning_month, $warning_day ) = split /-/,
+ $borrower->{'dateexpiry'};
+
+ # Renew day is calculated by adding the enrolment period to today
+ my ( $renew_year, $renew_month, $renew_day ) =
+ Add_Delta_YM( $today_year, $today_month, $today_day,
+ $borrower->{'enrolmentperiod'}, 0 );
+ # if the expiry date is before today
+ if ( Date_to_Days( $today_year, $today_month, $today_day ) >
+ Date_to_Days( $warning_year, $warning_month, $warning_day ) )
+ {
+
+ #borrowercard expired or nearly expired, warn the librarian
+ $template->param(
+ flagged => "1",
+ warndeparture => "1",
+ renewaldate => "$renew_year-$renew_month-$renew_day"
+ );
+ }
+ # check for NotifyBorrowerDeparture
+ if (C4::Context->preference('NotifyBorrowerDeparture') &&
+ Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
+ Date_to_Days( $today_year, $today_month, $today_day ) )
+ {
+ $template->param("warndeparture" => 1);
+ }
+ $template->param(
+ overduecount => $od,
+ issuecount => $issue,
+ finetotal => $fines
+ );
}
#
# STEP 3 : ISSUING
#
-#Try to issue
-
+#
if ($barcode) {
-
$barcode = cuecatbarcodedecode($barcode);
- my ($datedue, $invalidduedate) = fixdate($year, $month, $day);
+ my ( $datedue, $invalidduedate ) = fixdate( $year, $month, $day );
if ($issueconfirmed) {
- issuebook(\%env, $borrower, $barcode, $datedue,$cancelreserve);
- my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
- my $warning;
-
- $template->param(overduecount => $od,
- issuecount => $issue.$warning,
- finetotal => $fines);
-
- } else {
- my ($error, $question) = canbookbeissued(\%env, $borrower, $barcode, $year, $month, $day) unless %error;
- $error=\%error if %error;
-
- my $noerror=1;
+ issuebook( \%env, $borrower, $barcode, $datedue, $cancelreserve );
+ $inprocess = 1;
+ }
+ else {
+ my ( $error, $question ) =
+ canbookbeissued( \%env, $borrower, $barcode, $year, $month, $day,
+ $inprocess );
+ my $noerror = 1;
my $noquestion = 1;
- foreach my $impossible (keys %$error) {
- $template->param($impossible => $$error{$impossible},
- IMPOSSIBLE => 1) unless ($impossible eq 'SUCCESFULL_RENEW');
+# Get the item title for more information
+ my $getmessageiteminfo = getiteminformation( undef, $barcode );
+
+ 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);
+ foreach my $needsconfirmation ( keys %$question ) {
+ $template->param(
+ $needsconfirmation => $$question{$needsconfirmation},
+ getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
+ NEEDSCONFIRMATION => 1
+ );
$noquestion = 0;
}
- $template->param(day => $day,
+ $template->param(
+ day => $day,
month => $month,
- year => $year);
- if ($noerror && ($noquestion || $issueconfirmed)) {
-
- issuebook(\%env, $borrower, $barcode, $datedue);
- my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber);
- my $warning;
-
- $template->param(overduecount => $od,
- issuecount => $issue.$warning,
- finetotal => $fines);
+ year => $year
+ );
+ if ( $noerror && ( $noquestion || $issueconfirmed ) ) {
+ issuebook( \%env, $borrower, $barcode, $datedue );
+ $inprocess = 1;
}
}
+# FIXME If the issue is confirmed, we launch another time borrdata2, now display the issue count after issue
+ my ( $od, $issue, $fines ) = borrdata2( \%env, $borrowernumber );
+ $template->param(
+ issuecount => $issue,
+ );
}
-
-
+# reload the borrower info for the sake of reseting the flags.....
+if ($borrowernumber) {
+ $borrower = getpatroninformation( \%env, $borrowernumber, 0 );
+}
##################################################################################
# BUILD HTML
+# show all reserves of this borrower, and the position of the reservation ....
+if ($borrowernumber) {
+
+ # new op dev
+ # now we show the status of the borrower's reservations
+ my @borrowerreserv = GetReservations( 0, $borrowernumber );
+ my @reservloop;
+ my @WaitingReserveLoop;
+
+ foreach my $num_res (@borrowerreserv) {
+ my %getreserv;
+ my %getWaitingReserveInfo;
+ my %env;
+ my $getiteminfo = getiteminformation( $num_res->{'itemnumber'} );
+ my $itemtypeinfo = getitemtypeinfo( $getiteminfo->{'itemtype'} );
+ my ( $transfertwhen, $transfertfrom, $transfertto ) =
+ checktransferts( $num_res->{'itemnumber'} );
+
+ $getreserv{waiting} = 0;
+ $getreserv{transfered} = 0;
+ $getreserv{nottransfered} = 0;
+
+ $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
+ $getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
+ $getreserv{title} = $getiteminfo->{'title'};
+ $getreserv{itemtype} = $itemtypeinfo->{'description'};
+ $getreserv{author} = $getiteminfo->{'author'};
+ $getreserv{barcodereserv} = $getiteminfo->{'barcode'};
+ $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
+
+ # check if we have a waiting status for reservations
+ if ( $num_res->{'found'} eq 'W' ) {
+ $getreserv{color} = 'reserved';
+ $getreserv{waiting} = 1;
+# genarate information displaying only waiting reserves
+ $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
+ $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
+ $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
+ $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
+ if ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} ) {
+ $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
+ }
+
+ }
+ # check transfers with the itemnumber foud in th reservation loop
+ if ($transfertwhen) {
+ $getreserv{color} = 'transfered';
+ $getreserv{transfered} = 1;
+ $getreserv{datesent} = format_date($transfertwhen);
+ $getreserv{frombranch} = GetBranchName($transfertfrom);
+ }
+
+ if ( ( $getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'} )
+ and not $transfertwhen )
+ {
+ $getreserv{nottransfered} = 1;
+ $getreserv{nottransferedby} =
+ GetBranchName( $getiteminfo->{'holdingbranch'} );
+ }
+
+# if we don't have a reserv on item, we put the biblio infos and the waiting position
+ if ( $getiteminfo->{'title'} eq '' ) {
+ my $getbibinfo = GetBiblioItemData( $num_res->{'biblionumber'} );
+ my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} );
+ $getreserv{color} = 'inwait';
+ $getreserv{title} = $getbibinfo->{'title'};
+ $getreserv{waitingposition} = $num_res->{'priority'};
+ $getreserv{nottransfered} = 0;
+ $getreserv{itemtype} = $getbibtype->{'description'};
+ $getreserv{author} = $getbibinfo->{'author'};
+ $getreserv{itemcallnumber} = '----------';
+
+ }
+ push( @reservloop, \%getreserv );
+
+# if we have a reserve waiting, initiate waitingreserveloop
+ if ($getreserv{waiting} eq 1) {
+ push (@WaitingReserveLoop, \%getWaitingReserveInfo)
+ }
+
+ }
-# make the issued books table.....
-my $todaysissues='';
-my $previssues='';
+ # return result to the template
+ $template->param(
+ countreserv => scalar @reservloop,
+ reservloop => \@reservloop ,
+ WaitingReserveLoop => \@WaitingReserveLoop,
+ );
+}
+
+# make the issued books table.
+my $todaysissues = '';
+my $previssues = '';
my @realtodayissues;
my @realprevissues;
-#my @renewissues;
my $allowborrow;
+## ADDED BY JF: new itemtype issuingrules counter stuff
+my $issued_itemtypes_loop;
+my $issued_itemtypes_count;
+my $issued_itemtypes_allowed_count; # hashref with total allowed by itemtype
+my $issued_itemtypes_remaining; # hashref with remaining
+my $issued_itemtypes_flags; #hashref that stores flags
+
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) {
+ # split in 2 arrays for today & previous
+ my $dbh = C4::Context->dbh;
+ foreach my $it ( keys %$issueslist ) {
+ my $issuedate = $issueslist->{$it}->{'timestamp'};
+ $issuedate =~ s/-//g;
+ $issuedate = substr( $issuedate, 0, 8 );
+
+ # to let perl sort this correctly
+ $issueslist->{$it}->{'timestamp'} =~ s/(-|\:| )//g;
+
+ if ( $todaysdate == $issuedate ) {
+ (
+ $issueslist->{$it}->{'charge'},
+ $issueslist->{$it}->{'itemtype_charge'}
+ )
+ = calc_charges(
+ $dbh,
+ $issueslist->{$it}->{'itemnumber'},
+ $borrower->{'borrowernumber'}
+ );
+ $issueslist->{$it}->{'charge'} =
+ sprintf( "%.2f", $issueslist->{$it}->{'charge'} );
+ (
+ $issueslist->{$it}->{'can_renew'},
+ $issueslist->{$it}->{'can_renew_error'}
+ )
+ = renewstatus(
+ \%env,
+ $borrower->{'borrowernumber'},
+ $issueslist->{$it}->{'itemnumber'}
+ );
+ my ( $restype, $reserves ) =
+ CheckReserves( $issueslist->{$it}->{'itemnumber'} );
+ if ($restype) {
+ $issueslist->{$it}->{'can_renew'} = 0;
+ }
push @todaysissues, $issueslist->{$it};
- } else {
+ }
+ else {
+ (
+ $issueslist->{$it}->{'charge'},
+ $issueslist->{$it}->{'itemtype_charge'}
+ )
+ = calc_charges(
+ $dbh,
+ $issueslist->{$it}->{'itemnumber'},
+ $borrower->{'borrowernumber'}
+ );
+ $issueslist->{$it}->{'charge'} =
+ sprintf( "%.2f", $issueslist->{$it}->{'charge'} );
+ (
+ $issueslist->{$it}->{'can_renew'},
+ $issueslist->{$it}->{'can_renew_error'}
+ )
+ = renewstatus(
+ \%env,
+ $borrower->{'borrowernumber'},
+ $issueslist->{$it}->{'itemnumber'}
+ );
+ my ( $restype, $reserves ) =
+ CheckReserves( $issueslist->{$it}->{'itemnumber'} );
+ if ($restype) {
+ $issueslist->{$it}->{'can_renew'} = 0;
+ }
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){
+ foreach my $book ( sort { $b->{'timestamp'} <=> $a->{'timestamp'} }
+ @todaysissues )
+ {
+ #warn "TIMESTAMP".$book->{'timestamp'};
+ # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+ $issued_itemtypes_count->{ $book->{'itemtype'} }++;
+
my $dd = $book->{'date_due'};
my $datedue = $book->{'date_due'};
- $dd=format_date($dd);
-# $datedue=~s/-//g;
- if ($datedue lt $todaysdate) {
+ #$dd=format_date($dd);
+ $datedue =~ s/-//g;
+ if ( $datedue < $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'}=' ';
+ else {
+ $od = 0;
+ }
+ if ( $i % 2 ) {
+ $togglecolor = 0;
+ }
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'od'} = format_date($od);
+ $book->{'dd'} = format_date($dd);
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
}
- push @realtodayissues,$book;
+ push @realtodayissues, $book;
$i++;
}
+ # parses previous & build Template array
+ $i = 0;
+ foreach my $book ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+ @previousissues )
+ {
+ # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+ $issued_itemtypes_count->{ $book->{'itemtype'} }++;
- # 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 $dd = format_date($book->{'date_due'});
+ my $datedue = format_date($book->{'date_due'});
+
+ #$dd=format_date($dd);
my $pcolor = '';
my $od = '';
-# $datedue=~s/-//g;
- if ($datedue lt $todaysdate) {
-
+ $datedue =~ s/-//g;
+ if ( $datedue < $todaysdate ) {
$od = 1;
- } else {
+ }
+ 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'}=' ';
+ if ( $i % 2 ) {
+ $togglecolor = 0;
}
-
- push @realprevissues,$book;
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'dd'} = $dd;
+ $book->{'od'} = $od;
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
+ }
+ push @realprevissues, $book;
$i++;
}
+}
-}#borrower
+#### ADDED BY JF FOR COUNTS BY ITEMTYPE RULES
+# FIXME: This should utilize all the issuingrules options rather than just the defaults
+# and it should be moved to a module
+my $dbh = C4::Context->dbh;
+
+# how many of each is allowed?
+my $issueqty_sth = $dbh->prepare( "
+SELECT itemtypes.description AS description,issuingrules.itemtype,maxissueqty
+FROM issuingrules
+ LEFT JOIN itemtypes ON (itemtypes.itemtype=issuingrules.itemtype)
+ WHERE categorycode=?
+" );
+my @issued_itemtypes_count;
+$issueqty_sth->execute("*");
+while ( my $data = $issueqty_sth->fetchrow_hashref() ) {
+
+ # subtract how many of each this borrower has
+ $data->{'count'} = $issued_itemtypes_count->{ $data->{'description'} };
+ $data->{'left'} =
+ ( $data->{'maxissueqty'} -
+ $issued_itemtypes_count->{ $data->{'description'} } );
+
+ # can't have a negative number of remaining
+ if ( $data->{'left'} < 0 ) { $data->{'left'} = "0" }
+ $data->{'flag'} = 1 unless ( $data->{'maxissueqty'} > $data->{'count'} );
+ unless ( ( $data->{'maxissueqty'} < 1 )
+ || ( $data->{'itemtype'} eq "*" )
+ || ( $data->{'itemtype'} eq "CIRC" ) )
+ {
+ push @issued_itemtypes_count, $data;
+ }
+}
+$issued_itemtypes_loop = \@issued_itemtypes_count;
+#### / JF
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'} ";
+ foreach (
+ sort {
+ $a->{'surname'}
+ . $a->{'firstname'} cmp $b->{'surname'}
+ . $b->{'firstname'}
+ } @$borrowerslist
+ )
+ {
+ push @values, $_->{'borrowernumber'};
+ $labels{ $_->{'borrowernumber'} } =
+"$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ... $_->{'address'} ";
}
- $CGIselectborrower=CGI::scrolling_list( -name => 'borrnumber',
+ $CGIselectborrower = CGI::scrolling_list(
+ -name => 'borrowernumber',
-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,
+ -tabindex => '',
+ -multiple => 0
);
}
+#title
+my $flags = $borrower->{'flags'};
+my $flag;
-if ($branchcookie) {
- $cookie=[$cookie, $branchcookie, $printercookie];
-}
-
-output_html_with_http_headers $query, $cookie, $template->output;
-
-####################################################################
-# Extra subroutines,,,
+foreach $flag ( sort keys %$flags ) {
-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'}) {
+ $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 'GNA' ) {
+ $template->param( gna => 'true' );
}
- if ($flag eq 'LOST'){
- $template->param(
- lost => 'true'
- );
+ if ( $flag eq 'LOST' ) {
+ $template->param( lost => 'true' );
}
- if ($flag eq 'DBARRED'){
- $template->param(
- dbarred => 'true'
- );
+ if ( $flag eq 'DBARRED' ) {
+ $template->param( dbarred => 'true' );
}
- if ($flag eq 'CHARGES') {
+ if ( $flag eq 'CHARGES' ) {
$template->param(
charges => 'true',
chargesmsg => $flags->{'CHARGES'}->{'message'}
);
}
- } else {
- if ($flag eq 'CHARGES') {
+ if ( $flag eq 'CREDITS' ) {
+ $template->param(
+ credits => 'true',
+ creditsmsg => $flags->{'CREDITS'}->{'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;
- }
+ if ( $flag eq 'CREDITS' ) {
$template->param(
- flagged => 1,
- waiting => 'true',
- waitingmsg => $flags->{'WAITING'}->{'message'},
- itemswaiting => \@itemswaiting,
+ credits => 'true',
+ creditsmsg => $flags->{'CREDITS'}->{'message'}
);
}
- if ($flag eq 'ODUES') {
+ if ( $flag eq 'ODUES' ) {
$template->param(
odues => 'true',
flagged => 1,
oduesmsg => $flags->{'ODUES'}->{'message'}
);
- my $items=$flags->{$flag}->{'itemlist'};
+ my $items = $flags->{$flag}->{'itemlist'};
{
my @itemswaiting;
foreach my $item (@$items) {
- my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0);
+ my ($iteminformation) =
+ getiteminformation( $item->{'itemnumber'}, 0 );
push @itemswaiting, $iteminformation;
}
}
- if ($query->param('module') ne 'returns'){
+ if ( $query->param('module') ne 'returns' ) {
$template->param( nonreturns => 'true' );
}
}
- if ($flag eq 'NOTES') {
+ if ( $flag eq 'NOTES' ) {
$template->param(
notes => 'true',
flagged => 1,
@@ -465,22 +662,97 @@
);
}
}
- }
- return($patrontable, $flaginfotext);
}
+my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
+my @temp = split( /\$/, $amountold );
+
+my $CGIorganisations;
+my $member_of_institution;
+if ( C4::Context->preference("memberofinstitution") ) {
+ my $organisations = get_institutions();
+ my @orgs;
+ my %org_labels;
+ foreach my $organisation ( keys %$organisations ) {
+ push @orgs, $organisation;
+ $org_labels{$organisation} =
+ $organisations->{$organisation}->{'surname'};
+ }
+ $member_of_institution = 1;
+ $CGIorganisations = CGI::popup_menu(
+ -id => 'organisations',
+ -name => 'organisations',
+ -labels => \%org_labels,
+ -values => \@orgs,
+ );
+}
+
+$amountold = $temp[1];
+
+$template->param(
+ issued_itemtypes_count_loop => $issued_itemtypes_loop,
+ findborrower => $findborrower,
+ borrower => $borrower,
+ borrowernumber => $borrowernumber,
+ branch => $branch,
+ printer => $printer,
+ printername => $printer,
+ firstname => $borrower->{'firstname'},
+ surname => $borrower->{'surname'},
+ expiry =>
+ $borrower->{'dateexpiry'}, #format_date($borrower->{'dateexpiry'}),
+ categorycode => $borrower->{'categorycode'},
+ streetaddress => $borrower->{'address'},
+ 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,
+ inprocess => $inprocess,
+ memberofinstution => $member_of_institution,
+ CGIorganisations => $CGIorganisations,
+);
+
+# 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];
+#}
+
+$template->param(
+ SpecifyDueDate => C4::Context->preference("SpecifyDueDate")
+);
+output_html_with_http_headers $query, $cookie, $template->output;
+
+####################################################################
+# Extra subroutines,,,
+
sub cuecatbarcodedecode {
my ($barcode) = @_;
chomp($barcode);
- my @fields = split(/\./,$barcode);
- my @results = map(decode($_), @fields[1..$#fields]);
- if ($#results == 2){
+ my @fields = split( /\./, $barcode );
+ my @results = map( decode($_), @fields[ 1 .. $#fields ] );
+ if ( $#results == 2 ) {
return $results[2];
- } else {
+ }
+ else {
return $barcode;
}
}
-
-# Local Variables:
-# tab-width: 8
-# End:
Index: currenttransfers.pl
===================================================================
RCS file: /sources/koha/koha/circ/currenttransfers.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- currenttransfers.pl 21 Jul 2006 10:10:29 -0000 1.3
+++ currenttransfers.pl 9 Mar 2007 14:34:32 -0000 1.4
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: currenttransfers.pl,v 1.3 2006/07/21 10:10:29 toins Exp $
+# $Id: currenttransfers.pl,v 1.4 2007/03/09 14:34:32 tipaul Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -20,68 +20,82 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
+use CGI;
use C4::Context;
use C4::Output;
-use CGI;
-use HTML::Template;
+use C4::Branch;
use C4::Auth;
use C4::Date;
use C4::Circulation::Circ2;
-use Date::Manip;
+use C4::Interface::CGI::Output;
+use Date::Calc qw(
+ Today
+ Add_Delta_YM
+ Date_to_Days
+);
+
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');
+my $todaysdate = join "-", &Today;
+
# if we have a resturn of the form to delete the transfer, we launch the subrroutine
-if ($itemnumber){
+if ($itemnumber) {
C4::Circulation::Circ2::DeleteTransfer($itemnumber);
}
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "circ/currenttransfers.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/currenttransfers.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {borrowers => 1},
+ flagsrequired => { circulate => 1 },
debug => 1,
- });
-
+ }
+);
# set the userenv branch
my $default = C4::Context->userenv->{'branch'};
-
-my @datearr = localtime(time());
-my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
-
# get the all the branches for reference
my $branches = GetBranches();
my @branchesloop;
-foreach my $br (keys %$branches) {
+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){
+ my @gettransfers =
+ GetTransfersFromBib( $branches->{$br}->{'branchcode'}, $default );
+
+ if (@gettransfers) {
foreach my $num (@gettransfers) {
my %getransf;
my %env;
- my $calcDate=DateCalc($num->{'datesent'},"+".C4::Context->preference('TransfersMaxDaysWarning')." days");
- my $warning=Date_Cmp(ParseDate("today"),$calcDate);
- if ($warning>0){
+
+ my ( $sent_year, $sent_month, $sent_day ) = split "-",
+ $num->{'datesent'};
+ $sent_day = ( split " ", $sent_day )[0];
+ ( $sent_year, $sent_month, $sent_day ) =
+ Add_Delta_YM( $sent_year, $sent_month, $sent_day,
+ C4::Context->preference('TransfersMaxDaysWarning'), 0 );
+ my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day );
+ my $today = Date_to_Days(&Today);
+ my $warning = ( $today > $calcDate );
+
+ if ( $warning > 0 ) {
$getransf{'messcompa'} = 1;
}
- my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
- my $itemtypeinfo = getitemtypeinfo($gettitle->{'itemtype'});
+ my $gettitle = getiteminformation( $num->{'itemnumber'} );
+ my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
$getransf{'title'} = $gettitle->{'title'};
- $getransf{'datetransfer'} = format_date($num->{'datesent'});
+ $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
$getransf{'biblionumber'} = $gettitle->{'biblionumber'};
$getransf{'itemnumber'} = $gettitle->{'itemnumber'};
$getransf{'barcode'} = $gettitle->{'barcode'};
@@ -90,36 +104,39 @@
$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]);
+ # we check if we have a reserv for this transfer
+ my @checkreserv = GetReservations( $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'} ;
+ if ( $getborrower->{'emailaddress'} ) {
+ $getransf{'borrowermail'} = $getborrower->{'emailaddress'};
}
$getransf{'borrowerphone'} = $getborrower->{'phone'};
}
- push(@transferloop, \%getransf);
+ push( @transferloop, \%getransf );
}
-# If we have a return of reservloop we put it in the branchloop sequence
- $branchloop{'reserv'} = \@transferloop ;
+
+ # 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);
+ push( @branchesloop, \%branchloop );
}
- $template->param( branchesloop => \@branchesloop,
- show_date => format_date($todaysdate)
- );
-
- print "Content-Type: text/html\n\n", $template->output;
+$template->param(
+ branchesloop => \@branchesloop,
+ show_date => format_date($todaysdate),
+);
+output_html_with_http_headers $input, $cookie, $template->output;
Index: reserve.pl
===================================================================
RCS file: /sources/koha/koha/circ/reserve.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- reserve.pl 4 Jul 2006 14:36:51 -0000 1.3
+++ reserve.pl 9 Mar 2007 14:34:32 -0000 1.4
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: reserve.pl,v 1.3 2006/07/04 14:36:51 toins Exp $
+# $Id: reserve.pl,v 1.4 2007/03/09 14:34:32 tipaul Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -23,39 +23,30 @@
use C4::Context;
use C4::Output;
use CGI;
-use HTML::Template;
use C4::Auth;
use C4::Date;
+use C4::Interface::CGI::Output;
my $input = new CGI;
-my $type=$input->param('type');
-my $order=$input->param('order');
+my $order = $input->param('order');
+my $startdate=$input->param('from');
+my $enddate=$input->param('to');
my $theme = $input->param('theme'); # only used if allowthemeoverride is set
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "circ/reserve.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/reserve.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {borrowers => 1},
+ flagsrequired => { circulate => 1 },
debug => 1,
- });
-# borrowernumber int(11)
-# reservedate date
-# biblionumber int(11)
-# constrainttype char(1)
-# branchcode varchar(4)
-# notificationdate date
-# reminderdate date
-# cancellationdate date
-# reservenotes text
-# priority smallint(6)
-# found char(1)
-# timestamp timestamp ON UPDATE CURRENT_TIMESTAMP Oui CURRENT_TIMESTAMP Modifier Supprimer Primaire Index Unique Texte entier
-# itemnumber int(11)
+ }
+);
+
my $duedate;
-my $bornum;
+my $borrowernumber;
my $itemnum;
my $data1;
my $data2;
@@ -66,52 +57,106 @@
my $biblionumber;
my $title;
my $author;
-my @datearr = localtime(time());
-my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
+
+my @datearr = localtime( time() );
+my $todaysdate =
+ ( 1900 + $datearr[5] ) . '-'
+ . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+ . sprintf( "%0.2d", $datearr[3] );
my $dbh = C4::Context->dbh;
-my $strsth="select reservedate,reserves.borrowernumber as bornum, concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on items.itemnumber=reserves.itemnumber, borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by reservedate, borrower ";
-$strsth="select reservedate,reserves.borrowernumber as bornum,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on items.itemnumber=reserves.itemnumber , borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by borrower,reservedate " if ($order eq "borrower");
-$strsth="select reservedate,reserves.borrowernumber as bornum,concat(firstname,' ',surname) as borrower, borrowers.phone, borrowers.emailaddress,reserves.biblionumber, reserves.branchcode as branch, items.holdingbranch, items.itemcallnumber, items.itemnumber, notes, notificationdate, reminderdate, priority, reserves.found, biblio.title, biblio.author from reserves left join items on items.itemnumber=reserves.itemnumber, borrowers,biblio where isnull(cancellationdate) && reserves.borrowernumber=borrowers.borrowernumber && reserves.biblionumber=biblio.biblionumber order by biblio.title, priority,reservedate " if ($order eq "biblio");
-my $sth=$dbh->prepare($strsth);
-warn "".$strsth;
-$sth->execute();
+my ($sqlorderby, $sqldatewhere) = ("","");
+
+$sqldatewhere .= " && reservedate >= " . $dbh->quote($startdate) if ($startdate) ;
+$sqldatewhere .= " && reservedate <= " . $dbh->quote($enddate) if ($enddate) ;
+
+if ($order eq "borrower") {
+ $sqlorderby = " order by borrower, reservedate";
+} elsif ($order eq "biblio") {
+ $sqlorderby = " order by biblio.title, priority,reservedate";
+} elsif ($order eq "priority") {
+ $sqlorderby = "order by priority DESC";
+} else {
+ $sqlorderby = " order by reservedate, borrower";
+}
+my $strsth =
+"SELECT reservedate,
+ reserves.borrowernumber as borrowernumber,
+ concat(firstname,' ',surname) as borrower,
+ borrowers.phone,
+ borrowers.email,
+ reserves.biblionumber,
+ reserves.branchcode as branch,
+ items.holdingbranch,
+ items.itemcallnumber,
+ items.itemnumber,
+ notes,
+ notificationdate,
+ reminderdate,
+ priority,
+ reserves.found,
+ biblio.title,
+ biblio.author
+ FROM reserves
+ LEFT JOIN items ON items.biblionumber=reserves.biblionumber,
+ borrowers,biblio
+ WHERE isnull(cancellationdate)
+ && reserves.borrowernumber=borrowers.borrowernumber
+ && reserves.biblionumber=biblio.biblionumber
+ && reserves.found is NULL
+ && items.holdingbranch=?
+ ";
+
+$strsth .= $sqlorderby;
+
+my $sth = $dbh->prepare($strsth);
+
+$sth->execute(C4::Context->userenv->{'branch'});
my @reservedata;
-while (my $data=$sth->fetchrow_hashref) {
- push (@reservedata,
+my $previous;
+my $this;
+while ( my $data = $sth->fetchrow_hashref ) {
+ $this=$data->{biblionumber}.":".$data->{borrowernumber};
+ my @itemlist;
+ push(
+ @reservedata,
{
- reservedate => format_date($data->{reservedate}),
- priority => $data->{priority},
- name => $data->{borrower},
- title => $data->{title},
- author => $data->{author},
- bornum => $data->{bornum},
- itemnum => $data->{itemnumber},
- phone => $data->{phone},
- email => $data->{email},
- biblionumber => $data->{biblionumber},
- statusw => ($data->{found} eq "w"),
- statusf => ($data->{found} eq "f"),
+ reservedate => $previous eq $this?"":format_date( $data->{reservedate} ),
+ priority => $previous eq $this?"":$data->{priority},
+ name => $previous eq $this?"":$data->{borrower},
+ title => $previous eq $this?"":$data->{title},
+ author => $previous eq $this?"":$data->{author},
+ borrowernumber => $previous eq $this?"":$data->{borrowernumber},
+ itemnum => $previous eq $this?"":$data->{itemnumber},
+ phone => $previous eq $this?"":$data->{phone},
+ email => $previous eq $this?"":$data->{email},
+ biblionumber => $previous eq $this?"":$data->{biblionumber},
+ statusw => ( $data->{found} eq "w" ),
+ statusf => ( $data->{found} eq "f" ),
holdingbranch => $data->{holdingbranch},
- branch => $data->{branch},
+ branch => $previous eq $this?"":$data->{branch},
itemcallnumber => $data->{itemcallnumber},
- notes => $data->{notes},
- notificationdate => $data->{notificationdate},
- reminderdate => $data->{reminderdate}
+ notes => $previous eq $this?"":$data->{notes},
+ notificationdate => $previous eq $this?"":$data->{notificationdate},
+ reminderdate => $previous eq $this?"":$data->{reminderdate}
}
-
);
-
+ $previous=$this;
}
$sth->finish;
-$template->param(todaysdate => format_date($todaysdate),
+$template->param(
+ todaysdate => format_date($todaysdate),
+ from => $startdate,
+ to => $enddate,
reserveloop => \@reservedata,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
- );
+ "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
+);
-print "Content-Type: text/html\n\n", $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
Index: returns.pl
===================================================================
RCS file: /sources/koha/koha/circ/returns.pl,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- returns.pl 15 Nov 2006 01:41:51 -0000 1.45
+++ returns.pl 9 Mar 2007 14:34:32 -0000 1.46
@@ -1,10 +1,4 @@
#!/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
#
@@ -23,22 +17,31 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
+=head1 returns.pl
+
+script to execute returns of books
+
+written 11/3/2002 by Finlay
+
+=cut
+
use strict;
use CGI;
use C4::Circulation::Circ2;
-use C4::Search;
+use C4::Date;
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::Branch; # GetBranchName
+use C4::Koha; # FIXME : is it still useful ?
+use C4::Context;
+
my $query = new CGI;
#getting the template
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+my ( $template, $librarian, $cookie ) = get_template_and_user(
{
template_name => "circ/returns.tmpl",
query => $query,
@@ -51,24 +54,22 @@
#####################
#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 $printers = GetPrinters( \%env );
-# my $branch = getbranch( $query, $branches );
-my $printer = getprinter( $query, $printers );
+#my $branch = C4::Context->userenv?C4::Context->userenv->{'branch'}:"";
+my $printer = C4::Context->userenv?C4::Context->userenv->{'branchprinter'}:"";
#
# Some code to handle the error if there is no branch or printer setting.....
#
-my $branch=C4::Context->preference("defaultBranch");
-$env{'branchcode'} = $branch;
+
+#$env{'branchcode'} = $branch;
$env{'printer'} = $printer;
$env{'queue'} = $printer;
+
# Set up the item stack ....
my %returneditems;
my %riduedate;
@@ -97,37 +98,58 @@
$input{counter} = $counter;
$input{barcode} = $barcode;
$input{duedate} = $duedate;
- $input{bornum} = $borrowernumber;
- push ( @inputloop, \%input );
+ $input{borrowernumber} = $borrowernumber;
+ push( @inputloop, \%input );
}
############
-my $item;
# Deal with the requests....
+
+if ($query->param('WT-itemNumber')){
+updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
+}
+
+
if ( $query->param('resbarcode') ) {
- $item = $query->param('itemnumber');
- my $borrnum = $query->param('borrowernumber');
+ my $item = $query->param('itemnumber');
+ my $borrowernumber = $query->param('borrowernumber');
my $resbarcode = $query->param('resbarcode');
-
+ my $diffBranchReturned = $query->param('diffBranch');
# 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 $iteminfo = getiteminformation($item);
+ my $diffBranchSend;
+
+# addin in ReserveWaiting the possibility to check if the document is expected in this library or not,
+# if not we send a value in reserve waiting for not implementting waiting status
+ if ($diffBranchReturned) {
+ $diffBranchSend = $diffBranchReturned;
+ }
+ else {
+ $diffBranchSend = undef;
+ }
+
+ my $tobranchcd = ReserveWaiting( $item, $borrowernumber,$diffBranchSend);
+# check if we have other reservs for this document, if we have a return send the message of transfer
+ my ( $messages, $nextreservinfo ) = OtherReserves($item);
+
+ my $branchname = GetBranchName( $messages->{'transfert'} );
+ my ($borr) = getpatroninformation( \%env, $nextreservinfo, 0 );
my $borcnum = $borr->{'cardnumber'};
my $name =
- $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+ $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
my $slip = $query->param('resslip');
- printslip( \%env, $slip ); #removed by paul
- if ( $tobranchcd ne $branch ) {
+
+ if ( $messages->{'transfert'} ) {
$template->param(
itemtitle => $iteminfo->{'title'},
iteminfo => $iteminfo->{'author'},
- branchname => $branchname,
+ tobranchname => $branchname,
name => $name,
- bornum => $borrnum,
+ borrowernumber => $borrowernumber,
borcnum => $borcnum,
+ borfirstname => $borr->{'firstname'},
+ borsurname => $borr->{'surname'},
diffbranch => 1
);
}
@@ -141,11 +163,10 @@
# actually return book and prepare item table.....
if ($barcode) {
-
# decode cuecat
$barcode = cuecatbarcodedecode($barcode);
( $returned, $messages, $iteminformation, $borrower ) =
- returnbook( $barcode, $branch );
+ returnbook( $barcode, C4::Context->userenv->{'branch'} );
if ($returned) {
$returneditems{0} = $barcode;
$riborrowernumber{0} = $borrower->{'borrowernumber'};
@@ -155,22 +176,16 @@
$input{first} = 1;
$input{barcode} = $barcode;
$input{duedate} = $riduedate{0};
- $input{bornum} = $riborrowernumber{0};
- push ( @inputloop, \%input );
- }
- 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");
+ $input{borrowernumber} = $riborrowernumber{0};
+ push( @inputloop, \%input );
+
+ # check if the branch is the same as homebranch
+ # if not, we want to put a message
+ if ( $iteminformation->{'homebranch'} ne C4::Context->userenv->{'branch'} ) {
+ $template->param( homebranch => $iteminformation->{'homebranch'} );
}
}
+ elsif ( !$messages->{'BadBarcode'} ) {
my %input;
$input{counter} = 0;
$input{first} = 1;
@@ -181,14 +196,14 @@
$riduedate{0} = 0;
if ( $messages->{'wthdrawn'} ) {
$input{withdrawn} = 1;
- $input{bornum} = "Item Cancelled";
+ $input{borrowernumber} = "Item Cancelled";
$riborrowernumber{0} = 'Item Cancelled';
}
else {
- $input{bornum} = " ";
+ $input{borrowernumber} = " ";
$riborrowernumber{0} = ' ';
}
- push ( @inputloop, \%input );
+ push( @inputloop, \%input );
}
$template->param(
returned => $returned,
@@ -205,15 +220,77 @@
my $waiting = 0;
my $reserved = 0;
-if ( $messages->{'ResFound'} ) {
+# new op dev : we check if the document must be returned to his homebranch directly,
+# if the document is transfered, we have warning message .
+
+if ( $messages->{'WasTransfered'} ) {
+
+ my ($iteminfo) = getiteminformation( 0, $barcode );
+
+ $template->param(
+ found => 1,
+ transfer => 1,
+ itemhomebranch =>
+ $branches->{ $iteminfo->{'homebranch'} }->{'branchname'}
+ );
+
+}
+
+# adding a case of wrong transfert, if the document wasn't transfered in the good library (according to branchtransfer (tobranch) BDD)
+
+if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
+ $template->param(
+ WrongTransfer => 1,
+ TransferWaitingAt => $messages->{'WrongTransfer'},
+ WrongTransferItem => $messages->{'WrongTransferItem'},
+ );
+
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 );
+ my ($iteminfo) = getiteminformation( 0, $barcode );
+
+ $template->param(
+ wname => $name,
+ wborfirstname => $borr->{'firstname'},
+ wborsurname => $borr->{'surname'},
+ wbortitle => $borr->{'title'},
+ wborphone => $borr->{'phone'},
+ wboremail => $borr->{'emailaddress'},
+ wborstraddress => $borr->{'streetaddress'},
+ wborcity => $borr->{'city'},
+ wborzip => $borr->{'zipcode'},
+ wborrowernumber => $res->{'borrowernumber'},
+ wborcnum => $borr->{'cardnumber'},
+ witemtitle => $iteminfo->{'title'},
+ witemauthor => $iteminfo->{'author'},
+ witembarcode => $iteminfo->{'barcode'},
+ witemtype => $iteminfo->{'itemtype'},
+ wccode => $iteminfo->{'ccode'},
+ witembiblionumber => $iteminfo->{'biblionumber'},
+ wtransfertFrom => C4::Context->userenv->{'branch'},
+ );
+}
+
+
+if ( $messages->{'ResFound'} and not $messages->{'WrongTransfer'}) {
+ 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( 0, $barcode );
if ( $res->{'ResFound'} eq "Waiting" ) {
+ if ( C4::Context->userenv->{'branch'} eq $res->{'branchcode'} ) {
+ $template->param( waiting => 1 );
+ }
+ else {
+ $template->param( waiting => 0 );
+ }
+
$template->param(
found => 1,
name => $name,
@@ -221,46 +298,69 @@
borsurname => $borr->{'surname'},
bortitle => $borr->{'title'},
borphone => $borr->{'phone'},
+ boremail => $borr->{'emailaddress'},
borstraddress => $borr->{'streetaddress'},
borcity => $borr->{'city'},
borzip => $borr->{'zipcode'},
- bornum => $res->{'borrowernumber'},
+ borrowernumber => $res->{'borrowernumber'},
borcnum => $borr->{'cardnumber'},
- branchname => $branches->{ $res->{'branchcode'} }->{'branchname'},
- waiting => 1,
+ debarred => $borr->{'debarred'},
+ gonenoaddress => $borr->{'gonenoaddress'},
+ currentbranch => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
itemnumber => $res->{'itemnumber'},
itemtitle => $iteminfo->{'title'},
itemauthor => $iteminfo->{'author'},
itembarcode => $iteminfo->{'barcode'},
itemtype => $iteminfo->{'itemtype'},
+ ccode => $iteminfo->{'ccode'},
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 );
+
+ if ( C4::Context->userenv->{'branch'} eq $res->{'branchcode'} ) {
+ $template->param( intransit => 0 );
+ }
+ else {
+ $template->param( intransit => 1 );
+ }
$template->param(
found => 1,
- branchname => $branches->{ $res->{'branchcode'} }->{'branchname'},
+ currentbranch => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
+ name => $name,
+ destbranchname =>
+ $branches->{ $res->{'branchcode'} }->{'branchname'},
+ destbranch => $res->{'branchcode'},
+ transfertodo => ( C4::Context->userenv->{'branch'} eq $res->{'branchcode'} ? 0 : 1 ),
reserved => 1,
- today =>format_date( $todaysdate),
+ today => $todaysdate,
itemnumber => $res->{'itemnumber'},
itemtitle => $iteminfo->{'title'},
itemauthor => $iteminfo->{'author'},
itembarcode => $iteminfo->{'barcode'},
itemtype => $iteminfo->{'itemtype'},
+ ccode => $iteminfo->{'ccode'},
itembiblionumber => $iteminfo->{'biblionumber'},
borsurname => $borr->{'surname'},
bortitle => $borr->{'title'},
borfirstname => $borr->{'firstname'},
- bornum => $res->{'borrowernumber'},
+ borrowernumber => $res->{'borrowernumber'},
borcnum => $borr->{'cardnumber'},
borphone => $borr->{'phone'},
borstraddress => $borr->{'streetaddress'},
borsub => $borr->{'suburb'},
borcity => $borr->{'city'},
borzip => $borr->{'zipcode'},
- boremail => $borr->{'emailadress'},
+ boremail => $borr->{'emailaddress'},
+ debarred => $borr->{'debarred'},
+ gonenoaddress => $borr->{'gonenoaddress'},
barcode => $barcode
);
}
@@ -293,25 +393,28 @@
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 ) {
+ if ( $messages->{'IsPermanent'} ne C4::Context->userenv->{'branch'} ) {
$err{ispermanent} = 1;
$err{msg} =
$branches->{ $messages->{'IsPermanent'} }->{'branchname'};
}
}
+ elsif ( $code eq 'WrongTransfer' ) {
+ ; # FIXME... anything to do here?
+ }
+ elsif ( $code eq 'WrongTransferItem' ) {
+ ; # FIXME... anything to do here?
+ }
else {
die "Unknown error code $code"; # XXX
}
if (%err) {
- push ( @errmsgloop, \%err );
+ push( @errmsgloop, \%err );
}
last if $exit_required_p;
}
@@ -320,22 +423,17 @@
# 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};
+ $flaginfo{borrowernumber} = $borrower->{borrowernumber};
}
elsif ( $flag eq 'WAITING' ) {
$flaginfo{msg} = $flag;
@@ -344,15 +442,15 @@
my $items = $flags->{$flag}->{'itemlist'};
foreach my $item (@$items) {
my ($iteminformation) =
- getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+ getiteminformation( $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 );
+ $branches->{ $iteminformation->{'holdingbranch'} }
+ ->{'branchname'};
+ push( @waitingitemloop, \%waitingitem );
}
$flaginfo{itemloop} = \@waitingitemloop;
}
@@ -363,16 +461,16 @@
@$items )
{
my ($iteminformation) =
- getiteminformation( \%env, $item->{'itemnumber'}, 0 );
+ getiteminformation( $item->{'itemnumber'}, 0 );
my %overdueitem;
- $overdueitem{duedate} = $item->{'date_due'};
+ $overdueitem{duedate} = format_date( $item->{'date_due'} );
$overdueitem{biblionum} = $iteminformation->{'biblionumber'};
$overdueitem{barcode} = $iteminformation->{'barcode'};
$overdueitem{title} = $iteminformation->{'title'};
$overdueitem{brname} =
- $branches->{ $iteminformation->{'holdingbranch'} }->{
- 'branchname'};
- push ( @itemloop, \%overdueitem );
+ $branches->{ $iteminformation->{'holdingbranch'} }
+ ->{'branchname'};
+ push( @itemloop, \%overdueitem );
}
$flaginfo{itemloop} = \@itemloop;
$flaginfo{overdue} = 1;
@@ -381,12 +479,12 @@
$flaginfo{other} = 1;
$flaginfo{msg} = $flags->{$flag}->{'message'};
}
- push ( @flagloop, \%flaginfo );
+ push( @flagloop, \%flaginfo );
}
$template->param(
flagset => $flagset,
flagloop => \@flagloop,
- ribornum => $borrower->{'borrowernumber'},
+ riborrowernumber => $borrower->{'borrowernumber'},
riborcnum => $borrower->{'cardnumber'},
riborsurname => $borrower->{'surname'},
ribortitle => $borrower->{'title'},
@@ -394,60 +492,67 @@
);
}
-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 @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} = format_date($duedate);
my ($borrower) =
getpatroninformation( \%env, $riborrowernumber{$_}, 0 );
- $ri{bornum} = $borrower->{'borrowernumber'};
+ $ri{borrowernumber} = $borrower->{'borrowernumber'};
$ri{borcnum} = $borrower->{'cardnumber'};
$ri{borfirstname} = $borrower->{'firstname'};
$ri{borsurname} = $borrower->{'surname'};
$ri{bortitle} = $borrower->{'title'};
}
else {
- $ri{bornum} = $riborrowernumber{$_};
+ $ri{borrowernumber} = $riborrowernumber{$_};
}
-# my %ri;
- my ($iteminformation) = getiteminformation( \%env, 0, $barcode );
- $ri{color} = $color;
+
+ # my %ri;
+ my ($iteminformation) = getiteminformation( 0, $barcode );
$ri{itembiblionumber} = $iteminformation->{'biblionumber'};
$ri{itemtitle} = $iteminformation->{'title'};
$ri{itemauthor} = $iteminformation->{'author'};
$ri{itemtype} = $iteminformation->{'itemtype'};
+ $ri{ccode} = $iteminformation->{'ccode'};
$ri{barcode} = $barcode;
}
else {
last;
}
$count++;
- push ( @riloop, \%ri );
+ push( @riloop, \%ri );
}
$template->param( riloop => \@riloop );
$template->param(
- genbrname => $branches->{$branch}->{'branchname'},
+ genbrname => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
genprname => $printers->{$printer}->{'printername'},
- branch => $branch,
+ branchname => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
printer => $printer,
- errmsgloop => \@errmsgloop
+ errmsgloop => \@errmsgloop,
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
);
# actually print the page!
@@ -456,7 +561,7 @@
sub cuecatbarcodedecode {
my ($barcode) = @_;
chomp($barcode);
- my @fields = split ( /\./, $barcode );
+ my @fields = split( /\./, $barcode );
my @results = map( decode($_), @fields[ 1 .. $#fields ] );
if ( $#results == 2 ) {
return $results[2];
@@ -465,7 +570,3 @@
return $barcode;
}
}
-
-# Local Variables:
-# tab-width: 4
-# End:
Index: selectbranchprinter.pl
===================================================================
RCS file: /sources/koha/koha/circ/selectbranchprinter.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- selectbranchprinter.pl 21 Jul 2006 10:10:29 -0000 1.16
+++ selectbranchprinter.pl 9 Mar 2007 14:34:32 -0000 1.17
@@ -1,6 +1,4 @@
#!/usr/bin/perl
-# WARNING: This file uses 4-character tabs!
-
# Copyright 2000-2002 Katipo Communications
#
@@ -26,122 +24,102 @@
use C4::Auth;
use C4::Print;
use C4::Interface::CGI::Output;
-use HTML::Template;
-use DBI;
use C4::Koha;
-
+use C4::Branch; # GetBranches
# 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]);
+my $query = new CGI;
+my $branches = GetBranches();
+my $printers = GetPrinters( \%env );
+my $branch = $query->param('branch');
+my $printer = $query->param('printer');
+
+my %cookie = $query->cookie('userenv');
+($branch) || ( $branch = $cookie{'branch'} );
+($printer) || ( $printer = $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;
+$env{'branchcode'} = $branch;
+$env{'printer'} = $printer;
+$env{'queue'} = $printer;
# set up select options....
-my $branchcount=0;
-my $printercount=0;
+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
+foreach my $br ( keys %$branches ) {
+ next unless $br =~ /\S/; # next unless $br is not blank.
+
$branchcount++;
my %branch;
- $branch{selected}=($br eq $oldbranch);
- $branch{name}=$branches->{$br}->{'branchname'};
- $branch{value}=$br;
- push(@branchloop,\%branch);
+ $branch{selected} = ( $br eq $oldbranch );
+ $branch{name} = $branches->{$br}->{'branchname'};
+ $branch{value} = $br;
+ push( @branchloop, \%branch );
}
my @printerloop;
-foreach (keys %$printers) {
- (next) unless ($_);
+foreach ( keys %$printers ) {
+ (next) unless ($_); # next unless if this printer is blank.
$printercount++;
my %printer;
- $printer{selected}=($_ eq $oldprinter);
- $printer{name}=$printers->{$_}->{'printername'};
- $printer{value}=$_;
- push(@printerloop,\%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};
+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};
+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",
+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,
+ flagsrequired => { circulate => 1 },
+ }
+);
+$template->param(
oneprinter => $oneprinter,
onebranch => $onebranch,
printername => $printername,
branchname => $branchname,
printerloop => \@printerloop,
branchloop => \@branchloop,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ 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:
+output_html_with_http_headers $query, $cookie, $template->output;
Index: waitingreservestransfers.pl
===================================================================
RCS file: /sources/koha/koha/circ/waitingreservestransfers.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- waitingreservestransfers.pl 15 Nov 2006 01:41:51 -0000 1.5
+++ waitingreservestransfers.pl 9 Mar 2007 14:34:32 -0000 1.6
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: waitingreservestransfers.pl,v 1.5 2006/11/15 01:41:51 tgarip1957 Exp $
+# $Id: waitingreservestransfers.pl,v 1.6 2007/03/09 14:34:32 tipaul Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -23,11 +23,15 @@
use C4::Context;
use C4::Output;
use CGI;
-use HTML::Template;
+use C4::Branch; # GetBranches
use C4::Auth;
use C4::Date;
use C4::Circulation::Circ2;
-use Date::Manip;
+use Date::Calc qw(
+ Today
+ Add_Delta_YM
+ Date_to_Days
+);
use C4::Koha;
use C4::Biblio;
@@ -35,52 +39,74 @@
my $theme = $input->param('theme'); # only used if allowthemeoverride is set
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "circ/waitingreservestransfers.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/waitingreservestransfers.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {borrowers => 1},
+ flagsrequired => { circulate => 1 },
debug => 1,
- });
-
+ }
+);
# set the userenv branch
my $default = C4::Context->userenv->{'branch'};
+my @datearr = localtime( time() );
+my $todaysdate =
+ ( 1900 + $datearr[5] ) . '-'
+ . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+ . sprintf( "%0.2d", $datearr[3] );
+
+my $item = $input->param('itemnumber');
+my $fbr = $input->param('fbr');
+my $tbr = $input->param('tbr');
-my @datearr = localtime(time());
-my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
-
-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);
+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) {
+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){
+
+ # warn " branch=>".$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=DateCalc($num->{'reservedate'},"+".C4::Context->preference('TransfersMaxDaysWarning')." days");
- my $warning=Date_Cmp(ParseDate("today"),$calcDate);
- if ($warning>0){
+ my $gettitle = getiteminformation( $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=DateCalc($num->{'reservedate'},"+".C4::Context->preference('TransfersMaxDaysWarning')." days");
+#my $warning=Date_Cmp(ParseDate("today"),$calcDate);
+
+ my ( $reserve_year, $reserve_month, $reserve_day ) = split /-/,
+ $num->{'reservedate'};
+ ( $reserve_year, $reserve_month, $reserve_day ) =
+ Add_Delta_YM( $reserve_year, $reserve_month, $reserve_day,
+ C4::Context->preference('ReservesMaxPickUpDelay'), 0 );
+ my $calcDate =
+ Date_to_Days( $reserve_year, $reserve_month, $reserve_day );
+ my $today = Date_to_Days(&Today);
+ my $warning = ( $today > $calcDate );
+
+ if ( $warning > 0 ) {
$getreserv{'messcompa'} = 1;
}
$getreserv{'title'} = $gettitle->{'title'};
@@ -92,36 +118,39 @@
$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
$getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
$getreserv{'borrowername'} = $getborrower->{'surname'};
- $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ;
- if ($getborrower->{'emailaddress'}){
- $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ;
+ $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
+
+ if ( $getborrower->{'emailaddress'} ) {
+ $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
}
$getreserv{'borrowerphone'} = $getborrower->{'phone'};
- push(@reservloop, \%getreserv);
+ push( @reservloop, \%getreserv );
}
}
-# If we have a return of reservloop we put it in the branchloop sequence
- if (@reservloop){
- $branchloop{'reserv'} = \@reservloop ;
+
+ # 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{
+
+ # 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);
+ push( @branchesloop, \%branchloop );
}
- $template->param( branchesloop => \@branchesloop,
+$template->param(
+ branchesloop => \@branchesloop,
show_date => format_date($todaysdate)
- );
-
- print "Content-Type: text/html\n\n", $template->output;
-
+);
+print "Content-Type: text/html\n\n", $template->output;
More information about the Koha-cvs
mailing list