View | Details | Raw Unified | Return to bug 21756
Collapse All | Expand All

(-)a/members/maninvoice.pl (-9 / +22 lines)
Lines 38-43 use Koha::Patrons; Link Here
38
38
39
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
40
40
41
use Try::Tiny;
42
41
my $input=new CGI;
43
my $input=new CGI;
42
my $flagsrequired = { borrowers => 'edit_borrowers' };
44
my $flagsrequired = { borrowers => 'edit_borrowers' };
43
45
Lines 69-76 if ($add){ Link Here
69
        my $amount=$input->param('amount');
71
        my $amount=$input->param('amount');
70
        my $type=$input->param('type');
72
        my $type=$input->param('type');
71
        my $note    = $input->param('note');
73
        my $note    = $input->param('note');
72
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
74
        try {
73
        if ($error) {
75
            my $account = $patron->account;
76
            my $invoice = $account->add_debit(
77
                {
78
                    amount      => $amount,
79
                    item_id     => $itemnum,
80
                    description => $desc,
81
                    type        => $type,
82
                    note        => $note
83
                }
84
            );
85
        }
86
        catch {
74
            my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
87
            my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
75
                {   template_name   => "members/maninvoice.tt",
88
                {   template_name   => "members/maninvoice.tt",
76
                    query           => $input,
89
                    query           => $input,
Lines 80-95 if ($add){ Link Here
80
                    debug           => 1,
93
                    debug           => 1,
81
                }
94
                }
82
            );
95
            );
83
            if ( $error =~ /FOREIGN KEY/ && $error =~ /itemnumber/ ) {
96
            if ( $_->isa('Koha::Exceptions::Object::FKConstraint') $error =~ /FOREIGN KEY/ && $error =~ /itemnumber/ ) {
84
                $template->param( 'ITEMNUMBER' => 1 );
97
                $template->param( 'ITEMNUMBER' => 1 ) if ($_->broken_fk eq 'itemnumber');
98
                $template->param( 'ERROR' => $_->message );
85
            }
99
            }
86
            $template->param( csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }) );
100
            $template->param( csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }) );
87
            $template->param( 'ERROR' => $error );
88
            output_html_with_http_headers $input, $cookie, $template->output;
101
            output_html_with_http_headers $input, $cookie, $template->output;
89
        } else {
90
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
91
            exit;
102
            exit;
92
        }
103
        };
104
105
        print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
106
        exit;
93
    }
107
    }
94
} else {
108
} else {
95
109
96
- 

Return to bug 21756