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

(-)a/C4/Creators/Lib.pm (-13 / +7 lines)
Lines 263-270 NOTE: Do not pass in the keyword 'WHERE.' Link Here
263
sub get_batch_summary {
263
sub get_batch_summary {
264
    my %params = @_;
264
    my %params = @_;
265
    my @batches = ();
265
    my @batches = ();
266
    my $query = "SELECT DISTINCT batch_id FROM creator_batches WHERE creator=?";
266
    my $query = "SELECT batch_id,count(batch_id) as _item_count FROM creator_batches WHERE creator=?";
267
    $query .= ($params{'filter'} ? " AND $params{'filter'};" : ';');
267
    $query .= ($params{'filter'} ? " AND $params{'filter'}" : '');
268
    $query .= " GROUP BY batch_id";
268
    my $sth = C4::Context->dbh->prepare($query);
269
    my $sth = C4::Context->dbh->prepare($query);
269
#    $sth->{'TraceLevel'} = 3;
270
#    $sth->{'TraceLevel'} = 3;
270
    $sth->execute($params{'creator'});
271
    $sth->execute($params{'creator'});
Lines 272-288 sub get_batch_summary { Link Here
272
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
273
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
273
        return -1;
274
        return -1;
274
    }
275
    }
275
    ADD_BATCHES:
276
    while (my $batch = $sth->fetchrow_hashref) {
276
    while (my $batch = $sth->fetchrow_hashref) {
277
        my $query = "SELECT count(batch_id) FROM creator_batches WHERE batch_id=? AND creator=?;";
278
        my $sth1 = C4::Context->dbh->prepare($query);
279
        $sth1->execute($batch->{'batch_id'}, $params{'creator'});
280
        if ($sth1->err) {
281
            warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
282
            return -1;
283
        }
284
        my $count = $sth1->fetchrow_arrayref;
285
        $batch->{'_item_count'} = @$count[0];
286
        push(@batches, $batch);
277
        push(@batches, $batch);
287
    }
278
    }
288
    return \@batches;
279
    return \@batches;
Lines 521-527 be passed off as a T::P template parameter and used to build an html table. Link Here
521
512
522
=cut
513
=cut
523
514
515
use Carp;
516
use Data::Dump qw(dump);
517
524
sub html_table {
518
sub html_table {
519
Carp::cluck("# html_table ",dump(@_));
525
    my $headers = shift;
520
    my $headers = shift;
526
    my $data = shift;
521
    my $data = shift;
527
    return undef if scalar(@$data) == 0;      # no need to generate a table if there is not data to display
522
    return undef if scalar(@$data) == 0;      # no need to generate a table if there is not data to display
528
- 

Return to bug 7846