From ab39e57393702fd915a26eebb30d179af5817b85 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 18 Aug 2004 15:52:14 +0000 Subject: [PATCH] fixes in circulation module --- C4/Circulation/Circ2.pm | 168 ++++++++---------- circ/circulation.pl | 105 +---------- .../default/en/circ/circulation.tmpl | 14 +- 3 files changed, 88 insertions(+), 199 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index 71ed467d71..9be5d1c5df 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -308,14 +308,6 @@ yet. The date is in YYYY-MM-DD format. =back -=head3 loanlength - -=over 4 - -The length of time for which the item can be borrowed, in days. - -=back - =head3 notforloan =over 4 @@ -357,7 +349,6 @@ sub getiteminformation { $sth=$dbh->prepare("select * from itemtypes where itemtype=?"); $sth->execute($iteminformation->{'itemtype'}); my $itemtype=$sth->fetchrow_hashref; - $iteminformation->{'loanlength'}=$itemtype->{'loanlength'}; # if specific item notforloan, don't use itemtype notforloan field. # otherwise, use itemtype notforloan value to see if item can be issued. $iteminformation->{'notforloan'}=$itemtype->{'notforloan'} unless $iteminformation->{'notforloan'}; @@ -599,92 +590,91 @@ if the borrower borrows to much things # returns an array with errors if any sub TooMany ($$){ - my $borrower = shift; - my $iteminformation = shift; - my $cat_borrower = $borrower->{'categorycode'}; - my $branch_borrower = $borrower->{'branchcode'}; - my $dbh = C4::Context->dbh; - - - my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?'); - $sth->execute($iteminformation->{'biblionumber'}); - my $type = $sth->fetchrow; - - $sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?'); - my $sth2 = $dbh->prepare("select COUNT(i.borrowernumber) from issues i, biblioitems s where i.borrowernumber = ? and i.returndate is null and i.itemnumber = s.biblioitemnumber and s.itemtype like ?"); - my $sth3 = $dbh->prepare('select COUNT(borrowernumber) from issues where borrowernumber = ? and returndate is null'); - - $sth->execute($cat_borrower, $type, $branch_borrower); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); - return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow); - } + my $borrower = shift; + my $iteminformation = shift; + my $cat_borrower = $borrower->{'categorycode'}; + my $branch_borrower = $borrower->{'branchcode'}; + my $dbh = C4::Context->dbh; + - $sth->execute($cat_borrower, $type, "*"); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); - return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow); - } + my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?'); + $sth->execute($iteminformation->{'biblionumber'}); + my $type = $sth->fetchrow; + warn "checking $branch_borrower / $cat_borrower / $type"; + $sth = $dbh->prepare('select * from issuingrules where categorycode = ? and itemtype = ? and branchcode = ?'); + my $sth2 = $dbh->prepare("select COUNT(*) from issues i, biblioitems s where i.borrowernumber = ? and i.returndate is null and i.itemnumber = s.biblioitemnumber and s.itemtype like ?"); + my $sth3 = $dbh->prepare('select COUNT(*) from issues where borrowernumber = ? and returndate is null'); + my $alreadyissued; + $sth->execute($cat_borrower, $type, $branch_borrower); + my $result = $sth->fetchrow_hashref; + warn "==>".$result->{maxissueqty}; + if (defined($result)) { + $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); + my $alreadyissued = $sth2->fetchrow; + return ("A $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute($cat_borrower, "*", $branch_borrower); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth3->execute($borrower->{'borrowernumber'}); - return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow); - } + $sth->execute($cat_borrower, $type, "*"); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); + my $alreadyissued = $sth2->fetchrow; + return ("B $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute("*", $type, $branch_borrower); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); - return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow); - } + $sth->execute($cat_borrower, "*", $branch_borrower); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth3->execute($borrower->{'borrowernumber'}); + my $alreadyissued = $sth2->fetchrow; + return ("C $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute("*", "*", $branch_borrower); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth3->execute($borrower->{'borrowernumber'}); - return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow); - } + $sth->execute("*", $type, $branch_borrower); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); + my $alreadyissued = $sth2->fetchrow; + return ("D $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute("*", $type, "*"); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); - return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow); - } + $sth->execute("*", "*", $branch_borrower); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth3->execute($borrower->{'borrowernumber'}); + my $alreadyissued = $sth2->fetchrow; + return ("E $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute($cat_borrower, "*", "*"); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); - return (0) if ($result->{'maxissueqty'} <= $sth2->fetchrow); - } + $sth->execute("*", $type, "*"); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); + my $alreadyissued = $sth2->fetchrow; + return ("F $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - $sth->execute("*", "*", "*"); - my $result = $sth->fetchrow_hashref; - if (defined($result)) - { - $sth3->execute($borrower->{'borrowernumber'}); - return (0) if ($result->{'maxissueqty'} <= $sth3->fetchrow); - } + $sth->execute($cat_borrower, "*", "*"); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth2->execute($borrower->{'borrowernumber'}, "%$type%"); + my $alreadyissued = $sth2->fetchrow; + return ("G $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } - return (1); + $sth->execute("*", "*", "*"); + my $result = $sth->fetchrow_hashref; + if (defined($result)) { + $sth3->execute($borrower->{'borrowernumber'}); + my $alreadyissued = $sth2->fetchrow; + return ("H $alreadyissued / ".($result->{maxissueqty}+0)) if ($result->{'maxissueqty'} <= $alreadyissued); + } + return; } sub canbookbeissued { my ($env,$borrower,$barcode,$year,$month,$day) = @_; - warn "CHECKING CANBEISSUED for $borrower->{'borrowernumber'}, $barcode"; my %needsconfirmation; # filled with problems that needs confirmations my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE my $iteminformation = getiteminformation($env, 0, $barcode); @@ -698,13 +688,13 @@ sub canbookbeissued { # # BORROWER STATUS # - if ($borrower->{flags}->{'gonenoaddress'}) { + if ($borrower->{flags}->{GNA}) { $issuingimpossible{GNA} = 1; } - if ($borrower->{flags}->{'lost'}) { + if ($borrower->{flags}->{'LOST'}) { $issuingimpossible{CARD_LOST} = 1; } - if ($borrower->{flags}->{'debarred'}) { + if ($borrower->{flags}->{'DBARRED'}) { $issuingimpossible{DEBARRED} = 1; } # @@ -721,10 +711,8 @@ sub canbookbeissued { # # JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS # - - $needsconfirmation{TOO_MANY} = 1 - if (!TooMany($borrower, $iteminformation)); - + my $toomany = TooMany($borrower, $iteminformation); + $needsconfirmation{TOO_MANY} = $toomany if $toomany; # # ITEM CHECKING @@ -745,7 +733,7 @@ sub canbookbeissued { $issuingimpossible{RESTRICTED} = 1; } - + # # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER diff --git a/circ/circulation.pl b/circ/circulation.pl index e635ba70ff..113c08ad6c 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -73,7 +73,7 @@ if ($query->param('setcookies')) { $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); } -my %env; # env is used as an "environment" variable. Could be dropped probably... +my %env; # FIXME env is used as an "environment" variable. Could be dropped probably... $env{'branchcode'}=$branch; $env{'printer'}=$printer; $env{'queue'}=$printer; @@ -106,9 +106,8 @@ if ($findborrower) { # get the borrower information..... my $borrower; if ($borrowernumber) { - $borrower = getpatroninformation(\%env,$borrowernumber,0); - - my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber); + $borrower = getpatroninformation(\%env,$borrowernumber,0); + my ($od,$issue,$fines)=borrdata2(\%env,$borrowernumber); $template->param(overduecount => $od, issuecount => $issue, finetotal => $fines); @@ -134,10 +133,8 @@ if ($barcode) { $barcode = cuecatbarcodedecode($barcode); my ($datedue, $invalidduedate) = fixdate($year, $month, $day); if ($issueconfirmed) { - warn "CONFIRMED"; issuebook(\%env, $borrower, $barcode, $datedue); } else { - # unless ($invalidduedate) { my ($error, $question) = canbookbeissued(\%env, $borrower, $barcode, $year, $month, $day); my $noerror=1; my $noquestion = 1; @@ -152,12 +149,9 @@ if ($barcode) { $noquestion = 0; } if ($noerror && ($noquestion || $issueconfirmed)) { - warn "NO ERROR"; issuebook(\%env, $borrower, $barcode, $datedue); } } - -# } } # reload the borrower info for the sake of reseting the flags..... @@ -263,7 +257,6 @@ if ($borrowerslist) { } #title -my ($patrontable, $flaginfotable) = patrontable($borrower); my $amountold=$borrower->{flags}->{'CHARGES'}->{'message'}; my @temp=split(/\$/,$amountold); $amountold=$temp[1]; @@ -275,8 +268,6 @@ $template->param( printer => $printer, branchname => $branches->{$branch}->{'branchname'}, printername => $printers->{$printer}->{'printername'}, -# title => $iteminformation->{'title'}, -# author => $iteminformation->{'author'}, firstname => $borrower->{'firstname'}, surname => $borrower->{'surname'}, categorycode => $borrower->{'categorycode'}, @@ -325,96 +316,6 @@ sub cuecatbarcodedecode { } } - -sub patrontable { - my ($borrower) = @_; - my $flags = $borrower->{'flags'}; - my $flaginfotable=''; - my $flaginfotext; - #my $flaginfotext=''; - my $flag; - my $color=''; - foreach $flag (sort keys %$flags) { - $flags->{$flag}->{'message'}=~s/\n/
/g; - if ($flags->{$flag}->{'noissues'}) { - $template->param( - noissues => 'true', - color => $color, - ); - if ($flag eq 'GNA'){ - $template->param( - gna => 'true' - ); - } - if ($flag eq 'LOST'){ - $template->param( - lost => 'true' - ); - } - if ($flag eq 'DBARRED'){ - $template->param( - dbarred => 'true' - ); - } - if ($flag eq 'CHARGES') { - $template->param( - charges => 'true', - chargesmsg => $flags->{'CHARGES'}->{'message'} - ); - } - } else { - if ($flag eq 'CHARGES') { - $template->param( - charges => 'true', - chargesmsg => $flags->{'CHARGES'}->{'message'} - ); - } - if ($flag eq 'WAITING') { - my $items=$flags->{$flag}->{'itemlist'}; - my @itemswaiting; - foreach my $item (@$items) { - my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0); - $iteminformation->{'branchname'} = $branches->{$iteminformation->{'holdingbranch'}}->{'branchname'}; - push @itemswaiting, $iteminformation; - } - $template->param( - waiting => 'true', - waitingmsg => $flags->{'WAITING'}->{'message'}, - itemswaiting => \@itemswaiting, - ); - } - if ($flag eq 'ODUES') { - $template->param( - odues => 'true', - oduesmsg => $flags->{'ODUES'}->{'message'} - ); - - my $items=$flags->{$flag}->{'itemlist'}; - my $currentcolor=$color; - { - my $color=$currentcolor; - my @itemswaiting; - foreach my $item (@$items) { -# ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); - my ($iteminformation) = getiteminformation(\%env, $item->{'itemnumber'}, 0); - push @itemswaiting, $iteminformation; - } - } - if ($query->param('module') ne 'returns'){ - $template->param( nonreturns => 'true' ); - } - } - if ($flag eq 'NOTES') { - $template->param( - notes => 'true', - notesmsg => $flags->{'NOTES'}->{'message'} - ); - } - } - } - return($patrontable, $flaginfotext); -} - # Local Variables: # tab-width: 8 # End: diff --git a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl index 207297081b..ba9f97f472 100644 --- a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl @@ -149,19 +149,19 @@

Issuing impossible

The due date is invalid

- +

The barcode is unknown

- +

Item not for loan

- +

Item withdrawn

- +

Borrower is gone with no address

- +

Borrower's card is lost

@@ -176,7 +176,7 @@

I need confirmation before issuing

-

The borrower has debts

+

The borrower has a debt of

Not an issue but a renewal

@@ -188,7 +188,7 @@

Item issued to . Return & issue?

-

Too many issues!

+

Too many issues (already issued / max : )

-- 2.39.5