DBI call fix for bug 662
[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 # FIXME - I'm pretty sure that this, along with the rest of the
22 # CDK-based stuff, is obsolete.
23
24 use C4::Format;
25 use C4::InterfaceCDK;
26 use strict;
27
28 require Exporter;
29 use DBI;
30 use vars qw($VERSION @ISA @EXPORT);
31
32 # set the version for version checking
33 $VERSION = 0.01;
34
35 @ISA = qw(Exporter);
36 @EXPORT = qw(&trapscreen &trapsnotes &reservesdisplay);
37
38 sub trapscreen {
39   my ($env,$bornum,$borrower,$amount,$traps_set)=@_;
40   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Flags");
41   my @borinfo;
42   #debug_msg($env,"owwing = $amount");
43   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
44   $borpanel->draw();
45   my $hght = @$traps_set+4;
46   my $flagsset = new Cdk::Scroll ('Title'=>"Act On Flag",
47       'List'=>\@$traps_set,'Height'=>$hght,'Width'=>15,
48       'Xpos'=>4,'Ypos'=>3);
49   my $act =$flagsset->activate();
50   my $action;
51   if (!defined $act) {
52     $action = "NONE";
53   } else {
54     $action = @$traps_set[$act];
55   }
56   undef $titlepanel;
57   undef $flagsset;
58   undef $borpanel;
59   return($action);
60 }
61
62 sub trapsnotes {
63   my ($env,$bornum,$borrower,$amount) = @_;
64   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Borrower Notes");
65   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
66   $borpanel->draw();
67   my $notesbox = new Cdk::Mentry ('Label'=>"Notes:  ",
68     'Width'=>40,'Prows'=>10,'Lrows'=>30,
69     'Lpos'=>"Top",'Xpos'=>"RIGHT",'Ypos'=>10);
70   my $ln = length($borrower->{'borrowernotes'});
71   my $x = 0;
72   while ($x < $ln) {
73     my $y = substr($borrower->{'borrowernotes'},$x,1);
74     $notesbox->inject('Input'=>$y);
75     $x++;
76   }
77   my $notes =  $notesbox->activate();
78   if (!defined $notes) {
79     $notes = $borrower->{'borrowernotes'};
80   } else {
81     while (substr($notes,0,1) eq " ") {
82       my $temp;
83       if (length($notes) == 1) {
84         $temp = "";
85       } else {
86         $temp = substr($notes,1,length($notes)-1);
87       }
88       $notes = $temp;
89     }
90   }
91   undef $notesbox;
92   undef $borpanel;
93   undef $titlepanel;
94   return $notes;
95 }
96
97 sub reservesdisplay {
98   my ($env,$borrower,$amount,$odues,$items) = @_;
99   my $titlepanel = C4::InterfaceCDK::titlepanel($env,$env->{'sysarea'},"Reserves Waiting");
100   my $borpanel = C4::InterfaceCDK::borrowerbox($env,$borrower,$amount);
101   $borpanel->draw();
102   my $x = 0;
103   my @itemslist;
104   while (@$items[$x] ne "") {
105     my $itemdata = @$items[$x];
106     my $itemrow = fmtstr($env,$itemdata->{'holdingbranch'},"L6");
107     $itemrow = $itemrow.$itemdata->{'title'}.": ".$itemdata->{'author'};
108     $itemrow = fmtstr($env,$itemrow,"L68").$itemdata->{'itemtype'};
109     @itemslist[$x] = $itemrow;
110     $x++;
111   }
112   my $reslist = new Cdk::Scroll('Title'=>"",'List'=>\@itemslist,
113     'Height'=>10,'Width'=>76,'Xpos'=>1,'Ypos'=>10);
114   $reslist->activate();
115   undef $reslist;
116   undef $borpanel;
117   undef $titlepanel;
118 }
119
120 END { }       # module clean-up code here (global destructor)