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

(-)a/C4/Serials.pm (+13 lines)
Lines 2733-2738 sub subscriptionCurrentlyOnOrder { Link Here
2733
    return $sth->fetchrow_array;
2733
    return $sth->fetchrow_array;
2734
}
2734
}
2735
2735
2736
=head2 can_claim_subscription
2737
2738
    $can = can_claim_subscription( $subscriptionid[, $userid] );
2739
2740
Return 1 if the subscription can be claimed by the current logged user (or a given $userid), else 0.
2741
2742
=cut
2743
2744
sub can_claim_subscription {
2745
    my ( $subscription, $userid ) = @_;
2746
    return _can_do_on_subscription( $subscription, $userid, 'claim_serials' );
2747
}
2748
2736
=head2 can_edit_subscription
2749
=head2 can_edit_subscription
2737
2750
2738
    $can = can_edit_subscription( $subscriptionid[, $userid] );
2751
    $can = can_edit_subscription( $subscriptionid[, $userid] );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (+2 lines)
Lines 273-279 Link Here
273
                <tbody>[% FOREACH missingissue IN missingissues %]
273
                <tbody>[% FOREACH missingissue IN missingissues %]
274
                    <tr>
274
                    <tr>
275
                        <td>
275
                        <td>
276
                          [% UNLESS missingissue.cannot_claim %]
276
                            <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
277
                            <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
278
                          [% END %]
277
                        </td>
279
                        </td>
278
                        <td>[% missingissue.name %]</td>
280
                        <td>[% missingissue.name %]</td>
279
                        <td>
281
                        <td>
(-)a/serials/claims.pl (+4 lines)
Lines 85-90 my $letters = GetLetters({ module => 'claimissues' }); Link Here
85
my @missingissues;
85
my @missingissues;
86
if ($supplierid) {
86
if ($supplierid) {
87
    @missingissues = GetLateOrMissingIssues($supplierid);
87
    @missingissues = GetLateOrMissingIssues($supplierid);
88
    foreach my $issue (@missingissues) {
89
        $issue->{cannot_claim} = 1
90
          unless C4::Serials::can_claim_subscription($issue);
91
    }
88
}
92
}
89
93
90
$template->param(
94
$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