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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt (-2 / +2 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports &rsaquo; Average checkout period</title>
2
<title>Koha &rsaquo; Reports &rsaquo; Average loan time</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script type="text/javascript">
5
<script type="text/javascript">
Lines 40-46 Link Here
40
[% INCLUDE 'header.inc' %]
40
[% INCLUDE 'header.inc' %]
41
[% INCLUDE 'cat-search.inc' %]
41
[% INCLUDE 'cat-search.inc' %]
42
42
43
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> [% IF ( do_it ) %]&rsaquo; <a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average checkout period</a> &rsaquo; Results [% ELSE %]&rsaquo; Average checkout period[% END %]</div>
43
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> [% IF ( do_it ) %]&rsaquo; <a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a> &rsaquo; Results [% ELSE %]&rsaquo; Average loan time[% END %]</div>
44
44
45
<div id="doc3" class="yui-t2">
45
<div id="doc3" class="yui-t2">
46
   
46
   
(-)a/reports/issues_avg_stats.pl (-19 / +15 lines)
Lines 56-61 my $rodsp = $input->param("ReturnDisplay"); Link Here
56
my $calc = $input->param("Cellvalue");
56
my $calc = $input->param("Cellvalue");
57
my $output = $input->param("output");
57
my $output = $input->param("output");
58
my $basename = $input->param("basename");
58
my $basename = $input->param("basename");
59
my $itype = C4::Context->preference('item-level_itypes') ? "items.itype" : "biblioitems.itemtype";
60
59
#warn "calcul : ".$calc;
61
#warn "calcul : ".$calc;
60
my ($template, $borrowernumber, $cookie)
62
my ($template, $borrowernumber, $cookie)
61
    = get_template_and_user({template_name => $fullreportname,
63
    = get_template_and_user({template_name => $fullreportname,
Lines 242-249 sub calculate { Link Here
242
#	warn "filtres ".@filters[2];
244
#	warn "filtres ".@filters[2];
243
#	warn "filtres ".@filters[3];
245
#	warn "filtres ".@filters[3];
244
    $line = "old_issues.".$line if ($line=~/branchcode/) or ($line=~/timestamp/);
246
    $line = "old_issues.".$line if ($line=~/branchcode/) or ($line=~/timestamp/);
245
    $line = "biblioitems.".$line if $line=~/itemtype/;
247
    if ( $line=~/itemtype/ ) { $line = $itype; }
246
    
247
    $linefilter[0] = @$filters[0] if ($line =~ /timestamp/ )  ;
248
    $linefilter[0] = @$filters[0] if ($line =~ /timestamp/ )  ;
248
    $linefilter[1] = @$filters[1] if ($line =~ /timestamp/ )  ;
249
    $linefilter[1] = @$filters[1] if ($line =~ /timestamp/ )  ;
249
    $linefilter[2] = @$filters[2] if ($line =~ /timestamp/ )  ;
250
    $linefilter[2] = @$filters[2] if ($line =~ /timestamp/ )  ;
Lines 255-267 sub calculate { Link Here
255
    $linefilter[0] = @$filters[8] if ($line =~ /category/ )  ;
256
    $linefilter[0] = @$filters[8] if ($line =~ /category/ )  ;
256
    $linefilter[0] = @$filters[9] if ($line =~ /itemtype/ )  ;
257
    $linefilter[0] = @$filters[9] if ($line =~ /itemtype/ )  ;
257
    $linefilter[0] = @$filters[10] if ($line =~ /branch/ )  ;
258
    $linefilter[0] = @$filters[10] if ($line =~ /branch/ )  ;
258
# 	$linefilter[0] = @$filters[11] if ($line =~ /sort2/ ) ;
259
    $linefilter[0] = @$filters[11] if ($line =~ /sort1/ ) ;
259
    $linefilter[0] = @$filters[11] if ($line =~ /sort1/ ) ;
260
    $linefilter[0] = @$filters[12] if ($line =~ /sort2/ ) ;
260
    $linefilter[0] = @$filters[12] if ($line =~ /sort2/ ) ;
261
#warn "filtre lignes".$linefilter[0]." ".$linefilter[1];
261
262
# 
263
    $column = "old_issues.".$column if (($column=~/branchcode/) or ($column=~/timestamp/));
262
    $column = "old_issues.".$column if (($column=~/branchcode/) or ($column=~/timestamp/));
264
    $column = "biblioitems.".$column if $column=~/itemtype/;
263
    if ( $column=~/itemtype/ ) { $column = $itype; }
265
    my @colfilter ;
264
    my @colfilter ;
266
    $colfilter[0] = @$filters[0] if ($column =~ /timestamp/ )  ;
265
    $colfilter[0] = @$filters[0] if ($column =~ /timestamp/ )  ;
267
    $colfilter[1] = @$filters[1] if ($column =~ /timestamp/ )  ;
266
    $colfilter[1] = @$filters[1] if ($column =~ /timestamp/ )  ;
Lines 272-283 sub calculate { Link Here
272
    $colfilter[2] = @$filters[6] if ($column =~ /returndate/ )  ;
271
    $colfilter[2] = @$filters[6] if ($column =~ /returndate/ )  ;
273
    $colfilter[3] = @$filters[7] if ($column =~ /returndate/ )  ;
272
    $colfilter[3] = @$filters[7] if ($column =~ /returndate/ )  ;
274
    $colfilter[0] = @$filters[8] if ($column =~ /category/ )  ;
273
    $colfilter[0] = @$filters[8] if ($column =~ /category/ )  ;
275
    $colfilter[0] = @$filters[9] if ($column =~ /itemtype/ )  ;
274
    $colfilter[0] = @$filters[9] if ($column =~ $itype )  ;
276
    $colfilter[0] = @$filters[10] if ($column =~ /branch/ )  ;
275
    $colfilter[0] = @$filters[10] if ($column =~ /branch/ )  ;
277
# 	$colfilter[0] = @$filters[11] if ($column =~ /sort2/ ) ;
278
    $colfilter[0] = @$filters[11] if ($column =~ /sort1/ ) ;
276
    $colfilter[0] = @$filters[11] if ($column =~ /sort1/ ) ;
279
    $colfilter[0] = @$filters[12] if ($column =~ /sort2/ ) ;
277
    $colfilter[0] = @$filters[12] if ($column =~ /sort2/ ) ;
280
#warn "filtre col ".$colfilter[0]." ".$colfilter[1];
281
                                            
278
                                            
282
# 1st, loop rows.                             
279
# 1st, loop rows.                             
283
    my $linefield;
280
    my $linefield;
Lines 310-316 sub calculate { Link Here
310
                LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber=items.biblioitemnumber) 
307
                LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber=items.biblioitemnumber) 
311
                LEFT JOIN issuingrules ON 
308
                LEFT JOIN issuingrules ON 
312
                    (issuingrules.branchcode=old_issues.branchcode
309
                    (issuingrules.branchcode=old_issues.branchcode
313
                    AND  issuingrules.itemtype=biblioitems.itemtype 
310
                    AND  issuingrules.itemtype=$itype
314
                    AND  issuingrules.categorycode=borrowers.categorycode) 
311
                    AND  issuingrules.categorycode=borrowers.categorycode) 
315
                WHERE 1";
312
                WHERE 1";
316
    
313
    
Lines 338-344 sub calculate { Link Here
338
    my $sth = $dbh->prepare( $strsth );
335
    my $sth = $dbh->prepare( $strsth );
339
    $sth->execute;
336
    $sth->execute;
340
337
341
    
342
    while ( my ($celvalue) = $sth->fetchrow) {
338
    while ( my ($celvalue) = $sth->fetchrow) {
343
        my %cell;
339
        my %cell;
344
        if ($celvalue) {
340
        if ($celvalue) {
Lines 372-378 sub calculate { Link Here
372
        $colfield .= $column;
368
        $colfield .= $column;
373
        $colorder .= $column;
369
        $colorder .= $column;
374
    }  
370
    }  
375
    
371
376
    my $strsth2;
372
    my $strsth2;
377
    $strsth2 .= "SELECT distinctrow $colfield 
373
    $strsth2 .= "SELECT distinctrow $colfield 
378
                  FROM `old_issues`
374
                  FROM `old_issues`
Lines 381-387 sub calculate { Link Here
381
                  LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber=items.biblioitemnumber) 
377
                  LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber=items.biblioitemnumber) 
382
                  LEFT JOIN issuingrules ON 
378
                  LEFT JOIN issuingrules ON 
383
                    (issuingrules.branchcode=old_issues.branchcode 
379
                    (issuingrules.branchcode=old_issues.branchcode 
384
                    AND  issuingrules.itemtype=biblioitems.itemtype 
380
                    AND  issuingrules.itemtype=$itype
385
                    AND  issuingrules.categorycode=borrowers.categorycode) 
381
                    AND  issuingrules.categorycode=borrowers.categorycode) 
386
                  WHERE 1";
382
                  WHERE 1";
387
    
383
    
Lines 407-420 sub calculate { Link Here
407
    $strsth2 .=" ORDER BY $colorder";
403
    $strsth2 .=" ORDER BY $colorder";
408
    
404
    
409
    my $sth2 = $dbh->prepare( $strsth2 );
405
    my $sth2 = $dbh->prepare( $strsth2 );
406
410
    if (( @colfilter ) and ($colfilter[1])){
407
    if (( @colfilter ) and ($colfilter[1])){
411
        $sth2->execute("'".$colfilter[0]."'","'".$colfilter[1]."'");
408
        $sth2->execute("'".$colfilter[0]."'","'".$colfilter[1]."'");
412
    } elsif ($colfilter[0]) {
409
    } elsif ($colfilter[0]) {
413
        $sth2->execute($colfilter[0]);
410
        $sth2->execute;
414
    } else {
411
    } else {
415
        $sth2->execute;
412
        $sth2->execute;
416
    }
413
    }
417
    
418
414
419
    while (my ($celvalue) = $sth2->fetchrow) {
415
    while (my ($celvalue) = $sth2->fetchrow) {
420
        my %cell;
416
        my %cell;
Lines 449-455 sub calculate { Link Here
449
    
445
    
450
# Processing average loanperiods
446
# Processing average loanperiods
451
    $strcalc .= "SELECT $linefield, $colfield, ";
447
    $strcalc .= "SELECT $linefield, $colfield, ";
452
    $strcalc .= " issuedate, returndate, old_issues.timestamp, COUNT(*), date_due, old_issues.renewals, issuelength FROM `old_issues`,borrowers,biblioitems LEFT JOIN items ON (biblioitems.biblioitemnumber=items.biblioitemnumber) LEFT JOIN issuingrules ON (issuingrules.branchcode=branchcode AND  issuingrules.itemtype=biblioitems.itemtype AND  issuingrules.categorycode=categorycode) WHERE old_issues.itemnumber=items.itemnumber AND old_issues.borrowernumber=borrowers.borrowernumber";
448
    $strcalc .= " issuedate, returndate, old_issues.timestamp, COUNT(*), date_due, old_issues.renewals, issuelength FROM `old_issues`,borrowers,biblioitems LEFT JOIN items ON (biblioitems.biblioitemnumber=items.biblioitemnumber) LEFT JOIN issuingrules ON (issuingrules.branchcode=branchcode AND  issuingrules.itemtype=$itype AND  issuingrules.categorycode=categorycode) WHERE old_issues.itemnumber=items.itemnumber AND old_issues.borrowernumber=borrowers.borrowernumber";
453
449
454
    @$filters[0]=~ s/\*/%/g if (@$filters[0]);
450
    @$filters[0]=~ s/\*/%/g if (@$filters[0]);
455
    $strcalc .= " AND old_issues.timestamp > '" . @$filters[0] ."'" if ( @$filters[0] );
451
    $strcalc .= " AND old_issues.timestamp > '" . @$filters[0] ."'" if ( @$filters[0] );
Lines 462-468 sub calculate { Link Here
462
    @$filters[8]=~ s/\*/%/g if (@$filters[8]);
458
    @$filters[8]=~ s/\*/%/g if (@$filters[8]);
463
    $strcalc .= " AND borrowers.categorycode like '" . @$filters[8] ."'" if ( @$filters[8] );
459
    $strcalc .= " AND borrowers.categorycode like '" . @$filters[8] ."'" if ( @$filters[8] );
464
    @$filters[9]=~ s/\*/%/g if (@$filters[9]);
460
    @$filters[9]=~ s/\*/%/g if (@$filters[9]);
465
    $strcalc .= " AND biblioitems.itemtype like '" . @$filters[9] ."'" if ( @$filters[9] );
461
    $strcalc .= " AND $itype like '" . @$filters[9] ."'" if ( @$filters[9] );
466
    @$filters[10]=~ s/\*/%/g if (@$filters[10]);
462
    @$filters[10]=~ s/\*/%/g if (@$filters[10]);
467
    $strcalc .= " AND old_issues.branchcode like '" . @$filters[10] ."'" if ( @$filters[10] );
463
    $strcalc .= " AND old_issues.branchcode like '" . @$filters[10] ."'" if ( @$filters[10] );
468
    @$filters[11]=~ s/\*/%/g if (@$filters[11]);
464
    @$filters[11]=~ s/\*/%/g if (@$filters[11]);
Lines 486-492 sub calculate { Link Here
486
    my $err;
482
    my $err;
487
    my $emptycol;
483
    my $emptycol;
488
    my $weightrow;
484
    my $weightrow;
489
    
485
490
    while (my  @data = $dbcalc->fetchrow) {
486
    while (my  @data = $dbcalc->fetchrow) {
491
        my ($row, $col, $issuedate, $returndate, $weight)=@data;
487
        my ($row, $col, $issuedate, $returndate, $weight)=@data;
492
#		warn "filling table $row / $col / $issuedate / $returndate /$weight";
488
#		warn "filling table $row / $col / $issuedate / $returndate /$weight";
Lines 579-584 sub calculate { Link Here
579
    $globalline{column} = $column;
575
    $globalline{column} = $column;
580
    push @mainloop,\%globalline;
576
    push @mainloop,\%globalline;
581
    return \@mainloop;
577
    return \@mainloop;
578
582
}
579
}
583
580
584
1;
581
1;
585
- 

Return to bug 13452