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

(-)a/C4/Serials.pm (+13 lines)
Lines 2718-2723 sub subscriptionCurrentlyOnOrder { Link Here
2718
    return $sth->fetchrow_array;
2718
    return $sth->fetchrow_array;
2719
}
2719
}
2720
2720
2721
=head2 can_claim_subscription
2722
2723
    $can = can_claim_subscription( $subscriptionid[, $userid] );
2724
2725
Return 1 if the subscription can be claimed by the current logged user (or a given $userid), else 0.
2726
2727
=cut
2728
2729
sub can_claim_subscription {
2730
    my ( $subscription, $userid ) = @_;
2731
    return _can_do_on_subscription( $subscription, $userid, 'claim_serials' );
2732
}
2733
2721
=head2 can_edit_subscription
2734
=head2 can_edit_subscription
2722
2735
2723
    $can = can_edit_subscription( $subscriptionid[, $userid] );
2736
    $can = can_edit_subscription( $subscriptionid[, $userid] );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (-1 / +5 lines)
Lines 230-236 Link Here
230
                </tfoot>
230
                </tfoot>
231
                <tbody>[% FOREACH missingissue IN missingissues %]
231
                <tbody>[% FOREACH missingissue IN missingissues %]
232
                    <tr>
232
                    <tr>
233
                        <td><input type="checkbox" name="serialid" value="[% missingissue.serialid %]" /></td>
233
                        <td>
234
                          [% UNLESS missingissue.cannot_claim %]
235
                            <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
236
                          [% END %]
237
                        </td>
234
                        <td>[% missingissue.name %]</td>
238
                        <td>[% missingissue.name %]</td>
235
                        <td>
239
                        <td>
236
                            <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
240
                            <span class="branch-[% missingissue.branchcode %]">[% Branches.GetName( missingissue.branchcode ) %]</span>
(-)a/serials/claims.pl (+4 lines)
Lines 94-99 my $letters = GetLetters({ module => 'claimissues' }); Link Here
94
my @missingissues;
94
my @missingissues;
95
if ($supplierid) {
95
if ($supplierid) {
96
    @missingissues = GetLateOrMissingIssues($supplierid);
96
    @missingissues = GetLateOrMissingIssues($supplierid);
97
    foreach my $issue (@missingissues) {
98
        $issue->{cannot_claim} = 1
99
          unless C4::Serials::can_claim_subscription($issue);
100
    }
97
}
101
}
98
102
99
$template->param(
103
$template->param(
(-)a/t/db_dependent/Serials_2.t (-2 / +31 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
use Modern::Perl;
2
use Modern::Perl;
3
3
4
use Test::More tests => 36;
4
use Test::More tests => 46;
5
5
6
use MARC::Record;
6
use MARC::Record;
7
7
Lines 65-70 my $subscriptionid_from_another_branch = NewSubscription( Link Here
65
65
66
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch );
66
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch );
67
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
67
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
68
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
68
69
69
my $userid = 'my_userid';
70
my $userid = 'my_userid';
70
my $borrowernumber = C4::Members::AddMember(
71
my $borrowernumber = C4::Members::AddMember(
Lines 80-85 $userenv = { flags => 1, id => $borrowernumber, branch => '' }; Link Here
80
# Can edit a subscription
81
# Can edit a subscription
81
82
82
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
83
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
84
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
83
85
84
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch );
86
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch );
85
87
Lines 101-106 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
101
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
103
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
102
"With IndependentBranches, superlibrarian can show a subscription from another branch"
104
"With IndependentBranches, superlibrarian can show a subscription from another branch"
103
);
105
);
106
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
107
"With IndependentBranches, superlibrarian can claim a subscription from his branch"
108
);
109
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1,
110
"With IndependentBranches, superlibrarian can claim a subscription from another branch"
111
);
112
104
113
105
set_flags( 'superserials', $borrowernumber );
114
set_flags( 'superserials', $borrowernumber );
106
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1,
115
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1,
Lines 115-120 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
115
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
124
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
116
"With IndependentBranches, superserials can show a subscription from another branch"
125
"With IndependentBranches, superserials can show a subscription from another branch"
117
);
126
);
127
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
128
"With IndependentBranches, superserials can claim a subscription from his branch"
129
);
130
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1,
131
"With IndependentBranches, superserials can claim a subscription from another branch"
132
);
133
118
134
119
135
120
set_flags( 'edit_subscription', $borrowernumber );
136
set_flags( 'edit_subscription', $borrowernumber );
Lines 130-135 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
130
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
146
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
131
"With IndependentBranches, show_subscription cannot show a subscription from another branch"
147
"With IndependentBranches, show_subscription cannot show a subscription from another branch"
132
);
148
);
149
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0,
150
"With IndependentBranches, claim_subscription cannot claim a subscription from his branch with the edit_subscription permission"
151
);
152
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0,
153
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch"
154
);
155
133
156
134
set_flags( 'renew_subscription', $borrowernumber );
157
set_flags( 'renew_subscription', $borrowernumber );
135
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0,
158
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0,
Lines 145-150 is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, Link Here
145
"With IndependentBranches, renew_subscription cannot show a subscription from another branch"
168
"With IndependentBranches, renew_subscription cannot show a subscription from another branch"
146
);
169
);
147
170
171
set_flags( 'claim_serials', $borrowernumber );
172
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
173
"With IndependentBranches, claim_subscription can claim a subscription from his branch with the edit_subscription permission"
174
);
175
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0,
176
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch"
177
);
148
178
149
# Branches are not independent
179
# Branches are not independent
150
t::lib::Mocks::mock_preference( "IndependentBranches", 0 );
180
t::lib::Mocks::mock_preference( "IndependentBranches", 0 );
151
- 

Return to bug 8438