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

(-)a/C4/Serials.pm (+9 lines)
Lines 20-25 package C4::Serials; Link Here
20
20
21
use strict;
21
use strict;
22
use warnings;
22
use warnings;
23
use C4::Auth qw(haspermission);
23
use C4::Context;
24
use C4::Context;
24
use C4::Dates qw(format_date format_date_in_iso);
25
use C4::Dates qw(format_date format_date_in_iso);
25
use Date::Calc qw(:all);
26
use Date::Calc qw(:all);
Lines 2519-2524 sub subscriptionCurrentlyOnOrder { Link Here
2519
    return $sth->fetchrow_array;
2520
    return $sth->fetchrow_array;
2520
}
2521
}
2521
2522
2523
=head2 can_edit_subscription
2524
2525
    $can = can_edit_subscription( $subscriptionid[, $userid] );
2526
2527
Return 1 if the subscription is editable by the current logged user (or a given $userid), else 0.
2528
2529
=cut
2530
2522
sub can_edit_subscription {
2531
sub can_edit_subscription {
2523
    my ( $subscription, $userid ) = @_;
2532
    my ( $subscription, $userid ) = @_;
2524
    my $flags = C4::Context->userenv->{flags};
2533
    my $flags = C4::Context->userenv->{flags};
(-)a/t/db_dependent/Serials_2.t (-5 / +59 lines)
Lines 1-10 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
use strict;
2
use Modern::Perl;
3
use warnings;
4
3
5
use Test::More;
4
use Test::More tests => 4;
6
5
7
use_ok('C4::Serials');
6
use_ok('C4::Serials');
7
use_ok('C4::Budgets');
8
8
my $supplierlist=eval{GetSuppliersWithLateIssues()};
9
my $supplierlist=eval{GetSuppliersWithLateIssues()};
9
ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues");
10
ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues");
10
done_testing();
11
12
my $biblionumber = 1;
13
my $budgetid;
14
my $bpid = AddBudgetPeriod({
15
    budget_period_startdate => '01-01-2015',
16
    budget_period_enddate   => '31-12-2015',
17
    budget_description      => "budget desc"
18
});
19
20
my $budget_id = AddBudget({
21
    budget_code        => "ABCD",
22
    budget_amount      => "123.132",
23
    budget_name        => "Périodiques",
24
    budget_notes       => "This is a note",
25
    budget_description => "Serials",
26
    budget_active      => 1,
27
    budget_period_id   => $bpid
28
});
29
30
my $subscriptionid = NewSubscription(
31
    undef,      "",     undef, undef, $budget_id, $biblionumber, '01-01-2013',undef,
32
    undef,      undef,  undef, undef, undef,      undef,         undef,  undef,
33
    undef,      undef,  undef, undef, undef,      undef,         undef,  undef,
34
    undef,      undef,  undef, undef, undef,      undef,         undef,  1,
35
    "notes",    undef,  undef, undef, undef,      undef,         undef,  0,
36
    "intnotes", 0,      undef, undef, 0,          undef,         '31-12-2013',
37
);
38
die unless $subscriptionid;
39
40
# Can edit a subscription
41
my @USERENV = (
42
    1,
43
    'test',
44
    'MASTERTEST',
45
    'Test',
46
    'Test',
47
    't',
48
    0,
49
    0,
50
);
51
52
C4::Context->_new_userenv ('DUMMY_SESSION_ID');
53
C4::Context->set_userenv ( @USERENV );
54
my $userenv = C4::Context->userenv;
55
56
my $subscription = GetSubscription( $subscriptionid );
57
58
is( C4::Serials::can_edit_subscription($subscription), 1, "User can edit a subscription with an empty branchcode");
59
#TODO add UT when C4::Auth->set_permissions (or setuserflags) will exist.
60
61
62
# cleaning
63
DelSubscription( $subscription->{subscriptionid} );
64
DelBudgetPeriod($bpid);
65
DelBudget($budget_id);
11
- 

Return to bug 8435