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 (+1 lines)
Lines 335-340 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
335
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
335
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
336
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
336
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
337
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
337
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
338
('IndependentBranchesHolds','0', NULL, 'Allow non-superlibrarians to modify holds between libraries','YesNo'),
338
('intranet_includes','includes',NULL,'The includes directory you want for specific look of Koha (includes or includes_npl for example)','Free'),
339
('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'),
340
('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'),
341
('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'),
(-)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 (-6 / +9 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 1274-1280 Link Here
1274
                                            [% END %]
1274
                                            [% END %]
1275
                                            <div class="holds_by_library">
1275
                                            <div class="holds_by_library">
1276
                                                <h4>[% Branches.GetName( b ) | html %]</h4>
1276
                                                <h4>[% Branches.GetName( b ) | html %]</h4>
1277
1277
                                                
1278
                                                [% INCLUDE holds_table.inc holds=holds_by_branch %]
1278
                                                [% INCLUDE holds_table.inc holds=holds_by_branch %]
1279
                                            </div>
1279
                                            </div>
1280
                                        [% END # /FOREACh b %]
1280
                                        [% END # /FOREACh b %]
Lines 1806-1812 Link Here
1806
                return false;
1806
                return false;
1807
            });
1807
            });
1808
1808
1809
            [% IF (!CAN_user_superlibrarian) %]
1809
            [% IF ((!CAN_user_superlibrarian) || Koha.Preference('IndependentBranchesHolds')) %] 
1810
                var user_branch = "[% Branches.GetLoggedInBranchcode %]";
1810
                var user_branch = "[% Branches.GetLoggedInBranchcode %]";
1811
                if(user_branch !== undefined && user_branch !== ""){
1811
                if(user_branch !== undefined && user_branch !== ""){
1812
                    $('#patron_holds_table tbody tr').each(function() {
1812
                    $('#patron_holds_table tbody tr').each(function() {
Lines 1814-1823 Link Here
1814
                        var rankRequest = $(this).find("select[name='rank-request']");
1814
                        var rankRequest = $(this).find("select[name='rank-request']");
1815
                        if (!link.length){
1815
                        if (!link.length){
1816
                           $(this).find('.cancel-hold, .fa-trash').addClass('disabled_trash');
1816
                           $(this).find('.cancel-hold, .fa-trash').addClass('disabled_trash');
1817
                           $(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');
1818
                           $(this).find('.select_hold_all, .hold-arrow').addClass('disabled').attr('disabled', 'disabled');
1819
                           $(this).find('.suspend-hold').prop('disabled', true);
1820
                           $(this).find('.icon-move-hold-top').css('border-top', '2px solid #999999');
1821
                           $(this).find('.icon-move-hold-bottom').css('border-bottom', '2px solid #999999');
1817
                        }
1822
                        }
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');
1823
                        
1819
                        $('.select_hold_all, .hold-arrow').addClass('disabled').attr('disabled', 'disabled');
1820
                        $('.suspend-hold').prop('disabled', true);
1821
                    });
1824
                    });
1822
               }
1825
               }
1823
            [% END %]
1826
            [% END %]
(-)a/reserve/request.pl (-25 / +41 lines)
Lines 66-72 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( Link Here
66
);
66
);
67
67
68
my $is_super_librarian = C4::Context->IsSuperLibrarian();
68
my $is_super_librarian = C4::Context->IsSuperLibrarian();
69
my $user_branch = C4::Context->preference("IndependentBranches") ? C4::Context->userenv->{'branch'}: undef;
69
my $user_branch = C4::Context->preference("IndependentBranchesHolds") ? C4::Context->userenv->{'branch'}: undef;
70
70
71
$template->param(
71
$template->param(
72
    is_super_librarian => $is_super_librarian,
72
    is_super_librarian => $is_super_librarian,
Lines 97-104 my $warnings; Link Here
97
my $messages;
97
my $messages;
98
my $exceeded_maxreserves;
98
my $exceeded_maxreserves;
99
my $exceeded_holds_per_record;
99
my $exceeded_holds_per_record;
100
my @failed_holds   = $input->multi_param('failed_holds');
100
my @failed_holds     = $input->multi_param('failed_holds');
101
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); 
102
103
103
my $op = $input->param('op') || q{};
104
my $op = $input->param('op') || q{};
104
105
Lines 110-153 if ( $op eq 'cud-move' ) { Link Here
110
    my $first_priority  = $input->param('first_priority');
111
    my $first_priority  = $input->param('first_priority');
111
    my $last_priority   = $input->param('last_priority');
112
    my $last_priority   = $input->param('last_priority');
112
    my $hold_itemnumber = $input->param('itemnumber');
113
    my $hold_itemnumber = $input->param('itemnumber');
113
    if ( $prev_priority == 0 && $next_priority == 1 ) {
114
        if ( $prev_priority == 0 && $next_priority == 1 ) {
114
        C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } );
115
            C4::Reserves::RevertWaitingStatus( { itemnumber => $hold_itemnumber } );
115
    } else {
116
        } else {
116
        AlterPriority(
117
            AlterPriority(
117
            $where,         $reserve_id,     $prev_priority,
118
                $where,         $reserve_id,     $prev_priority,
118
            $next_priority, $first_priority, $last_priority
119
                $next_priority, $first_priority, $last_priority
119
        );
120
            );
120
    }
121
        }
121
} elsif ( $op eq 'cud-cancel' ) {
122
} elsif ( $op eq 'cud-cancel' ) {
122
    my $reserve_id          = $input->param('reserve_id');
123
    my $reserve_id          = $input->param('reserve_id');
123
    my $cancellation_reason = $input->param("cancellation-reason");
124
    my $cancellation_reason = $input->param("cancellation-reason");
124
    my $hold                = Koha::Holds->find($reserve_id);
125
    my $hold                = Koha::Holds->find($reserve_id);
125
    $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
    }
126
} elsif ( $op eq 'cud-setLowestPriority' ) {
129
} elsif ( $op eq 'cud-setLowestPriority' ) {
127
    my $reserve_id = $input->param('reserve_id');
130
    my $reserve_id = $input->param('reserve_id');
128
    ToggleLowestPriority($reserve_id);
131
    if ( $can_modify_all_holds || Koha::Holds->find($reserve_id) -> branchcode eq $user_branch ) {
132
        ToggleLowestPriority($reserve_id);
133
    }
129
} elsif ( $op eq 'cud-suspend' ) {
134
} elsif ( $op eq 'cud-suspend' ) {
130
    my $reserve_id    = $input->param('reserve_id');
135
    my $reserve_id    = $input->param('reserve_id');
131
    my $suspend_until = $input->param('suspend_until');
136
    my $suspend_until = $input->param('suspend_until');
132
    my $hold          = Koha::Holds->find($reserve_id);
137
    my $hold          = Koha::Holds->find($reserve_id);
133
    $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
    }
134
} elsif ( $op eq 'cud-unsuspend' ) {
141
} elsif ( $op eq 'cud-unsuspend' ) {
135
    my $reserve_id = $input->param('reserve_id');
142
    my $reserve_id = $input->param('reserve_id');
136
    my $hold       = Koha::Holds->find($reserve_id);
143
    my $hold       = Koha::Holds->find($reserve_id);
137
    $hold->resume() if $hold;
144
    if ( $can_modify_all_holds || $hold -> branchcode eq $user_branch ) {
145
        $hold->resume() if $hold;
146
    }
138
} elsif ( $op eq 'cud-cancel_bulk' ) {
147
} elsif ( $op eq 'cud-cancel_bulk' ) {
139
    my $cancellation_reason = $input->param("cancellation-reason");
148
    my $cancellation_reason = $input->param("cancellation-reason");
140
    my @hold_ids            = split( ',', scalar $input->param("ids") );
149
    my @hold_ids            = split( ',', scalar $input->param("ids") );
141
    my $params              = {
150
    for (my $i = 0; $i < @hold_ids; $i++) {
142
        reason   => $cancellation_reason,
151
        if (!( $can_modify_all_holds || (Koha::Holds->find($hold_ids[$i])->branchcode) eq $user_branch )) {
143
        hold_ids => \@hold_ids,
152
            splice(@hold_ids, $i, 1);
144
    };
153
            $i--; 
145
    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);
146
162
147
    $template->param(
163
        $template->param(
148
        enqueued => 1,
164
            enqueued => 1,
149
        job_id   => $job_id
165
            job_id   => $job_id
150
    );
166
        );
167
    }
151
}
168
}
152
169
153
if ($findborrower) {
170
if ($findborrower) {
154
- 

Return to bug 38040