1 package C4::Circulation::Fines;
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
25 use Date::Calc qw/Today/;
26 use vars qw($VERSION @ISA @EXPORT);
28 use Date::Manip qw/UnixDate/;
29 use C4::Log; # logaction
31 # set the version for version checking
32 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
33 shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
37 C4::Circulation::Fines - Koha module dealing with fines
41 use C4::Circulation::Fines;
45 This module contains several functions for dealing with fines for
46 overdue items. It is primarily used by the 'misc/fines2.pl' script.
55 # subs to rename (and maybe merge some...)
59 &CheckAccountLineLevelInfo
60 &CheckAccountLineItemInfo
61 &CheckExistantNotifyid
71 &CreateItemAccountLine
80 # All subs to move : check that an equivalent don't exist already before moving
83 # subs to move to Circulation.pm
88 # subs to move to Members.pm
90 &CheckBorrowerDebarred
91 &UpdateBorrowerDebarred
93 # subs to move to Biblio.pm
101 ($count, $overdues) = &Getoverdues();
103 Returns the list of all overdue books.
105 C<$count> is the number of elements in C<@{$overdues}>.
107 C<$overdues> is a reference-to-array. Each element is a
108 reference-to-hash whose keys are the fields of the issues table in the
115 my $dbh = C4::Context->dbh;
116 my $sth = $dbh->prepare(
117 "Select * from issues where date_due < now() and returndate is
118 NULL order by borrowernumber "
122 # FIXME - Use push @results
125 while ( my $data = $sth->fetchrow_hashref ) {
126 $results[$i] = $data;
133 return ( $i, \@results );
138 ($amount, $chargename, $message) =
139 &CalcFine($itemnumber, $borrowercode, $days_overdue);
141 Calculates the fine for a book.
143 The issuingrules table in the Koha database is a fine matrix, listing
144 the penalties for each type of patron for each type of item and each branch (e.g., the
145 standard fine for books might be $0.50, but $1.50 for DVDs, or staff
146 members might get a longer grace period between the first and second
147 reminders that a book is overdue).
149 The fine is calculated as follows: if it is time for the first
150 reminder, the fine is the value listed for the given (branch, item type,
151 borrower code) combination. If it is time for the second reminder, the
152 fine is doubled. Finally, if it is time to send the account to a
153 collection agency, the fine is set to 5 local monetary units (a really
154 good deal for the patron if the library is in Italy). Otherwise, the
157 Note that the way this function is currently implemented, it only
158 returns a nonzero value on the notable days listed above. That is, if
159 the categoryitems entry says to send a first reminder 7 days after the
160 book is due, then if you call C<&CalcFine> 7 days after the book is
161 due, it will give a nonzero fine. If you call C<&CalcFine> the next
162 day, however, it will say that the fine is 0.
164 C<$itemnumber> is the book's item number.
166 C<$borrowercode> is the borrower code of the patron who currently has
169 C<$days_overdue> is the number of days elapsed since the book's due
172 C<&CalcFine> returns a list of three values:
174 C<$amount> is the fine owed by the patron (see above).
176 C<$chargename> is the chargename field from the applicable record in
177 the categoryitem table, whatever that is.
179 C<$message> is a text message, either "First Notice", "Second Notice",
186 my ( $itemnumber, $bortype, $difference , $dues ) = @_;
187 my $dbh = C4::Context->dbh;
188 my $data = GetIssuingRules($itemnumber,$bortype);
191 my $countspecialday=&GetSpecialHolidays($dues,$itemnumber);
192 my $countrepeatableday=&GetRepeatableHolidays($dues,$itemnumber,$difference);
193 my $countalldayclosed = $countspecialday + $countrepeatableday;
194 my $daycount = $difference - $countalldayclosed;
195 my $daycounttotal = $daycount - $data->{'firstremind'};
196 if ($data->{'firstremind'} < $daycount)
198 $amount = $daycounttotal*$data->{'fine'};
200 return ( $amount, $data->{'chargename'}, $printout ,$daycounttotal ,$daycount );
204 =item GetSpecialHolidays
206 &GetSpecialHolidays($date_dues,$itemnumber);
208 return number of special days between date of the day and date due
210 C<$date_dues> is the envisaged date of book return.
212 C<$itemnumber> is the book's item number.
216 sub GetSpecialHolidays {
217 my ($date_dues,$itemnumber) = @_;
218 # calcul the today date
219 my $today = join "-", &Today();
221 # return the holdingbranch
222 my $iteminfo=GetIssuesIteminfo($itemnumber);
223 # use sql request to find all date between date_due and today
224 my $dbh = C4::Context->dbh;
225 my $query=qq|SELECT DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d')as date
226 FROM `special_holidays`
227 WHERE DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') >= ?
228 AND DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') <= ?
231 my @result=GetWdayFromItemnumber($itemnumber);
235 my $sth = $dbh->prepare($query);
236 $sth->execute($date_dues,$today,$iteminfo->{'branchcode'});
238 while ( my $special_date=$sth->fetchrow_hashref){
239 push (@result_date,$special_date);
242 my $specialdaycount=scalar(@result_date);
244 for (my $i=0;$i<scalar(@result_date);$i++){
245 $dateinsec=UnixDate($result_date[$i]->{'date'},"%o");
246 (undef,undef,undef,undef,undef,undef,$wday,undef,undef) =localtime($dateinsec);
247 for (my $j=0;$j<scalar(@result);$j++){
248 if ($wday == ($result[$j]->{'weekday'})){
254 return $specialdaycount;
257 =item GetRepeatableHolidays
259 &GetRepeatableHolidays($date_dues, $itemnumber, $difference,);
261 return number of day closed between date of the day and date due
263 C<$date_dues> is the envisaged date of book return.
265 C<$itemnumber> is item number.
267 C<$difference> numbers of between day date of the day and date due
271 sub GetRepeatableHolidays{
272 my ($date_dues,$itemnumber,$difference) = @_;
273 my $dateinsec=UnixDate($date_dues,"%o");
274 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($dateinsec);
275 my @result=GetWdayFromItemnumber($itemnumber);
279 for (my $i=0;$i<scalar(@result);$i++){
282 for ( $j=0;$j<$difference;$j++){
283 if ($result[$i]->{'weekday'} == $k)
285 push ( @dayclosedcount ,$k);
291 return scalar(@dayclosedcount);
295 =item GetWayFromItemnumber
297 &Getwdayfromitemnumber($itemnumber);
299 return the different week day from repeatable_holidays table
301 C<$itemnumber> is item number.
305 sub GetWdayFromItemnumber{
307 my $iteminfo=GetIssuesIteminfo($itemnumber);
309 my $dbh = C4::Context->dbh;
310 my $query = qq|SELECT weekday
311 FROM repeatable_holidays
314 my $sth = $dbh->prepare($query);
317 $sth->execute($iteminfo->{'branchcode'});
318 while ( my $weekday=$sth->fetchrow_hashref){
319 push (@result,$weekday);
325 =item GetIssuesIteminfo
327 &GetIssuesIteminfo($itemnumber);
329 return all data from issues about item
331 C<$itemnumber> is item number.
335 sub GetIssuesIteminfo{
337 my $dbh = C4::Context->dbh;
338 my $query = qq|SELECT *
342 my $sth = $dbh->prepare($query);
343 $sth->execute($itemnumber);
344 my ($issuesinfo)=$sth->fetchrow_hashref;
351 &UpdateFine($itemnumber, $borrowernumber, $amount, $type, $description);
353 (Note: the following is mostly conjecture and guesswork.)
355 Updates the fine owed on an overdue book.
357 C<$itemnumber> is the book's item number.
359 C<$borrowernumber> is the borrower number of the patron who currently
360 has the book on loan.
362 C<$amount> is the current amount owed by the patron.
364 C<$type> will be used in the description of the fine.
366 C<$description> is a string that must be present in the description of
367 the fine. I think this is expected to be a date in DD/MM/YYYY format.
369 C<&UpdateFine> looks up the amount currently owed on the given item
370 and sets it to C<$amount>, creating, if necessary, a new entry in the
371 accountlines table of the Koha database.
376 # FIXME - This API doesn't look right: why should the caller have to
377 # specify both the item number and the borrower number? A book can't
378 # be on loan to two different people, so the item number should be
381 my ( $itemnum, $borrowernumber, $amount, $type, $due ) = @_;
382 my $dbh = C4::Context->dbh;
383 # FIXME - What exactly is this query supposed to do? It looks up an
384 # entry in accountlines that matches the given item and borrower
385 # numbers, where the description contains $due, and where the
386 # account type has one of several values, but what does this _mean_?
387 # Does it look up existing fines for this item?
388 # FIXME - What are these various account types? ("FU", "O", "F", "M")
389 my $sth = $dbh->prepare(
390 "Select * from accountlines where itemnumber=? and
391 borrowernumber=? and (accounttype='FU' or accounttype='O' or
392 accounttype='F' or accounttype='M') and description like ?"
394 $sth->execute( $itemnum, $borrowernumber, "%$due%" );
396 if ( my $data = $sth->fetchrow_hashref ) {
398 # I think this if-clause deals with the case where we're updating
400 # print "in accounts ...";
401 if ( $data->{'amount'} != $amount ) {
404 my $diff = $amount - $data->{'amount'};
405 my $out = $data->{'amountoutstanding'} + $diff;
406 my $sth2 = $dbh->prepare(
407 "update accountlines set date=now(), amount=?,
408 amountoutstanding=?,accounttype='FU' where
409 borrowernumber=? and itemnumber=?
410 and (accounttype='FU' or accounttype='O') and description like ?"
412 $sth2->execute( $amount, $out, $data->{'borrowernumber'},
413 $data->{'itemnumber'}, "%$due%" );
418 # print "no update needed $data->{'amount'}"
423 # I think this else-clause deals with the case where we're adding
425 my $sth4 = $dbh->prepare(
426 "select title from biblio,items where items.itemnumber=?
427 and biblio.biblionumber=items.biblionumber"
429 $sth4->execute($itemnum);
430 my $title = $sth4->fetchrow_hashref;
433 # # print "not in account";
434 # my $sth3 = $dbh->prepare("Select max(accountno) from accountlines");
437 # # FIXME - Make $accountno a scalar.
438 # my @accountno = $sth3->fetchrow_array;
442 my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh);
443 my $sth2 = $dbh->prepare(
444 "Insert into accountlines
445 (borrowernumber,itemnumber,date,amount,
446 description,accounttype,amountoutstanding,accountno) values
447 (?,?,now(),?,?,'FU',?,?)"
449 $sth2->execute( $borrowernumber, $itemnum, $amount,
450 "$type $title->{'title'} $due",
451 $amount, $nextaccntno);
456 C4::Context->userenv->{'number'},
460 "due=".$due." amount=".$amount." itemnumber=".$itemnum
461 ) if C4::Context->preference("FinesLog");
468 $borrower = &BorType($borrowernumber);
470 Looks up a patron by borrower number.
472 C<$borrower> is a reference-to-hash whose keys are all of the fields
473 from the borrowers and categories tables of the Koha database. Thus,
474 C<$borrower> contains all information about both the borrower and
475 category he or she belongs to.
481 my ($borrowernumber) = @_;
482 my $dbh = C4::Context->dbh;
483 my $sth = $dbh->prepare(
484 "Select * from borrowers,categories where
486 borrowers.categorycode=categories.categorycode"
488 $sth->execute($borrowernumber);
489 my $data = $sth->fetchrow_hashref;
494 =item ReplacementCost
496 $cost = &ReplacementCost($itemnumber);
498 Returns the replacement cost of the item with the given item number.
503 sub ReplacementCost {
505 my $dbh = C4::Context->dbh;
507 $dbh->prepare("Select replacementprice from items where itemnumber=?");
508 $sth->execute($itemnum);
510 # FIXME - Use fetchrow_array or something.
511 my $data = $sth->fetchrow_hashref;
513 return ( $data->{'replacementprice'} );
518 $data->{'sum(amountoutstanding)'} = &GetFine($itemnum,$borrowernumber);
520 return the total of fine
522 C<$itemnum> is item number
524 C<$borrowernumber> is the borrowernumber
530 my ( $itemnum, $borrowernumber ) = @_;
531 my $dbh = C4::Context->dbh();
532 my $query = "SELECT sum(amountoutstanding) FROM accountlines
533 where accounttype like 'F%'
534 AND amountoutstanding > 0 AND itemnumber = ? AND borrowernumber=?";
535 my $sth = $dbh->prepare($query);
536 $sth->execute( $itemnum, $borrowernumber );
537 my $data = $sth->fetchrow_hashref();
540 return ( $data->{'sum(amountoutstanding)'} );
546 =item GetIssuingRules
548 $data = &GetIssuingRules($itemnumber,$categorycode);
550 Looks up for all issuingrules an item info
552 C<$itemnumber> is a reference-to-hash whose keys are all of the fields
553 from the borrowers and categories tables of the Koha database. Thus,
555 C<$categorycode> contains information about borrowers category
557 C<$data> contains all information about both the borrower and
558 category he or she belongs to.
561 sub GetIssuingRules {
562 my ($itemnumber,$categorycode)=@_;
563 my $dbh = C4::Context->dbh();
564 my $query=qq|SELECT *
565 FROM items,biblioitems,itemtypes,issuingrules
566 WHERE items.itemnumber=?
567 AND items.biblioitemnumber=biblioitems.biblioitemnumber
568 AND biblioitems.itemtype=itemtypes.itemtype
569 AND issuingrules.itemtype=itemtypes.itemtype
570 AND issuingrules.categorycode=?
571 AND (items.itemlost <> 1
572 OR items.itemlost is NULL)|;
573 my $sth = $dbh->prepare($query);
575 $sth->execute($itemnumber,$categorycode);
576 my ($data) = $sth->fetchrow_hashref;
583 sub ReplacementCost2 {
584 my ( $itemnum, $borrowernumber ) = @_;
585 my $dbh = C4::Context->dbh();
586 my $query = "SELECT amountoutstanding
588 WHERE accounttype like 'L'
589 AND amountoutstanding > 0
591 AND borrowernumber= ?";
592 my $sth = $dbh->prepare($query);
593 $sth->execute( $itemnum, $borrowernumber );
594 my $data = $sth->fetchrow_hashref();
597 return ( $data->{'amountoutstanding'} );
601 =item GetNextIdNotify
603 ($result) = &GetNextIdNotify($reference);
605 Returns the new file number
607 C<$result> contains the next file number
609 C<$reference> contains the beggining of file number
615 sub GetNextIdNotify {
617 my $query=qq|SELECT max(notify_id)
619 WHERE notify_id like \"$reference%\"
621 # AND borrowernumber=?|;
622 my $dbh = C4::Context->dbh;
623 my $sth=$dbh->prepare($query);
625 my $result=$sth->fetchrow;
630 ($result=$reference."01") ;
633 $count=substr($result,6)+1;
636 ($count = "0".$count);
638 $result=$reference.$count;
646 (@notify) = &AmountNotify($borrowernumber);
648 Returns amount for all file per borrowers
649 C<@notify> array contains all file per borrowers
651 C<$notify_id> contains the file number for the borrower number nad item number
656 my ($borrowernumber)=@_;
657 my $dbh = C4::Context->dbh;
659 my $query=qq| SELECT distinct(notify_id)
661 WHERE borrowernumber=?|;
663 my $sth=$dbh->prepare($query);
664 $sth->execute($borrowernumber);
665 while ( my $numberofotify=$sth->fetchrow_array){
666 push (@notify,$numberofotify);
676 ($totalnotify) = &AmountNotify($notifyid);
678 Returns amount for all file per borrowers
679 C<$notifyid> is the file number
681 C<$totalnotify> contains amount of a file
683 C<$notify_id> contains the file number for the borrower number nad item number
689 my $dbh = C4::Context->dbh;
690 my $query=qq| SELECT sum(amountoutstanding)
693 my $sth=$dbh->prepare($query);
694 $sth->execute($notifyid);
695 my $totalnotify=$sth->fetchrow;
697 return ($totalnotify);
703 ($notify_id) = &GetNotifyId($borrowernumber,$itemnumber);
705 Returns the file number per borrower and itemnumber
707 C<$borrowernumber> is a reference-to-hash whose keys are all of the fields
708 from the items tables of the Koha database. Thus,
710 C<$itemnumber> contains the borrower categorycode
712 C<$notify_id> contains the file number for the borrower number nad item number
717 my ($borrowernumber,$itemnumber)=@_;
718 my $query=qq|SELECT notify_id
720 WHERE borrowernumber=?
722 AND (accounttype='FU' or accounttype='O')|;
723 my $dbh = C4::Context->dbh;
724 my $sth=$dbh->prepare($query);
725 $sth->execute($borrowernumber,$itemnumber);
726 my ($notify_id)=$sth->fetchrow;
732 =item CreateItemAccountLine
734 () = &CreateItemAccountLine($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
736 update the account lines with file number or with file level
738 C<$items> is a reference-to-hash whose keys are all of the fields
739 from the items tables of the Koha database. Thus,
741 C<$itemnumber> contains the item number
743 C<$borrowernumber> contains the borrower number
745 C<$date> contains the date of the day
747 C<$amount> contains item price
749 C<$description> contains the descritpion of accounttype
751 C<$accounttype> contains the account type
753 C<$amountoutstanding> contains the $amountoutstanding
755 C<$timestamp> contains the timestamp with time and the date of the day
757 C<$notify_id> contains the file number
759 C<$level> contains the file level
764 sub CreateItemAccountLine {
765 my ($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level)=@_;
766 my $dbh = C4::Context->dbh;
767 my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh);
768 my $query= qq|INSERT into accountlines
769 (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level)
771 (?,?,?,?,?,?,?,?,?,?,?)|;
774 my $sth=$dbh->prepare($query);
775 $sth->execute($borrowernumber,$nextaccntno,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
779 =item UpdateAccountLines
781 () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber);
783 update the account lines with file number or with file level
785 C<$items> is a reference-to-hash whose keys are all of the fields
786 from the items tables of the Koha database. Thus,
788 C<$itemnumber> contains the item number
790 C<$notify_id> contains the file number
792 C<$notify_level> contains the file level
794 C<$borrowernumber> contains the borrowernumber
798 sub UpdateAccountLines {
799 my ($notify_id,$notify_level,$borrowernumber,$itemnumber)=@_;
801 if ($notify_id eq '')
804 $query=qq|UPDATE accountlines
806 WHERE borrowernumber=? AND itemnumber=?
807 AND (accounttype='FU' or accounttype='O')|;
810 $query=qq|UPDATE accountlines
811 SET notify_id=?, notify_level=?
812 WHERE borrowernumber=?
814 AND (accounttype='FU' or accounttype='O')|;
816 my $dbh = C4::Context->dbh;
817 my $sth=$dbh->prepare($query);
819 if ($notify_id eq '')
821 $sth->execute($notify_level,$borrowernumber,$itemnumber);
824 $sth->execute($notify_id,$notify_level,$borrowernumber,$itemnumber);
833 ($items) = &GetItems($itemnumber);
835 Returns the list of all delays from overduerules.
837 C<$items> is a reference-to-hash whose keys are all of the fields
838 from the items tables of the Koha database. Thus,
840 C<$itemnumber> contains the borrower categorycode
845 my($itemnumber) = @_;
846 my $query=qq|SELECT *
849 my $dbh = C4::Context->dbh;
850 my $sth=$dbh->prepare($query);
851 $sth->execute($itemnumber);
852 my ($items)=$sth->fetchrow_hashref;
857 =item GetOverdueDelays
859 (@delays) = &GetOverdueDelays($categorycode);
861 Returns the list of all delays from overduerules.
863 C<@delays> it's an array contains the three delays from overduerules table
865 C<$categorycode> contains the borrower categorycode
869 sub GetOverdueDelays {
871 my $dbh = C4::Context->dbh;
872 my $query=qq|SELECT delay1,delay2,delay3
874 WHERE categorycode=?|;
875 my $sth=$dbh->prepare($query);
876 $sth->execute($category);
877 my (@delays)=$sth->fetchrow_array;
882 =item CheckAccountLineLevelInfo
884 ($exist) = &CheckAccountLineLevelInfo($borrowernumber,$itemnumber,$accounttype,notify_level);
886 Check and Returns the list of all overdue books.
888 C<$exist> contains number of line in accounlines
889 with the same .biblionumber,itemnumber,accounttype,and notify_level
891 C<$borrowernumber> contains the borrower number
893 C<$itemnumber> contains item number
895 C<$accounttype> contains account type
897 C<$notify_level> contains the accountline level
902 sub CheckAccountLineLevelInfo {
903 my($borrowernumber,$itemnumber,$level) = @_;
904 my $dbh = C4::Context->dbh;
905 my $query= qq|SELECT count(*)
907 WHERE borrowernumber =?
910 my $sth=$dbh->prepare($query);
911 $sth->execute($borrowernumber,$itemnumber,$level);
912 my ($exist)=$sth->fetchrow;
917 =item GetOverduerules
919 ($overduerules) = &GetOverduerules($categorycode);
921 Returns the value of borrowers (debarred or not) with notify level
923 C<$overduerules> return value of debbraed field in overduerules table
925 C<$category> contains the borrower categorycode
927 C<$notify_level> contains the notify level
932 my($category,$notify_level) = @_;
933 my $dbh = C4::Context->dbh;
934 my $query=qq|SELECT debarred$notify_level
936 WHERE categorycode=?|;
937 my $sth=$dbh->prepare($query);
938 $sth->execute($category);
939 my ($overduerules)=$sth->fetchrow;
941 return($overduerules);
945 =item CheckBorrowerDebarred
947 ($debarredstatus) = &CheckBorrowerDebarred($borrowernumber);
949 Check if the borrowers is already debarred
951 C<$debarredstatus> return 0 for not debarred and return 1 for debarred
953 C<$borrowernumber> contains the borrower number
958 sub CheckBorrowerDebarred{
959 my($borrowernumber) = @_;
960 my $dbh = C4::Context->dbh;
961 my $query=qq|SELECT debarred
963 WHERE borrowernumber=?
965 my $sth=$dbh->prepare($query);
966 $sth->execute($borrowernumber);
967 my ($debarredstatus)=$sth->fetchrow;
969 if ($debarredstatus eq '1'){
976 =item UpdateBorrowerDebarred
978 ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
980 update status of borrowers in borrowers table (field debarred)
982 C<$borrowernumber> borrower number
986 sub UpdateBorrowerDebarred{
987 my($borrowernumber) = @_;
988 my $dbh = C4::Context->dbh;
989 my $query=qq|UPDATE borrowers
991 WHERE borrowernumber=?
993 my $sth=$dbh->prepare($query);
994 $sth->execute($borrowernumber);
999 =item CheckExistantNotifyid
1001 ($exist) = &CheckExistantNotifyid($borrowernumber,$itemnumber,$accounttype,$notify_id);
1003 Check and Returns the notify id if exist else return 0.
1005 C<$exist> contains a notify_id
1007 C<$borrowernumber> contains the borrower number
1009 C<$date_due> contains the date of item return
1014 sub CheckExistantNotifyid {
1015 my($borrowernumber,$date_due) = @_;
1016 my $dbh = C4::Context->dbh;
1017 my $query = qq|SELECT notify_id FROM issues,accountlines
1018 WHERE accountlines.borrowernumber =?
1019 AND issues.itemnumber= accountlines.itemnumber
1021 my $sth=$dbh->prepare($query);
1022 $sth->execute($borrowernumber,$date_due);
1023 my ($exist)=$sth->fetchrow;
1034 =item CheckAccountLineItemInfo
1036 ($exist) = &CheckAccountLineItemInfo($borrowernumber,$itemnumber,$accounttype,$notify_id);
1038 Check and Returns the list of all overdue items from the same file number(notify_id).
1040 C<$exist> contains number of line in accounlines
1041 with the same .biblionumber,itemnumber,accounttype,notify_id
1043 C<$borrowernumber> contains the borrower number
1045 C<$itemnumber> contains item number
1047 C<$accounttype> contains account type
1049 C<$notify_id> contains the file number
1053 sub CheckAccountLineItemInfo {
1054 my($borrowernumber,$itemnumber,$accounttype,$notify_id) = @_;
1055 my $dbh = C4::Context->dbh;
1056 my $query = qq|SELECT count(*) FROM accountlines
1057 WHERE borrowernumber =?
1061 my $sth=$dbh->prepare($query);
1062 $sth->execute($borrowernumber,$itemnumber,$accounttype,$notify_id);
1063 my ($exist)=$sth->fetchrow;
1076 Koha Developement team <info@koha.org>