# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
use CGI;
use C4::Context;
-use C4::Reports;
-use C4::Output;
-use C4::Koha;
-use C4::Circulation;
+use C4::Reports qw( GetDelimiterChoices );
+use C4::Output qw( output_html_with_http_headers );
use DateTime;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string );
use Text::CSV::Encoded;
-use List::Util qw/any/;
+use List::Util qw( any );
use Koha::Account::CreditTypes;
use Koha::Account::DebitTypes;
);
#Initialize date pickers to today
-my $fromDate = dt_from_string;
-my $toDate = dt_from_string;
+my $fromDate = $input->param("from") || dt_from_string;
+my $toDate = $input->param("to") || dt_from_string;
my @debit_types =
Koha::Account::DebitTypes->search()->as_list;
if ($do_it) {
- $fromDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("from")) } || dt_from_string,
- dateformat => 'sql', dateonly => 1 }); #for sql query
- $toDate = output_pref({ dt => eval { dt_from_string(scalar $input->param("to")) } || dt_from_string,
- dateformat => 'sql', dateonly => 1 }); #for sql query
my $whereTType = q{};
my @extra_params; # if we add conditions to the select we need extra params
}
my $query = "
- SELECT round(amount,2) AS amount, description,
+ SELECT round(amount,2) AS amount, al.description,
bo.surname AS bsurname, bo.firstname AS bfirstname, m.surname AS msurname, m.firstname AS mfirstname,
bo.cardnumber, br.branchname, bo.borrowernumber,
- al.borrowernumber, DATE(al.date) as date, al.credit_type_code, al.debit_type_code, al.amountoutstanding, al.note, al.timestamp,
+ al.borrowernumber, DATE(al.date) as date, al.credit_type_code, al.debit_type_code, COALESCE(act.description,al.credit_type_code,adt.description,al.debit_type_code) AS type_description, al.amountoutstanding, al.note, al.timestamp,
bi.title, bi.biblionumber, i.barcode, i.itype
FROM accountlines al
LEFT JOIN borrowers bo ON (al.borrowernumber = bo.borrowernumber)
LEFT JOIN borrowers m ON (al.manager_id = m.borrowernumber)
- LEFT JOIN branches br ON (br.branchcode = m.branchcode )
+ LEFT JOIN cash_registers cr ON (al.register_id = cr.id)
+ LEFT JOIN branches br ON (br.branchcode = cr.branch)
LEFT JOIN items i ON (i.itemnumber = al.itemnumber)
LEFT JOIN biblio bi ON (bi.biblionumber = i.biblionumber)
+ LEFT JOIN account_credit_types act ON (al.credit_type_code = act.code)
+ LEFT JOIN account_debit_types adt ON (al.debit_type_code = adt.code)
WHERE CAST(al.date AS DATE) BETWEEN ? AND ?
$whereTType
$whereBranchCode
my $format = 'csv';
my $reportname = $input->param('basename');
my $reportfilename = $reportname ? "$reportname.$format" : "reportresults.$format" ;
- my $delimiter = C4::Context->preference('CSVDelimiter') || ',';
+ my $delimiter = C4::Context->csv_delimiter;
my @rows;
foreach my $row (@loopresult) {
my @rowValues;
$row->{branchname},
$row->{date},
$row->{timestamp},
- $row->{credit_type_code},
- $row->{debit_type_code},
+ $row->{type_description},
$row->{note},
$row->{amount},
$row->{title},
push (@rows, \@rowValues) ;
}
my @total;
- for (1..6){push(@total,"")};
+ for (1..7){push(@total,"")};
push(@total, $grantotal);
print $input->header(
-type => 'text/csv',