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