sub MarkIssueReturned {
my ( $borrowernumber, $itemnumber, $dropbox_branch, $returndate, $privacy ) = @_;
+
+ # Retrieve the issue
+ my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return;
+ my $issue_id = $issue->issue_id;
+
my $anonymouspatron;
if ( $privacy == 2 ) {
# The default of 0 will not work due to foreign key constraints
my $schema = $database->schema;
my $dbh = C4::Context->dbh;
- my $issue_id = $dbh->selectrow_array(
- q|SELECT issue_id FROM issues WHERE itemnumber = ?|,
- undef, $itemnumber
- );
-
my $query = 'UPDATE issues SET returndate=';
my @bind;
if ($dropbox_branch) {
# Update the returndate
$dbh->do( $query, undef, @bind );
- # Retrieve the issue
- my $issue = Koha::Checkouts->find( $issue_id ); # FIXME should be fetched earlier
-
# Create the old_issues entry
my $old_checkout = Koha::OldIssue->new($issue->unblessed)->store;