From a35f2594b188befd8c524ba09601d58338c4d548 Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Fri, 22 Sep 2006 00:21:25 +0000 Subject: [PATCH] Patrons may pay their fines in instalments --- members/boraccount.pl | 10 ++-- members/mancredit.pl | 65 +++++++++++++++-------- members/maninvoice.pl | 18 +++---- members/pay.pl | 116 ++++++++++++++++++++---------------------- members/payprint.pl | 85 +++++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 98 deletions(-) create mode 100644 members/payprint.pl diff --git a/members/boraccount.pl b/members/boraccount.pl index 82ac243885..b5a4334ed7 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -29,14 +29,11 @@ use C4::Output; use C4::Interface::CGI::Output; use C4::Date; use CGI; +use C4::Search; use C4::Members; -use HTML::Template; - my $input=new CGI; my $theme = $input->param('theme'); # only used if allowthemeoverride is set -#my %tmpldata = pathtotemplate ( template => 'boraccount.tmpl', theme => $theme ); -#my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0); my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "members/boraccount.tmpl", query => $input, @@ -77,13 +74,16 @@ for (my $i=0;$i<$numaccts;$i++){ $accts->[$i]{'amountoutstandingcredit'} = 1; } my %row = ( 'date' => format_date($accts->[$i]{'date'}), + 'accountid' => $accts->[$i]{'accountid'}, + 'itemnum' => $accts->[$i]{'itemnumber'}, 'amountcredit' => $accts->[$i]{'amountcredit'}, 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, 'toggle' => $accts->[$i]{'toggle'}, 'description' => $accts->[$i]{'description'}, 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}), + 'accounttype' =>$accts->[$i]{'accounttype'}, 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}) ); - + if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){ $row{'printtitle'}=1; $row{'title'} = $accts->[$i]{'title'}; diff --git a/members/mancredit.pl b/members/mancredit.pl index bb508bae4b..4ef5aa116a 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -#wrriten 11/1/2000 by chris@katipo.oc.nz +#wrriten 18/09/2005 by TG #script to display borrowers account details @@ -26,37 +26,60 @@ use C4::Auth; use C4::Output; use C4::Interface::CGI::Output; use CGI; -use HTML::Template; -use C4::Members; + +use C4::Search; use C4::Accounts2; +use C4::Members; my $input=new CGI; - - + my $accounttype=$input->param('accounttype'); + my $accountid=$input->param('accountid'); +my $amount=$input->param('amount'); +my $itemnum=$input->param('itemnum'); +my $error=0; my $bornum=$input->param('bornum'); #get borrower details my $data=borrdata('',$bornum); +my $user=$data->{firstname}.",".$data->{surname}."-".$data->{cardnumber}; my $add=$input->param('add'); -if ($add){ - my $itemnum=$input->param('itemnum'); - my $desc=$input->param('desc'); - my $amount=$input->param('amount'); - $amount = -$amount; - my $type=$input->param('type'); - manualinvoice($bornum,$itemnum,$desc,$type,$amount); - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum"); -} else { - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "mancredit.tmpl", +# $error=$input->param('error'); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/mancredit.tmpl", query => $input, type => "intranet", authnotrequired => 0, flagsrequired => {borrowers => 1}, debug => 1, }); + $template->param(user => $user); $template->param( bornum => $bornum); - print $input->header( - -type => guesstype($template->output), - -cookie => $cookie - ),$template->output; - + $template->param( itemnum => $itemnum); + $template->param( amount => $amount); + $template->param( accounttype => $accounttype); + $template->param( accountid => $accountid); +if ($add){ +if ($accounttype eq "F" || $accounttype eq "FU"){ +$accounttype="CF"; +}else{ +$accounttype="C".$accounttype; } + + my $desc=$input->param('desc'); + my $amount=$input->param('amount'); + $amount = -$amount; +my $loggeduser=$input->param('loggedinuser'); +my $error=manualcredit($bornum,$accountid,$desc,$accounttype,$amount,$loggeduser); + if ($error>0 ) { + $template->param( error => "1"); + $template->param(user => $user); + $template->param( bornum => $bornum); + $template->param( itemnum => $itemnum); + $template->param( amount => $amount); + $template->param( accounttype => $accounttype); + $template->param( accountid => $accountid); + } else { + print $input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum"); + } +} + + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/maninvoice.pl b/members/maninvoice.pl index bb265c85d9..9dc43ac4a1 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -26,27 +26,28 @@ use C4::Auth; use C4::Output; use C4::Interface::CGI::Output; use CGI; -use C4::Members; +use C4::Search; use C4::Accounts2; -use HTML::Template; +use C4::Members; + my $input=new CGI; my $bornum=$input->param('bornum'); #get borrower details my $data=borrdata('',$bornum); +my $user=$data->{firstname}.",".$data->{surname}."-".$data->{cardnumber}; my $add=$input->param('add'); if ($add){ # print $input->header; - my $itemnum=$input->param('itemnum'); my $desc=$input->param('desc'); my $amount=$input->param('amount'); my $type=$input->param('type'); - manualinvoice($bornum,$itemnum,$desc,$type,$amount); + manualinvoice($bornum,$desc,$type,$amount); print $input->redirect("/cgi-bin/koha/members/boraccount.pl?bornum=$bornum"); } else { my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "maninvoice.tmpl", + = get_template_and_user({template_name => "members/maninvoice.tmpl", query => $input, type => "intranet", authnotrequired => 0, @@ -54,9 +55,6 @@ if ($add){ debug => 1, }); $template->param(bornum => $bornum); - print $input->header( - -type => guesstype($template->output), - -cookie => $cookie - ),$template->output; - + $template->param(user => $user); + output_html_with_http_headers $input, $cookie, $template->output; } diff --git a/members/pay.pl b/members/pay.pl index 2b4c442117..11305be9a4 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -1,9 +1,11 @@ #!/usr/bin/perl +# WARNING: Not enough context to figure out the correct tabstop size +# WARNING: Assume that this file uses 4-character tabs # $Id$ -# written 11/1/2000 by chris@katipo.oc.nz -# part of the koha library system, script to facilitate paying off fines +#written 11/1/2000 by chris@katipo.oc.nz +#part of the koha library system, script to facilitate paying off fines # Copyright 2000-2002 Katipo Communications @@ -26,70 +28,80 @@ use strict; use C4::Context; use C4::Auth; -use C4::Output; +use C4::Interface::CGI::Output; use CGI; -use C4::Members; +use C4::Search; use C4::Accounts2; use C4::Stats; -use C4::Koha; -use HTML::Template; +use C4::Members; my $input=new CGI; +my ($template, $loggedinuser, $cookie) + = get_template_and_user ({ template_name => "members/pay.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); -#print $input->header; my $bornum=$input->param('bornum'); if ($bornum eq ''){ $bornum=$input->param('bornum0'); } -# get borrower details +#get borrower details my $data=borrdata('',$bornum); -my $user=$input->remote_user; - -# get account details +my $user=C4::Context->preference('defaultBranch'); +my $me=borrdata('',$loggedinuser); +my $accountant=$me->{'firstname'}.' '.$me->{'surname'}; +#get account details my %bor; $bor{'borrowernumber'}=$bornum; -my $branches = GetBranches(); -my $printers = getprinters(); -my $branch = getbranch($input, $branches); my @names=$input->param; my %inp; my $check=0; +my $type; +my $totalamount; +my $totaldesc; +my $totalaccounttype; + for (my $i=0;$i<@names;$i++){ - my $temp=$input->param($names[$i]); + my$temp=$input->param($names[$i]); if ($temp eq 'wo'){ - $inp{$names[$i]}=$temp; - $check=1; + $type="W"; + $check=2; } - if ($temp eq 'yes'){ - # For HLT - $user=~ s/Levin/L/i; - $user=~ s/Foxton/F/i; - $user=~ s/Shannon/S/i; - # FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline +if ($temp eq 'yes'){ + $type="Pay"; + $check=2; + } + if ($temp eq 'yes' || $temp eq 'wo'){ + + my $desc=$input->param($names[$i+7]); + my $accounttype=$input->param($names[$i+2]); my $amount=$input->param($names[$i+4]); my $bornum=$input->param($names[$i+5]); my $accountno=$input->param($names[$i+6]); - makepayment($bornum,$accountno,$amount,$user,$branch); + my $amounttopay=$input->param($names[$i+8]); + + makepayment($bornum,$accountno,$amounttopay,$accountant, $type); + $totalamount=$totalamount+$amounttopay; + $totaldesc .="
".$desc."- Fee:".$amounttopay; + $totalaccounttype .="
".$accounttype; $check=2; } } +if ($type eq "Pay" || $type eq "W"){ +print $input->redirect("/cgi-bin/koha/members/payprint.pl?bornum=$bornum&accounttype=$totalaccounttype&amount=$totalamount&desc=$totaldesc"); +} my %env; - $user=~ s/Levin/L/i; - $user=~ s/Foxton/F/i; - $user=~ s/Shannon/S/i; + -$env{'branchcode'}=$branch; +$env{'branchcode'}=C4::Context->preference('defaultBranch'); my $total=$input->param('total'); if ($check ==0){ - my($template, $loggedinuser, $cookie) - = get_template_and_user ({ template_name => "members/pay.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1}, - debug => 1, - }); + if ($total ne ''){ recordpayment(\%env,$bornum,$total); } @@ -117,12 +129,11 @@ if ($check ==0){ surname => $data->{'surname'}, bornum => $bornum, loop_pay => \@loop_pay, - total => sprintf("%.2f",$total)); - print "Content-Type: text/html\n\n", $template->output; + total => sprintf("%.2f",$total), + totalamountopay => sprintf("%.2f",$total)); +output_html_with_http_headers $input, $cookie, $template->output; } else { -# my $quety=$input->query_string; -# print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety"); my%inp; my @name=$input->param; for (my $i=0;$i<@name;$i++){ @@ -140,33 +151,14 @@ if ($check ==0){ $bornum=$input->param("bornum$value"); my $itemno=$input->param("itemnumber$value"); my $amount=$input->param("amount$value"); - my $accountno=$input->param("accountno$value"); - writeoff($bornum,$accountno,$itemno,$accounttype,$amount); + } $bornum=$input->param('bornum'); - print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$bornum"); + print $input->redirect("/cgi-bin/koha/members/pay.pl?bornum=$bornum"); } -sub writeoff{ - my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_; - my $user=$input->remote_user; - my $dbh = C4::Context->dbh; - my $env; - my $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype='Res' and accountno=? and borrowernumber=?"); - $sth->execute($accountnum,$bornum); - $sth->finish; - $sth=$dbh->prepare("select max(accountno) from accountlines"); - $sth->execute; - my $account=$sth->fetchrow_hashref; - $sth->finish; - $account->{'max(accountno)'}++; - $sth=$dbh->prepare("insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype) - values (?,?,?,now(),?,'Writeoff','W')"); - $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount); - $sth->finish; - UpdateStats($env,$branch,'writeoff',$amount,'','','',$bornum); -} + # Local Variables: # tab-width: 4 diff --git a/members/payprint.pl b/members/payprint.pl new file mode 100644 index 0000000000..880da802a8 --- /dev/null +++ b/members/payprint.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl +# WARNING: Not enough context to figure out the correct tabstop size +# WARNING: Assume that this file uses 4-character tabs + +# $Id$ + +#written 11/1/2000 by chris@katipo.oc.nz +#part of the koha library system, script to facilitate paying off fines + + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Context; +use C4::Auth; +use C4::Interface::CGI::Output; +use CGI; +use C4::Search; +use C4::Date; +use C4::Members; +my $input=new CGI; + +#print $input->header; +my $bornum=$input->param('bornum'); + +#get borrower details +my $data=borrdata('',$bornum); +#my $user=C4::Context->preference('defaultbranch'); +my $amount=$input->param('amount'); +my $accounttype=$input->param('accounttype'); +my $desc=$input->param('desc'); + +if ($accounttype eq "FU"){ +$accounttype="Overdue item"; +}elsif ($accounttype eq "L"){ +$accounttype="Very Overdue or Lost item"; +}else{ +$accounttype="Miscelenaous Fees"; +} + my($template, $loggedinuser, $cookie) + = get_template_and_user ({ template_name => "members/payprint.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + my $user=borrdata('',$loggedinuser); +my @datearr = localtime(time()); +my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); + $template->param(firstname => $data->{'firstname'}, date=>format_date($todaysdate), + surname => $data->{'surname'}, + cardnumber => $data->{'cardnumber'}, + street => $data->{'street'}, + city => $data->{'city'}, + phone => $data->{'phone'}, + email => $data->{'email'}, + amount=> $amount, + desc=> $desc, + accounttype=> $accounttype, + bornum=>$bornum, + loggeduser=>$user->{'firstname'}.' '.$user->{'surname'}, + ); + output_html_with_http_headers $input, $cookie, $template->output; + + + +# Local Variables: +# tab-width: 4 +# End: -- 2.39.2