&IsBranchTransferAllowed
&CreateBranchTransferLimit
&DeleteBranchTransferLimits
+ &TransferSlip
);
# subs to deal with offline circulation
borrowernumber => $borrower->{borrowernumber},
message_name => $message_name{$type},
});
- my $letter = C4::Letters::getletter('circulation', $type);
- C4::Letters::parseletter($letter, 'biblio', $item->{biblionumber});
- C4::Letters::parseletter($letter, 'biblioitems', $item->{biblionumber});
- C4::Letters::parseletter($letter, 'borrowers', $borrower->{borrowernumber});
- C4::Letters::parseletter($letter, 'branches', $branch);
+ my $letter = C4::Letters::GetPreparedLetter (
+ module => 'circulation',
+ letter_code => $type,
+ branchcode => $branch,
+ tables => {
+ 'biblio' => $item->{biblionumber},
+ 'biblioitems' => $item->{biblionumber},
+ 'borrowers' => $borrower,
+ 'branches' => $branch,
+ }
+ ) or return;
+
my @transports = @{ $borrower_preferences->{transports} };
# warn "no transports" unless @transports;
for (@transports) {
$message->update;
}
}
- $letter;
+
+ return $letter;
}
=head2 updateWrongTransfer
}
sub GetOfflineOperations {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp");
- $sth->execute(C4::Context->userenv->{'branch'});
- my $results = $sth->fetchall_arrayref({});
- $sth->finish;
- return $results;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp");
+ $sth->execute(C4::Context->userenv->{'branch'});
+ my $results = $sth->fetchall_arrayref({});
+ $sth->finish;
+ return $results;
}
sub GetOfflineOperation {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?");
- $sth->execute( shift );
- my $result = $sth->fetchrow_hashref;
- $sth->finish;
- return $result;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?");
+ $sth->execute( shift );
+ my $result = $sth->fetchrow_hashref;
+ $sth->finish;
+ return $result;
}
sub AddOfflineOperation {
- my $dbh = C4::Context->dbh;
- warn Data::Dumper::Dumper(@_);
- my $sth = $dbh->prepare("INSERT INTO pending_offline_operations VALUES('',?,?,?,?,?,?)");
- $sth->execute( @_ );
- return "Added.";
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("INSERT INTO pending_offline_operations (userid, branchcode, timestamp, action, barcode, cardnumber) VALUES(?,?,?,?,?,?)");
+ $sth->execute( @_ );
+ return "Added.";
}
sub DeleteOfflineOperation {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?");
- $sth->execute( shift );
- return "Deleted.";
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?");
+ $sth->execute( shift );
+ return "Deleted.";
}
sub ProcessOfflineOperation {
- my $operation = shift;
+ my $operation = shift;
my $report;
- if ( $operation->{action} eq 'return' ) {
+ if ( $operation->{action} eq 'return' ) {
$report = ProcessOfflineReturn( $operation );
- } elsif ( $operation->{action} eq 'issue' ) {
- $report = ProcessOfflineIssue( $operation );
- }
+ } elsif ( $operation->{action} eq 'issue' ) {
+ $report = ProcessOfflineIssue( $operation );
+ }
- DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid};
+ DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid};
- return $report;
+ return $report;
}
sub ProcessOfflineReturn {
if ( $borrower->{borrowernumber} ) {
my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} );
unless ($itemnumber) {
- return "barcode not found";
+ return "Barcode not found.";
}
my $issue = GetOpenIssue( $itemnumber );
+=head2 TransferSlip
+
+ TransferSlip($user_branch, $itemnumber, $to_branch)
+
+ Returns letter hash ( see C4::Letters::GetPreparedLetter ) or undef
+
+=cut
+
+sub TransferSlip {
+ my ($branch, $itemnumber, $to_branch) = @_;
+
+ my $item = GetItem( $itemnumber )
+ or return;
+
+ my $pulldate = C4::Dates->new();
+
+ return C4::Letters::GetPreparedLetter (
+ module => 'circulation',
+ letter_code => 'TRANSFERSLIP',
+ branchcode => $branch,
+ tables => {
+ 'branches' => $to_branch,
+ 'biblio' => $item->{biblionumber},
+ 'items' => $item,
+ },
+ );
+}
+
+
1;
__END__