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