1 package C4::Interface::ReserveentCDK; #asummes C4/Interface/ReserveCDK
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
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
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.
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
29 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31 # set the version for version checking
35 @EXPORT = qw(&FindBiblioScreen &SelectBiblio &MakeReserveScreen);
36 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
38 # your exported package globals go here,
39 # as well as any optionally exported functions
41 @EXPORT_OK = qw($Var1 %Hashit);
42 # non-exported package globals go here
43 use vars qw(@more $stuff);
45 # initalize package globals, first exported ones
50 # then the others (which are still accessible as $Some::Module::stuff)
54 # all file-scoped lexicals must be created before
55 # the functions below that use them.
57 # file-private lexicals go here
61 # here's a file-private function as a closure,
62 # callable as &$priv_func; it cannot be prototyped.
67 # make all your functions, whether exported or not;
69 sub FindBiblioScreen {
70 my ($env,$title,$numflds,$flds,$fldlns)=@_;
71 my $titlepanel = titlepanel($env,"Reserves","Find a title");
72 #my @coltitles=("a","b");
76 while ($ow < $nflds) {
77 @rowtitles[$ow]=@$flds[$ow];
81 my @coltypes = ("UMIXED");
83 my $entrymatrix = new Cdk::Matrix (
84 'ColTitles'=> \@coltitles,
85 'RowTitles'=> \@rowtitles,
86 'ColWidths'=> \@colwidths,
87 'ColTypes'=> \@coltypes,
91 #$entrymatrix->set('BoxCell'=>"FALSE");
92 #$entrymatrix->draw();
93 $entrymatrix->inject('Input'=>"KEY_DOWN");
95 my ($rows,$cols,$info) = $entrymatrix->activate();
101 while ($i < $numflds) {
102 $responses[$i] =$info->[$i][0];
106 return($reason,@responses);
110 my ($env,$count,$entries) = @_;
111 my $titlepanel = titlepanel($env,"Reserves","Select title");
112 my $biblist = new Cdk::Alphalist('Title'=>"Select a Title",
113 'List'=>\@$entries,'Height' => 22,'Width' => 76,
115 my $selection = $biblist->activate();
118 if (!defined $selection) {
123 return($reason,$result);
126 sub MakeReserveScreen {
127 my ($env,$bibliorec,$bitems,$branches) = @_;
128 my $titlepanel = titlepanel($env,"Reserves","Create Reservation");
129 my $line = fmtstr($env,$bibliorec->{'title'},"L72");
130 my $authlen = length($bibliorec->{'author'});
131 my $testlen = length($bibliorec->{'title'}) + $authlen;
133 $line = substr($line,0,71-$authlen)." ".$bibliorec->{'author'};
134 $line = fmtstr($env,$line,"L72");
136 my $split = int(($testlen-72)*0.7);
137 $line = substr($line,0,72+$split-$authlen)." ".$bibliorec->{'author'};
138 $line = fmtstr($env,$line,"L72");
141 my $bookpanel = new Cdk::Label ('Message' =>\@book,
144 my $branchlist = new Cdk::Radio('Title'=>"Collection Branch",
146 'Xpos'=>"20",'Ypos'=>"5",'Width'=>"18",'Height'=>"6");
149 my $brcnt = @$branches;
151 while (($brdef == 0) && ($i < $brcnt)) {
152 my $brcode = substr(@$branches[$i],0,2);
153 my $brtest = fmtstr($env,$env->{'branchcode'},"L2");
154 if ($brcode eq $brtest) {
157 $branchlist->inject('Input'=>"KEY_DOWN");
161 $branchlist->inject('Input'=>" ");
162 my @constraintlist = ("Any item","Only Selected","Except Selected");
163 my $constrainttype = new Cdk::Radio('Title'=>"Reserve Constraints",
164 'List'=>\@constraintlist,
165 'Xpos'=>"54",'Ypos'=>"5",'Width'=>"17",'Height'=>"6");
166 $constrainttype->draw();
167 my $numbit = @$bitems;
170 while ($i < $numbit) {
171 my $bitline = @$bitems[$i];
172 my @blarr = split("\t",$bitline);
173 my $line = @blarr[1]." ".@blarr[2];
175 my $line = $line.@blarr[3];
177 my $line = $line.@blarr[4]." ".@blarr[5];
178 $line = fmtstr($env,$line,"L40");
179 #$bitx{$line} = @blarr[0];
183 my @sel = ("Y ","N ");
184 my $itemlist = new Cdk::Selection('Title'=>"Items Held",
185 'List'=>\@itemarr,'Choices'=>\@sel,
186 'Xpos'=>"1",'Ypos'=>"12",'Width'=>"70",'Height'=>"8");
188 my $borrowerentry = new Cdk::Entry('Label'=>"",'Title'=>"Borrower",
189 'Max'=>"11",'Width'=>"11",
190 'Xpos'=>"2",'Ypos'=>"5",
192 borrbind($env,$borrowerentry);
193 # $borrowentry->bind('Key'=>"KEY_TAB",'Function'=>sub {$x = act($scroll1);});
197 while ($complete == 0) {
198 my $borrowercode = $borrowerentry->activate();
199 if (!defined $borrowercode) {
204 @answers[0] = $borrowercode;
205 if ($borrowercode ne "") { $complete = 1; };
206 while ($complete == 1) {
207 my $x = $branchlist->activate();
212 my @brline = split(" ",@$branches[$x]);
213 @answers[1] = @brline[0];
217 while ($complete == 2) {
219 my @constarr = ("a", "o", "e");
220 my $constans = $constrainttype->activate();
221 if (!defined $constans) {
222 $complete = 1; # go back a step
224 @answers[2] = $constarr[$constans];
226 if ($answers[2] ne "a") {
227 while ($complete == 3) {
228 my @itemans = $itemlist->activate();
229 if (!defined @itemans) {
230 $complete = 2; # go back a step
233 my $no_ans = @itemans;
239 if ($itemans[$i] == 0) {
240 my $bitline = @$bitems[$i];
241 my @blarr = split("\t",$bitline);
242 @items[$j] = @blarr[0];
247 @answers[3] = \@items;
260 return ($reason,@answers);
262 END { } # module clean-up code here (global destructor)