[Koha-cvs] koha/members boraccount.pl mancredit.pl maninvo...

Tumer Garip tgarip at neu.edu.tr
Fri Sep 22 02:21:25 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Tumer Garip <tgarip1957>	06/09/22 00:21:25

Modified files:
	members        : boraccount.pl mancredit.pl maninvoice.pl pay.pl 
Added files:
	members        : payprint.pl 

Log message:
	Patrons may pay their fines in instalments

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/members/boraccount.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/members/mancredit.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/members/maninvoice.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/members/pay.pl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/members/payprint.pl?cvsroot=koha&rev=1.1

Patches:
Index: boraccount.pl
===================================================================
RCS file: /sources/koha/koha/members/boraccount.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- boraccount.pl	18 Jan 2006 17:23:32 -0000	1.2
+++ boraccount.pl	22 Sep 2006 00:21:25 -0000	1.3
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: boraccount.pl,v 1.2 2006/01/18 17:23:32 tipaul Exp $
+# $Id: boraccount.pl,v 1.3 2006/09/22 00:21:25 tgarip1957 Exp $
 
 #writen 11/1/2000 by chris at katipo.oc.nz
 #script to display borrowers account details
@@ -29,14 +29,11 @@
 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,11 +74,14 @@
   	$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'){

Index: mancredit.pl
===================================================================
RCS file: /sources/koha/koha/members/mancredit.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- mancredit.pl	24 Aug 2006 13:06:49 -0000	1.2
+++ mancredit.pl	22 Sep 2006 00:21:25 -0000	1.3
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-#wrriten 11/1/2000 by chris at katipo.oc.nz
+#wrriten 18/09/2005 by TG
 #script to display borrowers account details
 
 
@@ -26,37 +26,60 @@
 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;

Index: maninvoice.pl
===================================================================
RCS file: /sources/koha/koha/members/maninvoice.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- maninvoice.pl	24 Aug 2006 13:06:49 -0000	1.2
+++ maninvoice.pl	22 Sep 2006 00:21:25 -0000	1.3
@@ -26,27 +26,28 @@
 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 @@
 					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;
 }

Index: pay.pl
===================================================================
RCS file: /sources/koha/koha/members/pay.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- pay.pl	21 Jul 2006 09:57:30 -0000	1.4
+++ pay.pl	22 Sep 2006 00:21:25 -0000	1.5
@@ -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: pay.pl,v 1.4 2006/07/21 09:57:30 toins Exp $
+# $Id: pay.pl,v 1.5 2006/09/22 00:21:25 tgarip1957 Exp $
 
-# written 11/1/2000 by chris at katipo.oc.nz
-# part of the koha library system, script to facilitate paying off fines
+#written 11/1/2000 by chris at 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 .="<br> ".$desc."-  Fee:".$amounttopay;
+		$totalaccounttype .="<br> ".$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 @@
 							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 @@
 		$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

Index: payprint.pl
===================================================================
RCS file: payprint.pl
diff -N payprint.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ payprint.pl	22 Sep 2006 00:21:25 -0000	1.1
@@ -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: payprint.pl,v 1.1 2006/09/22 00:21:25 tgarip1957 Exp $
+
+#written 11/1/2000 by chris at 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:





More information about the Koha-cvs mailing list