|
Lines 7-13
package C4::SIP::ILS::Transaction::Checkout;
Link Here
|
| 7 |
use warnings; |
7 |
use warnings; |
| 8 |
use strict; |
8 |
use strict; |
| 9 |
|
9 |
|
| 10 |
use POSIX qw(strftime); |
10 |
use POSIX qw(strftime); |
| 11 |
use C4::SIP::Sip qw( siplog ); |
11 |
use C4::SIP::Sip qw( siplog ); |
| 12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
| 13 |
use CGI qw ( -utf8 ); |
13 |
use CGI qw ( -utf8 ); |
|
Lines 24-70
use parent qw(C4::SIP::ILS::Transaction);
Link Here
|
| 24 |
|
24 |
|
| 25 |
# Most fields are handled by the Transaction superclass |
25 |
# Most fields are handled by the Transaction superclass |
| 26 |
my %fields = ( |
26 |
my %fields = ( |
| 27 |
security_inhibit => 0, |
27 |
security_inhibit => 0, |
| 28 |
due => undef, |
28 |
due => undef, |
| 29 |
renew_ok => 0, |
29 |
renew_ok => 0, |
| 30 |
); |
30 |
); |
| 31 |
|
31 |
|
| 32 |
sub new { |
32 |
sub new { |
| 33 |
my $class = shift;; |
33 |
my $class = shift; |
| 34 |
my $self = $class->SUPER::new(); |
34 |
my $self = $class->SUPER::new(); |
| 35 |
foreach my $element (keys %fields) { |
35 |
foreach my $element ( keys %fields ) { |
| 36 |
$self->{_permitted}->{$element} = $fields{$element}; |
36 |
$self->{_permitted}->{$element} = $fields{$element}; |
| 37 |
} |
37 |
} |
| 38 |
@{$self}{keys %fields} = values %fields; |
38 |
@{$self}{ keys %fields } = values %fields; |
| 39 |
return bless $self, $class; |
39 |
return bless $self, $class; |
| 40 |
} |
40 |
} |
| 41 |
|
41 |
|
| 42 |
sub do_checkout { |
42 |
sub do_checkout { |
| 43 |
my $self = shift; |
43 |
my $self = shift; |
| 44 |
my $account = shift; |
44 |
my $account = shift; |
| 45 |
my $no_block_due_date = shift; |
45 |
my $no_block_due_date = shift; |
| 46 |
siplog( 'LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..." ); |
46 |
siplog( 'LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..." ); |
| 47 |
my $shelf = $self->{item}->hold_attached; |
47 |
my $shelf = $self->{item}->hold_attached; |
| 48 |
my $barcode = $self->{item}->id; |
48 |
my $barcode = $self->{item}->id; |
| 49 |
my $patron = Koha::Patrons->find( $self->{patron}->{borrowernumber} ); |
49 |
my $patron = Koha::Patrons->find( $self->{patron}->{borrowernumber} ); |
| 50 |
my $overridden_duedate; # usually passed as undef to AddIssue |
50 |
my $overridden_duedate; # usually passed as undef to AddIssue |
| 51 |
my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; |
51 |
my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; |
| 52 |
my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout}; |
52 |
my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout}; |
| 53 |
my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, 0 ); |
53 |
my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, 0 ); |
| 54 |
|
54 |
|
| 55 |
if ( $no_block_due_date ) { |
55 |
if ($no_block_due_date) { |
| 56 |
my $year = substr($no_block_due_date,0,4); |
56 |
my $year = substr( $no_block_due_date, 0, 4 ); |
| 57 |
my $month = substr($no_block_due_date,4,2); |
57 |
my $month = substr( $no_block_due_date, 4, 2 ); |
| 58 |
my $day = substr($no_block_due_date,6,2); |
58 |
my $day = substr( $no_block_due_date, 6, 2 ); |
| 59 |
my $hour = substr($no_block_due_date,12,2); |
59 |
my $hour = substr( $no_block_due_date, 12, 2 ); |
| 60 |
my $minute = substr($no_block_due_date,14,2); |
60 |
my $minute = substr( $no_block_due_date, 14, 2 ); |
| 61 |
my $second = substr($no_block_due_date,16,2); |
61 |
my $second = substr( $no_block_due_date, 16, 2 ); |
| 62 |
|
62 |
|
| 63 |
my $iso = "$year-$month-$day $hour:$minute:$second"; |
63 |
my $iso = "$year-$month-$day $hour:$minute:$second"; |
| 64 |
$no_block_due_date = dt_from_string( $iso, "iso" ); |
64 |
$no_block_due_date = dt_from_string( $iso, "iso" ); |
| 65 |
} |
65 |
} |
| 66 |
|
66 |
|
| 67 |
my $noerror=1; # If set to zero we block the issue |
67 |
my $noerror = 1; # If set to zero we block the issue |
| 68 |
if ( keys %{$issuingimpossible} ) { |
68 |
if ( keys %{$issuingimpossible} ) { |
| 69 |
foreach ( keys %{$issuingimpossible} ) { |
69 |
foreach ( keys %{$issuingimpossible} ) { |
| 70 |
|
70 |
|
|
Lines 136-165
sub do_checkout {
Link Here
|
| 136 |
} |
136 |
} |
| 137 |
} |
137 |
} |
| 138 |
my $itemnumber = $self->{item}->{itemnumber}; |
138 |
my $itemnumber = $self->{item}->{itemnumber}; |
| 139 |
my ($fee, undef) = GetIssuingCharges($itemnumber, $patron->borrowernumber); |
139 |
my ( $fee, undef ) = GetIssuingCharges( $itemnumber, $patron->borrowernumber ); |
| 140 |
if ( $fee > 0 ) { |
140 |
if ( $fee > 0 ) { |
| 141 |
$self->{sip_fee_type} = '06'; |
141 |
$self->{sip_fee_type} = '06'; |
| 142 |
$self->{fee_amount} = sprintf '%.2f', $fee; |
142 |
$self->{fee_amount} = sprintf '%.2f', $fee; |
| 143 |
if ($self->{fee_ack} eq 'N' ) { |
143 |
if ( $self->{fee_ack} eq 'N' ) { |
| 144 |
$noerror = 0; |
144 |
$noerror = 0; |
| 145 |
} |
145 |
} |
| 146 |
} |
146 |
} |
| 147 |
|
147 |
|
| 148 |
if ( $noerror == 0 && !$no_block_due_date ) { |
148 |
if ( $noerror == 0 && !$no_block_due_date ) { |
| 149 |
$self->ok(0); |
149 |
$self->ok(0); |
| 150 |
return $self; |
150 |
return $self; |
| 151 |
} |
151 |
} |
| 152 |
|
152 |
|
| 153 |
if ( $no_block_due_date ) { |
153 |
if ($no_block_due_date) { |
| 154 |
$overridden_duedate = $no_block_due_date; |
154 |
$overridden_duedate = $no_block_due_date; |
| 155 |
my ( $msg, $checkout ) = ProcessOfflineIssue({ |
155 |
my ( $msg, $checkout ) = ProcessOfflineIssue( |
| 156 |
cardnumber => $patron->cardnumber, |
156 |
{ |
| 157 |
barcode => $barcode, |
157 |
cardnumber => $patron->cardnumber, |
| 158 |
due_date => $no_block_due_date, |
158 |
barcode => $barcode, |
| 159 |
timestamp => dt_from_string, |
159 |
due_date => $no_block_due_date, |
| 160 |
}); |
160 |
timestamp => dt_from_string, |
| 161 |
$self->{due} = $self->duedatefromissue($checkout, $itemnumber); |
161 |
} |
|
|
162 |
); |
| 163 |
$self->{due} = $self->duedatefromissue( $checkout, $itemnumber ); |
| 162 |
} else { |
164 |
} else { |
|
|
165 |
|
| 163 |
# can issue |
166 |
# can issue |
| 164 |
my $recall_id; |
167 |
my $recall_id; |
| 165 |
foreach ( keys %{$messages} ) { |
168 |
foreach ( keys %{$messages} ) { |
|
Lines 179-185
sub _can_we_issue {
Link Here
|
| 179 |
my ( $patron, $barcode, $pref ) = @_; |
182 |
my ( $patron, $barcode, $pref ) = @_; |
| 180 |
|
183 |
|
| 181 |
my ( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
184 |
my ( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = |
| 182 |
CanBookBeIssued( $patron, $barcode, undef, 0, $pref ); |
185 |
CanBookBeIssued( $patron, $barcode, undef, 0, $pref ); |
| 183 |
for my $href ( $issuingimpossible, $needsconfirmation ) { |
186 |
for my $href ( $issuingimpossible, $needsconfirmation ) { |
| 184 |
|
187 |
|
| 185 |
# some data is returned using lc keys we only |
188 |
# some data is returned using lc keys we only |
| 186 |
- |
|
|