X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=reports%2Facquisitions_stats.pl;h=2c90fe32cca63e938d9bf92355e9865c53efa0df;hb=0d7ba6e5201b16f7e7a2332af7204cb6416c289a;hp=9bb439f1f4a76ae3bba328af0206cfe2b5256993;hpb=17af2c9a1e689ea845c65ffaaa6efaeb49eeec98;p=koha-ffzg.git diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl index 9bb439f1f4..2c90fe32cc 100755 --- a/reports/acquisitions_stats.pl +++ b/reports/acquisitions_stats.pl @@ -19,16 +19,15 @@ use Modern::Perl; -use C4::Auth; +use C4::Auth qw( get_template_and_user ); use CGI qw ( -utf8 ); use C4::Context; -use C4::Reports; -use C4::Output; -use C4::Koha; -use C4::Circulation; -use C4::Branch; -use C4::Biblio; -use Koha::DateUtils; +use C4::Reports qw( GetDelimiterChoices ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Koha qw( GetAuthorisedValues ); +use C4::Biblio qw( GetMarcSubfieldStructureFromKohaField ); +use Koha::ItemTypes; +use Koha::Libraries; =head1 NAME @@ -40,20 +39,12 @@ Plugin that shows a stats on borrowers =cut -my $input = new CGI; +my $input = CGI->new; my $do_it = $input->param('do_it'); my $fullreportname = "reports/acquisitions_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); -my @filters = $input->param("Filter"); -$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[0] ); -$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[1] ); -$filters[2] = eval { output_pref( { dt => dt_from_string( $filters[2]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[2] ); -$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } - if ( $filters[3] ); +my @filters = $input->multi_param("Filter"); my $podsp = $input->param("PlacedOnDisplay"); my $rodsp = $input->param("ReceivedOnDisplay"); my $calc = $input->param("Cellvalue"); @@ -65,14 +56,11 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( template_name => $fullreportname, query => $input, type => "intranet", - authnotrequired => 0, flagsrequired => { reports => '*' }, - debug => 1, } ); -our $sep = $input->param("sep") // ''; -$sep = "\t" if ($sep eq 'tabulation'); +our $sep = C4::Context->csv_delimiter(scalar $input->param("sep")); $template->param( do_it => $do_it, @@ -124,19 +112,6 @@ else { $req->execute; my $booksellers = $req->fetchall_arrayref({}); - $req = $dbh->prepare("SELECT DISTINCTROW itemtype,description FROM itemtypes ORDER BY description"); - $req->execute; - my @iselect; - my %iselect; - while ( my ( $value, $desc ) = $req->fetchrow ) { - push @iselect, $value; - $iselect{$value} = $desc; - } - my $ItemTypes = { - values => \@iselect, - labels => \%iselect, - }; - $req = $dbh->prepare("SELECT DISTINCTROW budget_code, budget_name FROM aqbudgets ORDER BY budget_name"); $req->execute; my @bselect; @@ -196,13 +171,9 @@ else { my $CGIsepChoice = GetDelimiterChoices; - my $branches = GetBranches; - my @branches; - foreach ( sort keys %$branches ) { - push @branches, $branches->{$_}; - } + my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' }); - my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', ''); + my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode'); my $ccode_label; my $ccode_avlist; if($ccode_subfield_structure) { @@ -210,16 +181,17 @@ else { $ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value}); } + my $itemtypes = Koha::ItemTypes->search_with_localization; $template->param( booksellers => $booksellers, - ItemTypes => $ItemTypes, + itemtypes => $itemtypes, # FIXME Should use the TT plugin instead Budgets => $Budgets, hassort1 => $hassort1, hassort2 => $hassort2, Sort1 => $Sort1, Sort2 => $Sort2, CGIsepChoice => $CGIsepChoice, - branches => \@branches, + branches => $libraries, ccode_label => $ccode_label, ccode_avlist => $ccode_avlist, ); @@ -253,13 +225,7 @@ sub calculate { if ( ( ( $i == 1 ) or ( $i == 3 ) ) and ( @$filters[ $i - 1 ] ) ) { $cell{err} = 1 if ( @$filters[$i] lt @$filters[ $i - 1 ] ); } - # format the dates filters, otherwise just fill as is - if ($i >= 4) { - $cell{filter} = @$filters[$i]; - } else { - $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } - if ( @$filters[$i] ); - } + $cell{filter} = @$filters[$i]; $cell{crit} = $i; push @loopfilter, \%cell; } @@ -295,7 +261,7 @@ sub calculate { } elsif ( $rodsp == 3 ) { $field{$a} = "Year($a)"; } else { - field{$a} = $a; + $field{$a} = $a; } } elsif ( $_ =~ /bookseller/ ) { @@ -441,7 +407,6 @@ sub calculate { } my $i = 0; - my @totalcol; my $hilighted = -1; #Initialization of cell values.....