Lines 100-105
BEGIN {
Link Here
|
100 |
&CreateBranchTransferLimit |
100 |
&CreateBranchTransferLimit |
101 |
&DeleteBranchTransferLimits |
101 |
&DeleteBranchTransferLimits |
102 |
); |
102 |
); |
|
|
103 |
|
104 |
# subs to deal with offline circulation |
105 |
push @EXPORT, qw( |
106 |
&GetOfflineOperations |
107 |
&GetOfflineOperation |
108 |
&AddOfflineOperation |
109 |
&DeleteOfflineOperation |
110 |
&ProcessOfflineOperation |
111 |
); |
103 |
} |
112 |
} |
104 |
|
113 |
|
105 |
=head1 NAME |
114 |
=head1 NAME |
Lines 3027-3032
sub LostItem{
Link Here
|
3027 |
} |
3036 |
} |
3028 |
} |
3037 |
} |
3029 |
|
3038 |
|
|
|
3039 |
sub GetOfflineOperations { |
3040 |
my $dbh = C4::Context->dbh; |
3041 |
my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp"); |
3042 |
$sth->execute(C4::Context->userenv->{'branch'}); |
3043 |
my $results = $sth->fetchall_arrayref({}); |
3044 |
$sth->finish; |
3045 |
return $results; |
3046 |
} |
3047 |
|
3048 |
sub GetOfflineOperation { |
3049 |
my $dbh = C4::Context->dbh; |
3050 |
my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?"); |
3051 |
$sth->execute( shift ); |
3052 |
my $result = $sth->fetchrow_hashref; |
3053 |
$sth->finish; |
3054 |
return $result; |
3055 |
} |
3056 |
|
3057 |
sub AddOfflineOperation { |
3058 |
my $dbh = C4::Context->dbh; |
3059 |
warn Data::Dumper::Dumper(@_); |
3060 |
my $sth = $dbh->prepare("INSERT INTO pending_offline_operations VALUES('',?,?,?,?,?,?)"); |
3061 |
$sth->execute( @_ ); |
3062 |
return "Added."; |
3063 |
} |
3064 |
|
3065 |
sub DeleteOfflineOperation { |
3066 |
my $dbh = C4::Context->dbh; |
3067 |
my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?"); |
3068 |
$sth->execute( shift ); |
3069 |
return "Deleted."; |
3070 |
} |
3071 |
|
3072 |
sub ProcessOfflineOperation { |
3073 |
my $operation = shift; |
3074 |
|
3075 |
my $report; |
3076 |
if ( $operation->{action} eq 'return' ) { |
3077 |
$report = ProcessOfflineReturn( $operation ); |
3078 |
} elsif ( $operation->{action} eq 'issue' ) { |
3079 |
$report = ProcessOfflineIssue( $operation ); |
3080 |
} |
3081 |
|
3082 |
DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; |
3083 |
|
3084 |
return $report; |
3085 |
} |
3086 |
|
3087 |
sub ProcessOfflineReturn { |
3088 |
my $operation = shift; |
3089 |
|
3090 |
my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} ); |
3091 |
|
3092 |
if ( $itemnumber ) { |
3093 |
my $issue = GetOpenIssue( $itemnumber ); |
3094 |
if ( $issue ) { |
3095 |
MarkIssueReturned( |
3096 |
$issue->{borrowernumber}, |
3097 |
$itemnumber, |
3098 |
undef, |
3099 |
$operation->{timestamp}, |
3100 |
); |
3101 |
ModItem( |
3102 |
{ renewals => 0, onloan => undef }, |
3103 |
$issue->{'biblionumber'}, |
3104 |
$itemnumber |
3105 |
); |
3106 |
return "Success."; |
3107 |
} else { |
3108 |
return "Item not issued."; |
3109 |
} |
3110 |
} else { |
3111 |
return "Item not found."; |
3112 |
} |
3113 |
} |
3114 |
|
3115 |
sub ProcessOfflineIssue { |
3116 |
my $operation = shift; |
3117 |
|
3118 |
my $borrower = C4::Members::GetMemberDetails( undef, $operation->{cardnumber} ); # Get borrower from operation cardnumber |
3119 |
|
3120 |
if ( $borrower->{borrowernumber} ) { |
3121 |
my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} ); |
3122 |
unless ($itemnumber) { |
3123 |
return "barcode not found"; |
3124 |
} |
3125 |
my $issue = GetOpenIssue( $itemnumber ); |
3126 |
|
3127 |
if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned |
3128 |
MarkIssueReturned( |
3129 |
$issue->{borrowernumber}, |
3130 |
$itemnumber, |
3131 |
undef, |
3132 |
$operation->{timestamp}, |
3133 |
); |
3134 |
} |
3135 |
AddIssue( |
3136 |
$borrower, |
3137 |
$operation->{'barcode'}, |
3138 |
undef, |
3139 |
1, |
3140 |
$operation->{timestamp}, |
3141 |
undef, |
3142 |
); |
3143 |
return "Success."; |
3144 |
} else { |
3145 |
return "Borrower not found."; |
3146 |
} |
3147 |
} |
3030 |
|
3148 |
|
3031 |
1; |
3149 |
1; |
3032 |
|
3150 |
|