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!
29 use C4::Circulation::Borrissues;
30 use C4::Circulation::Renewals;
35 use vars qw($VERSION @ISA @EXPORT);
37 # set the version for version checking
41 @EXPORT = qw(&dialog &startint &endint &output &clearscreen &pause &helptext
42 &textbox &menu &issuewindow &msg_yn &msg_ny &borrower_dialog &debug_msg &error_msg
43 &info_msg &selborrower &returnwindow &logondialog &borrowerwindow &titlepanel
44 &borrbind &borrfill &preeborr &borrowerbox &brmenu &prmenu);
47 # is this planned for something?
56 my ($env,$type,$title,@items)=@_;
57 $env->{'sysarea'}="Menu";
58 my $titlebar=titlepanel($env,"Koha","Main Menu");
63 while ($items[$x] ne "") {
64 $mitems[$x]="<C>".$items[$x];
67 if ($type eq 'console'){
69 my $menu = new Cdk::Scroll ('Title'=>" ",
71 'Height'=> $menucnt+4,
73 # Activate the object.
74 my ($menuItem) = $menu->activate();
77 if (!defined $menuItem) {
81 $data = $items[$menuItem];
84 return($reason,$data);
97 my($left,$top,$msg)=@_;
100 my $output = new Cdk::Label ('Message' =>\@outm,
101 'Ypos'=>$top, 'Xpos'=>$left, 'Box'=>0);
108 my $helptext = output(1,24,$text);
114 my ($env,$title,$title2)=@_;
116 @header[0] = fmtstr($env,$title,"L24");
117 @header[0] = @header[0].fmtstr($env,
118 $env->{'branchname'}."-".$env->{'queue'},"C28");
119 @header[0] = @header[0].fmtstr($env,$title2,"R24");
120 my $label = new Cdk::Label ('Message' =>\@header,'Ypos'=>0,'Xpos'=>0);
126 my ($env,$text1,$text2)=@_;
127 # Create the dialog buttons.
128 my @buttons = ("Yes", "No");
129 my @mesg = ("<C>$text1", "<C>$text2");
130 # Create the dialog object.
131 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
132 my $resp = $dialog->activate();
141 my ($env,$text1,$text2)=@_;
143 # Create the dialog buttons.
144 my @buttons = ("No", "Yes");
145 my @mesg = ("<C>$text1", "<C>$text2");
146 # Create the dialog object.
147 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
148 my $resp = $dialog->activate();
159 if ($env->{'telnet'} eq "Y") {
160 popupLabel (["Debug </R>$text"]);
162 # print "****DEBUG $text****";
169 popupLabel (["<C>Error </R>$text"]);
175 popupLabel ([$text]);
185 my ($env,$brrecs)=@_;
186 $env->{'sysarea'}="Menu";
187 my $titlebar=titlepanel($env,"Koha","Select branch");
190 while (@$brrecs[$x] ne "") {
191 my $brrec =@$brrecs[$x];
192 $mitems[$x]=fmtstr($env,$brrec->{'branchcode'},"L6");
193 $mitems[$x]=$mitems[$x].fmtstr($env,$brrec->{'branchname'},"L20");
196 my $menu = new Cdk::Scroll ('Title'=>" ",
200 # Activate the object.
201 my ($menuItem) = $menu->activate();
203 if (defined $menuItem) {
204 my $brrec = @$brrecs[$menuItem];
205 $env->{'branchcode'} = $brrec->{'branchcode'};
206 $env->{'branchname'} = $brrec->{'branchname'};
215 my ($env,$prrecs)=@_;
216 $env->{'sysarea'}="Menu";
217 my $titlebar=titlepanel($env,"Koha","Select printer");
220 while (@$prrecs[$x] ne "") {
221 my $prrec =@$prrecs[$x];
222 $mitems[$x]=fmtstr($env,$prrec->{'printername'},"L20");
225 my $menu = new Cdk::Scroll ('Title'=>" ",
229 # Activate the object.
230 my ($menuItem) = $menu->activate();
234 if (defined $menuItem) {
235 my $prrec = @$prrecs[$menuItem];
236 $env->{'queue'} = $prrec->{'printqueue'};
237 $env->{'printtype'} = $prrec->{'printtype'};
244 sub borrower_dialog {
249 my @coltitles = ("Borrower","Item");
250 my @rowtitles = (" ");
251 my @coltypes = ("UMIXED","UMIXED");
252 my @colwidths = (12,12);
253 my $matrix = new Cdk::Matrix (
254 'ColTitles'=> \@coltitles,
255 'RowTitles'=> \@rowtitles,
256 'ColWidths'=> \@colwidths,
257 'ColTypes'=> \@coltypes,
260 borrbind($env,$matrix);
262 my ($rows,$cols,$info) = $matrix->activate();
263 if ((!defined $rows) && ($info->[0][0] eq "")) {
266 $borrower = $info->[0][0];
267 $book = $info->[0][1];
270 $matrix->unregister();
272 Cdk::refreshCdkScreen();
273 return ($borrower,$result,$book);
277 my ($env,$dbh,$borrows,$bornums)=@_;
279 my $label = "Select a borrower";
280 my $scroll = new Cdk::Scroll ('Title'=>$label,
281 'List'=>\@$borrows,'Height'=>15,'Width'=>60);
282 my $returnValue = $scroll->activate ();
283 if (!defined $returnValue) {
286 $result = substr(@$borrows[$returnValue],0,9);
289 #$scroll->unregister();
291 Cdk::refreshCdkScreen();
296 my ($env,$title,$dbh,$items1,$items2,$borrower,$amountowing,$odues)=@_;
297 my @functs=("Due Date","Renewals","Payments","Print","Current","Previous");
298 my $titlepanel = titlepanel($env,"Issues","Issue an Item");
299 my $scroll2 = new Cdk::Scroll ('Title'=>"Previous Issues",
300 'List'=>\@$items1,'Height'=> 8,'Width'=>78,'Ypos'=>18);
301 my $scroll1 = new Cdk::Scroll ('Title'=>"Current Issues",
302 'List'=>\@$items2,'Height'=> 8,'Width'=>78,'Ypos'=>9);
303 my $funcmenu = new Cdk::Scroll ('Title'=>"",
304 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>28);
305 my $loanlength = new Cdk::Entry('Label'=>"Due Date: ",
306 'Max'=>"30",'Width'=>"11",
307 'Xpos'=>0,'Ypos'=>5,'Type'=>"UMIXED");
309 while ($x < length($env->{'loanlength'})) {
310 $loanlength->inject('Input'=>substr($env->{'loanlength'},$x,1));
313 my $borrbox = borrowerbox($env,$borrower,$amountowing);
314 my $entryBox = new Cdk::Entry('Label'=>"Item Barcode: ",
315 'Max'=>"11",'Width'=>"11",
316 'Xpos'=>"0",'Ypos'=>3,'Type'=>"UMIXED");
322 #$env->{'loanlength'} = "";
323 #debug_msg($env,"clear len");
326 $entryBox->preProcess ('Function' =>
327 sub{prebook(@_,$env,$dbh,$funcmenu,$entryBox,$loanlength,
328 $scroll1,$scroll2,$borrower,$amountowing,$odues);});
329 $barcode = $entryBox->activate();
331 if (!defined $barcode) {
332 $reason="Finished user"
339 $loanlength->erase();
347 Cdk::refreshCdkScreen();
348 #debug_msg($env,"exiting");
349 return $barcode,$reason;
352 my ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
353 $scroll2,$borrower,$amountowing,$odues) = @_;
354 my $funct = $funcmenu->activate();
355 if (!defined $funct) {
356 } elsif ($funct == 0 ) {
357 actloanlength ($env,$entryBox,$loanlength,$scroll1,$scroll2);
358 } elsif ($funct == 1 ) {
362 $loanlength->erase();
365 C4::Circulation::Renewals::bulkrenew($env,$dbh,
366 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
367 } elsif ($funct == 2 ) {
371 $loanlength->erase();
373 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
374 $amountowing,$borrower,$odues);
375 } elsif ($funct == 3 ) {
376 C4::Circulation::Borrissues::printallissues ($env,$borrower);
377 } elsif ($funct == 4 ) {
378 actscroll1 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
379 } elsif ($funct == 5 ) {
380 actscroll2 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
382 Cdk::refreshCdkScreen();
383 $entryBox->unregister();
384 $entryBox->register();
388 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
389 $scroll1->activate();
393 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
394 $scroll2->activate();
398 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
400 while ($validdate eq "N") {
401 my $loanlength = $loanlength->activate();
402 if (!defined $loanlength) {
403 $env->{'loanlength'} = "";
405 } elsif ($loanlength eq "") {
406 $env->{'loanlength'} = "";
409 my $date = ParseDate($loanlength);
410 if ( $date > ParseDate('today')){
412 my $fdate = substr($date,0,4).'-'.substr($date,4,2).'-'.substr($date,6,2);
413 #debug_msg($env,"$date $fdate");
414 $env->{'loanlength'} = $fdate;
416 error_msg($env,"Invalid date");
424 my ($input,$env,$dbh,$funcmenu,$entryBox,$loanlength,
425 $scroll1,$scroll2,$borrower,$amountowing,$odues)= @_;
426 # FIXME - $key_tab is undefined
427 if ($input eq $key_tab) {
428 actfmenu ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
429 $scroll2,$borrower,$amountowing,$odues);
436 my ($env,$borrower,$amountowing,$odues) = @_;
438 my $amountowing = fmtdec($env,$amountowing,"42");
439 my $line = "$borrower->{'cardnumber'} ";
440 $line = $line."$borrower->{'surname'}, ";
441 $line = $line."$borrower->{'title'} $borrower->{'firstname'}";
443 $line = "$borrower->{'streetaddress'}, $borrower->{'city'}";
445 $line = "$borrower->{'categorycode'}";
446 if ($borrower->{'gonenoaddress'} == 1) {
447 $line = $line." </R>GNA<!R>";
449 if ($borrower->{'lost'} == 1) {
450 $line = $line." </R>LOST<!R>";
453 $line = $line." </R>ODUE<!R>";
455 if ($borrower->{'borrowernotes'} ne "" ) {
456 $line = $line." </R>NOTES<!R>";
458 if ($amountowing > 0) {
459 $line = $line." </B>\$$amountowing";
462 if ($borrower->{'borrowernotes'} ne "" ) {
463 $borrinfo[3]=substr($borrower->{'borrowernotes'},0,40);
465 my $borrbox = new Cdk::Label ('Message' =>\@borrinfo,
466 'Ypos'=>3, 'Xpos'=>"RIGHT");
471 my ($env,$title,$item,$items,$borrower,$amountowing,$odues,$dbh,$resp)=@_;
472 #debug_msg($env,$borrower);
473 my $titlepanel = titlepanel($env,"Returns","Scan Item");
474 my @functs=("Payments","Renewal");
475 my $funcmenu = new Cdk::Scroll ('Title'=>"",
476 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>16);
477 my $returnlist = new Cdk::Scroll ('Title'=>"Items Returned",
478 'List'=>\@$items,'Height'=> 12,'Width'=>74,'Ypos'=>10,'Xpos'=>1);
482 if ($borrower->{'cardnumber'} ne "") {
483 $borrbox = borrowerbox($env,$borrower,$amountowing);
489 $borrbox = new Cdk::Label ('Message' =>\@text, 'Ypos'=>3, 'Xpos'=>"RIGHT");
493 my $bookentry = new Cdk::Entry('Label'=>" ",
494 'Max'=>"11",'Width'=>"11",
495 'Xpos'=>"2",'Ypos'=>"3",'Title'=>"Item Barcode",
497 $bookentry->preProcess ('Function' =>sub{preretbook(@_,$env,$dbh,
498 $funcmenu,$bookentry,$borrower,$amountowing,
499 $odues,$titlepanel,$borrbox,$returnlist);});
500 my $barcode = $bookentry->activate();
502 if (!defined $barcode) {
507 if ($borrbox ne "") {$borrbox->erase();}
508 $returnlist->erase();
517 return($reason,$barcode);
521 my ($input,$env,$dbh,$funcmenu,$bookentry,$borrower,
522 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)=@_;
523 if ($input eq $key_tab) {
524 actrfmenu($env,$dbh,$funcmenu,$bookentry,$borrower,
525 $amountowing,$odues,$titlepanel,$borrbox,$returnlist);
532 my ($env,$dbh,$funcmenu,$bookentry,$borrower,
533 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)= @_;
534 my $funct = $funcmenu->activate();
535 #debug_msg($env,"funtion $funct");
536 if (!defined $funct) {
537 } elsif ($funct == 1 ) {
538 if ($borrower->{'borrowernumber'} ne "") {
541 $titlepanel->erase();
543 $returnlist->erase();
544 C4::Circulation::Renewals::bulkrenew($env,$dbh,
545 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
546 Cdk::refreshCdkScreen();
553 } elsif ($funct == 0 ) {
554 if ($borrower->{'borrowernumber'} ne "") {
557 $titlepanel->erase();
559 $returnlist->erase();
560 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
561 $amountowing,$borrower,$odues);
567 #Cdk::refreshCdkScreen();
574 my $ans = $obj->activate();
579 my ($env,$entry) = @_;
580 my $lastborr = $env->{"bcard"};
581 $entry->preProcess ('Function' => sub {preborr (@_, $env,$entry);});
585 my ($input,$env, $entry) = @_;
586 if ($env->{"bcard"} ne "") {
587 # error_msg($env,"hi there");
588 # FIXME - $lastval is undefined
589 if ($input eq $lastval) {
590 # error_msg($env,"its a ctrl-r");
591 borfill($env,$entry);
600 my ($env,$entry) = @_;
601 error_msg($env,"in borfill: $env->{'bcard'}");
602 my $lastborr = $env->{"bcard"};
604 $entry->inject('Input'=>$lastborr);
606 # my $temp=substr($lastborr,$i,1);
607 # $entry->inject('Input'=>$temp);
613 END { } # module clean-up code here (global destructor)