Lines 70-76
my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
Link Here
|
70 |
); |
70 |
); |
71 |
|
71 |
|
72 |
my $is_super_librarian = C4::Context->IsSuperLibrarian(); |
72 |
my $is_super_librarian = C4::Context->IsSuperLibrarian(); |
73 |
my $user_branch = C4::Context->preference("IndependentBranches") ? C4::Context->userenv->{'branch'}: undef; |
73 |
my $user_branch = C4::Context->preference("IndependentBranchesHolds") ? C4::Context->userenv->{'branch'}: undef; |
74 |
|
74 |
|
75 |
$template->param( |
75 |
$template->param( |
76 |
is_super_librarian => $is_super_librarian, |
76 |
is_super_librarian => $is_super_librarian, |
Lines 101-108
my $warnings;
Link Here
|
101 |
my $messages; |
101 |
my $messages; |
102 |
my $exceeded_maxreserves; |
102 |
my $exceeded_maxreserves; |
103 |
my $exceeded_holds_per_record; |
103 |
my $exceeded_holds_per_record; |
104 |
my @failed_holds = $input->multi_param('failed_holds'); |
104 |
my @failed_holds = $input->multi_param('failed_holds'); |
105 |
my $form_submitted = $input->param('form_submitted'); |
105 |
my $form_submitted = $input->param('form_submitted'); |
|
|
106 |
my $can_modify_all_holds = $is_super_librarian || !defined($user_branch); |
106 |
|
107 |
|
107 |
my $op = $input->param('op') || q{}; |
108 |
my $op = $input->param('op') || q{}; |
108 |
|
109 |
|
Lines 114-157
if ( $op eq 'cud-move' ) {
Link Here
|
114 |
my $first_priority = $input->param('first_priority'); |
115 |
my $first_priority = $input->param('first_priority'); |
115 |
my $last_priority = $input->param('last_priority'); |
116 |
my $last_priority = $input->param('last_priority'); |
116 |
my $hold_itemnumber = $input->param('itemnumber'); |
117 |
my $hold_itemnumber = $input->param('itemnumber'); |
117 |
if ( $prev_priority == 0 && $next_priority == 1 ) { |
118 |
if ( $prev_priority == 0 && $next_priority == 1 ) { |
118 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } ); |
119 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } ); |
119 |
} else { |
120 |
} else { |
120 |
AlterPriority( |
121 |
AlterPriority( |
121 |
$where, $reserve_id, $prev_priority, |
122 |
$where, $reserve_id, $prev_priority, |
122 |
$next_priority, $first_priority, $last_priority |
123 |
$next_priority, $first_priority, $last_priority |
123 |
); |
124 |
); |
124 |
} |
125 |
} |
125 |
} elsif ( $op eq 'cud-cancel' ) { |
126 |
} elsif ( $op eq 'cud-cancel' ) { |
126 |
my $reserve_id = $input->param('reserve_id'); |
127 |
my $reserve_id = $input->param('reserve_id'); |
127 |
my $cancellation_reason = $input->param("cancellation-reason"); |
128 |
my $cancellation_reason = $input->param("cancellation-reason"); |
128 |
my $hold = Koha::Holds->find($reserve_id); |
129 |
my $hold = Koha::Holds->find($reserve_id); |
129 |
$hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold; |
130 |
if ( $can_modify_all_holds || $hold -> branchcode eq $user_branch ) { |
|
|
131 |
$hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold; |
132 |
} |
130 |
} elsif ( $op eq 'cud-setLowestPriority' ) { |
133 |
} elsif ( $op eq 'cud-setLowestPriority' ) { |
131 |
my $reserve_id = $input->param('reserve_id'); |
134 |
my $reserve_id = $input->param('reserve_id'); |
132 |
ToggleLowestPriority($reserve_id); |
135 |
if ( $can_modify_all_holds || Koha::Holds->find($reserve_id) -> branchcode eq $user_branch ) { |
|
|
136 |
ToggleLowestPriority($reserve_id); |
137 |
} |
133 |
} elsif ( $op eq 'cud-suspend' ) { |
138 |
} elsif ( $op eq 'cud-suspend' ) { |
134 |
my $reserve_id = $input->param('reserve_id'); |
139 |
my $reserve_id = $input->param('reserve_id'); |
135 |
my $suspend_until = $input->param('suspend_until'); |
140 |
my $suspend_until = $input->param('suspend_until'); |
136 |
my $hold = Koha::Holds->find($reserve_id); |
141 |
my $hold = Koha::Holds->find($reserve_id); |
137 |
$hold->suspend_hold($suspend_until) if $hold; |
142 |
if (( $can_modify_all_holds || $hold -> branchcode) eq $user_branch ) { |
|
|
143 |
$hold->suspend_hold($suspend_until) if $hold; |
144 |
} |
138 |
} elsif ( $op eq 'cud-unsuspend' ) { |
145 |
} elsif ( $op eq 'cud-unsuspend' ) { |
139 |
my $reserve_id = $input->param('reserve_id'); |
146 |
my $reserve_id = $input->param('reserve_id'); |
140 |
my $hold = Koha::Holds->find($reserve_id); |
147 |
my $hold = Koha::Holds->find($reserve_id); |
141 |
$hold->resume() if $hold; |
148 |
if ( $can_modify_all_holds || $hold -> branchcode eq $user_branch ) { |
|
|
149 |
$hold->resume() if $hold; |
150 |
} |
142 |
} elsif ( $op eq 'cud-cancel_bulk' ) { |
151 |
} elsif ( $op eq 'cud-cancel_bulk' ) { |
143 |
my $cancellation_reason = $input->param("cancellation-reason"); |
152 |
my $cancellation_reason = $input->param("cancellation-reason"); |
144 |
my @hold_ids = split( ',', scalar $input->param("ids") ); |
153 |
my @hold_ids = split( ',', scalar $input->param("ids") ); |
145 |
my $params = { |
154 |
for (my $i = 0; $i < @hold_ids; $i++) { |
146 |
reason => $cancellation_reason, |
155 |
if (!( $can_modify_all_holds || (Koha::Holds->find($hold_ids[$i])->branchcode) eq $user_branch )) { |
147 |
hold_ids => \@hold_ids, |
156 |
splice(@hold_ids, $i, 1); |
148 |
}; |
157 |
$i--; |
149 |
my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue($params); |
158 |
} |
|
|
159 |
} |
160 |
unless (scalar @hold_ids == 0) { |
161 |
my $params = { |
162 |
reason => $cancellation_reason, |
163 |
hold_ids => \@hold_ids, |
164 |
}; |
165 |
my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue($params); |
150 |
|
166 |
|
151 |
$template->param( |
167 |
$template->param( |
152 |
enqueued => 1, |
168 |
enqueued => 1, |
153 |
job_id => $job_id |
169 |
job_id => $job_id |
154 |
); |
170 |
); |
|
|
171 |
} |
155 |
} |
172 |
} |
156 |
|
173 |
|
157 |
if ($findborrower) { |
174 |
if ($findborrower) { |
158 |
- |
|
|