Cleaned things up a bit.
[koha.git] / C4 / Interface / FlagsCDK.pm
1 package C4::Interface::FlagsCDK; #asummes C4/Interface/FlagsCDK
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use C4::Format;
22 use C4::InterfaceCDK;
23 use strict;
24
25 require Exporter;
26 use DBI;
27 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
28   
29 # set the version for version checking
30 $VERSION = 0.01;
31     
32 @ISA = qw(Exporter);
33 @EXPORT = qw(&trapscreen &trapsnotes &reservesdisplay);
34 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
35                   
36 # your exported package globals go here,
37 # as well as any optionally exported functions
38
39 @EXPORT_OK   = qw($Var1 %Hashit);
40 # non-exported package globals go here
41 use vars qw(@more $stuff);
42         
43 # initalize package globals, first exported ones
44
45 my $Var1   = '';
46 my %Hashit = ();
47                     
48 # then the others (which are still accessible as $Some::Module::stuff)
49 my $stuff  = '';
50 my @more   = ();
51         
52 # all file-scoped lexicals must be created before
53 # the functions below that use them.
54                 
55 # file-private lexicals go here
56 my $priv_var    = '';
57 my %secret_hash = ();
58                             
59 # here's a file-private function as a closure,
60 # callable as &$priv_func;  it cannot be prototyped.
61 my $priv_func = sub {
62   # stuff goes here.
63 };
64                                                     
65 # make all your functions, whether exported or not;
66
67
68   
69 sub trapscreen {
70   my ($env,$bornum,$borrower,$amount,$traps_set)=@_;
71   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Flags");
72   my @borinfo;
73   #debug_msg($env,"owwing = $amount");
74   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
75   $borpanel->draw();
76   my $hght = @$traps_set+4;
77   my $flagsset = new Cdk::Scroll ('Title'=>"Act On Flag",
78       'List'=>\@$traps_set,'Height'=>$hght,'Width'=>15,
79       'Xpos'=>4,'Ypos'=>3);
80   my $act =$flagsset->activate();                                                               
81   my $action;
82   if (!defined $act) {
83     $action = "NONE";
84   } else {
85     $action = @$traps_set[$act];
86   }   
87   undef $titlepanel;
88   undef $flagsset;
89   undef $borpanel;
90   return($action);
91 }
92
93 sub trapsnotes {
94   my ($env,$bornum,$borrower,$amount) = @_;
95   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Notes");
96   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
97   $borpanel->draw();
98   my $notesbox = new Cdk::Mentry ('Label'=>"Notes:  ",
99     'Width'=>40,'Prows'=>10,'Lrows'=>30,
100     'Lpos'=>"Top",'Xpos'=>"RIGHT",'Ypos'=>10);
101   my $ln = length($borrower->{'borrowernotes'});
102   my $x = 0;
103   while ($x < $ln) {
104     my $y = substr($borrower->{'borrowernotes'},$x,1);
105     $notesbox->inject('Input'=>$y);
106     $x++;
107   }
108   my $notes =  $notesbox->activate();
109   if (!defined $notes) { 
110     $notes = $borrower->{'borrowernotes'}; 
111   } else {
112     while (substr($notes,0,1) eq " ") {
113       my $temp;
114       if (length($notes) == 1) {
115         $temp = "";
116       } else {
117         $temp = substr($notes,1,length($notes)-1);
118       }
119       $notes = $temp;
120     }
121   }
122   undef $notesbox;
123   undef $borpanel;
124   undef $titlepanel;
125   return $notes;
126 }
127
128 sub reservesdisplay {
129   my ($env,$borrower,$amount,$odues,$items) = @_;
130   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Reserves Waiting");
131   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
132   $borpanel->draw();
133   my $x = 0;
134   my @itemslist;
135   while (@$items[$x] ne "") {
136     my $itemdata = @$items[$x];
137     my $itemrow = fmtstr($env,$itemdata->{'holdingbranch'},"L6");
138     $itemrow = $itemrow.$itemdata->{'title'}.": ".$itemdata->{'author'};
139     $itemrow = fmtstr($env,$itemrow,"L68").$itemdata->{'itemtype'};
140     @itemslist[$x] = $itemrow;
141     $x++;
142   }
143   my $reslist = new Cdk::Scroll('Title'=>"",'List'=>\@itemslist,
144     'Height'=>10,'Width'=>76,'Xpos'=>1,'Ypos'=>10);
145   $reslist->activate();
146   undef $reslist;
147   undef $borpanel;
148   undef $titlepanel;
149 }
150
151 END { }       # module clean-up code here (global destructor)