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

(-)a/C4/Serials.pm (-59 / +1 lines)
Lines 48-54 BEGIN { Link Here
48
48
49
      &GetNextSeq &GetSeq &NewIssue           &ItemizeSerials    &GetSerials
49
      &GetNextSeq &GetSeq &NewIssue           &ItemizeSerials    &GetSerials
50
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
50
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
51
      &ReNewSubscription  &GetLateIssues      &GetLateOrMissingIssues
51
      &ReNewSubscription  &GetLateOrMissingIssues
52
      &GetSerialInformation                   &AddItem2Serial
52
      &GetSerialInformation                   &AddItem2Serial
53
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
53
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
54
54
Lines 110-173 sub GetSuppliersWithLateIssues { Link Here
110
    return $dbh->selectall_arrayref($query, { Slice => {} });
110
    return $dbh->selectall_arrayref($query, { Slice => {} });
111
}
111
}
112
112
113
=head2 GetLateIssues
114
115
@issuelist = GetLateIssues($supplierid)
116
117
this function selects late issues from the database
118
119
return :
120
the issuelist as an array. Each element of this array contains a hashi_ref containing
121
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio
122
123
=cut
124
125
sub GetLateIssues {
126
    my ($supplierid) = @_;
127
128
    return unless ($supplierid);
129
130
    my $dbh = C4::Context->dbh;
131
    my $sth;
132
    if ($supplierid) {
133
        my $query = qq|
134
            SELECT     name,title,planneddate,serialseq,serial.subscriptionid
135
            FROM       subscription
136
            LEFT JOIN  serial ON subscription.subscriptionid = serial.subscriptionid
137
            LEFT JOIN  biblio ON biblio.biblionumber = subscription.biblionumber
138
            LEFT JOIN  aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
139
            WHERE      ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3)
140
            AND        subscription.aqbooksellerid=?
141
            AND        subscription.closed = 0
142
            ORDER BY   title
143
        |;
144
        $sth = $dbh->prepare($query);
145
        $sth->execute($supplierid);
146
    } else {
147
        my $query = qq|
148
            SELECT     name,title,planneddate,serialseq,serial.subscriptionid
149
            FROM       subscription
150
            LEFT JOIN  serial ON subscription.subscriptionid = serial.subscriptionid
151
            LEFT JOIN  biblio ON biblio.biblionumber = subscription.biblionumber
152
            LEFT JOIN  aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
153
            WHERE      ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3)
154
            AND        subscription.closed = 0
155
            ORDER BY   title
156
        |;
157
        $sth = $dbh->prepare($query);
158
        $sth->execute;
159
    }
160
    my @issuelist;
161
    my $last_title;
162
    while ( my $line = $sth->fetchrow_hashref ) {
163
        $line->{title} = "" if $last_title and $line->{title} eq $last_title;
164
        $last_title = $line->{title} if ( $line->{title} );
165
        $line->{planneddate} = format_date( $line->{planneddate} );
166
        push @issuelist, $line;
167
    }
168
    return @issuelist;
169
}
170
171
=head2 GetSubscriptionHistoryFromSubscriptionId
113
=head2 GetSubscriptionHistoryFromSubscriptionId
172
114
173
$history = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
115
$history = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
(-)a/t/db_dependent/Serials.t (-4 / +1 lines)
Lines 15-21 use C4::Bookseller; Link Here
15
use C4::Biblio;
15
use C4::Biblio;
16
use C4::Budgets;
16
use C4::Budgets;
17
use Koha::DateUtils;
17
use Koha::DateUtils;
18
use Test::More tests => 44;
18
use Test::More tests => 43;
19
19
20
BEGIN {
20
BEGIN {
21
    use_ok('C4::Serials');
21
    use_ok('C4::Serials');
Lines 111-118 if (not $frequency->{unit}) { Link Here
111
my $expirationdate = GetExpirationDate($subscriptionid) ;
111
my $expirationdate = GetExpirationDate($subscriptionid) ;
112
ok( $expirationdate, "expiration date is not NULL" );
112
ok( $expirationdate, "expiration date is not NULL" );
113
113
114
is(C4::Serials::GetLateIssues(), undef, 'test getting late issues');
115
116
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription');
114
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription');
117
115
118
my ($serials_count, @serials) = GetSerials($subscriptionid);
116
my ($serials_count, @serials) = GetSerials($subscriptionid);
119
- 

Return to bug 12850