From 82683305614952072b5603edbce0bfccd81a2fef Mon Sep 17 00:00:00 2001 From: doxulting Date: Mon, 24 May 2004 12:14:38 +0000 Subject: [PATCH] Premier commit JB34. Verification du nombre maximum de livre a emprunter. --- C4/Circulation/Circ2.pm | 56 ++++++++++++++++++- .../default/en/circ/circulation.tmpl | 6 +- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index a7fe38381c..6e83844265 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -589,11 +589,52 @@ reserved for someone else. sticky due date is invalid +=head3 TOO_MUCH + +if the borrower borrows to much things + =cut # check if a book can be issued. # returns an array with errors if any +sub HowManyBurrows ($){ + my $borrower = shift; + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare('select COUNT(borrowernumber) nombre_livre_emprunte from issues where borrowernumber = ?'); + $sth->execute($borrower->{'borrowernumber'}); + my $data = $sth->fetchrow; + return $data; +} + +sub NumberBurrowsOk(@) +{ + (my $biblionbr, my $cat) = @_; + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare('select itemtype from biblioitems where biblionumber = ?'); + $sth->execute($biblionbr); + my $data = $sth->fetchrow; + $sth = $dbh->prepare('select maxissueqty from issuingrules where categorycode = ? and itemtype = ?'); + $sth->execute($cat, $data); + my $value = $sth->fetchrow; + return $value if (defined($value)); + $sth = $dbh->prepare('select maxissueqty from issuingrules where categorycode = "*" and itemtype = ?'); + $sth->execute($data); + $value = $sth->fetchrow; + return $value if (defined($value)); + $sth = $dbh->prepare('select maxissueqty from issuingrules where categorycode = ? and itemtype = "*"'); + $sth->execute($cat); + $value = $sth->fetchrow; + return $value if (defined($value)); + $sth = $dbh->prepare('select maxissueqty from issuingrules where categorycode = "*" and itemtype = "*"'); + $sth->execute(); + $value = $sth->fetchrow; + return $value if (defined($value)); + return 5; # valeur max par default si la base est endommagee +} + sub canbookbeissued { my ($env,$borrower,$barcode,$year,$month,$day) = @_; warn "CHECKING CANBEISSUED for $borrower->{'borrowernumber'}, $barcode"; @@ -629,6 +670,15 @@ sub canbookbeissued { $needsconfirmation{DEBT} = $amount; } + +# +# JB34 CHECK IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS +# + + $needsconfirmation{TOO_MUCH} = 1 + if (HowManyBurrows($borrower) > NumberBurrowsOk($iteminformation->{'biblionumber'}, + $borrower->{'categorycode'})); + # # ITEM CHECKING # @@ -648,6 +698,8 @@ sub canbookbeissued { $issuingimpossible{RESTRICTED} = 1; } + + # # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER # @@ -664,7 +716,7 @@ sub canbookbeissued { } elsif ($currentborrower) { # issued to someone else my $currborinfo = getpatroninformation(0,$currentborrower); - warn "=>.$currborinfo->{'firstname'} $currborinfo->{'surname'} ($currborinfo->{'cardnumber'})"; +# warn "=>.$currborinfo->{'firstname'} $currborinfo->{'surname'} ($currborinfo->{'cardnumber'})"; $needsconfirmation{ISSUED_TO_ANOTHER} = "$currborinfo->{'reservedate'} : $currborinfo->{'firstname'} $currborinfo->{'surname'} ($currborinfo->{'cardnumber'})"; } # See if the item is on reserve. @@ -715,7 +767,7 @@ sub issuebook { my $dbh = C4::Context->dbh; # my ($borrower, $flags) = &getpatroninformation($env, $borrowernumber, 0); my $iteminformation = getiteminformation($env, 0, $barcode); - warn "B : ".$borrower->{borrowernumber}." / I : ".$iteminformation->{'itemnumber'}; +# warn "B : ".$borrower->{borrowernumber}." / I : ".$iteminformation->{'itemnumber'}; # # check if we just renew the issue. # diff --git a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl index 01908feb89..8898783a94 100644 --- a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl @@ -185,7 +185,7 @@
- +

I need confirmation before issuing

The borrower has debts

@@ -199,7 +199,9 @@

Item issued to . Return & issue ?

- + +

Too much book!

+
"> -- 2.39.5