Lines 39-45
use C4::Koha qw( getitemtypeimagelocation );
Link Here
|
39 |
use C4::Serials qw( CountSubscriptionFromBiblionumber ); |
39 |
use C4::Serials qw( CountSubscriptionFromBiblionumber ); |
40 |
use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule ); |
40 |
use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule ); |
41 |
use Koha::DateUtils qw( dt_from_string ); |
41 |
use Koha::DateUtils qw( dt_from_string ); |
42 |
use C4::Search qw( enabled_staff_search_views ); |
42 |
use C4::Search qw( enabled_staff_search_views ); |
|
|
43 |
use C4::Context; |
43 |
|
44 |
|
44 |
use Koha::Biblios; |
45 |
use Koha::Biblios; |
45 |
use Koha::Checkouts; |
46 |
use Koha::Checkouts; |
Lines 64-69
my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
Link Here
|
64 |
} |
65 |
} |
65 |
); |
66 |
); |
66 |
|
67 |
|
|
|
68 |
my $is_super_librarian = C4::Context->IsSuperLibrarian(); |
69 |
my $user_branch = C4::Context->preference("IndependentBranches") ? C4::Context->userenv->{'branch'}: undef; |
70 |
|
71 |
$template->param( |
72 |
is_super_librarian => $is_super_librarian, |
73 |
user_branch => $user_branch, |
74 |
); |
75 |
|
67 |
my $showallitems = $input->param('showallitems'); |
76 |
my $showallitems = $input->param('showallitems'); |
68 |
my $pickup = $input->param('pickup'); |
77 |
my $pickup = $input->param('pickup'); |
69 |
|
78 |
|
Lines 88-95
my $warnings;
Link Here
|
88 |
my $messages; |
97 |
my $messages; |
89 |
my $exceeded_maxreserves; |
98 |
my $exceeded_maxreserves; |
90 |
my $exceeded_holds_per_record; |
99 |
my $exceeded_holds_per_record; |
91 |
my @failed_holds = $input->multi_param('failed_holds'); |
100 |
my @failed_holds = $input->multi_param('failed_holds'); |
92 |
my $form_submitted = $input->param('form_submitted'); |
101 |
my $form_submitted = $input->param('form_submitted'); |
|
|
102 |
my $can_modify_all_holds = $is_super_librarian || !defined($user_branch); |
93 |
|
103 |
|
94 |
my $op = $input->param('op') || q{}; |
104 |
my $op = $input->param('op') || q{}; |
95 |
|
105 |
|
Lines 101-144
if ( $op eq 'cud-move' ) {
Link Here
|
101 |
my $first_priority = $input->param('first_priority'); |
111 |
my $first_priority = $input->param('first_priority'); |
102 |
my $last_priority = $input->param('last_priority'); |
112 |
my $last_priority = $input->param('last_priority'); |
103 |
my $hold_itemnumber = $input->param('itemnumber'); |
113 |
my $hold_itemnumber = $input->param('itemnumber'); |
104 |
if ( $prev_priority == 0 && $next_priority == 1 ) { |
114 |
if ( $prev_priority == 0 && $next_priority == 1 ) { |
105 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } ); |
115 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } ); |
106 |
} else { |
116 |
} else { |
107 |
AlterPriority( |
117 |
AlterPriority( |
108 |
$where, $reserve_id, $prev_priority, |
118 |
$where, $reserve_id, $prev_priority, |
109 |
$next_priority, $first_priority, $last_priority |
119 |
$next_priority, $first_priority, $last_priority |
110 |
); |
120 |
); |
111 |
} |
121 |
} |
112 |
} elsif ( $op eq 'cud-cancel' ) { |
122 |
} elsif ( $op eq 'cud-cancel' ) { |
113 |
my $reserve_id = $input->param('reserve_id'); |
123 |
my $reserve_id = $input->param('reserve_id'); |
114 |
my $cancellation_reason = $input->param("cancellation-reason"); |
124 |
my $cancellation_reason = $input->param("cancellation-reason"); |
115 |
my $hold = Koha::Holds->find($reserve_id); |
125 |
my $hold = Koha::Holds->find($reserve_id); |
116 |
$hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold; |
126 |
if ( $can_modify_all_holds || $hold->branchcode eq $user_branch ) { |
|
|
127 |
$hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold; |
128 |
} |
117 |
} elsif ( $op eq 'cud-setLowestPriority' ) { |
129 |
} elsif ( $op eq 'cud-setLowestPriority' ) { |
118 |
my $reserve_id = $input->param('reserve_id'); |
130 |
my $reserve_id = $input->param('reserve_id'); |
119 |
ToggleLowestPriority($reserve_id); |
131 |
if ( $can_modify_all_holds || Koha::Holds->find($reserve_id)->branchcode eq $user_branch ) { |
|
|
132 |
ToggleLowestPriority($reserve_id); |
133 |
} |
120 |
} elsif ( $op eq 'cud-suspend' ) { |
134 |
} elsif ( $op eq 'cud-suspend' ) { |
121 |
my $reserve_id = $input->param('reserve_id'); |
135 |
my $reserve_id = $input->param('reserve_id'); |
122 |
my $suspend_until = $input->param('suspend_until'); |
136 |
my $suspend_until = $input->param('suspend_until'); |
123 |
my $hold = Koha::Holds->find($reserve_id); |
137 |
my $hold = Koha::Holds->find($reserve_id); |
124 |
$hold->suspend_hold($suspend_until) if $hold; |
138 |
if (( $can_modify_all_holds || $hold->branchcode) eq $user_branch ) { |
|
|
139 |
$hold->suspend_hold($suspend_until) if $hold; |
140 |
} |
125 |
} elsif ( $op eq 'cud-unsuspend' ) { |
141 |
} elsif ( $op eq 'cud-unsuspend' ) { |
126 |
my $reserve_id = $input->param('reserve_id'); |
142 |
my $reserve_id = $input->param('reserve_id'); |
127 |
my $hold = Koha::Holds->find($reserve_id); |
143 |
my $hold = Koha::Holds->find($reserve_id); |
128 |
$hold->resume() if $hold; |
144 |
if ( $can_modify_all_holds || $hold->branchcode eq $user_branch ) { |
|
|
145 |
$hold->resume() if $hold; |
146 |
} |
129 |
} elsif ( $op eq 'cud-cancel_bulk' ) { |
147 |
} elsif ( $op eq 'cud-cancel_bulk' ) { |
130 |
my $cancellation_reason = $input->param("cancellation-reason"); |
148 |
my $cancellation_reason = $input->param("cancellation-reason"); |
131 |
my @hold_ids = split( ',', scalar $input->param("ids") ); |
149 |
my @hold_ids = split( ',', scalar $input->param("ids") ); |
132 |
my $params = { |
150 |
for (my $i = 0; $i < @hold_ids; $i++) { |
133 |
reason => $cancellation_reason, |
151 |
if (!( $can_modify_all_holds || (Koha::Holds->find($hold_ids[$i])->branchcode) eq $user_branch )) { |
134 |
hold_ids => \@hold_ids, |
152 |
splice(@hold_ids, $i, 1); |
135 |
}; |
153 |
$i--; |
136 |
my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue($params); |
154 |
} |
|
|
155 |
} |
156 |
unless (scalar @hold_ids == 0) { |
157 |
my $params = { |
158 |
reason => $cancellation_reason, |
159 |
hold_ids => \@hold_ids, |
160 |
}; |
161 |
my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue($params); |
137 |
|
162 |
|
138 |
$template->param( |
163 |
$template->param( |
139 |
enqueued => 1, |
164 |
enqueued => 1, |
140 |
job_id => $job_id |
165 |
job_id => $job_id |
141 |
); |
166 |
); |
|
|
167 |
} |
142 |
} |
168 |
} |
143 |
|
169 |
|
144 |
if ($findborrower) { |
170 |
if ($findborrower) { |
145 |
- |
|
|