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

(-)a/C4/Serials.pm (-93 lines)
Lines 79-85 BEGIN { Link Here
79
      &GetPreviousSerialid
79
      &GetPreviousSerialid
80
80
81
      &GetSuppliersWithLateIssues
81
      &GetSuppliersWithLateIssues
82
      &GetDistributedTo   &SetDistributedTo
83
      &getroutinglist     &delroutingmember   &addroutingmember
82
      &getroutinglist     &delroutingmember   &addroutingmember
84
      &reorder_members
83
      &reorder_members
85
      &check_routing &updateClaim
84
      &check_routing &updateClaim
Lines 162-187 sub GetSubscriptionHistoryFromSubscriptionId { Link Here
162
    return $results;
161
    return $results;
163
}
162
}
164
163
165
=head2 GetSerialStatusFromSerialId
166
167
$sth = GetSerialStatusFromSerialId();
168
this function returns a statement handle
169
After this function, don't forget to execute it by using $sth->execute($serialid)
170
return :
171
$sth = $dbh->prepare($query).
172
173
=cut
174
175
sub GetSerialStatusFromSerialId {
176
    my $dbh   = C4::Context->dbh;
177
    my $query = qq|
178
        SELECT status
179
        FROM   serial
180
        WHERE  serialid = ?
181
    |;
182
    return $dbh->prepare($query);
183
}
184
185
=head2 GetSerialInformation
164
=head2 GetSerialInformation
186
165
187
$data = GetSerialInformation($serialid);
166
$data = GetSerialInformation($serialid);
Lines 843-870 sub GetPreviousSerialid { Link Here
843
    return $return;
822
    return $return;
844
}
823
}
845
824
846
847
848
=head2 GetDistributedTo
849
850
$distributedto=GetDistributedTo($subscriptionid)
851
This function returns the field distributedto for the subscription matching subscriptionid
852
853
=cut
854
855
sub GetDistributedTo {
856
    my $dbh = C4::Context->dbh;
857
    my $distributedto;
858
    my ($subscriptionid) = @_;
859
860
    return unless ($subscriptionid);
861
862
    my $query          = "SELECT distributedto FROM subscription WHERE subscriptionid=?";
863
    my $sth            = $dbh->prepare($query);
864
    $sth->execute($subscriptionid);
865
    return ($distributedto) = $sth->fetchrow;
866
}
867
868
=head2 GetNextSeq
825
=head2 GetNextSeq
869
826
870
    my (
827
    my (
Lines 1718-1743 sub HasSubscriptionExpired { Link Here
1718
    return 0;    # Notice that you'll never get here.
1675
    return 0;    # Notice that you'll never get here.
1719
}
1676
}
1720
1677
1721
=head2 SetDistributedto
1722
1723
SetDistributedto($distributedto,$subscriptionid);
1724
This function update the value of distributedto for a subscription given on input arg.
1725
1726
=cut
1727
1728
sub SetDistributedto {
1729
    my ( $distributedto, $subscriptionid ) = @_;
1730
    my $dbh   = C4::Context->dbh;
1731
    my $query = qq|
1732
        UPDATE subscription
1733
        SET    distributedto=?
1734
        WHERE  subscriptionid=?
1735
    |;
1736
    my $sth = $dbh->prepare($query);
1737
    $sth->execute( $distributedto, $subscriptionid );
1738
    return;
1739
}
1740
1741
=head2 DelSubscription
1678
=head2 DelSubscription
1742
1679
1743
DelSubscription($subscriptionid)
1680
DelSubscription($subscriptionid)
Lines 2187-2202 sub abouttoexpire { Link Here
2187
    return 0;
2124
    return 0;
2188
}
2125
}
2189
2126
2190
sub in_array {    # used in next sub down
2191
    my ( $val, @elements ) = @_;
2192
    foreach my $elem (@elements) {
2193
        if ( $val == $elem ) {
2194
            return 1;
2195
        }
2196
    }
2197
    return 0;
2198
}
2199
2200
=head2 GetFictiveIssueNumber
2127
=head2 GetFictiveIssueNumber
2201
2128
2202
$issueno = GetFictiveIssueNumber($subscription, $publishedate);
2129
$issueno = GetFictiveIssueNumber($subscription, $publishedate);
Lines 2520-2545 sub _numeration { Link Here
2520
    return $string;
2447
    return $string;
2521
}
2448
}
2522
2449
2523
=head2 is_barcode_in_use
2524
2525
Returns number of occurrences of the barcode in the items table
2526
Can be used as a boolean test of whether the barcode has
2527
been deployed as yet
2528
2529
=cut
2530
2531
sub is_barcode_in_use {
2532
    my $barcode = shift;
2533
    my $dbh       = C4::Context->dbh;
2534
    my $occurrences = $dbh->selectall_arrayref(
2535
        'SELECT itemnumber from items where barcode = ?',
2536
        {}, $barcode
2537
2538
    );
2539
2540
    return @{$occurrences};
2541
}
2542
2543
=head2 CloseSubscription
2450
=head2 CloseSubscription
2544
2451
2545
Close a subscription given a subscriptionid
2452
Close a subscription given a subscriptionid
(-)a/t/db_dependent/Serials.t (-6 / +1 lines)
Lines 18-24 use Koha::DateUtils; Link Here
18
use Koha::Acquisition::Booksellers;
18
use Koha::Acquisition::Booksellers;
19
use t::lib::Mocks;
19
use t::lib::Mocks;
20
use t::lib::TestBuilder;
20
use t::lib::TestBuilder;
21
use Test::More tests => 48;
21
use Test::More tests => 46;
22
22
23
BEGIN {
23
BEGIN {
24
    use_ok('C4::Serials');
24
    use_ok('C4::Serials');
Lines 139-146 my ($serials_count, @serials) = GetSerials($subscriptionid); Link Here
139
ok($serials_count > 0, 'Subscription has at least one serial');
139
ok($serials_count > 0, 'Subscription has at least one serial');
140
my $serial = $serials[0];
140
my $serial = $serials[0];
141
141
142
ok(C4::Serials::GetSerialStatusFromSerialId($serial->{serialid}), 'test getting Serial Status From Serial Id');
143
144
isa_ok(C4::Serials::GetSerialInformation($serial->{serialid}), 'HASH', 'test getting Serial Information');
142
isa_ok(C4::Serials::GetSerialInformation($serial->{serialid}), 'HASH', 'test getting Serial Information');
145
143
146
subtest 'Values should not be erased on editing' => sub {
144
subtest 'Values should not be erased on editing' => sub {
Lines 203-210 is(C4::Serials::GetSerials2(), undef, 'test getting serials when you enter nothi Link Here
203
201
204
is(C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials');
202
is(C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials');
205
203
206
is(C4::Serials::GetDistributedTo(), undef, 'test getting distributed when nothing is entered');
207
208
is(C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing');
204
is(C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing');
209
205
210
is(C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing');
206
is(C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing');
211
- 

Return to bug 21154