Browse Source

Adding functions to circulation

master
olwen 22 years ago
parent
commit
56d6d3c46c
  1. 29
      C4/Circulation.pm
  2. 25
      C4/Circulation/Issues.pm
  3. 74
      C4/Circulation/Renewals.pm
  4. 18
      C4/Circulation/Returns.pm
  5. 13
      C4/Interface.pm

29
C4/Circulation.pm

@ -7,6 +7,8 @@ require Exporter;
use DBI;
use C4::Database;
use C4::Circulation::Issues;
use C4::Circulation::Returns;
use C4::Circulation::Renewals;
use C4::Interface;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -74,10 +76,10 @@ 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");
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;
@ -119,12 +121,22 @@ sub previousissue {
$sth->finish;
if ($borrower->{'borrowernumber'} ne ''){
if ($bornum eq $borrower->{'borrowernumber'}){
# output(1,24,"Book is marked as issue to current borrower");
# no need to issue
my ($renewstatus) = &renewcheck($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'})";
# output(1,24,$text);
my $resp = &msg_yn($text,"Return?");
my $resp = &msg_yn($text,"Mark as returned?");
if ($resp == "y") {
&returnrecord($env,$dbh,$bornum,$itemnum);
# can issue
} else {
# can't issue
}
}
}
return($borrower->{'borrowernumber'});
@ -140,7 +152,6 @@ sub checkreserve{
where (items.itemnumber = '$itemnum')
and (items.biblionumber = reserves.biblionumber)
and (reserves.found is null) order by priority";
# print $query;
my $sth = $dbh->prepare($query);
$sth->execute();
if (my $data=$sth->fetchrow_hashref) {
@ -170,7 +181,6 @@ sub checkwaiting{
sub scanbook {
my ($env,$interface)=@_;
#scan barcode
# my $number='L01781778';
my ($number,$reason)=dialog("Book Barcode:");
$number=uc $number;
return ($number,$reason);
@ -179,7 +189,6 @@ sub scanbook {
sub scanborrower {
my ($env,$interface)=@_;
#scan barcode
# my $number='V00126643';
my ($number,$reason,$book)=&borrower_dialog($env);
$number=uc $number;
return ($number,$reason,$book);

25
C4/Circulation/Issues.pm

@ -94,23 +94,13 @@ sub processitems {
my $row=5;
# my $count=$$items;
my $i=0;
# while ($items->[$i]){
# output (1,$row,$items->[$i]);
# $i++;
# $row++;
# }
my ($itemnum,$reason)=issuewindow($env,'Issues',$items,$items2,$borrower,"Borrower barcode");
if ($itemnum ne ""){
debug_msg($env,"borrower $bornum item $itemnum");
my $item = &issueitem($env,$dbh,$itemnum,$bornum,$items);
output(40,$row2,$item->{'title'});
debug_msg($env,"$it2p - $item->{'title'}");
#unshift $items2,substr(($item->{'title'}.(" "x30)),0,30);
$items2->[$it2p]=substr(($item->{'title'}.(" "x30)),0,30);
$row2++;
$it2p++;
}
$dbh->disconnect;
#check to see if more books to process for this user
if ($reason eq 'Finished user'){
@ -129,20 +119,18 @@ sub issueitem{
my ($env,$dbh,$itemnum,$bornum,$items)=@_;
$itemnum=uc $itemnum;
my $canissue = 1;
## my ($itemnum,$reason)=&scanbook();
## my ($itemnum,$reason)=&scanbook();
my $query="Select * from items,biblio where (barcode='$itemnum') and
(items.biblionumber=biblio.biblionumber)";
my $item;
my $sth=$dbh->prepare($query);
$sth->execute;
if ($item=$sth->fetchrow_hashref) {
debug_msg($env,$item->{'title'});
#$items2=(substr($item.(" "x30),0,30));
#$items2->Append(substr($item.(" "x30),0,30));
$sth->finish;
#check if item is restricted
if ($item->{'restricted'} == 1 ){
output(20,1,"whoop whoop restricted");
error_msg($env,"Restricted Item");
#output(20,1,"whoop whoop restricted");
#check borrowers status to take out restricted items
# if borrower allowed {
# $canissue = 1
@ -158,12 +146,11 @@ sub issueitem{
}
if ($canissue == 1) {
#now mark as issued
&debug_msg($env,"Issueing $item->{'itemnumber'} $item->{'biblioitemnumber'} $bornum");
&updateissues($env,$item->{'itemnumber'},$item->{'biblioitemnumber'},$dbh,$bornum)
&UpdateStats($env,$env->{'branchcode'},'issue');
}
} else {
error_msg($env,"$itemnum not found");
error_msg($env,"$itemnum not found - rescan");
}
return($item);
}
@ -184,10 +171,6 @@ sub updateissues{
my $datedue = time + $loanlength;
my @datearr = localtime($datedue);
my $dateduef = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
# this ought to also insert the branch, but doen't do so yet.
# $query = "Insert into issues (borrowernumber,itemnumber, date_due,branchcode)
# values
# ($bornum,$itemno,datetime('now'::abstime) + $loanlength,$env->{'branchcode'})";
$query = "Insert into issues (borrowernumber,itemnumber, date_due,branchcode)
values
($bornum,$itemno,'$dateduef','$env->{'branchcode'}')";

74
C4/Circulation/Renewals.pm

@ -0,0 +1,74 @@
package C4::Circulation; #assumes C4/Circulation/Renewals
#package to deal with Renewals
#written 7/11/99 by olwen@katipo.co.nz
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Accounts;
use C4::Interface;
use C4::Circulation;
use C4::Scan;
use C4::Stats;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&renewstatus $renewbook);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;
sub Return {
}
sub renewstatus {
# check renewal status
my ($env,$dbh,$bornum,$itemno)=@_;
return();
}
sub renewbook {
# mark book as renewed
my ($env,$dbh,$bornum,$itemno)=@_;
return();
}
END { } # module clean-up code here (global destructor)

18
C4/Circulation/Returns.pm

@ -18,7 +18,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&markreturned);
@EXPORT = qw(&returnrecord);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -59,12 +59,18 @@ sub Return {
}
sub markreturned {
# mark items
my ($env,$dbh,$item,$bo)=@_;
sub returnrecord {
# mark items as returned
my ($env,$dbh,$bornum,$itemno)=@_;
my @datearr = localtime(time);
my $dateret = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
my $query = "update issues
set returnwhere
set returndate = $dateret, branchcode = $env->{'branchcode'}
where (borrowernumber = '$bornum') and (itemnumber = '$itemno')
and (returndate is null)";
my $sth = $dbh->prepare($query);
$sth->execute;
return();
}

13
C4/Interface.pm

@ -121,7 +121,7 @@ sub list {
# }
# }
my @stuff=$li->Get();
$data=$stuff[0];
$data=$stuff[0];
return($reason,$data);
}
@ -133,11 +133,8 @@ sub issuewindow {
my $l1 = Newt::Label("Previous");
my $l2 = Newt::Label("Current");
my $l3 = Newt::Label("Borrower Info");
# my $li1 = Newt::Listbox(10,
# NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE | NEWT_FLAG_SCROLL);
my $li1 = Newt::Listbox(10,NEWT_FLAG_SCROLL);
my $li2 = Newt::Listbox(10,
NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE | NEWT_FLAG_SCROLL);
my $li2 = Newt::Listbox(10,NEWT_FLAG_SCROLL);
my $li3 = Newt::Listbox(5, NEWT_FLAG_RETURNEXIT | NEWT_FLAG_MULTIPLE);
my $i = 0;
while ($items1->[$i]) {
@ -260,10 +257,8 @@ sub msg_yn {
$panel1->Add(0,1,$label2,NEWT_ANCHOR_TOP);
$panel1->Add(0,2,$bpanel,NEWT_ANCHOR_TOP);
my ($reason,$data) =$panel1->Run();
debug_msg("","Ybut $ybutt->get()");
debug_msg("","Nbut $nbutt->get()");
return($reason);
my $ans = $data->Tag();
return($ans);
}

Loading…
Cancel
Save