Mongolian updates
[koha.git] / reports / acquisitions_stats.pl
index c5c4036..1ce99ff 100755 (executable)
@@ -24,7 +24,7 @@ use strict;
 use C4::Auth;
 use CGI;
 use C4::Context;
-
+use C4::Reports;
 use C4::Output;
 use C4::Koha;
 use C4::Circulation;
@@ -57,7 +57,6 @@ my $calc           = $input->param("Cellvalue");
 my $output         = $input->param("output");
 my $basename       = $input->param("basename");
 my $mime           = $input->param("MIME");
-my $del            = $input->param("sep");
 
 #warn "calcul : ".$calc;
 my ($template, $borrowernumber, $cookie)
@@ -68,6 +67,8 @@ my ($template, $borrowernumber, $cookie)
                                flagsrequired => {reports => 1},
                                debug => 1,
                                });
+our $sep     = $input->param("sep");
+$sep = "\t" if ($sep eq 'tabulation');
 $template->param(do_it => $do_it,
         DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
                );
@@ -88,8 +89,6 @@ if ($do_it) {
         );
         my $cols  = @$results[0]->{loopcol};
         my $lines = @$results[0]->{looprow};
-        my $sep;
-        $sep = C4::Context->preference("delimiter");
         print @$results[0]->{line} . "/" . @$results[0]->{column} . $sep;
         foreach my $col (@$cols) {
             print $col->{coltitle} . $sep;
@@ -243,14 +242,7 @@ else {
         -multiple => 0
     );
 
-    my @dels         = ( C4::Context->preference("delimiter") );
-    my $CGIsepChoice = CGI::scrolling_list(
-        -name     => 'sep',
-        -id       => 'sep',
-        -values   => \@dels,
-        -size     => 1,
-        -multiple => 0
-    );
+    my $CGIsepChoice = GetDelimiterChoices;
 
     $template->param(
         CGIBookSeller => $CGIBookSellers,
@@ -486,17 +478,17 @@ sub calculate {
         $colfield .= "Year($column)";
 
     }
-    elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 1 ) ) {
+    elsif ( ( $column =~ /received/ ) and ( $rodsp == 1 ) ) {
 
         #Display by day
         $colfield .= "dayname($column)";
     }
-    elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 2 ) ) {
+    elsif ( ( $column =~ /received/ ) and ( $rodsp == 2 ) ) {
 
         #Display by Month
         $colfield .= "monthname($column)";
     }
-    elsif ( ( $column =~ /deliverydate/ ) and ( $rodsp == 3 ) ) {
+    elsif ( ( $column =~ /received/ ) and ( $rodsp == 3 ) ) {
 
         #Display by Year
         $colfield .= "Year($column)";
@@ -657,9 +649,9 @@ sub calculate {
     while ( my ( $row, $col, $value ) = $dbcalc->fetchrow ) {
                next if ($row eq undef || $col eq undef);
                #warn "filling table $row / $col / $value ";
-        $emptycol = 1         if ( $col eq undef );
-        $col      = "zzEMPTY" if ( $col eq undef );
-        $row      = "zzEMPTY" if ( $row eq undef );
+        $emptycol = 1         if ( !defined($col) );
+        $col      = "zzEMPTY" if ( !defined($col) );
+        $row      = "zzEMPTY" if ( !defined($row) );
 
         $table{$row}->{$col}     += $value;
         $table{$row}->{totalrow} += $value;