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);
88 # FIXME - Is this a placeholder?
92 # FIXME - Is this a placeholder?
98 my($left,$top,$msg)=@_;
101 my $output = new Cdk::Label ('Message' =>\@outm,
102 'Ypos'=>$top, 'Xpos'=>$left, 'Box'=>0);
109 my $helptext = output(1,24,$text);
115 my ($env,$title,$title2)=@_;
117 @header[0] = fmtstr($env,$title,"L24");
118 @header[0] = @header[0].fmtstr($env,
119 $env->{'branchname'}."-".$env->{'queue'},"C28");
120 @header[0] = @header[0].fmtstr($env,$title2,"R24");
121 my $label = new Cdk::Label ('Message' =>\@header,'Ypos'=>0,'Xpos'=>0);
127 my ($env,$text1,$text2)=@_;
128 # Create the dialog buttons.
129 my @buttons = ("Yes", "No");
130 my @mesg = ("<C>$text1", "<C>$text2");
131 # Create the dialog object.
132 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
133 my $resp = $dialog->activate();
142 my ($env,$text1,$text2)=@_;
144 # Create the dialog buttons.
145 my @buttons = ("No", "Yes");
146 my @mesg = ("<C>$text1", "<C>$text2");
147 # Create the dialog object.
148 my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
149 my $resp = $dialog->activate();
160 if ($env->{'telnet'} eq "Y") {
161 popupLabel (["Debug </R>$text"]);
163 # print "****DEBUG $text****";
170 popupLabel (["<C>Error </R>$text"]);
176 popupLabel ([$text]);
186 my ($env,$brrecs)=@_;
187 $env->{'sysarea'}="Menu";
188 my $titlebar=titlepanel($env,"Koha","Select branch");
191 while (@$brrecs[$x] ne "") {
192 my $brrec =@$brrecs[$x];
193 $mitems[$x]=fmtstr($env,$brrec->{'branchcode'},"L6");
194 $mitems[$x]=$mitems[$x].fmtstr($env,$brrec->{'branchname'},"L20");
197 my $menu = new Cdk::Scroll ('Title'=>" ",
201 # Activate the object.
202 my ($menuItem) = $menu->activate();
204 if (defined $menuItem) {
205 my $brrec = @$brrecs[$menuItem];
206 $env->{'branchcode'} = $brrec->{'branchcode'};
207 $env->{'branchname'} = $brrec->{'branchname'};
216 my ($env,$prrecs)=@_;
217 $env->{'sysarea'}="Menu";
218 my $titlebar=titlepanel($env,"Koha","Select printer");
221 while (@$prrecs[$x] ne "") {
222 my $prrec =@$prrecs[$x];
223 $mitems[$x]=fmtstr($env,$prrec->{'printername'},"L20");
226 my $menu = new Cdk::Scroll ('Title'=>" ",
230 # Activate the object.
231 my ($menuItem) = $menu->activate();
235 if (defined $menuItem) {
236 my $prrec = @$prrecs[$menuItem];
237 $env->{'queue'} = $prrec->{'printqueue'};
238 $env->{'printtype'} = $prrec->{'printtype'};
245 sub borrower_dialog {
250 my @coltitles = ("Borrower","Item");
251 my @rowtitles = (" ");
252 my @coltypes = ("UMIXED","UMIXED");
253 my @colwidths = (12,12);
254 my $matrix = new Cdk::Matrix (
255 'ColTitles'=> \@coltitles,
256 'RowTitles'=> \@rowtitles,
257 'ColWidths'=> \@colwidths,
258 'ColTypes'=> \@coltypes,
261 borrbind($env,$matrix);
263 my ($rows,$cols,$info) = $matrix->activate();
264 if ((!defined $rows) && ($info->[0][0] eq "")) {
267 $borrower = $info->[0][0];
268 $book = $info->[0][1];
271 $matrix->unregister();
273 Cdk::refreshCdkScreen();
274 return ($borrower,$result,$book);
278 my ($env,$dbh,$borrows,$bornums)=@_;
280 my $label = "Select a borrower";
281 my $scroll = new Cdk::Scroll ('Title'=>$label,
282 'List'=>\@$borrows,'Height'=>15,'Width'=>60);
283 my $returnValue = $scroll->activate ();
284 if (!defined $returnValue) {
287 $result = substr(@$borrows[$returnValue],0,9);
290 #$scroll->unregister();
292 Cdk::refreshCdkScreen();
297 my ($env,$title,$dbh,$items1,$items2,$borrower,$amountowing,$odues)=@_;
298 my @functs=("Due Date","Renewals","Payments","Print","Current","Previous");
299 my $titlepanel = titlepanel($env,"Issues","Issue an Item");
300 my $scroll2 = new Cdk::Scroll ('Title'=>"Previous Issues",
301 'List'=>\@$items1,'Height'=> 8,'Width'=>78,'Ypos'=>18);
302 my $scroll1 = new Cdk::Scroll ('Title'=>"Current Issues",
303 'List'=>\@$items2,'Height'=> 8,'Width'=>78,'Ypos'=>9);
304 my $funcmenu = new Cdk::Scroll ('Title'=>"",
305 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>28);
306 my $loanlength = new Cdk::Entry('Label'=>"Due Date: ",
307 'Max'=>"30",'Width'=>"11",
308 'Xpos'=>0,'Ypos'=>5,'Type'=>"UMIXED");
310 while ($x < length($env->{'loanlength'})) {
311 $loanlength->inject('Input'=>substr($env->{'loanlength'},$x,1));
314 my $borrbox = borrowerbox($env,$borrower,$amountowing);
315 my $entryBox = new Cdk::Entry('Label'=>"Item Barcode: ",
316 'Max'=>"11",'Width'=>"11",
317 'Xpos'=>"0",'Ypos'=>3,'Type'=>"UMIXED");
323 #$env->{'loanlength'} = "";
324 #debug_msg($env,"clear len");
327 $entryBox->preProcess ('Function' =>
328 sub{prebook(@_,$env,$dbh,$funcmenu,$entryBox,$loanlength,
329 $scroll1,$scroll2,$borrower,$amountowing,$odues);});
330 $barcode = $entryBox->activate();
332 if (!defined $barcode) {
333 $reason="Finished user"
340 $loanlength->erase();
348 Cdk::refreshCdkScreen();
349 #debug_msg($env,"exiting");
350 return $barcode,$reason;
353 my ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
354 $scroll2,$borrower,$amountowing,$odues) = @_;
355 my $funct = $funcmenu->activate();
356 if (!defined $funct) {
357 } elsif ($funct == 0 ) {
358 actloanlength ($env,$entryBox,$loanlength,$scroll1,$scroll2);
359 } elsif ($funct == 1 ) {
363 $loanlength->erase();
366 C4::Circulation::Renewals::bulkrenew($env,$dbh,
367 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
368 } elsif ($funct == 2 ) {
372 $loanlength->erase();
374 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
375 $amountowing,$borrower,$odues);
376 } elsif ($funct == 3 ) {
377 C4::Circulation::Borrissues::printallissues ($env,$borrower);
378 } elsif ($funct == 4 ) {
379 actscroll1 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
380 } elsif ($funct == 5 ) {
381 actscroll2 ($env,$entryBox,$loanlength,$scroll1,$scroll2);
383 Cdk::refreshCdkScreen();
384 $entryBox->unregister();
385 $entryBox->register();
389 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
390 $scroll1->activate();
394 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
395 $scroll2->activate();
399 my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_;
401 while ($validdate eq "N") {
402 my $loanlength = $loanlength->activate();
403 if (!defined $loanlength) {
404 $env->{'loanlength'} = "";
406 } elsif ($loanlength eq "") {
407 $env->{'loanlength'} = "";
410 my $date = ParseDate($loanlength);
411 if ( $date > ParseDate('today')){
413 my $fdate = substr($date,0,4).'-'.substr($date,4,2).'-'.substr($date,6,2);
414 #debug_msg($env,"$date $fdate");
415 $env->{'loanlength'} = $fdate;
417 error_msg($env,"Invalid date");
425 my ($input,$env,$dbh,$funcmenu,$entryBox,$loanlength,
426 $scroll1,$scroll2,$borrower,$amountowing,$odues)= @_;
427 # FIXME - $key_tab is undefined
428 if ($input eq $key_tab) {
429 actfmenu ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
430 $scroll2,$borrower,$amountowing,$odues);
437 my ($env,$borrower,$amountowing,$odues) = @_;
439 my $amountowing = fmtdec($env,$amountowing,"42");
440 my $line = "$borrower->{'cardnumber'} ";
441 $line = $line."$borrower->{'surname'}, ";
442 $line = $line."$borrower->{'title'} $borrower->{'firstname'}";
444 $line = "$borrower->{'streetaddress'}, $borrower->{'city'}";
446 $line = "$borrower->{'categorycode'}";
447 if ($borrower->{'gonenoaddress'} == 1) {
448 $line = $line." </R>GNA<!R>";
450 if ($borrower->{'lost'} == 1) {
451 $line = $line." </R>LOST<!R>";
454 $line = $line." </R>ODUE<!R>";
456 if ($borrower->{'borrowernotes'} ne "" ) {
457 $line = $line." </R>NOTES<!R>";
459 if ($amountowing > 0) {
460 $line = $line." </B>\$$amountowing";
463 if ($borrower->{'borrowernotes'} ne "" ) {
464 $borrinfo[3]=substr($borrower->{'borrowernotes'},0,40);
466 my $borrbox = new Cdk::Label ('Message' =>\@borrinfo,
467 'Ypos'=>3, 'Xpos'=>"RIGHT");
472 my ($env,$title,$item,$items,$borrower,$amountowing,$odues,$dbh,$resp)=@_;
473 #debug_msg($env,$borrower);
474 my $titlepanel = titlepanel($env,"Returns","Scan Item");
475 my @functs=("Payments","Renewal");
476 my $funcmenu = new Cdk::Scroll ('Title'=>"",
477 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>16);
478 my $returnlist = new Cdk::Scroll ('Title'=>"Items Returned",
479 'List'=>\@$items,'Height'=> 12,'Width'=>74,'Ypos'=>10,'Xpos'=>1);
483 if ($borrower->{'cardnumber'} ne "") {
484 $borrbox = borrowerbox($env,$borrower,$amountowing);
490 $borrbox = new Cdk::Label ('Message' =>\@text, 'Ypos'=>3, 'Xpos'=>"RIGHT");
494 my $bookentry = new Cdk::Entry('Label'=>" ",
495 'Max'=>"11",'Width'=>"11",
496 'Xpos'=>"2",'Ypos'=>"3",'Title'=>"Item Barcode",
498 $bookentry->preProcess ('Function' =>sub{preretbook(@_,$env,$dbh,
499 $funcmenu,$bookentry,$borrower,$amountowing,
500 $odues,$titlepanel,$borrbox,$returnlist);});
501 my $barcode = $bookentry->activate();
503 if (!defined $barcode) {
508 if ($borrbox ne "") {$borrbox->erase();}
509 $returnlist->erase();
518 return($reason,$barcode);
522 my ($input,$env,$dbh,$funcmenu,$bookentry,$borrower,
523 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)=@_;
524 if ($input eq $key_tab) {
525 actrfmenu($env,$dbh,$funcmenu,$bookentry,$borrower,
526 $amountowing,$odues,$titlepanel,$borrbox,$returnlist);
533 my ($env,$dbh,$funcmenu,$bookentry,$borrower,
534 $amountowing,$odues,$titlepanel,$borrbox,$returnlist)= @_;
535 my $funct = $funcmenu->activate();
536 #debug_msg($env,"funtion $funct");
537 if (!defined $funct) {
538 } elsif ($funct == 1 ) {
539 if ($borrower->{'borrowernumber'} ne "") {
542 $titlepanel->erase();
544 $returnlist->erase();
545 C4::Circulation::Renewals::bulkrenew($env,$dbh,
546 $borrower->{'borrowernumber'},$amountowing,$borrower,$odues);
547 Cdk::refreshCdkScreen();
554 } elsif ($funct == 0 ) {
555 if ($borrower->{'borrowernumber'} ne "") {
558 $titlepanel->erase();
560 $returnlist->erase();
561 C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'},
562 $amountowing,$borrower,$odues);
568 #Cdk::refreshCdkScreen();
575 my $ans = $obj->activate();
580 my ($env,$entry) = @_;
581 my $lastborr = $env->{"bcard"};
582 $entry->preProcess ('Function' => sub {preborr (@_, $env,$entry);});
586 my ($input,$env, $entry) = @_;
587 if ($env->{"bcard"} ne "") {
588 # error_msg($env,"hi there");
589 # FIXME - $lastval is undefined
590 if ($input eq $lastval) {
591 # error_msg($env,"its a ctrl-r");
592 borfill($env,$entry);
601 my ($env,$entry) = @_;
602 error_msg($env,"in borfill: $env->{'bcard'}");
603 my $lastborr = $env->{"bcard"};
605 $entry->inject('Input'=>$lastborr);
607 # my $temp=substr($lastborr,$i,1);
608 # $entry->inject('Input'=>$temp);
614 END { } # module clean-up code here (global destructor)