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

(-)a/reports/acquisitions_stats.pl (-47 / +54 lines)
Lines 301-351 sub calculate { Link Here
301
    foreach ($line, $column) {
301
    foreach ($line, $column) {
302
        $filter{$_} = [];
302
        $filter{$_} = [];
303
        $field{$_} = $_;
303
        $field{$_} = $_;
304
        given ($_) {
304
        if ( $_ =~ /closedate/ ) {
305
            when (/closedate/) {
305
            $filter{$_}->[0] = @$filters[0];
306
                $filter{$_}->[0] = @$filters[0];
306
            $filter{$_}->[1] = @$filters[1];
307
                $filter{$_}->[1] = @$filters[1];
307
            my $a = $_;
308
                my $a = $_;
308
            if ( $podsp == 1 ) {
309
                given ($podsp) {
309
                $field{$a} = "concat(hex(weekday($a)+1),'-',dayname($a))";
310
                    when (1) { $field{$a} = "concat(hex(weekday($a)+1),'-',dayname($a))" }
310
            } elsif ( $podsp == 2 ) {
311
                    when (2) { $field{$a} = "concat(hex(month($a)),'-',monthname($a))" }
311
                $field{$a} = "concat(hex(month($a)),'-',monthname($a))";
312
                    when (3) { $field{$a} = "Year($a)" }
312
            } elsif ( $podsp == 3 ) {
313
                    default  { $field{$a} = $a }
313
                $field{$a} = "Year($a)";
314
                }
314
            } else {
315
            }
315
                $field{$a} = $a;
316
            when (/received/) {
317
                $filter{$_}->[0] = @$filters[2];
318
                $filter{$_}->[1] = @$filters[3];
319
                my $a = $_;
320
                given ($rodsp) {
321
                    when (1) { $field{$a} = "concat(hex(weekday($a)+1),'-',dayname($a))" }
322
                    when (2) { $field{$a} = "concat(hex(month($a)),'-',monthname($a))" }
323
                    when (3) { $field{$a} = "Year($a)" }
324
                    default  { $field{$a} = $a }
325
                }
326
            }
327
            when (/bookseller/) {
328
                $filter{$_}->[0] = @$filters[4];
329
            }
330
            when (/homebranch/) {
331
                $filter{$_}->[0] = @$filters[5];
332
            }
333
            when (/ccode/) {
334
                $filter{$_}->[0] = @$filters[6];
335
            }
336
            when (/itemtype/) {
337
                $filter{$_}->[0] = @$filters[7];
338
            }
339
            when (/budget/) {
340
                $filter{$_}->[0] = @$filters[8];
341
            }
342
            when (/sort1/) {
343
                $filter{$_}->[0] = @$filters[9];
344
            }
316
            }
345
            when (/sort2/) {
317
        }
346
                $filter{$_}->[0] = @$filters[10];
318
        elsif ( $_ =~ /received/ ) {
319
            $filter{$_}->[0] = @$filters[2];
320
            $filter{$_}->[1] = @$filters[3];
321
            my $a = $_;
322
            if ( $rodsp == 1 ) {
323
                $field{$a} = "concat(hex(weekday($a)+1),'-',dayname($a))";
324
            } elsif ( $rodsp == 2 ) {
325
                $field{$a} = "concat(hex(month($a)),'-',monthname($a))";
326
            } elsif ( $rodsp == 3 ) {
327
                $field{$a} = "Year($a)";
328
            } else {
329
                field{$a} = $a;
347
            }
330
            }
348
        }
331
        }
332
        elsif ( $_ =~ /bookseller/ ) {
333
            $filter{$_}->[0] = @$filters[4];
334
        }
335
        elsif ( $_ =~ /homebranch/ ) {
336
            $filter{$_}->[0] = @$filters[5];
337
        }
338
        elsif ( $_ =~ /ccode/ ) {
339
            $filter{$_}->[0] = @$filters[6];
340
        }
341
        elsif ( $_ =~ /itemtype/ ) {
342
            $filter{$_}->[0] = @$filters[7];
343
        }
344
        elsif ( $_ =~ /budget/ ) {
345
            $filter{$_}->[0] = @$filters[8];
346
        }
347
        elsif ( $_ =~ /sort1/ ) {
348
            $filter{$_}->[0] = @$filters[9];
349
        }
350
        elsif ( $_ =~ /sort2/ ) {
351
            $filter{$_}->[0] = @$filters[10];
352
        }
349
    }
353
    }
350
354
351
    my @linefilter = @{ $filter{$line} };
355
    my @linefilter = @{ $filter{$line} };
Lines 484-494 sub calculate { Link Here
484
    # preparing calculation
488
    # preparing calculation
485
    my $strcalc;
489
    my $strcalc;
486
    $strcalc .= "SELECT $linefield, $colfield, ";
490
    $strcalc .= "SELECT $linefield, $colfield, ";
487
    given ($process) {
491
    if ( $process == 1 ) {
488
        when (1) { $strcalc .= "COUNT(*) " }
492
        $strcalc .= "COUNT(*) ";
489
        when (2) { $strcalc .= "COUNT(DISTINCT(aqorders.biblionumber)) " }
493
    } elsif ( $process == 2 ) {
490
        when ([3,4,5]) { $strcalc .= "SUM(aqorders.listprice) " }
494
        $strcalc .= "COUNT(DISTINCT(aqorders.biblionumber)) ";
491
        default { $strcalc .= "NULL " }
495
    } elsif ( $process == 3 || $process == 4 || $process == 5 ) {
496
        $strcalc .= "SUM(aqorders.listprice) ";
497
    } else {
498
        $strcalc .= "NULL ";
492
    }
499
    }
493
    $strcalc .= "
500
    $strcalc .= "
494
        FROM aqorders
501
        FROM aqorders
(-)a/reports/borrowers_stats.pl (-33 / +28 lines)
Lines 154-165 if ($do_it) { Link Here
154
}
154
}
155
output_html_with_http_headers $input, $cookie, $template->output;
155
output_html_with_http_headers $input, $cookie, $template->output;
156
156
157
sub catcode_aref() {
157
sub catcode_aref {
158
	my $req = C4::Context->dbh->prepare("SELECT categorycode, description FROM categories ORDER BY description");
158
	my $req = C4::Context->dbh->prepare("SELECT categorycode, description FROM categories ORDER BY description");
159
	$req->execute;
159
	$req->execute;
160
	return $req->fetchall_arrayref({});
160
	return $req->fetchall_arrayref({});
161
}
161
}
162
sub catcodes_hash() {
162
sub catcodes_hash {
163
	my %cathash;
163
	my %cathash;
164
	my $catcodes = &catcode_aref;
164
	my $catcodes = &catcode_aref;
165
	foreach (@$catcodes) {
165
	foreach (@$catcodes) {
Lines 202-229 sub calculate { Link Here
202
202
203
    # Filters
203
    # Filters
204
    my $linefilter;
204
    my $linefilter;
205
    given ($line) {
205
    if    ( $line =~ /categorycode/ ) { $linefilter = @$filters[0]; }
206
        when (/categorycode/) { $linefilter = @$filters[0] }
206
    elsif ( $line =~ /zipcode/ )      { $linefilter = @$filters[1]; }
207
        when (/zipcode/) { $linefilter = @$filters[1] }
207
    elsif ( $line =~ /branchcode/ )   { $linefilter = @$filters[2]; }
208
        when (/branchcode/) { $linefilter = @$filters[2] }
208
    elsif ( $line =~ /sex/ )          { $linefilter = @$filters[5]; }
209
        when (/sex/) { $linefilter = @$filters[5] }
209
    elsif ( $line =~ /sort1/ )        { $linefilter = @$filters[6]; }
210
        when (/sort1/) { $linefilter = @$filters[6] }
210
    elsif ( $line =~ /sort2/ )        { $linefilter = @$filters[7]; }
211
        when (/sort2/) { $linefilter = @$filters[7] }
211
    elsif ( $line =~ /^patron_attr\.(.*)$/ ) { $linefilter = $attr_filters->{$1}; }
212
        when (/^patron_attr\.(.*)$/) { $linefilter = $attr_filters->{$1} }
212
    else  { $linefilter = ''; }
213
        default { $linefilter = '' }
214
    }
215
213
216
    my $colfilter;
214
    my $colfilter;
217
    given ($column) {
215
    if    ( $column =~ /categorycode/ ) { $colfilter = @$filters[0]; }
218
        when (/categorycode/) { $colfilter = @$filters[0] }
216
    elsif ( $column =~ /zipcode/ )      { $colfilter = @$filters[1]; }
219
        when (/zipcode/) { $colfilter = @$filters[1] }
217
    elsif ( $column =~ /branchcode/)    { $colfilter = @$filters[2]; }
220
        when (/branchcode/) { $colfilter = @$filters[2] }
218
    elsif ( $column =~ /sex/)           { $colfilter = @$filters[5]; }
221
        when (/sex/) { $colfilter = @$filters[5] }
219
    elsif ( $column =~ /sort1/)         { $colfilter = @$filters[6]; }
222
        when (/sort1/) { $colfilter = @$filters[6] }
220
    elsif ( $column =~ /sort2/)         { $colfilter = @$filters[7]; }
223
        when (/sort2/) { $colfilter = @$filters[7] }
221
    elsif ( $column =~ /^patron_attr\.(.*)$/) { $colfilter = $attr_filters->{$1}; }
224
        when (/^patron_attr\.(.*)$/) { $colfilter = $attr_filters->{$1} }
222
    else  { $colfilter = ''; }
225
        default { $colfilter = '' }
226
    }
227
223
228
    my @loopfilter;
224
    my @loopfilter;
229
    foreach my $i (0 .. scalar @$filters) {
225
    foreach my $i (0 .. scalar @$filters) {
Lines 235-250 sub calculate { Link Here
235
                $cell{filter} = @$filters[$i];
231
                $cell{filter} = @$filters[$i];
236
            }
232
            }
237
233
238
            given ($i) {
234
            if    ( $i == 0)  { $cell{crit} = "Cat code"; }
239
                when (0) { $cell{crit} = "Cat code" }
235
            elsif ( $i == 1 ) { $cell{crit} = "Zip code"; }
240
                when (1) { $cell{crit} = "Zip code" }
236
            elsif ( $i == 2 ) { $cell{crit} = "Branch code"; }
241
                when (2) { $cell{crit} = "Branch code" }
237
            elsif ( $i == 3 ||
242
                when ([3,4]) { $cell{crit} = "Date of birth" }
238
                    $i == 4 ) { $cell{crit} = "Date of birth"; }
243
                when (5) { $cell{crit} = "Sex" }
239
            elsif ( $i == 5 ) { $cell{crit} = "Sex"; }
244
                when (6) { $cell{crit} = "Sort1" }
240
            elsif ( $i == 6 ) { $cell{crit} = "Sort1"; }
245
                when (7) { $cell{crit} = "Sort2" }
241
            elsif ( $i == 7 ) { $cell{crit} = "Sort2"; }
246
                default { $cell{crit} = "Unknown" }
242
            else { $cell{crit} = "Unknown"; }
247
            }
243
248
            push @loopfilter, \%cell;
244
            push @loopfilter, \%cell;
249
        }
245
        }
250
    }
246
    }
251
- 

Return to bug 12151