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

(-)a/C4/Serials.pm (+13 lines)
Lines 2787-2792 sub subscriptionCurrentlyOnOrder { Link Here
2787
    return $sth->fetchrow_array;
2787
    return $sth->fetchrow_array;
2788
}
2788
}
2789
2789
2790
=head2 can_claim_subscription
2791
2792
    $can = can_claim_subscription( $subscriptionid[, $userid] );
2793
2794
Return 1 if the subscription can be claimed by the current logged user (or a given $userid), else 0.
2795
2796
=cut
2797
2798
sub can_claim_subscription {
2799
    my ( $subscription, $userid ) = @_;
2800
    return _can_do_on_subscription( $subscription, $userid, 'claim_serials' );
2801
}
2802
2790
=head2 can_edit_subscription
2803
=head2 can_edit_subscription
2791
2804
2792
    $can = can_edit_subscription( $subscriptionid[, $userid] );
2805
    $can = can_edit_subscription( $subscriptionid[, $userid] );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt (+2 lines)
Lines 275-281 Link Here
275
                <tbody>[% FOREACH missingissue IN missingissues %]
275
                <tbody>[% FOREACH missingissue IN missingissues %]
276
                    <tr>
276
                    <tr>
277
                        <td>
277
                        <td>
278
                          [% UNLESS missingissue.cannot_claim %]
278
                            <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
279
                            <input type="checkbox" name="serialid" value="[% missingissue.serialid %]" />
280
                          [% END %]
279
                        </td>
281
                        </td>
280
                        <td>
282
                        <td>
281
                        [% missingissue.name %]
283
                        [% missingissue.name %]
(-)a/serials/claims.pl (+5 lines)
Lines 67-72 if ($supplierid) { Link Here
67
    @supplierinfo=GetBookSeller($supplierid);
67
    @supplierinfo=GetBookSeller($supplierid);
68
}
68
}
69
69
70
foreach my $issue (@missingissues) {
71
    $issue->{cannot_claim} = 1
72
      unless C4::Serials::can_claim_subscription($issue);
73
}
74
70
my $branchloop = GetBranchesLoop();
75
my $branchloop = GetBranchesLoop();
71
76
72
my $preview=0;
77
my $preview=0;
(-)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 => 37;
4
use Test::More tests => 47;
5
5
6
use MARC::Record;
6
use MARC::Record;
7
7
Lines 71-76 my $subscriptionid_from_another_branch = NewSubscription( Link Here
71
71
72
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch );
72
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch );
73
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
73
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
74
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set");
74
75
75
my $userid = 'my_userid';
76
my $userid = 'my_userid';
76
my $borrowernumber = C4::Members::AddMember(
77
my $borrowernumber = C4::Members::AddMember(
Lines 86-91 $userenv = { flags => 1, id => $borrowernumber, branch => '' }; Link Here
86
# Can edit a subscription
87
# Can edit a subscription
87
88
88
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
89
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
90
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode");
89
91
90
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch );
92
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch );
91
93
Lines 107-112 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
107
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
109
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
108
"With IndependentBranches, superlibrarian can show a subscription from another branch"
110
"With IndependentBranches, superlibrarian can show a subscription from another branch"
109
);
111
);
112
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
113
"With IndependentBranches, superlibrarian can claim a subscription from his branch"
114
);
115
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1,
116
"With IndependentBranches, superlibrarian can claim a subscription from another branch"
117
);
118
110
119
111
set_flags( 'superserials', $borrowernumber );
120
set_flags( 'superserials', $borrowernumber );
112
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1,
121
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1,
Lines 121-126 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
121
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
130
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1,
122
"With IndependentBranches, superserials can show a subscription from another branch"
131
"With IndependentBranches, superserials can show a subscription from another branch"
123
);
132
);
133
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
134
"With IndependentBranches, superserials can claim a subscription from his branch"
135
);
136
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1,
137
"With IndependentBranches, superserials can claim a subscription from another branch"
138
);
139
124
140
125
141
126
set_flags( 'edit_subscription', $borrowernumber );
142
set_flags( 'edit_subscription', $borrowernumber );
Lines 136-141 is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1, Link Here
136
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
152
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
137
"With IndependentBranches, show_subscription cannot show a subscription from another branch"
153
"With IndependentBranches, show_subscription cannot show a subscription from another branch"
138
);
154
);
155
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0,
156
"With IndependentBranches, claim_subscription cannot claim a subscription from his branch with the edit_subscription permission"
157
);
158
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0,
159
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch"
160
);
161
139
162
140
set_flags( 'renew_subscription', $borrowernumber );
163
set_flags( 'renew_subscription', $borrowernumber );
141
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0,
164
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0,
Lines 151-156 is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, Link Here
151
"With IndependentBranches, renew_subscription cannot show a subscription from another branch"
174
"With IndependentBranches, renew_subscription cannot show a subscription from another branch"
152
);
175
);
153
176
177
set_flags( 'claim_serials', $borrowernumber );
178
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1,
179
"With IndependentBranches, claim_subscription can claim a subscription from his branch with the edit_subscription permission"
180
);
181
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0,
182
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch"
183
);
154
184
155
# Branches are not independent
185
# Branches are not independent
156
t::lib::Mocks::mock_preference( "IndependentBranches", 0 );
186
t::lib::Mocks::mock_preference( "IndependentBranches", 0 );
157
- 

Return to bug 8438