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

(-)a/installer/data/mysql/mandatory/sysprefs.sql (+2 lines)
Lines 336-343 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
336
('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo'),
336
('IncludeSeeAlsoFromInSearches','0','','Include see-also-from references in searches.','YesNo'),
337
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
337
('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo'),
338
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
338
('IndependentBranches','0',NULL,'If ON, increases security between libraries','YesNo'),
339
('IndependentBranchesHolds','0', NULL, 'Allow non-superlibrarians to modify holds between libraries','YesNo'),
339
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
340
('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'),
340
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
341
('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'),
342
('intranet_includes','includes',NULL,'The includes directory you want for specific look of Koha (includes or includes_npl for example)','Free'),
341
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
343
('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'),
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'),
344
('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'),
343
('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'),
345
('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 (-1 / +26 lines)
Lines 105-110 Link Here
105
        :disabled {
105
        :disabled {
106
            opacity: 0.5;
106
            opacity: 0.5;
107
        }
107
        }
108
109
        .disabled_trash{
110
            pointer-events: none;
111
            cursor: not-allowed ;
112
            color: #777;
113
        }
108
    </style>
114
    </style>
109
[% END %]
115
[% END %]
110
</head>
116
</head>
Lines 1247-1253 Link Here
1247
                                    </h3>
1253
                                    </h3>
1248
                                [% END %]
1254
                                [% END %]
1249
1255
1250
                                [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
1256
                                [% IF Koha.Preference('HoldsSplitQueue') == 'branch' || ((!CAN_user_superlibrarian) && Koha.Preference('IndependentBranchesHolds'))%]
1251
1257
1252
                                    [% SET branchcodes = [] %]
1258
                                    [% SET branchcodes = [] %]
1253
1259
Lines 1801-1806 Link Here
1801
                return false;
1807
                return false;
1802
            });
1808
            });
1803
1809
1810
            [% IF ((!CAN_user_superlibrarian) || Koha.Preference('IndependentBranchesHolds')) %]
1811
                var user_branch = "[% Branches.GetLoggedInBranchcode %]";
1812
                if(user_branch !== undefined && user_branch !== ""){
1813
                    $('#patron_holds_table tbody tr').each(function() {
1814
                        var link = $(this).find('a[href*="member"]');
1815
                        var rankRequest = $(this).find("select[name='rank-request']");
1816
                        if (!link.length){
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');
1823
                           $(this).find('.pickup_location_dropdown').prop('disabled', true);
1824
                        }
1825
                    });
1826
               }
1827
            [% END %]
1828
1804
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1829
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1805
                [% IF ( PatronAutoComplete ) %]
1830
                [% IF ( PatronAutoComplete ) %]
1806
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
1831
                    patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' });
(-)a/reserve/modrequest.pl (-29 / +35 lines)
Lines 49-94 my $count = @rank; Link Here
49
49
50
@biblionumber = uniq @biblionumber;
50
@biblionumber = uniq @biblionumber;
51
51
52
my $is_super_librarian = C4::Context->IsSuperLibrarian();
53
my $user_branch = C4::Context->preference("IndependentBranches") ? C4::Context->userenv->{'branch'}: undef;
54
my $can_modify_all_holds = $is_super_librarian || !defined($user_branch);
55
52
# Cancel or modify the queue list of reserves (without item linked)
56
# Cancel or modify the queue list of reserves (without item linked)
53
if ( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) {
57
if ( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) {
54
    for ( my $i = 0 ; $i < $count ; $i++ ) {
58
    for ( my $i = 0 ; $i < $count ; $i++ ) {
55
        undef $itemnumber[$i] if !$itemnumber[$i];
59
        if ( $can_modify_all_holds || $branch[$i] eq $user_branch ) {
56
        my $suspend_until       = $query->param( "suspend_until_" . $reserve_id[$i] );
60
            undef $itemnumber[$i] if !$itemnumber[$i];
57
        my $cancellation_reason = $query->param("cancellation-reason");
61
            my $suspend_until       = $query->param( "suspend_until_" . $reserve_id[$i] );
58
        my $params              = {
62
            my $cancellation_reason = $query->param("cancellation-reason");
59
            rank           => $rank[$i],
63
            my $params              = {
60
            reserve_id     => $reserve_id[$i],
64
                rank           => $rank[$i],
61
            expirationdate => $expirationdates[$i] || undef,
65
                reserve_id     => $reserve_id[$i],
62
            branchcode     => $branch[$i],
66
                expirationdate => $expirationdates[$i] || undef,
63
            itemnumber     => $itemnumber[$i],
67
                branchcode     => $branch[$i],
64
            defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
68
                itemnumber     => $itemnumber[$i],
65
            cancellation_reason => $cancellation_reason,
69
                defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
66
        };
70
                cancellation_reason => $cancellation_reason,
67
        if ( C4::Context->preference('AllowHoldDateInFuture') ) {
71
            };
68
            $params->{reservedate} = $reservedates[$i] || undef;
72
            if ( C4::Context->preference('AllowHoldDateInFuture') ) {
69
        }
73
                $params->{reservedate} = $reservedates[$i] || undef;
70
71
        try {
72
            ModReserve($params);
73
        } catch {
74
            if ( $_->isa('Koha::Exceptions::ObjectNotFound') ) {
75
                warn $_;
76
            } else {
77
                $_->rethrow;
78
            }
74
            }
79
        };
80
81
        if ( $query->param( "change_hold_type_" . $reserve_id[$i] ) ) {
82
            my $hold = Koha::Holds->find( $reserve_id[$i] );
83
75
84
            try {
76
            try {
85
                $hold->change_type;
77
                ModReserve($params);
86
            } catch {
78
            } catch {
87
                if ( $_->isa('Koha::Exceptions::Hold::CannotChangeHoldType') ) {
79
                if ( $_->isa('Koha::Exceptions::ObjectNotFound') ) {
88
                    warn $_;
80
                    warn $_;
89
                } else {
81
                } else {
90
                    $_->rethrow;
82
                    $_->rethrow;
91
                }
83
                }
84
            };
85
86
            if ( $query->param( "change_hold_type_" . $reserve_id[$i] ) ) {
87
                my $hold = Koha::Holds->find( $reserve_id[$i] );
88
89
                try {
90
                    $hold->change_type;
91
                } catch {
92
                    if ( $_->isa('Koha::Exceptions::Hold::CannotChangeHoldType') ) {
93
                        warn $_;
94
                    } else {
95
                        $_->rethrow;
96
                    }
97
                }
92
            }
98
            }
93
        }
99
        }
94
    }
100
    }
(-)a/reserve/request.pl (-24 / +49 lines)
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
- 

Return to bug 38040