|
Lines 52-137
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 52 |
} |
52 |
} |
| 53 |
); |
53 |
); |
| 54 |
|
54 |
|
| 55 |
my $borrowernumber = $input->param('borrowernumber'); |
55 |
my $borrowernumber = $input->param('borrowernumber') || $input->param('borrowernumber00'); |
| 56 |
if ( $borrowernumber eq '' ) { |
|
|
| 57 |
$borrowernumber = $input->param('borrowernumber0'); |
| 58 |
} |
| 59 |
|
56 |
|
| 60 |
# get borrower details |
57 |
# get borrower details |
| 61 |
my $data = GetMember( borrowernumber => $borrowernumber ); |
58 |
my $data = GetMember( borrowernumber => $borrowernumber ); |
| 62 |
my $user = $input->remote_user; |
|
|
| 63 |
|
59 |
|
| 64 |
# get account details |
60 |
# get account details |
| 65 |
my $branches = GetBranches(); |
61 |
my $branches = GetBranches(); |
| 66 |
my $branch = GetBranch( $input, $branches ); |
62 |
my $branch = GetBranch( $input, $branches ); |
| 67 |
|
63 |
|
| 68 |
my @names = $input->param; |
64 |
my $index = '0'; |
| 69 |
my %inp; |
65 |
while ( $input->param( "payfine$index") ) { |
| 70 |
my $check = 0; |
66 |
my $payfine = $input->param( "payfine$index" ); |
| 71 |
for ( my $i = 0 ; $i < @names ; $i++ ) { |
67 |
my $amount = $input->param( "amount$index" ); |
| 72 |
my $temp = $input->param( $names[$i] ); |
68 |
my $accountno = $input->param( "accountno$index" ); |
| 73 |
if ( $temp eq 'wo' ) { |
69 |
my $amount_to_pay = $input->param( "amount_to_pay$index" ); |
| 74 |
$inp{ $names[$i] } = $temp; |
70 |
my $itemnumber = $input->param( "itemnumber$index" ); |
| 75 |
$check = 1; |
71 |
my $accounttype = $input->param( "accounttype$index" ); |
| 76 |
} |
72 |
$amount = $amount_to_pay if ( $amount_to_pay ); |
| 77 |
if ( $temp eq 'yes' ) { |
73 |
|
| 78 |
|
74 |
if ( $payfine eq 'yes' ) { ## Standard Fine Payment |
| 79 |
# FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline |
75 |
makepayment( $borrowernumber, $accountno, $amount, '', $branch ); |
| 80 |
my $amount = $input->param( $names[ $i + 4 ] ); |
76 |
} elsif ( $payfine eq 'wo' ) { ## Writeoff |
| 81 |
my $borrowernumber = $input->param( $names[ $i + 5 ] ); |
77 |
writeoff( $borrowernumber, $accountno, $itemnumber, $accounttype, $amount ); |
| 82 |
my $accountno = $input->param( $names[ $i + 6 ] ); |
78 |
} elsif ( $payfine eq 'ng' ) { ## Negotiate Fine |
| 83 |
makepayment( $borrowernumber, $accountno, $amount, $user, $branch ); |
79 |
negotiate( $borrowernumber, $accountno, $amount, $itemnumber ); |
| 84 |
$check = 2; |
|
|
| 85 |
} |
80 |
} |
|
|
81 |
|
| 82 |
$index++; |
| 86 |
} |
83 |
} |
| 87 |
my $total = $input->param('total') || ''; |
|
|
| 88 |
if ( $check == 0 ) { |
| 89 |
if ( $total ne '' ) { |
| 90 |
recordpayment( $borrowernumber, $total ); |
| 91 |
} |
| 92 |
|
84 |
|
| 93 |
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); |
85 |
## Pay by Amount |
| 94 |
|
86 |
my $total_to_pay = $input->param('pay_by_amount'); |
| 95 |
my @allfile; |
87 |
if ( $total_to_pay ) { |
| 96 |
my @notify = NumberNotifyId($borrowernumber); |
88 |
recordpayment( $borrowernumber, $total_to_pay ); |
| 97 |
|
89 |
} |
| 98 |
my $numberofnotify = scalar(@notify); |
|
|
| 99 |
for ( my $j = 0 ; $j < scalar(@notify) ; $j++ ) { |
| 100 |
my @loop_pay; |
| 101 |
my ( $total , $accts, $numaccts) = |
| 102 |
GetBorNotifyAcctRecord( $borrowernumber, $notify[$j] ); |
| 103 |
for ( my $i = 0 ; $i < $numaccts ; $i++ ) { |
| 104 |
my %line; |
| 105 |
if ( $accts->[$i]{'amountoutstanding'} != 0 ) { |
| 106 |
$accts->[$i]{'amount'} += 0.00; |
| 107 |
$accts->[$i]{'amountoutstanding'} += 0.00; |
| 108 |
$line{i} = $j . "" . $i; |
| 109 |
$line{itemnumber} = $accts->[$i]{'itemnumber'}; |
| 110 |
$line{accounttype} = $accts->[$i]{'accounttype'}; |
| 111 |
$line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} ); |
| 112 |
$line{amountoutstanding} = |
| 113 |
sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ); |
| 114 |
$line{borrowernumber} = $borrowernumber; |
| 115 |
$line{accountno} = $accts->[$i]{'accountno'}; |
| 116 |
$line{description} = $accts->[$i]{'description'}; |
| 117 |
$line{title} = $accts->[$i]{'title'}; |
| 118 |
$line{notify_id} = $accts->[$i]{'notify_id'}; |
| 119 |
$line{notify_level} = $accts->[$i]{'notify_level'}; |
| 120 |
$line{net_balance} = 1 if($accts->[$i]{'amountoutstanding'} > 0); # you can't pay a credit. |
| 121 |
push( @loop_pay, \%line ); |
| 122 |
} |
| 123 |
} |
| 124 |
|
90 |
|
| 125 |
my $totalnotify = AmountNotify( $notify[$j], $borrowernumber ); |
91 |
## Get Fine Details |
| 126 |
( $totalnotify = '0' ) if ( $totalnotify =~ /^0.00/ ); |
92 |
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); |
| 127 |
push @allfile, |
93 |
|
| 128 |
{ |
94 |
my @allfile; |
| 129 |
'loop_pay' => \@loop_pay, |
95 |
my @notify = NumberNotifyId($borrowernumber); |
| 130 |
'notify' => $notify[$j], |
96 |
|
| 131 |
'total' => sprintf( "%.2f",$totalnotify), |
97 |
my $numberofnotify = scalar(@notify); |
| 132 |
|
98 |
my $k = 0; |
| 133 |
}; |
99 |
for ( my $j = 0 ; $j < scalar(@notify) ; $j++ ) { |
|
|
100 |
my @loop_pay; |
| 101 |
my ( $total , $accts, $numaccts) = GetBorNotifyAcctRecord( $borrowernumber, $notify[$j] ); |
| 102 |
for ( my $i = 0 ; $i < $numaccts ; $i++ ) { |
| 103 |
my %line; |
| 104 |
if ( $accts->[$i]{'amountoutstanding'} != 0 ) { |
| 105 |
$accts->[$i]{'amount'} += 0.00; |
| 106 |
$accts->[$i]{'amountoutstanding'} += 0.00; |
| 107 |
$line{i} = $k; |
| 108 |
$line{itemnumber} = $accts->[$i]{'itemnumber'}; |
| 109 |
$line{accounttype} = $accts->[$i]{'accounttype'}; |
| 110 |
$line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} ); |
| 111 |
$line{amountoutstanding} = sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ); |
| 112 |
$line{borrowernumber} = $borrowernumber; |
| 113 |
$line{accountno} = $accts->[$i]{'accountno'}; |
| 114 |
$line{description} = $accts->[$i]{'description'}; |
| 115 |
$line{title} = $accts->[$i]{'title'}; |
| 116 |
$line{notify_id} = $accts->[$i]{'notify_id'}; |
| 117 |
$line{notify_level} = $accts->[$i]{'notify_level'}; |
| 118 |
$line{net_balance} = 1 if($accts->[$i]{'amountoutstanding'} > 0); # you can't pay a credit. |
| 119 |
push( @loop_pay, \%line ); |
| 120 |
$k++; |
| 121 |
} |
| 134 |
} |
122 |
} |
|
|
123 |
|
| 124 |
my $totalnotify = AmountNotify( $notify[$j], $borrowernumber ); |
| 125 |
$totalnotify = '0' if ( $totalnotify =~ /^0.00/ ); |
| 126 |
push @allfile, |
| 127 |
{ |
| 128 |
'loop_pay' => \@loop_pay, |
| 129 |
'notify' => $notify[$j], |
| 130 |
'total' => sprintf( "%.2f",$totalnotify), |
| 131 |
}; |
| 132 |
} |
| 135 |
|
133 |
|
| 136 |
if ( $data->{'category_type'} eq 'C') { |
134 |
if ( $data->{'category_type'} eq 'C') { |
| 137 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
135 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
|
Lines 144-150
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
Link Here
|
| 144 |
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); |
142 |
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); |
| 145 |
$template->param( picture => 1 ) if $picture; |
143 |
$template->param( picture => 1 ) if $picture; |
| 146 |
|
144 |
|
| 147 |
$template->param( |
145 |
$template->param( |
| 148 |
allfile => \@allfile, |
146 |
allfile => \@allfile, |
| 149 |
firstname => $data->{'firstname'}, |
147 |
firstname => $data->{'firstname'}, |
| 150 |
surname => $data->{'surname'}, |
148 |
surname => $data->{'surname'}, |
|
Lines 164-223
$template->param( picture => 1 ) if $picture;
Link Here
|
| 164 |
branchname => GetBranchName($data->{'branchcode'}), |
162 |
branchname => GetBranchName($data->{'branchcode'}), |
| 165 |
is_child => ($data->{'category_type'} eq 'C'), |
163 |
is_child => ($data->{'category_type'} eq 'C'), |
| 166 |
total => sprintf( "%.2f", $total ) |
164 |
total => sprintf( "%.2f", $total ) |
| 167 |
); |
165 |
); |
| 168 |
output_html_with_http_headers $input, $cookie, $template->output; |
|
|
| 169 |
|
| 170 |
} |
| 171 |
else { |
| 172 |
|
| 173 |
my %inp; |
| 174 |
my @name = $input->param; |
| 175 |
for ( my $i = 0 ; $i < @name ; $i++ ) { |
| 176 |
my $test = $input->param( $name[$i] ); |
| 177 |
if ( $test eq 'wo' ) { |
| 178 |
my $temp = $name[$i]; |
| 179 |
$temp =~ s/payfine//; |
| 180 |
$inp{ $name[$i] } = $temp; |
| 181 |
} |
| 182 |
} |
| 183 |
my $borrowernumber; |
| 184 |
while ( my ( $key, $value ) = each %inp ) { |
| 185 |
|
| 186 |
my $accounttype = $input->param("accounttype$value"); |
| 187 |
$borrowernumber = $input->param("borrowernumber$value"); |
| 188 |
my $itemno = $input->param("itemnumber$value"); |
| 189 |
my $amount = $input->param("amount$value"); |
| 190 |
my $accountno = $input->param("accountno$value"); |
| 191 |
writeoff( $borrowernumber, $accountno, $itemno, $accounttype, $amount ); |
| 192 |
} |
| 193 |
$borrowernumber = $input->param('borrowernumber'); |
| 194 |
print $input->redirect( |
| 195 |
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); |
| 196 |
} |
| 197 |
|
166 |
|
| 198 |
sub writeoff { |
167 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 199 |
my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount ) = @_; |
|
|
| 200 |
my $user = $input->remote_user; |
| 201 |
my $dbh = C4::Context->dbh; |
| 202 |
undef $itemnum unless $itemnum; # if no item is attached to fine, make sure to store it as a NULL |
| 203 |
my $sth = |
| 204 |
$dbh->prepare( |
| 205 |
"Update accountlines set amountoutstanding=0 where accountno=? and borrowernumber=?" |
| 206 |
); |
| 207 |
$sth->execute( $accountnum, $borrowernumber ); |
| 208 |
$sth->finish; |
| 209 |
$sth = $dbh->prepare("select max(accountno) from accountlines"); |
| 210 |
$sth->execute; |
| 211 |
my $account = $sth->fetchrow_hashref; |
| 212 |
$sth->finish; |
| 213 |
$account->{'max(accountno)'}++; |
| 214 |
$sth = $dbh->prepare( |
| 215 |
"insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype) |
| 216 |
values (?,?,?,now(),?,'Writeoff','W')" |
| 217 |
); |
| 218 |
$sth->execute( $borrowernumber, $account->{'max(accountno)'}, |
| 219 |
$itemnum, $amount ); |
| 220 |
$sth->finish; |
| 221 |
UpdateStats( $branch, 'writeoff', $amount, '', '', '', |
| 222 |
$borrowernumber ); |
| 223 |
} |
| 224 |
- |
|
|