Lines 29-34
use C4::Output;
Link Here
|
29 |
use CGI qw ( -utf8 ); |
29 |
use CGI qw ( -utf8 ); |
30 |
use C4::Members; |
30 |
use C4::Members; |
31 |
use C4::Accounts; |
31 |
use C4::Accounts; |
|
|
32 |
use Koha::Account::Lines; |
32 |
use Koha::DateUtils; |
33 |
use Koha::DateUtils; |
33 |
use Koha::Patrons; |
34 |
use Koha::Patrons; |
34 |
use Koha::Patron::Categories; |
35 |
use Koha::Patron::Categories; |
Lines 69-122
if ( $data->{'category_type'} eq 'C') {
Link Here
|
69 |
} |
70 |
} |
70 |
|
71 |
|
71 |
#get account details |
72 |
#get account details |
72 |
my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber); |
73 |
my $total = $patron->account->balance; |
|
|
74 |
|
75 |
# FIXME This whole stuff is ugly and should be rewritten |
76 |
# FIXME We should pass the $accts iterator to the template and do this formatting part there |
77 |
my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed; |
73 |
my $totalcredit; |
78 |
my $totalcredit; |
74 |
if($total <= 0){ |
79 |
if($total <= 0){ |
75 |
$totalcredit = 1; |
80 |
$totalcredit = 1; |
76 |
} |
81 |
} |
77 |
my @accountrows; # this is for the tmpl-loop |
82 |
|
78 |
|
83 |
$accountline->{'amount'} += 0.00; |
79 |
my $toggle; |
84 |
if ( $accountline->{'amount'} <= 0 ) { |
80 |
for (my $i=0;$i<$numaccts;$i++){ |
85 |
$accountline->{'amountcredit'} = 1; |
81 |
next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id ); |
86 |
$accountline->{'amount'} *= -1.00; |
82 |
if($i%2){ |
87 |
} |
83 |
$toggle = 0; |
88 |
$accountline->{'amountoutstanding'} += 0.00; |
84 |
} else { |
89 |
if ( $accountline->{'amountoutstanding'} <= 0 ) { |
85 |
$toggle = 1; |
90 |
$accountline->{'amountoutstandingcredit'} = 1; |
86 |
} |
|
|
87 |
$accts->[$i]{'toggle'} = $toggle; |
88 |
$accts->[$i]{'amount'}+=0.00; |
89 |
if($accts->[$i]{'amount'} <= 0){ |
90 |
$accts->[$i]{'amountcredit'} = 1; |
91 |
$accts->[$i]{'amount'}*=-1.00; |
92 |
} |
93 |
$accts->[$i]{'amountoutstanding'}+=0.00; |
94 |
if($accts->[$i]{'amountoutstanding'} <= 0){ |
95 |
$accts->[$i]{'amountoutstandingcredit'} = 1; |
96 |
} |
97 |
|
98 |
my %row = ( 'date' => dt_from_string( $accts->[$i]{'date'} ), |
99 |
'amountcredit' => $accts->[$i]{'amountcredit'}, |
100 |
'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, |
101 |
'toggle' => $accts->[$i]{'toggle'}, |
102 |
'description' => $accts->[$i]{'description'}, |
103 |
'itemnumber' => $accts->[$i]{'itemnumber'}, |
104 |
'biblionumber' => $accts->[$i]{'biblionumber'}, |
105 |
'amount' => sprintf("%.2f",$accts->[$i]{'amount'}), |
106 |
'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}), |
107 |
'accountno' => $accts->[$i]{'accountno'}, |
108 |
accounttype => $accts->[$i]{accounttype}, |
109 |
'note' => $accts->[$i]{'note'}, |
110 |
); |
111 |
|
112 |
if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){ |
113 |
$row{'printtitle'}=1; |
114 |
$row{'title'} = $accts->[$i]{'title'}; |
115 |
} |
116 |
|
117 |
push(@accountrows, \%row); |
118 |
} |
91 |
} |
119 |
|
92 |
|
|
|
93 |
my %row = ( |
94 |
'date' => dt_from_string( $accountline->{'date'} ), |
95 |
'amountcredit' => $accountline->{'amountcredit'}, |
96 |
'amountoutstandingcredit' => $accountline->{'amountoutstandingcredit'}, |
97 |
'description' => $accountline->{'description'}, |
98 |
'amount' => sprintf( "%.2f", $accountline->{'amount'} ), |
99 |
'amountoutstanding' => |
100 |
sprintf( "%.2f", $accountline->{'amountoutstanding'} ), |
101 |
'accountno' => $accountline->{'accountno'}, |
102 |
accounttype => $accountline->{accounttype}, |
103 |
'note' => $accountline->{'note'}, |
104 |
); |
105 |
|
120 |
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' ); |
106 |
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' ); |
121 |
|
107 |
|
122 |
$template->param( picture => 1 ) if $patron->image; |
108 |
$template->param( picture => 1 ) if $patron->image; |
Lines 142-147
$template->param(
Link Here
|
142 |
total => sprintf("%.2f",$total), |
128 |
total => sprintf("%.2f",$total), |
143 |
totalcredit => $totalcredit, |
129 |
totalcredit => $totalcredit, |
144 |
is_child => ($data->{'category_type'} eq 'C'), |
130 |
is_child => ($data->{'category_type'} eq 'C'), |
145 |
accounts => \@accountrows ); |
131 |
accounts => [$accountline], # FIXME There is always only 1 row! |
|
|
132 |
); |
146 |
|
133 |
|
147 |
output_html_with_http_headers $input, $cookie, $template->output; |
134 |
output_html_with_http_headers $input, $cookie, $template->output; |