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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt (-17 / +15 lines)
Lines 20-38 Link Here
20
    }
20
    }
21
21
22
    $(document).ready(function() {
22
    $(document).ready(function() {
23
        var datesRO = $( "#fromRO, #toRO" ).datepicker({
23
        $('#acqdateFrom, #deldateFrom')
24
            changeMonth: true,
24
          .datepicker('option', 'onSelect', function(selectedDate) {
25
            numberOfMonths: 1,
25
            var id = $(this).attr('id').replace('From', 'To');
26
            onSelect: function( selectedDate ) {
26
            $('#' + id).datepicker('option', 'minDate', selectedDate);
27
                var option = this.id == "fromRO" ? "minDate" : "maxDate",
27
          });
28
                    instance = $( this ).data( "datepicker" );
28
        $('#acqdateTo, #deldateTo')
29
                    date = $.datepicker.parseDate(
29
          .datepicker('option', 'onSelect', function(selectedDate) {
30
                        instance.settings.dateFormat ||
30
            var id = $(this).attr('id').replace('To', 'From');
31
                        $.datepicker._defaults.dateFormat,
31
            $('#' + id).datepicker('option', 'maxDate', selectedDate);
32
                        selectedDate, instance.settings );
32
          });
33
                datesRO.not( this ).datepicker( "option", option, date );
33
34
            }
35
        });
36
        $("input[name='Cellvalue']").change(function() {
34
        $("input[name='Cellvalue']").change(function() {
37
            changeRemovedDateTrStatus();
35
            changeRemovedDateTrStatus();
38
        });
36
        });
Lines 259-267 Link Here
259
                <td><input type="radio" name="Line" value="items.dateaccessioned" /></td>
257
                <td><input type="radio" name="Line" value="items.dateaccessioned" /></td>
260
                <td><input type="radio" name="Column" value="items.dateaccessioned" /></td>
258
                <td><input type="radio" name="Column" value="items.dateaccessioned" /></td>
261
                <td>
259
                <td>
262
                    <label for="acqdateFrom">From:</label>
260
                    <label for="acqdateFrom">From</label>
263
                    <input type="text" name="Filter" id="acqdateFrom" class="datepicker" />
261
                    <input type="text" name="Filter" id="acqdateFrom" class="datepicker" />
264
                    <label for="acqdateTo">To:</label>
262
                    <label for="acqdateTo">To</label>
265
                    <input type="text" name="Filter" id="acqdateTo" class="datepicker" />
263
                    <input type="text" name="Filter" id="acqdateTo" class="datepicker" />
266
                </td>
264
                </td>
267
            </tr>
265
            </tr>
Lines 270-278 Link Here
270
                <td><input type="radio" name="Line" value="deleteditems.timestamp" /></td>
268
                <td><input type="radio" name="Line" value="deleteditems.timestamp" /></td>
271
                <td><input type="radio" name="Column" value="deleteditems.timestamp" /></td>
269
                <td><input type="radio" name="Column" value="deleteditems.timestamp" /></td>
272
                <td>
270
                <td>
273
                    <label for="deldateFrom">From:</label>
271
                    <label for="deldateFrom">From</label>
274
                    <input type="text" name="Filter" id="deldateFrom" class="datepicker" />
272
                    <input type="text" name="Filter" id="deldateFrom" class="datepicker" />
275
                    <label for="deldateTo">To:</label>
273
                    <label for="deldateTo">To</label>
276
                    <input type="text" name="Filter" id="deldateTo" class="datepicker"/>
274
                    <input type="text" name="Filter" id="deldateTo" class="datepicker"/>
277
                </td>
275
                </td>
278
            </tr>
276
            </tr>
(-)a/reports/catalogue_stats.pl (-28 / +46 lines)
Lines 30-35 use C4::Reports; Link Here
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
31
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
32
32
33
use Koha::DateUtils;
34
33
=head1 NAME
35
=head1 NAME
34
36
35
plugin that shows a stats on borrowers
37
plugin that shows a stats on borrowers
Lines 81-87 if ($do_it) { Link Here
81
        exit;
83
        exit;
82
    } else {
84
    } else {
83
        print $input->header(
85
        print $input->header(
84
            -type       => 'application/vnd.sun.xml.calc',
86
            -type       => 'text/csv',
85
            -encoding   => 'utf-8',
87
            -encoding   => 'utf-8',
86
            -attachment => "$basename.csv",
88
            -attachment => "$basename.csv",
87
            -name       => "$basename.csv"
89
            -name       => "$basename.csv"
Lines 231-240 sub calculate { Link Here
231
        }
233
        }
232
    }
234
    }
233
235
234
    @$filters[13] = C4::Dates->new(@$filters[13])->output('iso') if @$filters[13];
236
    @$filters[13] = dt_from_string(@$filters[13])->date() if @$filters[13];
235
    @$filters[14] = C4::Dates->new(@$filters[14])->output('iso') if @$filters[14];
237
    @$filters[14] = dt_from_string(@$filters[14])->date() if @$filters[14];
236
    @$filters[15] = C4::Dates->new(@$filters[15])->output('iso') if @$filters[15];
238
    @$filters[15] = dt_from_string(@$filters[15])->date() if @$filters[15];
237
    @$filters[16] = C4::Dates->new(@$filters[16])->output('iso') if @$filters[16];
239
    @$filters[16] = dt_from_string(@$filters[16])->date() if @$filters[16];
238
240
239
    my @linefilter;
241
    my @linefilter;
240
    $linefilter[0] = @$filters[0] if ( $line =~ /items\.itemcallnumber/ );
242
    $linefilter[0] = @$filters[0] if ( $line =~ /items\.itemcallnumber/ );
Lines 427-510 sub calculate { Link Here
427
        LEFT JOIN biblioitems ON ($itemstable.biblioitemnumber = biblioitems.biblioitemnumber)
429
        LEFT JOIN biblioitems ON ($itemstable.biblioitemnumber = biblioitems.biblioitemnumber)
428
        LEFT JOIN biblio ON (biblioitems.biblionumber = biblio.biblionumber)
430
        LEFT JOIN biblio ON (biblioitems.biblionumber = biblio.biblionumber)
429
        WHERE 1 ";
431
        WHERE 1 ";
430
    $strcalc .= "AND barcode $not like ? " if ($barcodefilter);
432
433
    my @sqlargs;
434
435
    if ($barcodefilter) {
436
        $strcalc .= "AND barcode $not like ? ";
437
        push @sqlargs, $barcodefilter;
438
    }
431
439
432
    if ( @$filters[0] ) {
440
    if ( @$filters[0] ) {
441
        $strcalc .= " AND $itemstable.itemcallnumber >= ? ";
433
        @$filters[0] =~ s/\*/%/g;
442
        @$filters[0] =~ s/\*/%/g;
434
        $strcalc .= " AND $itemstable.itemcallnumber >=" . $dbh->quote( @$filters[0] );
443
        push @sqlargs, @$filters[0];
435
    }
444
    }
436
445
437
    if ( @$filters[1] ) {
446
    if ( @$filters[1] ) {
447
        $strcalc .= " AND $itemstable.itemcallnumber <= ? ";
438
        @$filters[1] =~ s/\*/%/g;
448
        @$filters[1] =~ s/\*/%/g;
439
        $strcalc .= " AND $itemstable.itemcallnumber <=" . $dbh->quote( @$filters[1] );
449
        push @sqlargs, @$filters[1];
440
    }
450
    }
441
451
442
    if ( @$filters[2] ) {
452
    if ( @$filters[2] ) {
453
        $strcalc .= " AND " . ( C4::Context->preference('item-level_itypes') ? "$itemstable.itype" : 'biblioitems.itemtype' ) . " LIKE ? ";
443
        @$filters[2] =~ s/\*/%/g;
454
        @$filters[2] =~ s/\*/%/g;
444
        $strcalc .= " AND " . ( C4::Context->preference('item-level_itypes') ? "$itemstable.itype" : 'biblioitems.itemtype' ) . " LIKE '" . @$filters[2] . "'";
455
        push @sqlargs, @$filters[2];
445
    }
456
    }
446
457
447
    if ( @$filters[3] ) {
458
    if ( @$filters[3] ) {
459
        $strcalc .= " AND biblioitems.publishercode LIKE ? ";
448
        @$filters[3] =~ s/\*/%/g;
460
        @$filters[3] =~ s/\*/%/g;
449
        @$filters[3] .= "%" unless @$filters[3] =~ /%/;
461
        @$filters[3] .= "%" unless @$filters[3] =~ /%/;
450
        $strcalc .= " AND biblioitems.publishercode LIKE \"" . @$filters[3] . "\"";
462
        push @sqlargs, @$filters[3];
451
    }
463
    }
452
    if ( @$filters[4] ) {
464
    if ( @$filters[4] ) {
453
        @$filters[4] =~ s/\*/%/g;
454
        $strcalc .= " AND " .
465
        $strcalc .= " AND " .
455
        (C4::Context->preference('marcflavour') eq 'UNIMARC' ? 'publicationyear' : 'copyrightdate')
466
        (C4::Context->preference('marcflavour') eq 'UNIMARC' ? 'publicationyear' : 'copyrightdate')
456
        . ">" . @$filters[4];
467
        . "> ? ";
468
        @$filters[4] =~ s/\*/%/g;
469
        push @sqlargs, @$filters[4];
457
    }
470
    }
458
    if ( @$filters[5] ) {
471
    if ( @$filters[5] ) {
459
        @$filters[5] =~ s/\*/%/g;
472
        @$filters[5] =~ s/\*/%/g;
460
        $strcalc .= " AND " .
473
        $strcalc .= " AND " .
461
        (C4::Context->preference('marcflavour') eq 'UNIMARC' ? 'publicationyear' : 'copyrightdate')
474
        (C4::Context->preference('marcflavour') eq 'UNIMARC' ? 'publicationyear' : 'copyrightdate')
462
        . "<" . @$filters[5];
475
        . "< ? ";
476
        push @sqlargs, @$filters[5];
463
    }
477
    }
464
    if ( @$filters[6] ) {
478
    if ( @$filters[6] ) {
479
        $strcalc .= " AND $itemstable.homebranch LIKE ? ";
465
        @$filters[6] =~ s/\*/%/g;
480
        @$filters[6] =~ s/\*/%/g;
466
        $strcalc .= " AND $itemstable.homebranch LIKE '" . @$filters[6] . "'";
481
        push @sqlargs, @$filters[6];
467
    }
482
    }
468
    if ( @$filters[7] ) {
483
    if ( @$filters[7] ) {
484
        $strcalc .= " AND $itemstable.location LIKE ? ";
469
        @$filters[7] =~ s/\*/%/g;
485
        @$filters[7] =~ s/\*/%/g;
470
        $strcalc .= " AND $itemstable.location LIKE '" . @$filters[7] . "'";
486
        push @sqlargs, @$filters[7];
471
    }
487
    }
472
    if ( @$filters[8] ) {
488
    if ( @$filters[8] ) {
489
        $strcalc .= " AND $itemstable.ccode  LIKE ? ";
473
        @$filters[8] =~ s/\*/%/g;
490
        @$filters[8] =~ s/\*/%/g;
474
        $strcalc .= " AND $itemstable.ccode  LIKE '" . @$filters[8] . "'";
491
        push @sqlargs, @$filters[8];
475
    }
492
    }
476
    if ( defined @$filters[9] and @$filters[9] ne '' ) {
493
    if ( defined @$filters[9] and @$filters[9] ne '' ) {
494
        $strcalc .= " AND $itemstable.notforloan  LIKE ? ";
477
        @$filters[9] =~ s/\*/%/g;
495
        @$filters[9] =~ s/\*/%/g;
478
        $strcalc .= " AND $itemstable.notforloan  LIKE '" . @$filters[9] . "'";
496
        push @sqlargs, @$filters[9];
479
    }
497
    }
480
    if ( defined @$filters[10] and @$filters[10] ne '' ) {
498
    if ( defined @$filters[10] and @$filters[10] ne '' ) {
499
        $strcalc .= " AND $itemstable.materials  LIKE ? ";
481
        @$filters[10] =~ s/\*/%/g;
500
        @$filters[10] =~ s/\*/%/g;
482
        $strcalc .= " AND $itemstable.materials  LIKE '" . @$filters[10] . "'";
501
        push @sqlargs, @$filters[10];
483
    }
502
    }
484
    if ( @$filters[13] ) {
503
    if ( @$filters[13] ) {
504
        $strcalc .= " AND $itemstable.dateaccessioned >= ? ";
485
        @$filters[13] =~ s/\*/%/g;
505
        @$filters[13] =~ s/\*/%/g;
486
        $strcalc .= " AND $itemstable.dateaccessioned >= '@$filters[13]' ";
506
        push @sqlargs, @$filters[13];
487
    }
507
    }
488
    if ( @$filters[14] ) {
508
    if ( @$filters[14] ) {
509
        $strcalc .= " AND $itemstable.dateaccessioned <= ? ";
489
        @$filters[14] =~ s/\*/%/g;
510
        @$filters[14] =~ s/\*/%/g;
490
        $strcalc .= " AND $itemstable.dateaccessioned <= '@$filters[14]' ";
511
        push @sqlargs, @$filters[14];
491
    }
512
    }
492
    if ( $cellvalue eq 'deleteditems' and @$filters[15] ) {
513
    if ( $cellvalue eq 'deleteditems' and @$filters[15] ) {
514
        $strcalc .= " AND DATE(deleteditems.timestamp) >= ? ";
493
        @$filters[15] =~ s/\*/%/g;
515
        @$filters[15] =~ s/\*/%/g;
494
        $strcalc .= " AND DATE(deleteditems.timestamp) >= '@$filters[15]' ";
516
        push @sqlargs, @$filters[15];
495
    }
517
    }
496
    if ( $cellvalue eq 'deleteditems' and @$filters[16] ) {
518
    if ( $cellvalue eq 'deleteditems' and @$filters[16] ) {
497
        @$filters[16] =~ s/\*/%/g;
519
        @$filters[16] =~ s/\*/%/g;
498
        $strcalc .= " AND DATE(deleteditems.timestamp) <= '@$filters[16]' ";
520
        $strcalc .= " AND DATE(deleteditems.timestamp) <= ?";
521
        push @sqlargs, @$filters[16];
499
    }
522
    }
500
    $strcalc .= " group by $linefield, $colfield order by $linefield,$colfield";
523
    $strcalc .= " group by $linefield, $colfield order by $linefield,$colfield";
501
    $debug and warn "SQL: $strcalc";
524
    $debug and warn "SQL: $strcalc";
502
    my $dbcalc = $dbh->prepare($strcalc);
525
    my $dbcalc = $dbh->prepare($strcalc);
503
    if ($barcodefilter) {
526
    $dbcalc->execute(@sqlargs);
504
        $dbcalc->execute($barcodefilter);
505
    } else {
506
        $dbcalc->execute();
507
    }
508
527
509
    while ( my ( $row, $col, $value ) = $dbcalc->fetchrow ) {
528
    while ( my ( $row, $col, $value ) = $dbcalc->fetchrow ) {
510
529
511
- 

Return to bug 7683