1 package C4::Interface::ReserveentCDK; #asummes C4/Interface/ReserveCDK
11 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
13 # set the version for version checking
17 @EXPORT = qw(&FindBiblioScreen &SelectBiblio &MakeReserveScreen);
18 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
20 # your exported package globals go here,
21 # as well as any optionally exported functions
23 @EXPORT_OK = qw($Var1 %Hashit);
24 # non-exported package globals go here
25 use vars qw(@more $stuff);
27 # initalize package globals, first exported ones
32 # then the others (which are still accessible as $Some::Module::stuff)
36 # all file-scoped lexicals must be created before
37 # the functions below that use them.
39 # file-private lexicals go here
43 # here's a file-private function as a closure,
44 # callable as &$priv_func; it cannot be prototyped.
49 # make all your functions, whether exported or not;
51 sub FindBiblioScreen {
52 my ($env,$title,$numflds,$flds,$fldlns)=@_;
53 my $titlepanel = titlepanel($env,"Reserves","Find a title");
54 #my @coltitles=("a","b");
58 while ($ow < $nflds) {
59 @rowtitles[$ow]=@$flds[$ow];
63 my @coltypes = ("UMIXED");
65 my $entrymatrix = new Cdk::Matrix (
66 'ColTitles'=> \@coltitles,
67 'RowTitles'=> \@rowtitles,
68 'ColWidths'=> \@colwidths,
69 'ColTypes'=> \@coltypes,
73 #$entrymatrix->set('BoxCell'=>"FALSE");
74 #$entrymatrix->draw();
75 $entrymatrix->inject('Input'=>"KEY_DOWN");
77 my ($rows,$cols,$info) = $entrymatrix->activate();
83 while ($i < $numflds) {
84 $responses[$i] =$info->[$i][0];
88 return($reason,@responses);
92 my ($env,$count,$entries) = @_;
93 my $titlepanel = titlepanel($env,"Reserves","Select title");
94 my $biblist = new Cdk::Alphalist('Title'=>"Select a Title",
95 'List'=>\@$entries,'Height' => 22,'Width' => 76,
97 my $selection = $biblist->activate();
100 if (!defined $selection) {
105 return($reason,$result);
108 sub MakeReserveScreen {
109 my ($env,$bibliorec,$bitems,$branches) = @_;
110 my $titlepanel = titlepanel($env,"Reserves","Create Reservation");
111 my $line = fmtstr($env,$bibliorec->{'title'},"L72");
112 my $authlen = length($bibliorec->{'author'});
113 my $testlen = length($bibliorec->{'title'}) + $authlen;
115 $line = substr($line,0,71-$authlen)." ".$bibliorec->{'author'};
116 $line = fmtstr($env,$line,"L72");
118 my $split = int(($testlen-72)*0.7);
119 $line = substr($line,0,72+$split-$authlen)." ".$bibliorec->{'author'};
120 $line = fmtstr($env,$line,"L72");
123 my $bookpanel = new Cdk::Label ('Message' =>\@book,
126 my $branchlist = new Cdk::Radio('Title'=>"Collection Branch",
128 'Xpos'=>"20",'Ypos'=>"5",'Width'=>"18",'Height'=>"6");
131 my $brcnt = @$branches;
133 while (($brdef == 0) && ($i < $brcnt)) {
134 my $brcode = substr(@$branches[$i],0,2);
135 my $brtest = fmtstr($env,$env->{'branchcode'},"L2");
136 if ($brcode eq $brtest) {
139 $branchlist->inject('Input'=>"KEY_DOWN");
143 $branchlist->inject('Input'=>" ");
144 my @constraintlist = ("Any item","Only Selected","Except Selected");
145 my $constrainttype = new Cdk::Radio('Title'=>"Reserve Constraints",
146 'List'=>\@constraintlist,
147 'Xpos'=>"54",'Ypos'=>"5",'Width'=>"17",'Height'=>"6");
148 $constrainttype->draw();
149 my $numbit = @$bitems;
152 while ($i < $numbit) {
153 my $bitline = @$bitems[$i];
154 my @blarr = split("\t",$bitline);
155 my $line = @blarr[1]." ".@blarr[2];
157 my $line = $line.@blarr[3];
159 my $line = $line.@blarr[4]." ".@blarr[5];
160 $line = fmtstr($env,$line,"L40");
161 #$bitx{$line} = @blarr[0];
165 my @sel = ("Y ","N ");
166 my $itemlist = new Cdk::Selection('Title'=>"Items Held",
167 'List'=>\@itemarr,'Choices'=>\@sel,
168 'Xpos'=>"1",'Ypos'=>"12",'Width'=>"70",'Height'=>"8");
170 my $borrowerentry = new Cdk::Entry('Label'=>"",'Title'=>"Borrower",
171 'Max'=>"11",'Width'=>"11",
172 'Xpos'=>"2",'Ypos'=>"5",
174 borrbind($env,$borrowerentry);
175 # $borrowentry->bind('Key'=>"KEY_TAB",'Function'=>sub {$x = act($scroll1);});
179 while ($complete == 0) {
180 my $borrowercode = $borrowerentry->activate();
181 if (!defined $borrowercode) {
186 @answers[0] = $borrowercode;
187 if ($borrowercode ne "") { $complete = 1; };
188 while ($complete == 1) {
189 my $x = $branchlist->activate();
194 my @brline = split(" ",@$branches[$x]);
195 @answers[1] = @brline[0];
199 while ($complete == 2) {
201 my @constarr = ("a", "o", "e");
202 my $constans = $constrainttype->activate();
203 if (!defined $constans) {
204 $complete = 1; # go back a step
206 @answers[2] = $constarr[$constans];
208 if ($answers[2] ne "a") {
209 while ($complete == 3) {
210 my @itemans = $itemlist->activate();
211 if (!defined @itemans) {
212 $complete = 2; # go back a step
215 my $no_ans = @itemans;
221 if ($itemans[$i] == 0) {
222 my $bitline = @$bitems[$i];
223 my @blarr = split("\t",$bitline);
224 @items[$j] = @blarr[0];
229 @answers[3] = \@items;
242 return ($reason,@answers);
244 END { } # module clean-up code here (global destructor)