From 84f6e5b457f76c3e0b8685ba38ad02f39ae66186 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 9 Apr 2014 10:56:25 +1200 Subject: [PATCH] Continuing on with the changes --- lib/NCIP/ILS/Koha.pm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/NCIP/ILS/Koha.pm b/lib/NCIP/ILS/Koha.pm index c78b52a..a5f5590 100644 --- a/lib/NCIP/ILS/Koha.pm +++ b/lib/NCIP/ILS/Koha.pm @@ -27,7 +27,7 @@ use C4::Circulation qw { AddReturn CanBookBeIssued AddIssue }; use C4::Context; use C4::Items qw { GetItem }; use C4::Reserves - qw {CanBookBeReserved AddReserve GetReservesFromItemnumber CancelReserve}; + qw {CanBookBeReserved AddReserve GetReservesFromItemnumber CancelReserve GetReservesFromBiblionumber}; use C4::Biblio qw {AddBiblio GetMarcFromKohaField GetBiblioData}; use C4::Barcodes::ValueBuilder; use C4::Items qw{AddItem}; @@ -146,6 +146,7 @@ sub request { my $barcode = shift; my $biblionumber = shift; my $borrower = GetMemberDetails( undef, $cardnumber ); + warn $cardnumber; my $result; unless ($borrower) { $result = { success => 0, messages => { 'BORROWER_NOT_FOUND' => 1 } }; @@ -163,6 +164,7 @@ sub request { return $result; } $self->userenv(); + warn $borrower->{borrowernumber}; if ( CanBookBeReserved( $borrower->{borrowernumber}, @@ -171,23 +173,36 @@ sub request { ) { my $biblioitemnumber = $itemdata->{biblionumber}; - my $branchcode = 'AS'; - + my $branchcode = 'CALG'; + warn $borrower->{borrwerborrowernumber}; # Add reserve here AddReserve( - $branchcode, $borrower->{borrwerborrowernumber}, + $branchcode, $borrower->{borrowernumber}, $itemdata->{biblionumber}, 'a', [$biblioitemnumber], 1, undef, undef, 'Placed By ILL', '', - $itemdata->{'itemnumber'}, undef + $itemdata->{'itemnumber'} || undef, undef ); + my $request_id; + if ($biblionumber){ + warn "yo $biblionumber"; + my $reserves = GetReservesFromBiblionumber({biblionumber => $itemdata->{biblionumber}}); + use Data::Dumper; + warn Dumper $reserves; + $request_id=$reserves->[1]->{reserve_id}; + } + else { my ( $reservedate, $borrowernumber, $branchcode2, $reserve_id, $wait ) = GetReservesFromItemnumber( $itemdata->{'itemnumber'} ); + $request_id = $reserve_id; + } + warn $request_id; $result = { success => 1, - messages => { request_id => $reserve_id } + messages => { request_id => $request_id } }; + warn return $result; } else { @@ -260,6 +275,7 @@ sub acceptitem { GetMarcFromKohaField( "items.barcode", '' ); my ( $nextnum, $scr ) = C4::Barcodes::ValueBuilder::incremental::get_barcode( \%args ); + $nextnum=sprintf("%.0f",$nextnum); my $item = { 'barcode' => $nextnum }; ( $biblionumber, $biblioitemnumber, $itemnumber ) = AddItem( $item, $biblionumber ); @@ -275,7 +291,7 @@ sub acceptitem { # now we have to check the requested action if ( $action =~ /^Hold For Pickup And Notify/ ) { unless ($reserve_id) { - $branchcode = 'AS'; # set this properly + $branchcode = 'CALG'; # set this properly # no reserve, place one if ($user) { my $borrower = GetMemberDetails( undef, $user ); -- 2.11.0