Fixes for flags

This commit is contained in:
olwen 2000-01-18 04:41:59 +00:00
parent 3c781b8693
commit cca628a0f2
5 changed files with 88 additions and 49 deletions

View file

@ -69,10 +69,9 @@ sub Start_circ{
my $data;
while ($donext ne 'Quit') {
if ($donext eq "Circ") {
clearscreen();
#
#($reason,$data) = menu($env,'console','Circulation',
# ('Issues','Returns','Borrower Enquiries','Reserves','Log In'));
#&startint($env,"Menu");
($reason,$data) = menu($env,'console','Circulation',
('Issues','Returns','Select Branch','Select Printer'));
} else {
@ -94,7 +93,7 @@ sub Start_circ{
$donext = $data;
}
}
&endint($env)
#&endint($env)
}

View file

@ -184,7 +184,6 @@ sub checktraps {
my $amount;
while ($traps_done ne "DONE") {
my @traps_set;
#debug_msg($env,"entering traps");
$amount=checkaccount($env,$bornum,$dbh); #from C4::Accounts
if ($amount > 0) { push (@traps_set,"CHARGES");}
if ($borrower->{'gonenoaddress'} == 1){ push (@traps_set,"GNA");}
@ -201,15 +200,13 @@ sub checktraps {
&C4::Circulation::Main::checkwaiting($env,$dbh,$bornum);
if ($nowaiting > 0) { push (@traps_set,"WAITING"); }
if (@traps_set[0] ne "" ) {
$issuesallowed,$traps_done =
process_traps($env,$dbh,$bornum,$borrower,
$amount,$odues,\@traps_set,$itemswaiting);
#debug_msg($env,"returned issuesallowed $env->{'IssuesAllowed'}");
($issuesallowed,$traps_done,$amount,$odues) =
process_traps($env,$dbh,$bornum,$borrower,
$amount,$odues,\@traps_set,$itemswaiting);
} else {
$traps_done = "DONE";
$traps_done = "DONE";
}
}
#debug_msg($env,"returning issuesallowed $env->{'IssuesAllowed'}");
return ($issuesallowed, $odues,$amount);
}
@ -220,31 +217,73 @@ sub process_traps {
my %traps;
while (@$traps_set[$x] ne "") {
$traps{@$traps_set[$x]} = 1;
#debug_msg($env,"set @$traps_set[$x]");
$x++;
}
my $traps_done;
my $trapact;
my $issues;
while ($trapact ne "NONE") {
$trapact = &trapscreen($env,$bornum,$borrower,$amount,$traps_set);
if ($trapact eq "CHARGES") {
&reconcileaccount($env,$dbh,$bornum,$amount,$borrower,$odues);
} elsif ($trapact eq "WAITING") {
reserveslist($env,$borrower,$amount,$odues,$waiting);
} elsif ($trapact eq "ODUES") {
&bulkrenew($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'
where borrowernumber = $bornum";
my $sth = $dbh->prepare($query);
$sth->execute();
$sth->finish();
$borrower->{'borrowernotes'} = $notes;
}
}
$traps_done = "DONE";
$trapact = &trapscreen($env,$bornum,$borrower,$amount,$traps_set);
if ($trapact eq "CHARGES") {
&reconcileaccount($env,$dbh,$bornum,$amount,$borrower,$odues);
($odues,$issues,$amount)=borrdata2($env,$bornum);
if ($amount <= 0) {
$traps{'CHARGES'} = 0;
my @newtraps;
$x =0;
while ($traps_set->[$x] ne "") {
if ($traps_set->[$x] ne "CHARGES") {
push @newtraps,$traps_set->[$x];
}
$x++;
}
$traps_set = \@newtraps;
}
} elsif ($trapact eq "WAITING") {
reserveslist($env,$borrower,$amount,$odues,$waiting);
} elsif ($trapact eq "ODUES") {
&bulkrenew($env,$dbh,$bornum,$amount,$borrower,$odues);
($odues,$issues,$amount)=borrdata2($env,$bornum);
if ($odues == 0) {
$traps{'ODUES'} = 0;
my @newtraps;
$x =0;
while ($traps_set->[$x] ne "") {
if ($traps_set->[$x] ne "ODUES") {
push @newtraps,$traps_set->[$x];
}
$x++;
}
$traps_set = \@newtraps;
}
} elsif ($trapact eq "NOTES") {
my $notes = trapsnotes($env,$bornum,$borrower,$amount);
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;
}
if ($notes eq "") {
$traps{'NOTES'} = 0;
my @newtraps;
$x =0;
while ($traps_set->[$x] ne "") {
if ($traps_set->[$x] ne "NOTES") {
push @newtraps,$traps_set->[$x];
}
$x++;
}
$traps_set = \@newtraps;
}
}
my $notr = @$traps_set;
if ($notr == 0) {
$trapact = "NONE";
}
$traps_done = "DONE";
}
if ($traps{'GNA'} eq 1 ) {
$issuesallowed=0;
@ -256,7 +295,7 @@ sub process_traps {
$issuesallowed=0;
}
}
return ($issuesallowed,$traps_done);
return ($issuesallowed,$traps_done,$amount,$odues);
} # end of process_traps
sub Borenq {

View file

@ -97,7 +97,6 @@ sub renewbook {
# mark book as renewed
my ($env,$dbh,$bornum,$itemno,$datedue)=@_;
if ($datedue eq "" ) {
#debug_msg($env, "getting date");
my $loanlength=21;
my $query= "Select * from biblioitems,items,itemtypes
where (items.itemnumber = '$itemno')
@ -115,6 +114,8 @@ sub renewbook {
my @datearr = localtime($datedu);
$datedue = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
}
my @date = split("-",$datedue);
my $odatedue = (@date[2]+0)."-".(@date[1]+0)."-".@date[0];
my $issquery = "select * from issues where borrowernumber='$bornum' and
itemnumber='$itemno' and returndate is null";
my $sth=$dbh->prepare($issquery);
@ -122,7 +123,6 @@ sub renewbook {
my $issuedata=$sth->fetchrow_hashref;
$sth->finish;
my $renews = $issuedata->{'renewals'} +1;
#debug_msg($env,"renewing $datedue");
my $updquery = "update issues
set date_due = '$datedue', renewals = '$renews'
where borrowernumber='$bornum' and
@ -130,7 +130,7 @@ sub renewbook {
my $sth=$dbh->prepare($updquery);
$sth->execute;
$sth->finish;
return();
return($odatedue);
}
sub bulkrenew {
@ -146,9 +146,11 @@ sub bulkrenew {
my @barcodes;
while (my $issrec = $sth->fetchrow_hashref) {
my $itemdata = C4::Search::itemnodata($env,$dbh,$issrec->{'itemnumber'});
my $line = $issrec->{'date_due'}." ";
my $line = $line.fmtdec($env,$issrec->{'renewals'},"20")." ";
my $line = $line.$itemdata->{'barcode'}." ".$itemdata->{'title'};
my @date = split("-",$issrec->{'date_due'});
#my $line = $issrec->{'date_due'}." ";
my $line = @date[2]."-".@date[1]."-".@date[0]." ";
$line = $line.fmtdec($env,$issrec->{'renewals'},"20")." ";
$line = $line.$itemdata->{'barcode'}." ".$itemdata->{'title'};
$items[$x] = $line;
#debug_msg($env,$line);
$issues[$x] = $issrec;
@ -170,7 +172,6 @@ sub bulkrenew {
my $y = 0;
my @renew_errors = "";
while ($x < $isscnt) {
if (@$renews[$x] == 1) {
my $issrec = $issues[$x];
renewbook($env,$dbh,$issrec->{'borrowernumber'},$issrec->{'itemnumber'},"");
@ -178,15 +179,5 @@ sub bulkrenew {
$x++;
}
$sth->finish();
#if ($barcodes[0] ne "") {
# my $errmsg = join(@barcodes,",");
# if ($barcodes[1] eq "") {
# $errmsg = $errmsg." has";
# } else {
# $errmsg = $errmsg." have";
# }
# $errmsg = $errmsg." been renewed before";
# C4::InterfaceCDK::error_msg($env,$errmsg);
#}
}
END { } # module clean-up code here (global destructor)

View file

@ -53,7 +53,7 @@ my $priv_func = sub {
sub C4Connect {
my $dbname="c4";
# my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", "chris", "");
my $database='koha2';
my $database='c4test';
my $hostname='localhost';
my $user='hdl';
my $pass='testing';

View file

@ -90,6 +90,16 @@ sub trapsnotes {
my $notes = $notesbox->activate();
if (!defined $notes) {
$notes = $borrower->{'borrowernotes'};
} else {
while (substr($notes,0,1) eq " ") {
my $temp;
if (length($notes) == 1) {
$temp = "";
} else {
$temp = substr($notes,1,length($notes)-1);
}
$notes = $temp;
}
}
undef $notesbox;
undef $borpanel;