From b5113b8e5b64c1ba4ecc271fc72102687cca1c22 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 4 Mar 2004 15:39:41 +0000 Subject: [PATCH] unsued package. beginning code cleaning --- C4/Circulation.pm | 213 ------------ C4/Circulation/Borrissues.pm | 63 ---- C4/InterfaceCDK.pm | 617 ----------------------------------- 3 files changed, 893 deletions(-) delete mode 100755 C4/Circulation.pm delete mode 100755 C4/Circulation/Borrissues.pm delete mode 100755 C4/InterfaceCDK.pm diff --git a/C4/Circulation.pm b/C4/Circulation.pm deleted file mode 100755 index 829b849117..0000000000 --- a/C4/Circulation.pm +++ /dev/null @@ -1,213 +0,0 @@ -package C4::Circulation; - -# $Id$ - -#package to deal with circulation - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -# FIXME - This package is never used. Is it obsolete? - -use strict; -require Exporter; -use DBI; -use C4::Circulation::Issues; -use C4::Circulation::Returns; -use C4::Circulation::Renewals; -use C4::Circulation::Borrower; -use C4::Reserves; -#use C4::Interface; -use C4::Security; - -use vars qw($VERSION @ISA @EXPORT); - -# set the version for version checking -$VERSION = 0.01; - -@ISA = qw(Exporter); -@EXPORT = qw(&Start_circ &scanborrower); - -sub Start_circ{ - my ($env)=@_; - #connect to database - #start interface - &startint($env,'Circulation'); - my $donext = 'Circ'; - my $reason; - my $data; - while ($donext ne 'Quit') { - if ($donext eq "Circ") { - clearscreen(); - ($reason,$data) = menu($env,'console','Circulation', - ('Issues','Returns','Borrower Enquiries','Reserves','Log In')); - #debug_msg($env,"data = $data"); - } else { - $data = $donext; - } - if ($data eq 'Issues') { - $donext=Issue($env); #C4::Circulation::Issues - #debug_msg("","do next $donext"); - } elsif ($data eq 'Returns') { - $donext=Returns($env); #C4::Circulation::Returns - } elsif ($data eq 'Borrower Enquiries'){ - $donext=Borenq($env); #C4::Circulation::Borrower - } elsif ($data eq 'Reserves'){ - $donext=EnterReserves($env); #C4::Reserves - } elsif ($data eq 'Log In') { - &endint($env); - &Login($env); #C4::Security - &startint($env,'Circulation'); - } elsif ($data eq 'Quit') { - $donext = $data; - } - #debug_msg($env,"donext - $donext"); - } - &endint($env) -} - -# Not exported. -# FIXME - This is not the same as &C4::Circulation::Main::pastitems, -# though the two appear to share some code. -sub pastitems{ - #Get list of all items borrower has currently on issue - my ($env,$bornum,$dbh)=@_; - my $sth=$dbh->prepare("Select * from issues,items,biblio - where borrowernumber=$bornum and issues.itemnumber=items.itemnumber - and items.biblionumber=biblio.biblionumber - and returndate is null - order by date_due"); - $sth->execute; - my $i=0; - my @items; - my @items2; - #$items[0]=" "x29; - #$items2[0]=" "x29; - $items[0]=" "x72; - $items2[0]=" "x72; - while (my $data=$sth->fetchrow_hashref) { - my $line = "$data->{'date_due'} $data->{'title'}"; - # $items[$i]=fmtstr($env,$line,"L29"); - $items[$i]=fmtstr($env,$line,"L72"); - $i++; - } - return(\@items,\@items2); - $sth->finish; -} - -sub checkoverdues{ - #checks whether a borrower has overdue items - my ($env,$bornum,$dbh)=@_; - my $sth=$dbh->prepare("Select * from issues,items,biblio where - borrowernumber=$bornum and issues.itemnumber=items.itemnumber and - items.biblionumber=biblio.biblionumber"); - $sth->execute; - my $row=1; - my $col=40; - while (my $data=$sth->fetchrow_hashref){ - output($row,$col,$data->{'title'}); - $row++; - } - $sth->finish; -} - -# FIXME - This is quite similar to &C4::Circulation::Main::previousissue -# FIXME - Never used. Obsolete, presumably. -sub previousissue { - my ($env,$itemnum,$dbh,$bornum)=@_; - my $sth=$dbh->prepare("Select firstname,surname,issues.borrowernumber,cardnumber,returndate - from issues,borrowers where - issues.itemnumber='$itemnum' and - issues.borrowernumber=borrowers.borrowernumber and issues.returndate is -NULL"); - $sth->execute; - my $borrower=$sth->fetchrow_hashref; - $sth->finish; - if ($borrower->{'borrowernumber'} ne ''){ - if ($bornum eq $borrower->{'borrowernumber'}){ - # no need to issue - my ($renewstatus) = &renewstatus($env,$dbh,$bornum,$itemnum); - my $resp = &msg_yn("Book is issued to this borrower", "Renew?"); - if ($resp == "y") { - &renewbook($env,$dbh,$bornum,$itemnum); - } - - } else { - my $text="Issued to $borrower->{'firstname'} $borrower->{'surname'} ($borrower->{'cardnumber'})"; - my $resp = &msg_yn($text,"Mark as returned?"); - if ($resp == "y") { - &returnrecord($env,$dbh,$borrower->{'borrowernumber'},$itemnum); - # can issue - } else { - # can't issue - } - } - } - return($borrower->{'borrowernumber'}); - $sth->finish; -} - - -sub checkreserve{ - # Check for reserves for biblio - # does not look at constraints yet - my ($env,$dbh,$itemnum)=@_; - my $resbor = ""; - my $sth = $dbh->prepare("select * from reserves,items - where (items.itemnumber = ?) - and (items.biblionumber = reserves.biblionumber) - and (reserves.found is null) order by priority"); - $sth->execute($itemnum); - if (my $data=$sth->fetchrow_hashref) { - $resbor = $data->{'borrowernumber'}; - } - $sth->finish; - return ($resbor); -} - -sub checkwaiting{ - # check for reserves waiting - my ($env,$dbh,$bornum)=@_; - my @itemswaiting=""; - my $sth = $dbh->prepare("select * from reserves where (borrowernumber = ?) and (reserves.found='W')"); - $sth->execute($bornum); - if (my $data=$sth->fetchrow_hashref) { - push @itemswaiting,$data->{'itemnumber'}; - } - $sth->finish; - return (\@itemswaiting); -} - -# FIXME - This is identical to &C4::Circulation/Main::scanbook -sub scanbook { - my ($env,$interface)=@_; - #scan barcode - my ($number,$reason)=dialog("Book Barcode:"); - $number=uc $number; - return ($number,$reason); -} - -# FIXME - This is very similar to &C4::Circulation::Main::scanborrower -sub scanborrower { - my ($env,$interface)=@_; - #scan barcode - my ($number,$reason,$book)=&borrower_dialog($env); #C4::Interface - $number= $number; # FIXME - WTF? - $book=uc $book; - return ($number,$reason,$book); -} diff --git a/C4/Circulation/Borrissues.pm b/C4/Circulation/Borrissues.pm deleted file mode 100755 index 60513629b0..0000000000 --- a/C4/Circulation/Borrissues.pm +++ /dev/null @@ -1,63 +0,0 @@ -package C4::Circulation::Borrissues; - -# $Id$ - -#package to deal with Issues -#written 3/11/99 by chris@katipo.co.nz - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -require Exporter; -use DBI; -use C4::Context; -use C4::Print; -use vars qw($VERSION @ISA @EXPORT); - -# set the version for version checking -$VERSION = 0.01; - -@ISA = qw(Exporter); -@EXPORT = qw(&printallissues); - -# FIXME - This function is only used in C4::InterfaceCDK, which looks -# obsolete. Does that mean that this module is also obsolete? -# Otherwise, this needs a POD. -sub printallissues { - my ($env,$borrower)=@_; - my @issues; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("select * from issues,items,biblioitems,biblio - where borrowernumber = ? - and (returndate is null) - and (issues.itemnumber = items.itemnumber) - and (items.biblioitemnumber = biblioitems.biblioitemnumber) - and (items.biblionumber = biblio.biblionumber) - order by date_due"); - $sth->execute($borrower->{'borrowernumber'}); - my $x; - while (my $data = $sth->fetchrow_hashref) { - # FIXME - This should be $issues[$x] = $data, right? - # Or better yet, push @issues, $data. - @issues[$x] =$data; - $x++; - } - $sth->finish(); - remoteprint ($env,\@issues,$borrower); -} diff --git a/C4/InterfaceCDK.pm b/C4/InterfaceCDK.pm deleted file mode 100755 index 5103dcbe83..0000000000 --- a/C4/InterfaceCDK.pm +++ /dev/null @@ -1,617 +0,0 @@ -package C4::InterfaceCDK; #assumes C4/InterfaceCDK - -#uses Newt - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -# FIXME - This module doesn't compile! But I'm pretty sure it, like -# the rest of the CDK-based stuff, is obsolete. - -use C4::Format; -use strict; -use Cdk; -use Date::Manip; -use C4::Accounts; -use C4::Circulation::Borrissues; -use C4::Circulation::Renewals; -#use C4::Circulation; - -require Exporter; -use DBI; -use vars qw($VERSION @ISA @EXPORT); - -# set the version for version checking -$VERSION = 0.01; - -@ISA = qw(Exporter); -@EXPORT = qw(&dialog &startint &endint &output &clearscreen &pause &helptext -&textbox &menu &issuewindow &msg_yn &msg_ny &borrower_dialog &debug_msg &error_msg -&info_msg &selborrower &returnwindow &logondialog &borrowerwindow &titlepanel -&borrbind &borrfill &preeborr &borrowerbox &brmenu &prmenu); - -sub suspend_cb { - # is this planned for something? -} - -sub startint { - my ($env,$msg)=@_; - Cdk::init(); -} - -sub menu { - my ($env,$type,$title,@items)=@_; - $env->{'sysarea'}="Menu"; - my $titlebar=titlepanel($env,"Koha","Main Menu"); - my $reason; - my $data; - my @mitems; - my $x = 0; - while ($items[$x] ne "") { - $mitems[$x]="".$items[$x]; - $x++; - } - if ($type eq 'console'){ - my $menucnt = @items; - my $menu = new Cdk::Scroll ('Title'=>" ", - 'List'=>\@mitems, - 'Height'=> $menucnt+4, - 'Width'=> 26); - # Activate the object. - my ($menuItem) = $menu->activate(); - # Check the results. - undef $menu; - if (!defined $menuItem) { - $data = "Quit"; - } - else { - $data = $items[$menuItem]; - } - } - return($reason,$data); - # end of menu -} - -# FIXME - Is this a placeholder? -sub clearscreen { -} - -# FIXME - Is this a placeholder? -sub pause { - -} - -sub output { - my($left,$top,$msg)=@_; - my @outm; - $outm[0]=$msg; - my $output = new Cdk::Label ('Message' =>\@outm, - 'Ypos'=>$top, 'Xpos'=>$left, 'Box'=>0); - $output->draw(); - return $output; -} - -sub helptext { - my ($text)=@_; - my $helptext = output(1,24,$text); - return $helptext; -} - - -sub titlepanel{ - my ($env,$title,$title2)=@_; - my @header; - @header[0] = fmtstr($env,$title,"L24"); - @header[0] = @header[0].fmtstr($env, - $env->{'branchname'}."-".$env->{'queue'},"C28"); - @header[0] = @header[0].fmtstr($env,$title2,"R24"); - my $label = new Cdk::Label ('Message' =>\@header,'Ypos'=>0,'Xpos'=>0); - $label->draw(); - return $label; - } - -sub msg_yn { - my ($env,$text1,$text2)=@_; - # Create the dialog buttons. - my @buttons = ("Yes", "No"); - my @mesg = ("$text1", "$text2"); - # Create the dialog object. - my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons); - my $resp = $dialog->activate(); - my $response = "Y"; - if ($resp == 1) { - $response = "N"; - } - undef $dialog; - return $response; -} -sub msg_ny { - my ($env,$text1,$text2)=@_; - # Cdk::init(); - # Create the dialog buttons. - my @buttons = ("No", "Yes"); - my @mesg = ("$text1", "$text2"); - # Create the dialog object. - my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons); - my $resp = $dialog->activate(); - my $response = "N"; - if ($resp == 1) { - $response = "Y"; - } - undef $dialog; - return $response; -} - -sub debug_msg { - my ($env,$text)=@_; - if ($env->{'telnet'} eq "Y") { - popupLabel (["Debug $text"]); -# } else { -# print "****DEBUG $text****"; - } - return(); -} - -sub error_msg { - my ($env,$text)=@_; - popupLabel (["Error $text"]); - return(); -} - -sub info_msg { - my ($env,$text)=@_; - popupLabel ([$text]); - return(); -} - -sub endint { - Cdk::end(); -} - - -sub brmenu { - my ($env,$brrecs)=@_; - $env->{'sysarea'}="Menu"; - my $titlebar=titlepanel($env,"Koha","Select branch"); - my @mitems; - my $x = 0; - while (@$brrecs[$x] ne "") { - my $brrec =@$brrecs[$x]; - $mitems[$x]=fmtstr($env,$brrec->{'branchcode'},"L6"); - $mitems[$x]=$mitems[$x].fmtstr($env,$brrec->{'branchname'},"L20"); - $x++; - } - my $menu = new Cdk::Scroll ('Title'=>" ", - 'List'=>\@mitems, - 'Height'=> 16, - 'Width'=> 30); - # Activate the object. - my ($menuItem) = $menu->activate(); - # Check the results. - if (defined $menuItem) { - my $brrec = @$brrecs[$menuItem]; - $env->{'branchcode'} = $brrec->{'branchcode'}; - $env->{'branchname'} = $brrec->{'branchname'}; - } - undef $menu; - undef $titlebar; - return(); - -} - -sub prmenu { - my ($env,$prrecs)=@_; - $env->{'sysarea'}="Menu"; - my $titlebar=titlepanel($env,"Koha","Select printer"); - my @mitems; - my $x = 0; - while (@$prrecs[$x] ne "") { - my $prrec =@$prrecs[$x]; - $mitems[$x]=fmtstr($env,$prrec->{'printername'},"L20"); - $x++; - } - my $menu = new Cdk::Scroll ('Title'=>" ", - 'List'=>\@mitems, - 'Height'=> 16, - 'Width'=> 30); - # Activate the object. - my ($menuItem) = $menu->activate(); - undef $menu; - undef $titlebar; - # Check the results. - if (defined $menuItem) { - my $prrec = @$prrecs[$menuItem]; - $env->{'queue'} = $prrec->{'printqueue'}; - $env->{'printtype'} = $prrec->{'printtype'}; - } - return(); - -} - - -sub borrower_dialog { - my ($env)=@_; - my $result; - my $borrower; - my $book; - my @coltitles = ("Borrower","Item"); - my @rowtitles = (" "); - my @coltypes = ("UMIXED","UMIXED"); - my @colwidths = (12,12); - my $matrix = new Cdk::Matrix ( - 'ColTitles'=> \@coltitles, - 'RowTitles'=> \@rowtitles, - 'ColWidths'=> \@colwidths, - 'ColTypes'=> \@coltypes, - 'Vrows'=> 1, - 'Vcols'=> 2); - borrbind($env,$matrix); - #$matrix->draw(); - my ($rows,$cols,$info) = $matrix->activate(); - if ((!defined $rows) && ($info->[0][0] eq "")) { - $result = "Circ"; - } else { - $borrower = $info->[0][0]; - $book = $info->[0][1]; - } - $matrix->erase(); - $matrix->unregister(); - undef $matrix; - Cdk::refreshCdkScreen(); - return ($borrower,$result,$book); -} - -sub selborrower { - my ($env,$dbh,$borrows,$bornums)=@_; - my $result; - my $label = "Select a borrower"; - my $scroll = new Cdk::Scroll ('Title'=>$label, - 'List'=>\@$borrows,'Height'=>15,'Width'=>60); - my $returnValue = $scroll->activate (); - if (!defined $returnValue) { - #$result = "Circ"; - } else { - $result = substr(@$borrows[$returnValue],0,9); - } - $scroll->erase(); - #$scroll->unregister(); - undef $scroll; - Cdk::refreshCdkScreen(); - return $result; -} - -sub issuewindow { - my ($env,$title,$dbh,$items1,$items2,$borrower,$amountowing,$odues)=@_; - my @functs=("Due Date","Renewals","Payments","Print","Current","Previous"); - my $titlepanel = titlepanel($env,"Issues","Issue an Item"); - my $scroll2 = new Cdk::Scroll ('Title'=>"Previous Issues", - 'List'=>\@$items1,'Height'=> 8,'Width'=>78,'Ypos'=>18); - my $scroll1 = new Cdk::Scroll ('Title'=>"Current Issues", - 'List'=>\@$items2,'Height'=> 8,'Width'=>78,'Ypos'=>9); - my $funcmenu = new Cdk::Scroll ('Title'=>"", - 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>28); - my $loanlength = new Cdk::Entry('Label'=>"Due Date: ", - 'Max'=>"30",'Width'=>"11", - 'Xpos'=>0,'Ypos'=>5,'Type'=>"UMIXED"); - my $x = 0; - while ($x < length($env->{'loanlength'})) { - $loanlength->inject('Input'=>substr($env->{'loanlength'},$x,1)); - $x++; - } - my $borrbox = borrowerbox($env,$borrower,$amountowing); - my $entryBox = new Cdk::Entry('Label'=>"Item Barcode: ", - 'Max'=>"11",'Width'=>"11", - 'Xpos'=>"0",'Ypos'=>3,'Type'=>"UMIXED"); - $scroll2->draw(); - $scroll1->draw(); - $funcmenu->draw(); - $loanlength->draw(); - $borrbox->draw(); - #$env->{'loanlength'} = ""; - #debug_msg($env,"clear len"); - my $x; - my $barcode; - $entryBox->preProcess ('Function' => - sub{prebook(@_,$env,$dbh,$funcmenu,$entryBox,$loanlength, - $scroll1,$scroll2,$borrower,$amountowing,$odues);}); - $barcode = $entryBox->activate(); - my $reason; - if (!defined $barcode) { - $reason="Finished user" - } - $borrbox->erase(); - $entryBox->erase(); - $scroll2->erase(); - $scroll1->erase(); - $funcmenu->erase(); - $loanlength->erase(); - undef $titlepanel; - undef $borrbox; - undef $entryBox; - undef $scroll2; - undef $scroll1; - undef $funcmenu; - undef $loanlength; - Cdk::refreshCdkScreen(); - #debug_msg($env,"exiting"); - return $barcode,$reason; -} -sub actfmenu { - my ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1, - $scroll2,$borrower,$amountowing,$odues) = @_; - my $funct = $funcmenu->activate(); - if (!defined $funct) { - } elsif ($funct == 0 ) { - actloanlength ($env,$entryBox,$loanlength,$scroll1,$scroll2); - } elsif ($funct == 1 ) { - $entryBox->erase(); - $scroll1->erase(); - $scroll2->erase(); - $loanlength->erase(); - $funcmenu->erase(); - #debug_msg($env,""); - C4::Circulation::Renewals::bulkrenew($env,$dbh, - $borrower->{'borrowernumber'},$amountowing,$borrower,$odues); - } elsif ($funct == 2 ) { - $entryBox->erase(); - $scroll1->erase(); - $scroll2->erase(); - $loanlength->erase(); - $funcmenu->erase(); - C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'}, - $amountowing,$borrower,$odues); - } elsif ($funct == 3 ) { - C4::Circulation::Borrissues::printallissues ($env,$borrower); - } elsif ($funct == 4 ) { - actscroll1 ($env,$entryBox,$loanlength,$scroll1,$scroll2); - } elsif ($funct == 5 ) { - actscroll2 ($env,$entryBox,$loanlength,$scroll1,$scroll2); - } - Cdk::refreshCdkScreen(); - $entryBox->unregister(); - $entryBox->register(); - return -} -sub actscroll1 { - my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_; - $scroll1->activate(); - return 1; -} -sub actscroll2 { - my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_; - $scroll2->activate(); - return 1; -} -sub actloanlength { - my ($env,$entryBox,$loanlength,$scroll1,$scroll2) = @_; - my $validdate = "N"; - while ($validdate eq "N") { - my $loanlength = $loanlength->activate(); - if (!defined $loanlength) { - $env->{'loanlength'} = ""; - $validdate = "Y"; - } elsif ($loanlength eq "") { - $env->{'loanlength'} = ""; - $validdate = "Y"; - } else { - my $date = ParseDate($loanlength); - if ( $date > ParseDate('today')){ - $validdate="Y"; - my $fdate = substr($date,0,4).'-'.substr($date,4,2).'-'.substr($date,6,2); - #debug_msg($env,"$date $fdate"); - $env->{'loanlength'} = $fdate; - } else { - error_msg($env,"Invalid date"); - } - } - } - return; -} - -sub prebook { - my ($input,$env,$dbh,$funcmenu,$entryBox,$loanlength, - $scroll1,$scroll2,$borrower,$amountowing,$odues)= @_; - # FIXME - $key_tab is undefined - if ($input eq $key_tab) { - actfmenu ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1, - $scroll2,$borrower,$amountowing,$odues); - return 0; - } - return 1; -} - -sub borrowerbox { - my ($env,$borrower,$amountowing,$odues) = @_; - my @borrinfo; - my $amountowing = fmtdec($env,$amountowing,"42"); - my $line = "$borrower->{'cardnumber'} "; - $line = $line."$borrower->{'surname'}, "; - $line = $line."$borrower->{'title'} $borrower->{'firstname'}"; - $borrinfo[0]=$line; - $line = "$borrower->{'streetaddress'}, $borrower->{'city'}"; - $borrinfo[1]=$line; - $line = "$borrower->{'categorycode'}"; - if ($borrower->{'gonenoaddress'} == 1) { - $line = $line." GNA"; - } - if ($borrower->{'lost'} == 1) { - $line = $line." LOST"; - } - if ($odues > 0) { - $line = $line." ODUE"; - } - if ($borrower->{'borrowernotes'} ne "" ) { - $line = $line." NOTES"; - } - if ($amountowing > 0) { - $line = $line." \$$amountowing"; - } - $borrinfo[2]=$line; - if ($borrower->{'borrowernotes'} ne "" ) { - $borrinfo[3]=substr($borrower->{'borrowernotes'},0,40); - } - my $borrbox = new Cdk::Label ('Message' =>\@borrinfo, - 'Ypos'=>3, 'Xpos'=>"RIGHT"); - return $borrbox; -} - -sub returnwindow { - my ($env,$title,$item,$items,$borrower,$amountowing,$odues,$dbh,$resp)=@_; - #debug_msg($env,$borrower); - my $titlepanel = titlepanel($env,"Returns","Scan Item"); - my @functs=("Payments","Renewal"); - my $funcmenu = new Cdk::Scroll ('Title'=>"", - 'List'=>\@functs,'Height'=>5,'Width'=>12,'Ypos'=>3,'Xpos'=>16); - my $returnlist = new Cdk::Scroll ('Title'=>"Items Returned", - 'List'=>\@$items,'Height'=> 12,'Width'=>74,'Ypos'=>10,'Xpos'=>1); - $returnlist->draw(); - $funcmenu->draw(); - my $borrbox; - if ($borrower->{'cardnumber'} ne "") { - $borrbox = borrowerbox($env,$borrower,$amountowing); - $borrbox->draw(); - } else { - if ($resp ne "") { - my @text; - @text[0] = $resp; - $borrbox = new Cdk::Label ('Message' =>\@text, 'Ypos'=>3, 'Xpos'=>"RIGHT"); - $borrbox->draw(); - } - } - my $bookentry = new Cdk::Entry('Label'=>" ", - 'Max'=>"11",'Width'=>"11", - 'Xpos'=>"2",'Ypos'=>"3",'Title'=>"Item Barcode", - 'Type'=>"UMIXED"); - $bookentry->preProcess ('Function' =>sub{preretbook(@_,$env,$dbh, - $funcmenu,$bookentry,$borrower,$amountowing, - $odues,$titlepanel,$borrbox,$returnlist);}); - my $barcode = $bookentry->activate(); - my $reason; - if (!defined $barcode) { - $barcode=""; - $reason="Circ"; - $bookentry->erase(); - $funcmenu->erase(); - if ($borrbox ne "") {$borrbox->erase();} - $returnlist->erase(); - } else { - $reason=""; - } - undef $bookentry; - undef $funcmenu; - undef $borrbox; - undef $returnlist; - undef $titlepanel; - return($reason,$barcode); - } - -sub preretbook { - my ($input,$env,$dbh,$funcmenu,$bookentry,$borrower, - $amountowing,$odues,$titlepanel,$borrbox,$returnlist)=@_; - if ($input eq $key_tab) { - actrfmenu($env,$dbh,$funcmenu,$bookentry,$borrower, - $amountowing,$odues,$titlepanel,$borrbox,$returnlist); - return 0; - } - return 1; - } - -sub actrfmenu { - my ($env,$dbh,$funcmenu,$bookentry,$borrower, - $amountowing,$odues,$titlepanel,$borrbox,$returnlist)= @_; - my $funct = $funcmenu->activate(); - #debug_msg($env,"funtion $funct"); - if (!defined $funct) { - } elsif ($funct == 1 ) { - if ($borrower->{'borrowernumber'} ne "") { - $funcmenu->erase(); - $bookentry->erase(); - $titlepanel->erase(); - $borrbox->erase(); - $returnlist->erase(); - C4::Circulation::Renewals::bulkrenew($env,$dbh, - $borrower->{'borrowernumber'},$amountowing,$borrower,$odues); - Cdk::refreshCdkScreen(); - $funcmenu->draw(); - $bookentry->draw(); - $titlepanel->draw(); - $borrbox->draw(); - $returnlist->draw(); - } - } elsif ($funct == 0 ) { - if ($borrower->{'borrowernumber'} ne "") { - $funcmenu->erase(); - $bookentry->erase(); - $titlepanel->erase(); - $borrbox->erase(); - $returnlist->erase(); - C4::Accounts::reconcileaccount($env,$dbh,$borrower->{'borrowernumber'}, - $amountowing,$borrower,$odues); - $funcmenu->draw(); - $bookentry->draw(); - $titlepanel->draw(); - $borrbox->draw(); - $returnlist->draw(); - #Cdk::refreshCdkScreen(); - } - } -} - -sub act { - my ($obj) = @_; - my $ans = $obj->activate(); - return $ans; - } - -sub borrbind { - my ($env,$entry) = @_; - my $lastborr = $env->{"bcard"}; - $entry->preProcess ('Function' => sub {preborr (@_, $env,$entry);}); -} - -sub preborr { - my ($input,$env, $entry) = @_; - if ($env->{"bcard"} ne "") { -# error_msg($env,"hi there"); - # FIXME - $lastval is undefined - if ($input eq $lastval) { -# error_msg($env,"its a ctrl-r"); - borfill($env,$entry); - return 0; - } - } - return 1; -} - - -sub borfill { - my ($env,$entry) = @_; - error_msg($env,"in borfill: $env->{'bcard'}"); - my $lastborr = $env->{"bcard"}; - my $i = 1; - $entry->inject('Input'=>$lastborr); - while ($i < 9) { -# my $temp=substr($lastborr,$i,1); -# $entry->inject('Input'=>$temp); - $i++; - } - -} - -END { } # module clean-up code here (global destructor) - - -- 2.39.5