=cut
-use strict;
-use warnings;
use Modern::Perl;
-use CGI;
+use CGI qw( -utf8 );
use C4::Auth;
use C4::Output;
use C4::Budgets;
use C4::Biblio;
use C4::Reports;
use C4::Acquisition; #GetBasket()
+use Koha::Biblios;
+use Koha::DateUtils;
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
# Format the order's informations
foreach my $order (@orders) {
# Get the title of the ordered item
- my $biblio = C4::Biblio::GetBiblio($order->{'biblionumber'});
+ my $biblio = Koha::Biblios->find( $order->{biblionumber} );
my $basket = C4::Acquisition::GetBasket($order->{'basketno'});
$order->{'basketname'} = $basket->{'basketname'};
$order->{'authorisedbyname'} = $basket->{'authorisedbyname'};
- $order->{'title'} = $biblio->{'title'} || $order->{'biblionumber'};
+ $order->{title} = $biblio ? $biblio->title : '';
+ $order->{title} ||= $order->{biblionumber};
$order->{'total_rrp'} = $order->{'quantity'} * $order->{'rrp'};
$order->{'total_ecost'} = $order->{'quantity'} * $order->{'ecost'};
# Format the dates and currencies correctly
- $order->{'datereceived'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'datereceived'}));
- $order->{'entrydate'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'entrydate'}));
+ $order->{'datereceived'} = output_pref(dt_from_string($order->{'datereceived'}));
+ $order->{'entrydate'} = output_pref(dt_from_string($order->{'entrydate'}));
$total_quantity += $order->{'quantity'};
$total_rrp += $order->{'total_rrp'};
$total_ecost += $order->{'total_ecost'};
my $sep = $params->{"sep"};
$sep = "\t" if ($sep eq 'tabulation');
+ # TODO Use Text::CSV to generate the CSV file
print $query->header(
- -type => 'application/vnd.sun.xml.calc',
+ -type => 'text/csv',
-encoding => 'utf-8',
-attachment => "$basename.csv",
-name => "$basename.csv"