View | Details | Raw Unified | Return to bug 38040
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_38040-IndependentBranchesHolds_syspref.pl (+14 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "38040",
6
    description => "Prevent staff (but not superlibrarians) from modifying holds from other libraries:",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('IndependentBranchesHolds', '1', NULL, 'Prevent staff (but not superlibrarians) from modifying holds from other libraries', 'YESNO')});
12
        say_success( $out, "Added new system preference 'IndependentBranchesHolds'" );
13
    },
14
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+2 lines)
Lines 336-341 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
336
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
336
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
337
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
337
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
338
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
338
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
339
('IndependentBranchesHolds','0', NULL, 'Allow non-superlibrarians to modify holds between libraries','YesNo'),
340
('intranet_includes','includes',NULL,'The includes directory you want for specific look of Koha (includes or includes_npl for example)','Free'),
339
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
341
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
340
('IntranetBiblioDefaultView','normal','normal|marc|isbd|labeled_marc','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','Choice'),
342
('IntranetBiblioDefaultView','normal','normal|marc|isbd|labeled_marc','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','Choice'),
341
('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'),
343
('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-2 / +8 lines)
Lines 33-39 Link Here
33
33
34
    [% SET all_priorities = [] %]
34
    [% SET all_priorities = [] %]
35
    [% FOREACH hold IN holds %]
35
    [% FOREACH hold IN holds %]
36
        [% all_priorities.push( hold.priority ) %]
36
        [% IF CAN_user_superlibrarian  || !Koha.Preference('IndependentBranchesHolds') %]
37
              [% all_priorities.push( hold.priority ) %]
38
        [% ELSE %]
39
            [% IF Branches.GetLoggedInBranchcode == hold.branchcode %]
40
                [% all_priorities.push( hold.priority ) %]
41
            [% END %]
42
        [% END %]
37
    [% END %]
43
    [% END %]
38
44
39
    <tbody>
45
    <tbody>
Lines 42-48 Link Here
42
                [%- first_priority = hold.priority -%]
48
                [%- first_priority = hold.priority -%]
43
                [%- found_holds = loop.index() -%]
49
                [%- found_holds = loop.index() -%]
44
            [%- END -%]
50
            [%- END -%]
45
            [%- IF Koha.Preference('HoldsSplitQueueNumbering') == 'actual' -%]
51
            [%- IF Koha.Preference('HoldsSplitQueueNumbering') == 'actual' || (Koha.Preference('IndependentBranchesHolds') && !CAN_user_superlibrarian) -%]
46
                [%- this_priority = hold.priority -%]
52
                [%- this_priority = hold.priority -%]
47
            [%- ELSE -%]
53
            [%- ELSE -%]
48
                [%- this_priority = loop.count() - found_holds -%]
54
                [%- this_priority = loop.count() - found_holds -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+7 lines)
Lines 148-153 Administration: Link Here
148
              choices:
148
              choices:
149
                  1: "Yes"
149
                  1: "Yes"
150
                  0: "No"
150
                  0: "No"
151
        -
152
            - "Prevent staff (but not superlibrarians) from modifying holds from other libraries: "
153
            - pref: IndependentBranchesHolds
154
              default: 0
155
              choices:
156
                  1: "Yes"
157
                  0: "No"
151
        -
158
        -
152
            - pref: ForceLibrarySelection
159
            - pref: ForceLibrarySelection
153
              choices:
160
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-5 / +8 lines)
Lines 1253-1259 Link Here
1253
                                    </h3>
1253
                                    </h3>
1254
                                [% END %]
1254
                                [% END %]
1255
1255
1256
                                [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
1256
                                [% IF Koha.Preference('HoldsSplitQueue') == 'branch' || ((!CAN_user_superlibrarian) && Koha.Preference('IndependentBranchesHolds'))%]
1257
1257
1258
                                    [% SET branchcodes = [] %]
1258
                                    [% SET branchcodes = [] %]
1259
1259
Lines 1807-1813 Link Here
1807
                return false;
1807
                return false;
1808
            });
1808
            });
1809
1809
1810
            [% IF (!CAN_user_superlibrarian) %]
1810
            [% IF ((!CAN_user_superlibrarian) || Koha.Preference('IndependentBranchesHolds')) %]
1811
                var user_branch = "[% Branches.GetLoggedInBranchcode %]";
1811
                var user_branch = "[% Branches.GetLoggedInBranchcode %]";
1812
                if(user_branch !== undefined && user_branch !== ""){
1812
                if(user_branch !== undefined && user_branch !== ""){
1813
                    $('#patron_holds_table tbody tr').each(function() {
1813
                    $('#patron_holds_table tbody tr').each(function() {
Lines 1815-1824 Link Here
1815
                        var rankRequest = $(this).find("select[name='rank-request']");
1815
                        var rankRequest = $(this).find("select[name='rank-request']");
1816
                        if (!link.length){
1816
                        if (!link.length){
1817
                           $(this).find('.cancel-hold, .fa-trash').addClass('disabled_trash');
1817
                           $(this).find('.cancel-hold, .fa-trash').addClass('disabled_trash');
1818
                           $(this).find('.select_hold, .rank-request, td a[data-op="cud-move"], .flatpickr, .toggle-suspend, .clear_date, [name*="change_hold_type_"]').addClass('disabled').attr('disabled', 'disabled');
1819
                           $(this).find('.select_hold_all, .hold-arrow').addClass('disabled').attr('disabled', 'disabled');
1820
                           $(this).find('.suspend-hold').prop('disabled', true);
1821
                           $(this).find('.icon-move-hold-top').css('border-top', '2px solid #999999');
1822
                           $(this).find('.icon-move-hold-bottom').css('border-bottom', '2px solid #999999');
1818
                        }
1823
                        }
1819
                        $(this).find('.select_hold, .rank-request, td a[data-op="cud-move"], .flatpickr, .toggle-suspend, .clear_date, [name*="change_hold_type_"]').addClass('disabled').attr('disabled', 'disabled');
1824
1820
                        $('.select_hold_all, .hold-arrow').addClass('disabled').attr('disabled', 'disabled');
1821
                        $('.suspend-hold').prop('disabled', true);
1822
                    });
1825
                    });
1823
               }
1826
               }
1824
            [% END %]
1827
            [% END %]
(-)a/reserve/request.pl (-25 / +41 lines)
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
- 

Return to bug 38040