my @elements = $root->findnodes('CheckOutItem/ItemElementType/Value');
# checkout the item
- my ( $error, $messages ) = $self->ils->checkout( $userid, $itemid );
+ my ( $error, $messages, $datedue ) = $self->ils->checkout( $userid, $itemid );
my $vars;
my $output;
- my $vars->{'barcode'}=$itemid;
+ $vars->{'barcode'}=$itemid;
$vars->{'messagetype'} = 'CheckOutItemResponse';
if ($error) {
+ warn "Error!!!";
$vars->{'processingerror'} = 1;
+ use Data::Dumper;
+ warn Dumper $messages;
$vars->{'processingerrortype'} = $messages;
$vars->{'processingerrorelement'} = 'UniqueItemIdentifier';
$output = $self->render_output( 'problem.tt', $vars );
}
else {
$vars->{'elements'} = \@elements;
-
+ $vars->{'datedue'} = $datedue;
$output = $self->render_output( 'response.tt', $vars );
}
return $output;
use C4::Members qw{ GetMemberDetails };
use C4::Circulation qw { AddReturn CanBookBeIssued AddIssue };
+use C4::Context;
sub itemdata {
my $self = shift;
}
sub checkin {
- my $self = shift;
- my $barcode = shift;
- my $branch = shift;
+ my $self = shift;
+ my $barcode = shift;
+ my $branch = shift;
my $exemptfine = undef;
- my $dropbox = undef;
+ my $dropbox = undef;
my ( $success, $messages, $issue, $borrower ) =
AddReturn( $barcode, $branch, $exemptfine, $dropbox );
my $result = {
}
sub checkout {
- my $self = shift;
- my $userid = shift;
- my $barcode = shift;
- my ( $error, $confirm ) = CanBookBeIssued( $userid, $barcode );
+ my $self = shift;
+ my $userid = shift;
+ my $barcode = shift;
+ my $borrower = GetMemberDetails( undef, $userid );
+ my $error;
+ my $confirm;
+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)= @_;
+ my @USERENV = (
+ 1,
+ 'test',
+ 'MASTERTEST',
+ 'Test',
+ 'Test',
+ 'AS', #branchcode need to set this properly
+ 'Auckland',
+ 0,
+ );
+
+C4::Context->_new_userenv ('DUMMY_SESSION_ID');
+C4::Context->set_userenv ( @USERENV );
+
+
+ if ($borrower) {
+
+ ( $error, $confirm ) = CanBookBeIssued( $borrower, $barcode );
#( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower,
# $barcode, $duedatespec, $inprocess, $ignore_reserves );
- if ( $error || $confirm ) {
+ if (%$error) {
- # Can't issue item, return error hash
- return ( 1, $error || $confirm );
+ # Can't issue item, return error hash
+ return ( 1, $error );
+ }
+ elsif (%$confirm) {
+ return ( 1, $confirm );
+ }
+ else {
+ my $datedue = AddIssue( $borrower, $barcode );
+ return (0, undef, $datedue); #successfully issued
+ }
}
else {
- AddIssue( $userid, $barcode );
- return (0); #successfully issued
+ $error->{'badborrower'} = 1;
+ return ( 1, $error );
}
}