Browse Source

Work on Circulation

master
olwen 22 years ago
parent
commit
1daf7732d7
  1. 14
      C4/Accounts.pm
  2. 66
      C4/Circulation/Borrower.pm
  3. 12
      C4/Circulation/Main.pm
  4. 7
      C4/Reserves.pm
  5. 2
      C4/Search.pm

14
C4/Accounts.pm

@ -64,17 +64,17 @@ sub checkaccount {
$sth->execute;
my $total=0;
while (my $data=$sth->fetchrow_hashref){
$total=$total+$data->{'sum'};
$total=$total+$data->{'sum(amountoutstanding)'};
}
$sth->finish;
# output(1,2,"borrower owes $total");
# output(1,2,"borrower owes $total");
if ($total > 0){
output(1,2,"borrower owes $total");
# output(1,2,"borrower owes $total");
if ($total > 5){
reconcileaccount($env,$dbh,$bornumber,$total);
}
}
# pause();
# pause();
return($total);
}
@ -168,9 +168,13 @@ sub recordpayment{
$usth->finish;
}
# create new line
#$updquery = "insert into accountlines (borrowernumber,
#accountno,date,amount,description,accounttype,amountoutstanding) values
#($bornumber,$nextaccntno,datetime('now'::abstime),0-$data,'Payment,thanks',
#'Pay',0-$amountleft)";
$updquery = "insert into accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornumber,$nextaccntno,datetime('now'::abstime),0-$data,'Payment,thanks',
values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
'Pay',0-$amountleft)";
my $usth = $dbh->prepare($updquery);
$usth->execute;

66
C4/Circulation/Borrower.pm

@ -101,7 +101,6 @@ sub findborrower {
$env->{'bornum'} = $bornum;
$env->{'bcard'} = $borrower->{'cardnumber'};
my $borrowers=join(' ',($borrower->{'title'},$borrower->{'firstname'},$borrower->{'surname'}));
# output(1,1,$borrowers);
$issuesallowed = &checktraps($env,$dbh,$bornum,$borrower);
}
return ($bornum, $issuesallowed,$borrower,$reason);
@ -166,43 +165,31 @@ sub findoneborrower {
sub checktraps {
my ($env,$dbh,$bornum,$borrower) = @_;
my $issuesallowed = "1";
#process borrower traps (could be function)
#check first GNA trap (no address this is the 22nd item in the table)
my @traps_set;
if ($borrower->{'gonenoaddress'} == 1){
push (@traps_set,"GNA");
}
#check if member has a card reported as lost
if ($borrower->{'lost'} ==1){
push (@traps_set,"LOST");
}
#check the notes field if notes exist display them
if ($borrower->{'borrowernotes'} ne ''){
push (@traps_set,"NOTES");
}
#check if borrower has overdue items
#call overdue checker
my $odues = &C4::Circulation::Main::checkoverdues($env,$bornum,$dbh);
if ($odues > 0) {
push (@traps_set,"ODUES");
}
#check amountowing
my $amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
if ($amount > 0) {
push (@traps_set,"FINES");
}
#check if borrower has any items waiting
my $itemswaiting = &C4::Circulation::Main::checkwaiting($env,$dbh,$bornum);
if (@traps_set[0] ne "" ) {
$issuesallowed =
process_traps($env,$dbh,$bornum,$borrower,$amount,$odues,\@traps_set);
my $traps_done;
my $odues;
while ($traps_done ne "DONE") {
my $amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
if ($amount > 0) { push (@traps_set,"FINES");}
if ($borrower->{'gonenoaddress'} == 1){ push (@traps_set,"GNA");}
#check if member has a card reported as lost
if ($borrower->{'lost'} ==1){push (@traps_set,"LOST");}
#check the notes field if notes exist display them
if ($borrower->{'borrowernotes'} ne ''){ push (@traps_set,"NOTES");}
#check if borrower has overdue items
#call overdue checker
my $odues = &C4::Circulation::Main::checkoverdues($env,$bornum,$dbh);
if ($odues > 0) {push (@traps_set,"ODUES");}
#check if borrower has any items waiting
my $itemswaiting = &C4::Circulation::Main::checkwaiting($env,$dbh,$bornum);
if (@traps_set[0] ne "" ) {
$issuesallowed,$traps_done =
process_traps($env,$dbh,$bornum,$borrower,$amount,$odues,\@traps_set);
} else {
$traps_done = "DONE";
}
}
#deal with any money still owing
if ($amount > 0){
&reconcileaccount($env,$dbh,$bornum,$amount,$borrower,$odues);
}
return ($issuesallowed, $odues);
}
@ -215,6 +202,7 @@ sub process_traps {
$traps{'@$traps_set[$x]'} = 1;
$x++;
}
my $traps_done;
my $trapact;
while ($trapact ne "NONE") {
$trapact = &trapscreen($env,$bornum,$borrower,$amount,$traps_set);
@ -222,17 +210,17 @@ sub process_traps {
&reconcileaccount($env,$dbh,$bornum,$amount,$borrower,$odues);
} elsif ($trapact eq "NOTES") {
my $notes = trapsnotes($env,$bornum,$borrower,$amount);
if ($notes ne $borrower->{'borrowernotes'}) {
my $query = "update borrowers set borrowernotes = '$notes'
if ($notes ne $borrower->{'borrowernotes'}) {
my $query = "update borrowers set borrowernotes = '$notes'
where borrowernumber = $bornum";
my $sth = $dbh->prepare($query);
$sth->execute();
$sth->finish();
$borrower->{'borrowernotes'} = $notes;
}
}
}
}
return ($issuesallowed);
return ($issuesallowed,$traps_done);
}

12
C4/Circulation/Main.pm

@ -66,21 +66,9 @@ sub pastitems{
and (returndate is null) order by date_due";
my $sth=$dbh->prepare($query1);
$sth->execute;
#my $sth=$dbh->prepare("Select * from issues,items,biblio,biblioitems
# where (borrowernumber=$bornum
# and (returndate is null)
# and ((issues.itemnumber=items.itemnumber)
# and items.biblionumber=biblio.biblionumber
# and biblioitems.biblioitemnumber=items.biblioitemnumber))
# 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 $data1=$sth->fetchrow_hashref) {
my $data = itemnodata($env,$dbh,$data1->{'itemnumber'}); #C4::Search
my $line = C4::Circulation::Issues::formatitem($env,$data,$data1->{'date_due'},"");

7
C4/Reserves.pm

@ -129,10 +129,9 @@ sub EnterReserves{
if ($biblionumber eq "") {
error_msg($env,"No items found");
} else {
debug_msg($env,"getting items ");
my @items = GetItems($env,$biblionumber);
debug_msg($env,"got items ");
debug_msg($env,"getting items $biblionumber");
my @items = C4::Search::GetItems($env,$biblionumber);
debug_msg($env,"got items ");
my $cnt_it = @items;
my $dbh = &C4Connect;

2
C4/Search.pm

@ -248,8 +248,10 @@ $results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchnam
sub GetItems {
my ($env,$biblionumber)=@_;
debug_msg($env,"GetItems");
my $dbh = &C4Connect;
my $query = "Select * from biblioitems where (biblionumber = $biblionumber)";
debug_msg($env,$query);
my $sth=$dbh->prepare($query);
$sth->execute;
debug_msg($env,"executed query");

Loading…
Cancel
Save