# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use Try::Tiny;
+use Try::Tiny qw( catch try );
+use URI::Escape qw( uri_escape_utf8 );
-use C4::Auth;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
use CGI qw ( -utf8 );
use C4::Members;
use C4::Accounts;
-use C4::Items;
use Koha::Token;
use Koha::Patrons;
use Koha::Patron::Categories;
use Koha::Account::DebitTypes;
-my $input = new CGI;
+my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "members/maninvoice.tt",
unless ($failed) {
try {
- $patron->account->add_debit(
+ my $line = $patron->account->add_debit(
{
amount => $amount,
description => $desc,
}
if ( $add eq 'save and pay' ) {
- print $input->redirect(
- "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"
+ my $url = sprintf(
+ '/cgi-bin/koha/members/paycollect.pl?borrowernumber=%s&pay_individual=1&debit_type_code=%s&amount=%s&amountoutstanding=%s&description=%s&itemnumber=%s&accountlines_id=%s',
+ map { uri_escape_utf8($_) } (
+ $borrowernumber,
+ $line->debit_type_code,
+ $line->amount,
+ $line->amountoutstanding,
+ $line->description,
+ $line->itemnumber,
+ $line->id
+ )
);
+
+ print $input->redirect($url);
}
else {
print $input->redirect(
}
}
-my @debit_types = Koha::Account::DebitTypes->search_with_library_limits(
+my $debit_types = Koha::Account::DebitTypes->search_with_library_limits(
{ can_be_invoiced => 1, archived => 0 },
{}, $library_id );
$template->param(
- debit_types => \@debit_types,
+ debit_types => $debit_types,
csrf_token => Koha::Token->new->generate_csrf(
{ session_id => scalar $input->cookie('CGISESSID') }
),