Lines 84-99
if ($add) {
Link Here
|
84 |
} |
84 |
} |
85 |
); |
85 |
); |
86 |
|
86 |
|
87 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
87 |
# Note: If the logged in user is not allowed to see this patron an invoice can be forced |
88 |
# Here we are trusting librarians not to hack the system |
88 |
# Here we are trusting librarians not to hack the system |
89 |
my $desc = $input->param('desc'); |
89 |
my $desc = $input->param('desc'); |
90 |
my $amount = $input->param('amount'); |
90 |
my $amount = $input->param('amount'); |
91 |
my $note = $input->param('note'); |
91 |
my $note = $input->param('note'); |
92 |
my $debit_type = $input->param('type'); |
92 |
my $debit_type = $input->param('type'); |
93 |
|
93 |
|
94 |
# If LOST try to match barcode to Item and then try to match Item + Borrower to an Issue. |
94 |
# If barcode is passed, attempt to find the associated item |
95 |
my $failed; |
95 |
my $failed; |
96 |
my $item_id; |
96 |
my $item_id; |
|
|
97 |
my $issue_id; |
97 |
my $barcode = $input->param('barcode'); |
98 |
my $barcode = $input->param('barcode'); |
98 |
if ($barcode) { |
99 |
if ($barcode) { |
99 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
100 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
Lines 101-122
if ($add) {
Link Here
|
101 |
$item_id = $item->itemnumber; |
102 |
$item_id = $item->itemnumber; |
102 |
} |
103 |
} |
103 |
else { |
104 |
else { |
104 |
$template->param( error => 'itemnumber' ); |
105 |
$item = Koha::Old::Items->find( { barcode => $barcode } ); |
105 |
$failed = 1; |
106 |
if ($item) { |
|
|
107 |
$item_id = $item->itemnumber; |
108 |
} |
109 |
else { |
110 |
$template->param( error => 'itemnumber' ); |
111 |
$failed = 1; |
112 |
} |
113 |
} |
114 |
|
115 |
if ( ( $debit_type eq 'LOST' ) && $item_id ) { |
116 |
my $checkouts = Koha::Checkouts->search( |
117 |
{ |
118 |
itemnumber => $item_id, |
119 |
borrowernumber => $borrowernumber |
120 |
} |
121 |
); |
122 |
my $checkout = |
123 |
$checkouts->count |
124 |
? $checkouts->next |
125 |
: Koha::Old::Checkouts->search( |
126 |
{ |
127 |
itemnumber => $item_id, |
128 |
borrowernumber => $borrowernumber |
129 |
}, |
130 |
{ order_by => { -desc => 'returndate' }, rows => 1 } |
131 |
)->next; |
132 |
$issue_id = $checkout ? $checkout->issue_id : undef; |
106 |
} |
133 |
} |
107 |
} |
|
|
108 |
my $issue_id; |
109 |
if ( $debit_type eq 'LOST' && $item_id ) { |
110 |
my $checkouts = Koha::Checkouts->search( |
111 |
{ itemnumber => $item_id, borrowernumber => $borrowernumber } ); |
112 |
my $checkout = |
113 |
$checkouts->count |
114 |
? $checkouts->next |
115 |
: Koha::Old::Checkouts->search( |
116 |
{ itemnumber => $item_id, borrowernumber => $borrowernumber }, |
117 |
{ order_by => { -desc => 'returndate' }, rows => 1 } |
118 |
)->next; |
119 |
$issue_id = $checkout ? $checkout->issue_id : undef; |
120 |
} |
134 |
} |
121 |
|
135 |
|
122 |
unless ($failed) { |
136 |
unless ($failed) { |
Lines 139-154
if ($add) {
Link Here
|
139 |
$patron->account->reconcile_balance; |
153 |
$patron->account->reconcile_balance; |
140 |
} |
154 |
} |
141 |
|
155 |
|
142 |
print $input->redirect( |
156 |
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); |
143 |
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber" |
|
|
144 |
); |
145 |
exit; |
157 |
exit; |
146 |
} |
158 |
} |
147 |
catch { |
159 |
catch { |
148 |
my $error = $_; |
160 |
my $error = $_; |
149 |
if ( ref($error) eq 'Koha::Exceptions::Object::FKConstraint' ) { |
161 |
if ( ref($error) eq 'Koha::Exceptions::Object::FKConstraint' ) { |
150 |
$template->param( error => $error->broken_fk ); |
162 |
$template->param( error => $error->broken_fk ); |
151 |
} else { |
163 |
} |
|
|
164 |
else { |
152 |
$template->param( error => '1' ); |
165 |
$template->param( error => '1' ); |
153 |
} |
166 |
} |
154 |
} |
167 |
} |
155 |
- |
|
|