Fixed a few warnings.
[koha.git] / C4 / Interface / FlagsCDK.pm
1 package C4::Interface::FlagsCDK; #asummes C4/Interface/FlagsCDK
2
3 use C4::Format;
4 use C4::InterfaceCDK;
5 use strict;
6
7 require Exporter;
8 use DBI;
9 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
10   
11 # set the version for version checking
12 $VERSION = 0.01;
13     
14 @ISA = qw(Exporter);
15 @EXPORT = qw(&trapscreen &trapsnotes &reservesdisplay);
16 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
17                   
18 # your exported package globals go here,
19 # as well as any optionally exported functions
20
21 @EXPORT_OK   = qw($Var1 %Hashit);
22 # non-exported package globals go here
23 use vars qw(@more $stuff);
24         
25 # initalize package globals, first exported ones
26
27 my $Var1   = '';
28 my %Hashit = ();
29                     
30 # then the others (which are still accessible as $Some::Module::stuff)
31 my $stuff  = '';
32 my @more   = ();
33         
34 # all file-scoped lexicals must be created before
35 # the functions below that use them.
36                 
37 # file-private lexicals go here
38 my $priv_var    = '';
39 my %secret_hash = ();
40                             
41 # here's a file-private function as a closure,
42 # callable as &$priv_func;  it cannot be prototyped.
43 my $priv_func = sub {
44   # stuff goes here.
45 };
46                                                     
47 # make all your functions, whether exported or not;
48
49
50   
51 sub trapscreen {
52   my ($env,$bornum,$borrower,$amount,$traps_set)=@_;
53   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Flags");
54   my @borinfo;
55   #debug_msg($env,"owwing = $amount");
56   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
57   $borpanel->draw();
58   my $hght = @$traps_set+4;
59   my $flagsset = new Cdk::Scroll ('Title'=>"Act On Flag",
60       'List'=>\@$traps_set,'Height'=>$hght,'Width'=>15,
61       'Xpos'=>4,'Ypos'=>3);
62   my $act =$flagsset->activate();                                                               
63   my $action;
64   if (!defined $act) {
65     $action = "NONE";
66   } else {
67     $action = @$traps_set[$act];
68   }   
69   undef $titlepanel;
70   undef $flagsset;
71   undef $borpanel;
72   return($action);
73 }
74
75 sub trapsnotes {
76   my ($env,$bornum,$borrower,$amount) = @_;
77   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Notes");
78   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
79   $borpanel->draw();
80   my $notesbox = new Cdk::Mentry ('Label'=>"Notes:  ",
81     'Width'=>40,'Prows'=>10,'Lrows'=>30,
82     'Lpos'=>"Top",'Xpos'=>"RIGHT",'Ypos'=>10);
83   my $ln = length($borrower->{'borrowernotes'});
84   my $x = 0;
85   while ($x < $ln) {
86     my $y = substr($borrower->{'borrowernotes'},$x,1);
87     $notesbox->inject('Input'=>$y);
88     $x++;
89   }
90   my $notes =  $notesbox->activate();
91   if (!defined $notes) { 
92     $notes = $borrower->{'borrowernotes'}; 
93   } else {
94     while (substr($notes,0,1) eq " ") {
95       my $temp;
96       if (length($notes) == 1) {
97         $temp = "";
98       } else {
99         $temp = substr($notes,1,length($notes)-1);
100       }
101       $notes = $temp;
102     }
103   }
104   undef $notesbox;
105   undef $borpanel;
106   undef $titlepanel;
107   return $notes;
108 }
109
110 sub reservesdisplay {
111   my ($env,$borrower,$amount,$odues,$items) = @_;
112   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Reserves Waiting");
113   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
114   $borpanel->draw();
115   my $x = 0;
116   my @itemslist;
117   while (@$items[$x] ne "") {
118     my $itemdata = @$items[$x];
119     my $itemrow = fmtstr($env,$itemdata->{'holdingbranch'},"L6");
120     $itemrow = $itemrow.$itemdata->{'title'}.": ".$itemdata->{'author'};
121     $itemrow = fmtstr($env,$itemrow,"L68").$itemdata->{'itemtype'};
122     @itemslist[$x] = $itemrow;
123     $x++;
124   }
125   my $reslist = new Cdk::Scroll('Title'=>"",'List'=>\@itemslist,
126     'Height'=>10,'Width'=>76,'Xpos'=>1,'Ypos'=>10);
127   $reslist->activate();
128   undef $reslist;
129   undef $borpanel;
130   undef $titlepanel;
131 }
132
133 END { }       # module clean-up code here (global destructor)