Browse Source

changes to issue logic

master
olwen 23 years ago
parent
commit
f99ea625ec
  1. 21
      C4/Circulation.pm
  2. 56
      C4/Circulation/Issues.pm
  3. 49
      C4/Interface.pm
  4. 2
      testissue.pl

21
C4/Circulation.pm

@ -125,6 +125,7 @@ sub previousissue {
return($borrower->{'borrowernumber'});
}
sub checkreserve{
# Check for reserves for biblio
# does not look at constraints yet
@ -144,7 +145,21 @@ sub checkreserve{
}
sub checkwaiting{
# check for reserves waiting
my ($env,$dbh,$bornum)=@_;
my @itemswaiting="";
my $query = "select * from reserves
where (borrowernumber = '$bornum')
and (reserves.found='W')";
if ($env->{'debug'} > 4) {
output(1,20,$query);
}
my $sth = $dbh->prepare($query);
$sth->execute();
if (my $data=$sth->fetchrow_hashref) {
push @itemswaiting,$data->{'itemnumber'};
}
return (\@itemswaiting);
}
sub scanbook {
@ -159,8 +174,8 @@ sub scanbook {
sub scanborrower {
my ($env,$interface)=@_;
#scan barcode
# my $number='V00126643';
my ($number,$reason)=&dialog("Borrower Barcode:");
# my $number='V00126643';
my ($number,$reason)=&Borr_dialog($env);
$number=uc $number;
return ($number,$reason);
}

56
C4/Circulation/Issues.pm

@ -61,25 +61,35 @@ sub Issue {
#clear help
helptext('');
clearscreen();
#get borrowerbarcode from scanner
my ($borcode,$reason)=&scanborrower();
# output(1,1,$borcode);
my $sth=$dbh->prepare("Select * from borrowers where cardnumber='$borcode'");
$sth->execute;
my $borrower=$sth->fetchrow_hashref;
my $bornum=$borrower->{'borrowernumber'};
$sth->finish;
while ($bornum eq ''){
#If borrower not found enter loop until borrower is found
output(1,1,"Borrower not found, please rescan or reenter borrower code");
($borcode,$reason)=&scanborrower();
$sth=$dbh->prepare("Select * from borrowers where cardnumber='$borcode'");
$sth->execute;
$borrower=$sth->fetchrow_hashref;
$bornum=$borrower->{'borrowernumber'};
$sth->finish;
}
my $bornum = "";
my $borrower = "";
my $sth = "";
while ($bornum eq '') {
#get borrowerbarcode from scanner
my ($borcode,$reason)=&scanborrower();
if ($borcode ne '') {
# output(1,1,$borcode);
$sth=$dbh->prepare("Select * from borrowers where cardnumber='$borcode'");
$sth->execute;
$borrower=$sth->fetchrow_hashref;
$bornum=$borrower->{'borrowernumber'};
$sth->finish;
if ($bornum eq '') {
output(1,1,"Borrower not found, please rescan or reenter borrower code");
}
}
}
# while ($bornum eq ''){
# #If borrower not found enter loop until borrower is found
# output(1,1,"Borrower not found, please rescan or reenter borrower code");
# ($borcode,$reason)=&scanborrower();
# $sth=$dbh->prepare("Select * from borrowers where cardnumber='$borcode'");
# $sth->execute;
# $borrower=$sth->fetchrow_hashref;
# $bornum=$borrower->{'borrowernumber'};
# $sth->finish;
# }
my $borrowers=join(' ',($borrower->{'title'},$borrower->{'firstname'},
$borrower->{'surname'}));
output(1,1,$borrowers);
@ -107,7 +117,7 @@ sub Issue {
#check amountowing
my $amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
#check if borrower has any items waiting
&checkwaiting;
my $itemswaiting = &checkwaiting($env,$dbh,$bornum);
#deal with any money still owing
# output(30,1,$amount);
if ($amount > 0){
@ -133,6 +143,7 @@ sub Issue {
}
}
sub processitems {
#process a users items
# clearscreen();
@ -209,8 +220,9 @@ sub updateissues{
}
$sth->finish;
# this ought to also insert the branch, but doen't do so yet.
$query = "Insert into issues (borrowernumber,itemnumber,date_due)
values ($bornum,$itemno,datetime('now'::abstime)+$loanlength)";
$query = "Insert into issues (borrowernumber,itemnumber,date_due,branchcode)
values
($bornum,$itemno,datetime('now'::abstime)+$loanlength,$env->{'branchcode'})";
my $sth=$dbh->prepare($query);
# print "\n$query\n";
$sth->execute;

49
C4/Interface.pm

@ -4,7 +4,7 @@ package C4::Interface; #asummes C4/Interface
use strict;
use Newt qw(NEWT_ANCHOR_LEFT NEWT_FLAG_SCROLL NEWT_KEY_F11 NEWT_KEY_F10
NEWT_KEY_F1 NEWT_KEY_F2 NEWT_KEY_F4 NEWT_KEY_F5 NEWT_KEY_F12
NEWT_KEY_F1 NEWT_KEY_F2 NEWT_KEY_F4 NEWT_KEY_F5 NEWT_KEY_F9 NEWT_KEY_F12
NEWT_FLAG_RETURNEXIT NEWT_EXIT_HOTKEY NEWT_FLAG_WRAP NEWT_FLAG_MULTIPLE);
#use C4::Circulation;
@ -17,7 +17,7 @@ $VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&dialog &startint &endint &output &clearscreen &pause &helptext
&textbox &menu &issuewindow &msg_yn);
&textbox &menu &issuewindow &msg_yn &borrower_dialog);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -124,14 +124,14 @@ sub list {
}
sub issuewindow {
my ($env,$title,$items1,$items2,$borrower,$name)=@_;
my ($env,$title,$items1,$items2,$/borrower,$name)=@_;
my $entry=Newt::Entry(20,NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
my $label=Newt::Label("book");
my $panel = Newt::Panel(5, 5, $title);
my $l1=Newt::Label("Previous");
my $l2=Newt::Label("Current");
my $l3=Newt::Label("Borrower Info");
my $li = Newt::Listbox(5,NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE);
my $panel = Newt::Panel(50,25, $title,5,5);
my $l1 = Newt::Label("Previous");
my $l2 = Newt::Label("Current");
my $l3 = Newt::Label("Borrower Info");
my $li = Newt::Listbox(5,NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE);
my $li2 = Newt::Listbox(5,NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE);
my $li3 = Newt::Listbox(5,NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE);
$li->Add($items1->[0],$items1->[1]);
@ -185,7 +185,38 @@ sub dialog {
$reason="Finished issues";
}
if ($data eq NEWT_KEY_F12){
$reason="Quit"
$reason="Quit";
}
}
# Newt::Finished();
my $stuff=$entry->Get();
return($stuff,$reason);
}
sub borrower_dialog {
my ($env)=@_;
my $name = "Borrower";
my $entry=Newt::Entry(20,NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
my $label=Newt::Label($name);
my $panel1=Newt::Panel(2,4,$name);
$panel1->AddHotKey(NEWT_KEY_F11);
$panel1->AddHotKey(NEWT_KEY_F10);
$panel1->AddHotKey(NEWT_KEY_F9);
$panel1->Add(0,0,$label,NEWT_ANCHOR_LEFT);
$panel1->Add(1,0,$entry,NEWT_ANCHOR_LEFT);
my ($reason,$data)=$panel1->Run();
if ($reason eq NEWT_EXIT_HOTKEY) {
if ($data eq NEWT_KEY_F11) {
$reason="Finished user";
}
if ($data eq NEWT_KEY_F10) {
$reason="Finished issues";
}
if ($data eq NEWT_KEY_F12){
$reason="Quit";
}
if ($data eq NEWT_KEY_F9) {
}
}
# Newt::Finished();

2
testissue.pl

@ -14,7 +14,7 @@ use C4::Circulation;
# tempuser - temporary user
my %env = (
branchcode => "", usercode => "", proccode => "lgon", borrowernumber => "",
logintime => "", lasttime => "", tempuser => ""
logintime => "", lasttime => "", tempuser => "", debug => "9"
);
Login(\%env);
Start_circ(\%env);

Loading…
Cancel
Save