Browse Source

work on renewals

master
olwen 22 years ago
parent
commit
48a701869b
  1. 28
      C4/Circulation.pm
  2. 56
      C4/Circulation/Returns.pm
  3. 12
      C4/Interface.pm

28
C4/Circulation.pm

@ -58,21 +58,19 @@ sub Start_circ{
#connect to database
#start interface
&startint($env,'Circulation');
my ($reason,$data)=menu('console','Circulation',('Issues','Returns','Borrower Enquiries'));
my $donext;
if ($data eq 'Issues'){
$donext=Issue($env);
} elsif ($data eq 'Returns') {
$donext=Returns($env);
} else {
&endint($env);
}
debug_msg($env,"donext - $donext");
if ($donext eq 'Circ'){
Start_circ($env);
} else {
&endint($env);
my $donext = 'Circ';
while ($donext eq 'Circ') {
my ($reason,$data)=menu('console','Circulation',('Issues','Returns','Borrower Enquiries'));
if ($data eq 'Issues') {
$donext=Issue($env);
} elsif ($data eq 'Returns') {
$donext=Returns($env);
} elsif ($data eq 'Quit') {
$donext = $data;
}
debug_msg($env,"donext - $donext");
}
&endint($env)
}
sub pastitems{
@ -89,7 +87,7 @@ sub pastitems{
my @items2;
$items[0]=" "x40;
$items2[0]=" "x36;
while (my $data=$sth->fetchrow_hashref){
while (my $data=$sth->fetchrow_hashref) {
my $line = "$data->{'date_due'} $data->{'title'}";
$items[$i]=fmtstr($env,$line,"L40");
$i++;

56
C4/Circulation/Returns.pm

@ -56,8 +56,61 @@ my $priv_func = sub {
sub Returns {
my ($env)=@_;
returnwindow($env);
my $dbh=&C4Connect;
my @items;
$items[0]="."x50;
my $itcnt=0;
my $reason;
my $item;
my $reason;
my $borrower;
my $itemno;
my $itemrec;
my $bornum;
until (($reason eq "Circ") || ($reason eq "Quit") {
($reason,$item) = returnwindow($env,"Enter Returns",\@items);
if (($reason ne "Circ") || ($reason eq "Quit")) {
($reason,$bornum,$borrower,$itemno,$itemrec) = checkissue($env,$dbh,$item);
if (($reason ne "") && ($reason ne "Circ") && ($reason ne "Quit")) {
debug_msg($env,$reason);
}
}
}
$dbh->disconnect;
return($reason);
}
sub checkissue {
my ($env,$dbh, $item) = @_;
my $reason='Circ';
my $bornum;
my $borrower;
my $itemno;
my $itemrec;
my $query = "select * from items where barcode = '$item'";
my $sth=$dbh->prepare($query);
$sth->execute;
if ($itemrec=$sth->fetchrow_hashref) {
$sth->finish;
$query = "select * from issues where
(itemnumber='$itemrec->{'itemnumber'}') and (returndate is null)";
my $sth=$dbh->prepare($query);
$sth->execute;
if (my $issuerec=$sth->fetchrow_hashref) {
$sth->finish;
$reason = "Issued to $issuerec->{'borrowernumber'}";
} else {
$sth->finish;
$reason = "Item not issued";
}
} else {
$sth->finish;
$reason = "Item not found";
}
return ($reason,$bornum,$borrower,$itemno,$itemrec);
# end checkissue
}
sub returnrecord {
# mark items as returned
my ($env,$dbh,$bornum,$itemno)=@_;
@ -67,7 +120,6 @@ sub returnrecord {
debug_msg($env,"before return");
my $query = "update issues set returndate = '$dateret', branchcode ='$env->{'branchcode'}' where (borrowernumber = '$bornum') and (itemnumber = '$itemno')
and (returndate is null)";
#output(1,10,$query);
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;

12
C4/Interface.pm

@ -76,7 +76,7 @@ sub menu {
my ($type,$title,@items)=@_;
if ($type eq 'console'){
# my ($reason,$data)=list($title,@items);
my ($reason,$data)=menu2($title,@items);
my ($reason,$data)=menu2($title,@items);
return($reason,$data);
# end of menu
@ -199,6 +199,11 @@ sub returnwindow {
my $fee = Newt::Label(fmtdec($env,$amountowing,"$32"));
my $l1 = Newt::Label("Returned");
my $li1 = Newt::Listbox(15,NEWT_FLAG_SCROLL | NEWT_FLAG_BORDER);
my $i = 0;
while ($items->[$i]) {
$li1->Add($items->[$i]);
$i++;
}
$panel->Add(0,0,$entry,NEWT_ANCHOR_TOP);
$panel->Add(0,1,$accchk,NEWT_ANCHOR_TOP);
$panel->Add(1,0,$la1);
@ -212,15 +217,12 @@ sub returnwindow {
if ($data eq NEWT_KEY_F11) {
$reason="Circ";
}
if ($data eq NEWT_KEY_F10) {
$reason="Finished issues";
}
if ($data eq NEWT_KEY_F12){
$reason="Quit"
}
}
my $stuff=$entry->Get();
return($stuff,$reason);
return($reason,$stuff);
}

Loading…
Cancel
Save