moving dotransfer to Biblio.pm::ModItemTransfer + some CheckReserves fixes

This commit is contained in:
tipaul 2007-04-24 09:07:53 +00:00
parent 0c020dd8bf
commit 4dea4d29b3
6 changed files with 54 additions and 51 deletions

View file

@ -81,6 +81,7 @@ push @EXPORT, qw(
push @EXPORT, qw(
&ModBiblio
&ModItem
&ModItemTransfer
&ModBiblioframework
&ModZebra
&ModItemInMarc
@ -420,6 +421,47 @@ sub ModItem {
}
}
sub ModItemTransfer {
my ( $itemnumber, $frombranch, $tobranch ) = @_;
my $dbh = C4::Context->dbh;
#new entry in branchtransfers....
my $sth = $dbh->prepare(
"INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch)
VALUES (?, ?, now(), $?)");
$sth->execute($itemnumber, $frombranch, $tobranch);
#update holdingbranch in items .....
$sth= $dbh->prepare(
"UPDATE items set holdingbranch = ? WHERE items.itemnumber = ?");
$sth->execute($tobranch,$itemnumber);
&ModDateLastSeen($itemnumber);
$sth = $dbh->prepare(
"SELECT biblionumber FROM items WHERE itemnumber=?"
);
$sth->execute($itemnumber);
while ( my ( $biblionumber ) = $sth->fetchrow ) {
&ModItemInMarconefield( $biblionumber, $itemnumber,
'items.holdingbranch', $tobranch );
}
return;
}
##New sub to dotransfer in marc tables as well. Not exported -TG 10/04/2006
# sub domarctransfer {
# my ( $dbh, $itemnumber ) = @_;
# $itemnumber =~ s /\'//g; ##itemnumber seems to come with quotes-TG
# my $sth =
# $dbh->prepare(
# "select biblionumber,holdingbranch from items where itemnumber=$itemnumber"
# );
# $sth->execute();
# while ( my ( $biblionumber, $holdingbranch ) = $sth->fetchrow ) {
# &ModItemInMarconefield( $biblionumber, $itemnumber,
# 'items.holdingbranch', $holdingbranch );
# }
# return;
# }
=head2 ModBiblioframework
=over
@ -760,7 +802,7 @@ sub GetItemsInfo {
if ( $datedue eq '' ) {
#$datedue="Available";
my ( $restype, $reserves ) =
CheckReserves( $data->{'itemnumber'} );
C4::Reserves::CheckReserves( $data->{'itemnumber'} );
if ($restype) {
#$datedue=$restype;
@ -3649,6 +3691,9 @@ Joshua Ferraro jmf@liblime.com
# $Id$
# $Log$
# Revision 1.199 2007/04/24 09:07:53 tipaul
# moving dotransfer to Biblio.pm::ModItemTransfer + some CheckReserves fixes
#
# Revision 1.198 2007/04/23 15:21:17 tipaul
# renaming currenttransfers to transferstoreceive
#

View file

@ -47,7 +47,7 @@ $VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v).".".join( "_", map { s
=head1 NAME
C4::Circulation::Circ2 - Koha circulation module
C4::Circulation - Koha circulation module
=head1 SYNOPSIS
@ -98,11 +98,6 @@ push @EXPORT, qw(
&DeleteTransfer
);
# subs to remove
push @EXPORT, qw(
&dotransfer
);
# FIXME - At least, I'm pretty sure this is for decoding CueCat stuff.
# FIXME From Paul : i don't understand what this sub does & why it has to be called on every circ. Speak of this with chris maybe ?
@ -274,7 +269,7 @@ sub transferbook {
#actually do the transfer....
if ($dotransfer) {
dotransfer( $itemnumber, $fbr, $tbr );
ModItemTransfer( $itemnumber, $fbr, $tbr );
# don't need to update MARC anymore, we do it in batch now
$messages->{'WasTransfered'} = 1;
@ -282,44 +277,6 @@ sub transferbook {
return ( $dotransfer, $messages, $biblio );
}
sub dotransfer {
my ( $itm, $fbr, $tbr ) = @_;
my $dbh = C4::Context->dbh;
$itm = $dbh->quote($itm);
$fbr = $dbh->quote($fbr);
$tbr = $dbh->quote($tbr);
#new entry in branchtransfers....
$dbh->do(
"INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch)
VALUES ($itm, $fbr, now(), $tbr)"
);
#update holdingbranch in items .....
$dbh->do(
"UPDATE items set holdingbranch = $tbr WHERE items.itemnumber = $itm");
&ModDateLastSeen($itm);
&domarctransfer( $dbh, $itm );
return;
}
##New sub to dotransfer in marc tables as well. Not exported -TG 10/04/2006
sub domarctransfer {
my ( $dbh, $itemnumber ) = @_;
$itemnumber =~ s /\'//g; ##itemnumber seems to come with quotes-TG
my $sth =
$dbh->prepare(
"select biblionumber,holdingbranch from items where itemnumber=$itemnumber"
);
$sth->execute();
while ( my ( $biblionumber, $holdingbranch ) = $sth->fetchrow ) {
&ModItemInMarconefield( $biblionumber, $itemnumber,
'items.holdingbranch', $holdingbranch );
}
return;
}
=head2 CanBookBeIssued
Check if a book can be issued.
@ -1324,7 +1281,7 @@ sub AddReturn {
if ( ($iteminformation->{'holdingbranch'} ne $iteminformation->{'homebranch'}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){
if (C4::Context->preference("AutomaticItemReturn") == 1) {
dotransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'});
ModItemTransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'});
$messages->{'WasTransfered'} = 1;
warn "was transfered";
}
@ -1989,7 +1946,7 @@ sub updateWrongTransfer {
$sth->finish;
# second step create a new line of branchtransfer to the right location .
dotransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
#third step changing holdingbranch of item
UpdateHoldingbranch($FromLibrary,$itemNumber);

View file

@ -129,7 +129,7 @@ sub OtherReserves {
);
#launch the subroutine dotransfer
C4::Circulation::dotransfer(
C4::Circulation::ModItemTransfer(
$itemnumber,
$iteminfo->{'holdingbranch'},
$checkreserves->{'branchcode'}

View file

@ -65,7 +65,7 @@ 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 );
C4::Circulation::Circ2::ModItemTransfer( $item, $fbr, $tbr );
}
# get the all the branches for reference

View file

@ -104,7 +104,7 @@ if ($item) {
# 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 ) ) {
dotransfer( $item, $fbr, $tbr );
ModItemTransfer( $item, $fbr, $tbr );
}
}

View file

@ -47,6 +47,7 @@ use C4::Circulation;
use C4::Koha;
use C4::Letters;
use C4::Biblio;
use C4::Reserves;
use C4::Branch; # GetBranchName
my $dbh = C4::Context->dbh;