Lines 35-106
my ($template, $loggedinuser, $cookie)= get_template_and_user(
Link Here
|
35 |
} |
35 |
} |
36 |
); |
36 |
); |
37 |
|
37 |
|
38 |
my $op = $input->param('op') || 'list'; |
38 |
my $op = $input->param('op') || 'list'; |
39 |
my @recall_ids = $input->multi_param('recall_ids'); |
39 |
my @recall_ids = $input->multi_param('recall_ids'); |
40 |
my $biblionumber = $input->param('biblionumber'); |
40 |
my $biblionumber = $input->param('biblionumber'); |
41 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
41 |
my $biblio = Koha::Biblios->find($biblionumber); |
42 |
my $borrowernumber = $input->param('borrowernumber'); |
42 |
my $borrowernumber = $input->param('borrowernumber'); |
43 |
my $error = $input->param('error'); |
43 |
my $error = $input->param('error'); |
44 |
|
44 |
|
45 |
if ( $op eq 'cancel_multiple_recalls' ) { |
45 |
if ( $op eq 'cancel_multiple_recalls' ) { |
46 |
foreach my $id ( @recall_ids ) { |
46 |
foreach my $id (@recall_ids) { |
47 |
Koha::Recalls->find( $id )->set_cancelled; |
47 |
Koha::Recalls->find($id)->set_cancelled; |
48 |
} |
48 |
} |
49 |
print $input->redirect('/cgi-bin/koha/recalls/request.pl?biblionumber='.$biblionumber); |
49 |
print $input->redirect( '/cgi-bin/koha/recalls/request.pl?biblionumber=' . $biblionumber ); |
50 |
} |
50 |
} |
51 |
elsif ( $op eq 'request' ) { |
51 |
elsif ( $op eq 'request' ) { |
52 |
|
52 |
|
53 |
if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $borrowernumber ) { |
53 |
if ( C4::Context->preference('UseRecalls') |
54 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
54 |
and C4::Context->preference('RecallsInterface') ne 'opac' |
|
|
55 |
and $borrowernumber ) |
56 |
{ |
57 |
my $patron = Koha::Patrons->find($borrowernumber); |
55 |
|
58 |
|
56 |
unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; } |
59 |
unless ( $biblio->can_be_recalled( { patron => $patron } ) ) { $error = 'unavailable'; } |
57 |
my $items = Koha::Items->search({ biblionumber => $biblionumber })->as_list; |
60 |
my $items = Koha::Items->search( { biblionumber => $biblionumber } )->as_list; |
58 |
|
61 |
|
59 |
# check if already recalled |
62 |
# check if already recalled |
60 |
my $recalled = $biblio->recalls->filter_by_current->search({ patron_id => $borrowernumber })->count; |
63 |
my $recalled = $biblio->recalls->filter_by_current->search( { patron_id => $borrowernumber } )->count; |
61 |
if ( defined $recalled and $recalled > 0 ) { |
64 |
if ( defined $recalled and $recalled > 0 ) { |
62 |
my $recalls_per_record = Koha::CirculationRules->get_effective_rule({ |
65 |
my $recalls_per_record = Koha::CirculationRules->get_effective_rule( |
63 |
categorycode => $patron->categorycode, |
66 |
{ |
64 |
branchcode => undef, |
67 |
categorycode => $patron->categorycode, |
65 |
itemtype => undef, |
68 |
branchcode => undef, |
66 |
rule_name => 'recalls_per_record' |
69 |
itemtype => undef, |
67 |
}); |
70 |
rule_name => 'recalls_per_record' |
68 |
if ( defined $recalls_per_record and $recalls_per_record->rule_value and $recalled >= $recalls_per_record->rule_value ){ |
71 |
} |
|
|
72 |
); |
73 |
if ( defined $recalls_per_record |
74 |
and $recalls_per_record->rule_value |
75 |
and $recalled >= $recalls_per_record->rule_value ) |
76 |
{ |
69 |
$error = 'duplicate'; |
77 |
$error = 'duplicate'; |
70 |
} |
78 |
} |
71 |
} |
79 |
} |
72 |
|
80 |
|
73 |
if ( !defined $error ){ |
81 |
if ( !defined $error ) { |
74 |
my $pickuploc = $input->param('pickup'); |
82 |
my $pickuploc = $input->param('pickup'); |
75 |
my $expdate = $input->param('expirationdate'); |
83 |
my $expdate = $input->param('expirationdate'); |
76 |
my $level = $input->param('type'); |
84 |
my $level = $input->param('type'); |
77 |
my $itemnumber = $input->param('itemnumber'); |
85 |
my $itemnumber = $input->param('itemnumber'); |
78 |
|
86 |
|
79 |
my ( $recall, $due_interval, $due_date ); |
87 |
my ( $recall, $due_interval, $due_date ); |
80 |
|
88 |
|
81 |
if ( !defined $level and defined $itemnumber ) { |
89 |
if ( !defined $level and defined $itemnumber ) { |
82 |
my $item = Koha::Items->find( $itemnumber ); |
90 |
my $item = Koha::Items->find($itemnumber); |
83 |
if ( $item->can_be_recalled({ patron => $patron }) ) { |
91 |
if ( $item->can_be_recalled( { patron => $patron } ) ) { |
84 |
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({ |
92 |
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall( |
85 |
patron => $patron, |
93 |
{ |
86 |
biblio => $biblio, |
94 |
patron => $patron, |
87 |
branchcode => $pickuploc, |
95 |
biblio => $biblio, |
88 |
item => $item, |
96 |
branchcode => $pickuploc, |
89 |
expirationdate => $expdate, |
97 |
item => $item, |
90 |
interface => 'staff', |
98 |
expirationdate => $expdate, |
91 |
}); |
99 |
interface => 'staff', |
|
|
100 |
} |
101 |
); |
92 |
} else { |
102 |
} else { |
93 |
$error = 'cannot'; |
103 |
$error = 'cannot'; |
94 |
} |
104 |
} |
95 |
} else { |
105 |
} else { |
96 |
if ( $biblio->can_be_recalled({ patron => $patron }) ) { |
106 |
if ( $biblio->can_be_recalled( { patron => $patron } ) ) { |
97 |
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({ |
107 |
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall( |
98 |
patron => $patron, |
108 |
{ |
99 |
biblio => $biblio, |
109 |
patron => $patron, |
100 |
branchcode => $pickuploc, |
110 |
biblio => $biblio, |
101 |
expirationdate => $expdate, |
111 |
branchcode => $pickuploc, |
102 |
interface => 'staff', |
112 |
expirationdate => $expdate, |
103 |
}); |
113 |
interface => 'staff', |
|
|
114 |
} |
115 |
); |
104 |
} else { |
116 |
} else { |
105 |
$error = 'cannot'; |
117 |
$error = 'cannot'; |
106 |
} |
118 |
} |
Lines 108-113
elsif ( $op eq 'request' ) {
Link Here
|
108 |
if ( !defined $recall ) { |
120 |
if ( !defined $recall ) { |
109 |
$error = 'failed'; |
121 |
$error = 'failed'; |
110 |
} else { |
122 |
} else { |
|
|
123 |
|
111 |
# successful recall, go back to Recalls tab |
124 |
# successful recall, go back to Recalls tab |
112 |
print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber"); |
125 |
print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber"); |
113 |
} |
126 |
} |
Lines 115-152
elsif ( $op eq 'request' ) {
Link Here
|
115 |
} |
128 |
} |
116 |
} |
129 |
} |
117 |
|
130 |
|
118 |
if ( $borrowernumber ) { |
131 |
if ($borrowernumber) { |
119 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
132 |
my $patron = Koha::Patrons->find($borrowernumber); |
120 |
|
133 |
|
121 |
if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $patron and $patron->borrowernumber ) { |
134 |
if ( C4::Context->preference('UseRecalls') |
122 |
if ( !$biblio->can_be_recalled({ patron => $patron }) ) { |
135 |
and C4::Context->preference('RecallsInterface') ne 'opac' |
|
|
136 |
and $patron |
137 |
and $patron->borrowernumber ) |
138 |
{ |
139 |
if ( !$biblio->can_be_recalled( { patron => $patron } ) ) { |
123 |
$error = 1; |
140 |
$error = 1; |
124 |
} |
141 |
} |
125 |
my $patron_holds_count = Koha::Holds->search({ borrowernumber => $borrowernumber, biblionumber => $biblio->biblionumber, item_level_hold => 0 })->count; |
142 |
my $patron_holds_count = Koha::Holds->search( |
|
|
143 |
{ borrowernumber => $borrowernumber, biblionumber => $biblio->biblionumber, item_level_hold => 0 } )->count; |
126 |
|
144 |
|
127 |
$template->param( |
145 |
$template->param( |
128 |
patron => $patron, |
146 |
patron => $patron, |
129 |
patron_holds_count => $patron_holds_count, |
147 |
patron_holds_count => $patron_holds_count, |
130 |
); |
148 |
); |
131 |
} |
149 |
} |
132 |
} |
150 |
} |
133 |
|
151 |
|
134 |
my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 }); |
152 |
my $recalls = Koha::Recalls->search( { biblio_id => $biblionumber, completed => 0 } ); |
135 |
my $branches = Koha::Libraries->search; |
153 |
my $branches = Koha::Libraries->search; |
136 |
my $single_branch_mode = $branches->count == 1; |
154 |
my $single_branch_mode = $branches->count == 1; |
137 |
my $items = Koha::Items->search({ biblionumber => $biblionumber }); |
155 |
my $items = Koha::Items->search( { biblionumber => $biblionumber } ); |
138 |
|
156 |
|
139 |
$template->param( |
157 |
$template->param( |
140 |
recalls => $recalls, |
158 |
recalls => $recalls, |
141 |
recallsview => 1, |
159 |
recallsview => 1, |
142 |
biblio => $biblio, |
160 |
biblio => $biblio, |
143 |
checkboxes => 1, |
161 |
checkboxes => 1, |
144 |
branches => $branches, |
162 |
branches => $branches, |
145 |
items => $items, |
163 |
items => $items, |
146 |
error => $error, |
164 |
error => $error, |
147 |
single_branch_mode => $single_branch_mode, |
165 |
single_branch_mode => $single_branch_mode, |
148 |
C4::Search::enabled_staff_search_views, |
166 |
C4::Search::enabled_staff_search_views, |
149 |
attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') |
167 |
attribute_type_codes => ( |
|
|
168 |
C4::Context->preference('ExtendedPatronAttributes') |
150 |
? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] |
169 |
? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] |
151 |
: [] |
170 |
: [] |
152 |
), |
171 |
), |