Deleted unused variables.
[koha.git] / C4 / Interface / AccountsCDK.pm
1 package C4::Interface::AccountsCDK; #asummes C4/Interface/AccountsCDK
2
3 #uses Newt
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 # FIXME - I'm pretty sure that this, along with the rest of the
23 # CDK-based stuff, is obsolete.
24
25 use C4::InterfaceCDK;
26 use C4::Accounts2;
27 use strict;
28
29 require Exporter;
30 use DBI;
31 use vars qw($VERSION @ISA @EXPORT);
32
33 # set the version for version checking
34 $VERSION = 0.01;
35 @ISA = qw(Exporter);
36 @EXPORT = qw(&accountsdialog);
37
38 sub accountsdialog {
39   my ($env,$title,$borrower,$accountlines,$amountowing)=@_;
40   my $titlepanel = titlepanel($env,$env->{'sysarea'},"Money Owing");
41   my @borinfo;
42   my $reason;
43   #$borinfo[0]  = "$borrower->{'cardnumber'}";
44   #$borinfo[1] = "$borrower->{'surname'}, $borrower->{'title'} $borrower->{'firstname'} ";
45   #$borinfo[2] = "$borrower->{'streetaddress'}, $borrower->{'city'}";
46   #$borinfo[3] = "<R>Total Due:  </B>".fmtdec($env,$amountowing,"52");
47   #my $borpanel =
48   #  new Cdk::Label ('Message' =>\@borinfo, 'Ypos'=>4, 'Xpos'=>"RIGHT");
49   my $borpanel = borrowerbox($env,$borrower,$amountowing);
50   $borpanel->draw();
51   my @sel = ("N ","Y ");
52   my $acctlist = new Cdk::Selection ('Title'=>"Outstanding Items",
53       'List'=>\@$accountlines,'Choices'=>\@sel,'Height'=>12,'Width'=>80,
54       'Xpos'=>1,'Ypos'=>10);
55   my @amounts=$acctlist->activate();
56   my $accountno;
57   my $amount2;
58   my $count=@amounts;
59   my $amount;
60   my $check=0;
61   for (my $i=0;$i<$count;$i++){
62     if ($amounts[$i] == 1){
63       $check=1;
64       if ($accountlines->[$i]=~ /(^[0-9]+)/){
65         $accountno=$1;
66       }
67       if ($accountlines->[$i]=~/([0-9]+\.[0-9]+)/){
68         $amount2=$1;
69       }
70       my $borrowerno=$borrower->{'borrowernumber'};
71       makepayment($borrowerno,$accountno,$amount2);
72       $amount+=$amount2;
73     }
74   }
75   my $amountentry = new Cdk::Entry('Label'=>"Amount:  ",
76      'Max'=>"10",'Width'=>"10",
77      'Xpos'=>"1",'Ypos'=>"3",
78      'Type'=>"INT");
79   $amountentry->preProcess ('Function' => sub{preamt(@_,$env,$acctlist);});
80   #
81
82   if ($amount eq ''){
83     $amount =$amountentry->activate();
84   } else {
85     $amountentry->set('Value'=>$amount);
86     $amount=$amountentry->activate();
87   }
88 #  debug_msg($env,"accounts $amount barcode=$accountno");
89   if (!defined $amount) {
90      #debug_msg($env,"escaped");
91      #$reason="Finished user";
92   }
93   $borpanel->erase();
94   $acctlist->erase();
95   $amountentry->erase();
96   undef $acctlist;
97   undef $borpanel;
98   undef $borpanel;
99   undef $titlepanel;
100   if ($check == 1){
101     $amount=0;
102   }
103   return($amount,$reason);
104 }
105
106 sub preamt {
107   my ($input,$env,$acctlist)= @_;
108   my $key_tab  = chr(9);
109   if ($input eq $key_tab) {
110     actlist ($env,$acctlist);
111     return 0;
112   }
113   return 1;
114 }
115
116 sub actlist {
117   my ($env,$acctlist) = @_;
118   $acctlist->activate();
119 }
120
121
122 END { }       # module clean-up code here (global destructor)