1 package C4::InterfaceCDK; #assumes C4/InterfaceCDK
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
22 # FIXME - This module doesn't compile! But I'm pretty sure it, like
23 # the rest of the CDK-based stuff, is obsolete.
30 use C4::Circulation::Borrissues;
31 use C4::Circulation::Renewals;
36 use vars qw($VERSION @ISA @EXPORT);
38 # set the version for version checking
42 @EXPORT = qw(&dialog &startint &endint &output &clearscreen &pause &helptext
43 &textbox &menu &issuewindow &msg_yn &msg_ny &borrower_dialog &debug_msg &error_msg
44 &info_msg &selborrower &returnwindow &logondialog &borrowerwindow &titlepanel
45 &borrbind &borrfill &preeborr &borrowerbox &brmenu &prmenu);
48 # is this planned for something?
57 my ($env,$type,$title,@items)=@_;
58 $env->{'sysarea'}="Menu";
59 my $titlebar=titlepanel($env,"Koha","Main Menu");
64 while ($items[$x] ne "") {
65 $mitems[$x]="<C>".$items[$x];
68 if ($type eq 'console'){
70 my $menu = new Cdk::Scroll ('Title'=>" ",
72 'Height'=> $menucnt+4,
74 # Activate the object.
75 my ($menuItem) = $menu->activate();
78 if (!defined $menuItem) {
82 $data = $items[$menuItem];
85 return($reason,$data);
89 # FIXME - Is this a placeholder?
93 # FIXME - Is this a placeholder?
99 my($left,$top,$msg)=@_;
102 my $output = new Cdk::Label ('Message' =>\@outm,
103 'Ypos'=>$top, 'Xpos'=>$left, 'Box'=>0);
110 my $helptext = output(1,24,$text);
116 my ($env,$title,$title2)=@_;
118 @header[0] = fmtstr($env,$title,"L24");
119 @header[0] = @header[0].fmtstr($env,
120 $env->{'branchname'}."-".$env->{'queue'},"C28");
121 @header[0] = @header[0].fmtstr($env,$title2,"R24");
122 my $label = new Cdk::Label ('Message' =>\@header,'Ypos'=>0,'Xpos'=>0);
128 my ($env,$text1,$text2)=@_;
129 # Create the dialog buttons.
130 my @buttons = ("Yes", "No");
131 my @mesg = ("<C>$text1", "<C>$text2");
132 # Create the dialog object.
133 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
134 my $resp = $dialog->activate();
143 my ($env,$text1,$text2)=@_;
145 # Create the dialog buttons.
146 my @buttons = ("No", "Yes");
147 my @mesg = ("<C>$text1", "<C>$text2");
148 # Create the dialog object.
149 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
150 my $resp = $dialog->activate();
161 if ($env->{'telnet'} eq "Y") {
162 popupLabel (["Debug </R>$text"]);
164 # print "****DEBUG $text****";
171 popupLabel (["<C>Error </R>$text"]);
177 popupLabel ([$text]);
187 my ($env,$brrecs)=@_;
188 $env->{'sysarea'}="Menu";
189 my $titlebar=titlepanel($env,"Koha","Select branch");
192 while (@$brrecs[$x] ne "") {
193 my $brrec =@$brrecs[$x];
194 $mitems[$x]=fmtstr($env,$brrec->{'branchcode'},"L6");
195 $mitems[$x]=$mitems[$x].fmtstr($env,$brrec->{'branchname'},"L20");
198 my $menu = new Cdk::Scroll ('Title'=>" ",
202 # Activate the object.
203 my ($menuItem) = $menu->activate();
205 if (defined $menuItem) {
206 my $brrec = @$brrecs[$menuItem];
207 $env->{'branchcode'} = $brrec->{'branchcode'};
208 $env->{'branchname'} = $brrec->{'branchname'};
217 my ($env,$prrecs)=@_;
218 $env->{'sysarea'}="Menu";
219 my $titlebar=titlepanel($env,"Koha","Select printer");
222 while (@$prrecs[$x] ne "") {
223 my $prrec =@$prrecs[$x];
224 $mitems[$x]=fmtstr($env,$prrec->{'printername'},"L20");
227 my $menu = new Cdk::Scroll ('Title'=>" ",
231 # Activate the object.
232 my ($menuItem) = $menu->activate();
236 if (defined $menuItem) {
237 my $prrec = @$prrecs[$menuItem];
238 $env->{'queue'} = $prrec->{'printqueue'};
239 $env->{'printtype'} = $prrec->{'printtype'};
246 sub borrower_dialog {
251 my @coltitles = ("Borrower","Item");
252 my @rowtitles = (" ");
253 my @coltypes = ("UMIXED","UMIXED");
254 my @colwidths = (12,12);
255 my $matrix = new Cdk::Matrix (
256 'ColTitles'=> \@coltitles,
257 'RowTitles'=> \@rowtitles,
258 'ColWidths'=> \@colwidths,
259 'ColTypes'=> \@coltypes,
262 borrbind($env,$matrix);
264 my ($rows,$cols,$info) = $matrix->activate();
265 if ((!defined $rows) && ($info->[0][0] eq "")) {
268 $borrower = $info->[0][0];
269 $book = $info->[0][1];
272 $matrix->unregister();
274 Cdk::refreshCdkScreen();
275 return ($borrower,$result,$book);
279 my ($env,$dbh,$borrows,$bornums)=@_;
281 my $label = "Select a borrower";
282 my $scroll = new Cdk::Scroll ('Title'=>$label,
283 'List'=>\@$borrows,'Height'=>15,'Width'=>60);
284 my $returnValue = $scroll->activate ();
285 if (!defined $returnValue) {
288 $result = substr(@$borrows[$returnValue],0,9);
291 #$scroll->unregister();
293 Cdk::refreshCdkScreen();
298 my ($env,$title,$dbh,$items1,$items2,$borrower,$amountowing,$odues)=@_;
299 my @functs=("Due Date","Renewals","Payments","Print","Current","Previous");
300 my $titlepanel = titlepanel($env,"Issues","Issue an Item");
301 my $scroll2 = new Cdk::Scroll ('Title'=>"Previous Issues",
302 'List'=>\@$items1,'Height'=> 8,'Width'=>78,'Ypos'=>18);
303 my $scroll1 = new Cdk::Scroll ('Title'=>"Current Issues",
304 'List'=>\@$items2,'Height'=> 8,'Width'=>78,'Ypos'=>9);
305 my $funcmenu = new Cdk::Scroll ('Title'=>"",
306 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>28);
307 my $loanlength = new Cdk::Entry('Label'=>"Due Date: ",
308 'Max'=>"30",'Width'=>"11",
309 'Xpos'=>0,'Ypos'=>5,'Type'=>"UMIXED");
311 while ($x < length($env->{'loanlength'})) {
312 $loanlength->inject('Input'=>substr($env->{'loanlength'},$x,1));
315 my $borrbox = borrowerbox($env,$borrower,$amountowing);
316 my $entryBox = new Cdk::Entry('Label'=>"Item Barcode: ",
317 'Max'=>"11",'Width'=>"11",
318 'Xpos'=>"0",'Ypos'=>3,'Type'=>"UMIXED");
324 #$env->{'loanlength'} = "";
325 #debug_msg($env,"clear len");
328 $entryBox->preProcess ('Function' =>
329 sub{prebook(@_,$env,$dbh,$funcmenu,$entryBox,$loanlength,
330 $scroll1,$scroll2,$borrower,$amountowing,$odues);});
331 $barcode = $entryBox->activate();
333 if (!defined $barcode) {
334 $reason="Finished user"
341 $loanlength->erase();
349 Cdk::refreshCdkScreen();
350 #debug_msg($env,"exiting");
351 return $barcode,$reason;
354 my ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
355 $scroll2,$borrower,$amountowing,$odues) = @_;
356 my $funct = $funcmenu->activate();
357 if (!defined $funct) {
358 } elsif ($funct == 0 ) {
359 actloanlength ($env,$entryBox,$loanlength,$scroll1,$scroll2);
360 } elsif ($funct == 1 ) {
364 $loanlength->erase();
367 C4::Circulation::Renewals::bulkrenew($env,$dbh,
368 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
369 } elsif ($funct == 2 ) {
373 $loanlength->erase();
375 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
376 $amountowing,$borrower,$odues);
377 } elsif ($funct == 3 ) {
378 C4::Circulation::Borrissues::printallissues ($env,$borrower);
379 } elsif ($funct == 4 ) {
380 actscroll1 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
381 } elsif ($funct == 5 ) {
382 actscroll2 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
384 Cdk::refreshCdkScreen();
385 $entryBox->unregister();
386 $entryBox->register();
390 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
391 $scroll1->activate();
395 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
396 $scroll2->activate();
400 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
402 while ($validdate eq "N") {
403 my $loanlength = $loanlength->activate();
404 if (!defined $loanlength) {
405 $env->{'loanlength'} = "";
407 } elsif ($loanlength eq "") {
408 $env->{'loanlength'} = "";
411 my $date = ParseDate($loanlength);
412 if ( $date > ParseDate('today')){
414 my $fdate = substr($date,0,4).'-'.substr($date,4,2).'-'.substr($date,6,2);
415 #debug_msg($env,"$date $fdate");
416 $env->{'loanlength'} = $fdate;
418 error_msg($env,"Invalid date");
426 my ($input,$env,$dbh,$funcmenu,$entryBox,$loanlength,
427 $scroll1,$scroll2,$borrower,$amountowing,$odues)= @_;
428 # FIXME - $key_tab is undefined
429 if ($input eq $key_tab) {
430 actfmenu ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
431 $scroll2,$borrower,$amountowing,$odues);
438 my ($env,$borrower,$amountowing,$odues) = @_;
440 my $amountowing = fmtdec($env,$amountowing,"42");
441 my $line = "$borrower->{'cardnumber'} ";
442 $line = $line."$borrower->{'surname'}, ";
443 $line = $line."$borrower->{'title'} $borrower->{'firstname'}";
445 $line = "$borrower->{'streetaddress'}, $borrower->{'city'}";
447 $line = "$borrower->{'categorycode'}";
448 if ($borrower->{'gonenoaddress'} == 1) {
449 $line = $line." </R>GNA<!R>";
451 if ($borrower->{'lost'} == 1) {
452 $line = $line." </R>LOST<!R>";
455 $line = $line." </R>ODUE<!R>";
457 if ($borrower->{'borrowernotes'} ne "" ) {
458 $line = $line." </R>NOTES<!R>";
460 if ($amountowing > 0) {
461 $line = $line." </B>\$$amountowing";
464 if ($borrower->{'borrowernotes'} ne "" ) {
465 $borrinfo[3]=substr($borrower->{'borrowernotes'},0,40);
467 my $borrbox = new Cdk::Label ('Message' =>\@borrinfo,
468 'Ypos'=>3, 'Xpos'=>"RIGHT");
473 my ($env,$title,$item,$items,$borrower,$amountowing,$odues,$dbh,$resp)=@_;
474 #debug_msg($env,$borrower);
475 my $titlepanel = titlepanel($env,"Returns","Scan Item");
476 my @functs=("Payments","Renewal");
477 my $funcmenu = new Cdk::Scroll ('Title'=>"",
478 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>16);
479 my $returnlist = new Cdk::Scroll ('Title'=>"Items Returned",
480 'List'=>\@$items,'Height'=> 12,'Width'=>74,'Ypos'=>10,'Xpos'=>1);
484 if ($borrower->{'cardnumber'} ne "") {
485 $borrbox = borrowerbox($env,$borrower,$amountowing);
491 $borrbox = new Cdk::Label ('Message' =>\@text, 'Ypos'=>3, 'Xpos'=>"RIGHT");
495 my $bookentry = new Cdk::Entry('Label'=>" ",
496 'Max'=>"11",'Width'=>"11",
497 'Xpos'=>"2",'Ypos'=>"3",'Title'=>"Item Barcode",
499 $bookentry->preProcess ('Function' =>sub{preretbook(@_,$env,$dbh,
500 $funcmenu,$bookentry,$borrower,$amountowing,
501 $odues,$titlepanel,$borrbox,$returnlist);});
502 my $barcode = $bookentry->activate();
504 if (!defined $barcode) {
509 if ($borrbox ne "") {$borrbox->erase();}
510 $returnlist->erase();
519 return($reason,$barcode);
523 my ($input,$env,$dbh,$funcmenu,$bookentry,$borrower,
524 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)=@_;
525 if ($input eq $key_tab) {
526 actrfmenu($env,$dbh,$funcmenu,$bookentry,$borrower,
527 $amountowing,$odues,$titlepanel,$borrbox,$returnlist);
534 my ($env,$dbh,$funcmenu,$bookentry,$borrower,
535 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)= @_;
536 my $funct = $funcmenu->activate();
537 #debug_msg($env,"funtion $funct");
538 if (!defined $funct) {
539 } elsif ($funct == 1 ) {
540 if ($borrower->{'borrowernumber'} ne "") {
543 $titlepanel->erase();
545 $returnlist->erase();
546 C4::Circulation::Renewals::bulkrenew($env,$dbh,
547 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
548 Cdk::refreshCdkScreen();
555 } elsif ($funct == 0 ) {
556 if ($borrower->{'borrowernumber'} ne "") {
559 $titlepanel->erase();
561 $returnlist->erase();
562 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
563 $amountowing,$borrower,$odues);
569 #Cdk::refreshCdkScreen();
576 my $ans = $obj->activate();
581 my ($env,$entry) = @_;
582 my $lastborr = $env->{"bcard"};
583 $entry->preProcess ('Function' => sub {preborr (@_, $env,$entry);});
587 my ($input,$env, $entry) = @_;
588 if ($env->{"bcard"} ne "") {
589 # error_msg($env,"hi there");
590 # FIXME - $lastval is undefined
591 if ($input eq $lastval) {
592 # error_msg($env,"its a ctrl-r");
593 borfill($env,$entry);
602 my ($env,$entry) = @_;
603 error_msg($env,"in borfill: $env->{'bcard'}");
604 my $lastborr = $env->{"bcard"};
606 $entry->inject('Input'=>$lastborr);
608 # my $temp=substr($lastborr,$i,1);
609 # $entry->inject('Input'=>$temp);
615 END { } # module clean-up code here (global destructor)