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 @EXPORT = qw( &BorType
59 &CheckAccountLineLevelInfo
60 &CheckAccountLineItemInfo
61 &CheckExistantNotifyid
62 &CheckBorrowerDebarred
75 &UpdateBorrowerDebarred
76 &CreateItemAccountLine
82 ($count, $overdues) = &Getoverdues();
84 Returns the list of all overdue books.
86 C<$count> is the number of elements in C<@{$overdues}>.
88 C<$overdues> is a reference-to-array. Each element is a
89 reference-to-hash whose keys are the fields of the issues table in the
96 my $dbh = C4::Context->dbh;
97 my $sth = $dbh->prepare(
98 "Select * from issues where date_due < now() and returndate is
99 NULL order by borrowernumber "
103 # FIXME - Use push @results
106 while ( my $data = $sth->fetchrow_hashref ) {
107 $results[$i] = $data;
114 return ( $i, \@results );
119 ($amount, $chargename, $message) =
120 &CalcFine($itemnumber, $borrowercode, $days_overdue);
122 Calculates the fine for a book.
124 The issuingrules table in the Koha database is a fine matrix, listing
125 the penalties for each type of patron for each type of item and each branch (e.g., the
126 standard fine for books might be $0.50, but $1.50 for DVDs, or staff
127 members might get a longer grace period between the first and second
128 reminders that a book is overdue).
130 The fine is calculated as follows: if it is time for the first
131 reminder, the fine is the value listed for the given (branch, item type,
132 borrower code) combination. If it is time for the second reminder, the
133 fine is doubled. Finally, if it is time to send the account to a
134 collection agency, the fine is set to 5 local monetary units (a really
135 good deal for the patron if the library is in Italy). Otherwise, the
138 Note that the way this function is currently implemented, it only
139 returns a nonzero value on the notable days listed above. That is, if
140 the categoryitems entry says to send a first reminder 7 days after the
141 book is due, then if you call C<&CalcFine> 7 days after the book is
142 due, it will give a nonzero fine. If you call C<&CalcFine> the next
143 day, however, it will say that the fine is 0.
145 C<$itemnumber> is the book's item number.
147 C<$borrowercode> is the borrower code of the patron who currently has
150 C<$days_overdue> is the number of days elapsed since the book's due
153 C<&CalcFine> returns a list of three values:
155 C<$amount> is the fine owed by the patron (see above).
157 C<$chargename> is the chargename field from the applicable record in
158 the categoryitem table, whatever that is.
160 C<$message> is a text message, either "First Notice", "Second Notice",
167 my ( $itemnumber, $bortype, $difference , $dues ) = @_;
168 my $dbh = C4::Context->dbh;
169 my $data = GetIssuingRules($itemnumber,$bortype);
172 my $countspecialday=&GetSpecialHolidays($dues,$itemnumber);
173 my $countrepeatableday=&GetRepeatableHolidays($dues,$itemnumber,$difference);
174 my $countalldayclosed = $countspecialday + $countrepeatableday;
175 my $daycount = $difference - $countalldayclosed;
176 my $daycounttotal = $daycount - $data->{'firstremind'};
177 if ($data->{'firstremind'} < $daycount)
179 $amount = $daycounttotal*$data->{'fine'};
181 return ( $amount, $data->{'chargename'}, $printout ,$daycounttotal ,$daycount );
185 =item GetSpecialHolidays
187 &GetSpecialHolidays($date_dues,$itemnumber);
189 return number of special days between date of the day and date due
191 C<$date_dues> is the envisaged date of book return.
193 C<$itemnumber> is the book's item number.
197 sub GetSpecialHolidays {
198 my ($date_dues,$itemnumber) = @_;
199 # calcul the today date
200 my $today = join "-", &Today();
202 # return the holdingbranch
203 my $iteminfo=GetIssuesIteminfo($itemnumber);
204 # use sql request to find all date between date_due and today
205 my $dbh = C4::Context->dbh;
206 my $query=qq|SELECT DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d')as date
207 FROM `special_holidays`
208 WHERE DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') >= ?
209 AND DATE_FORMAT(concat(year,'-',month,'-',day),'%Y-%m-%d') <= ?
212 my @result=GetWdayFromItemnumber($itemnumber);
216 my $sth = $dbh->prepare($query);
217 $sth->execute($date_dues,$today,$iteminfo->{'branchcode'});
219 while ( my $special_date=$sth->fetchrow_hashref){
220 push (@result_date,$special_date);
223 my $specialdaycount=scalar(@result_date);
225 for (my $i=0;$i<scalar(@result_date);$i++){
226 $dateinsec=UnixDate($result_date[$i]->{'date'},"%o");
227 (undef,undef,undef,undef,undef,undef,$wday,undef,undef) =localtime($dateinsec);
228 for (my $j=0;$j<scalar(@result);$j++){
229 if ($wday == ($result[$j]->{'weekday'})){
235 return $specialdaycount;
238 =item GetRepeatableHolidays
240 &GetRepeatableHolidays($date_dues, $itemnumber, $difference,);
242 return number of day closed between date of the day and date due
244 C<$date_dues> is the envisaged date of book return.
246 C<$itemnumber> is item number.
248 C<$difference> numbers of between day date of the day and date due
252 sub GetRepeatableHolidays{
253 my ($date_dues,$itemnumber,$difference) = @_;
254 my $dateinsec=UnixDate($date_dues,"%o");
255 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($dateinsec);
256 my @result=GetWdayFromItemnumber($itemnumber);
260 for (my $i=0;$i<scalar(@result);$i++){
263 for ( $j=0;$j<$difference;$j++){
264 if ($result[$i]->{'weekday'} == $k)
266 push ( @dayclosedcount ,$k);
272 return scalar(@dayclosedcount);
276 =item GetWayFromItemnumber
278 &Getwdayfromitemnumber($itemnumber);
280 return the different week day from repeatable_holidays table
282 C<$itemnumber> is item number.
286 sub GetWdayFromItemnumber{
288 my $iteminfo=GetIssuesIteminfo($itemnumber);
290 my $dbh = C4::Context->dbh;
291 my $query = qq|SELECT weekday
292 FROM repeatable_holidays
295 my $sth = $dbh->prepare($query);
298 $sth->execute($iteminfo->{'branchcode'});
299 while ( my $weekday=$sth->fetchrow_hashref){
300 push (@result,$weekday);
306 =item GetIssuesIteminfo
308 &GetIssuesIteminfo($itemnumber);
310 return all data from issues about item
312 C<$itemnumber> is item number.
316 sub GetIssuesIteminfo{
318 my $dbh = C4::Context->dbh;
319 my $query = qq|SELECT *
323 my $sth = $dbh->prepare($query);
324 $sth->execute($itemnumber);
325 my ($issuesinfo)=$sth->fetchrow_hashref;
332 &UpdateFine($itemnumber, $borrowernumber, $amount, $type, $description);
334 (Note: the following is mostly conjecture and guesswork.)
336 Updates the fine owed on an overdue book.
338 C<$itemnumber> is the book's item number.
340 C<$borrowernumber> is the borrower number of the patron who currently
341 has the book on loan.
343 C<$amount> is the current amount owed by the patron.
345 C<$type> will be used in the description of the fine.
347 C<$description> is a string that must be present in the description of
348 the fine. I think this is expected to be a date in DD/MM/YYYY format.
350 C<&UpdateFine> looks up the amount currently owed on the given item
351 and sets it to C<$amount>, creating, if necessary, a new entry in the
352 accountlines table of the Koha database.
357 # FIXME - This API doesn't look right: why should the caller have to
358 # specify both the item number and the borrower number? A book can't
359 # be on loan to two different people, so the item number should be
362 my ( $itemnum, $borrowernumber, $amount, $type, $due ) = @_;
363 my $dbh = C4::Context->dbh;
364 # FIXME - What exactly is this query supposed to do? It looks up an
365 # entry in accountlines that matches the given item and borrower
366 # numbers, where the description contains $due, and where the
367 # account type has one of several values, but what does this _mean_?
368 # Does it look up existing fines for this item?
369 # FIXME - What are these various account types? ("FU", "O", "F", "M")
370 my $sth = $dbh->prepare(
371 "Select * from accountlines where itemnumber=? and
372 borrowernumber=? and (accounttype='FU' or accounttype='O' or
373 accounttype='F' or accounttype='M') and description like ?"
375 $sth->execute( $itemnum, $borrowernumber, "%$due%" );
377 if ( my $data = $sth->fetchrow_hashref ) {
379 # I think this if-clause deals with the case where we're updating
381 # print "in accounts ...";
382 if ( $data->{'amount'} != $amount ) {
385 my $diff = $amount - $data->{'amount'};
386 my $out = $data->{'amountoutstanding'} + $diff;
387 my $sth2 = $dbh->prepare(
388 "update accountlines set date=now(), amount=?,
389 amountoutstanding=?,accounttype='FU' where
390 borrowernumber=? and itemnumber=?
391 and (accounttype='FU' or accounttype='O') and description like ?"
393 $sth2->execute( $amount, $out, $data->{'borrowernumber'},
394 $data->{'itemnumber'}, "%$due%" );
399 # print "no update needed $data->{'amount'}"
404 # I think this else-clause deals with the case where we're adding
406 my $sth4 = $dbh->prepare(
407 "select title from biblio,items where items.itemnumber=?
408 and biblio.biblionumber=items.biblionumber"
410 $sth4->execute($itemnum);
411 my $title = $sth4->fetchrow_hashref;
414 # # print "not in account";
415 # my $sth3 = $dbh->prepare("Select max(accountno) from accountlines");
418 # # FIXME - Make $accountno a scalar.
419 # my @accountno = $sth3->fetchrow_array;
423 my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh);
424 my $sth2 = $dbh->prepare(
425 "Insert into accountlines
426 (borrowernumber,itemnumber,date,amount,
427 description,accounttype,amountoutstanding,accountno) values
428 (?,?,now(),?,?,'FU',?,?)"
430 $sth2->execute( $borrowernumber, $itemnum, $amount,
431 "$type $title->{'title'} $due",
432 $amount, $nextaccntno);
437 C4::Context->userenv->{'number'},
441 "due=".$due." amount=".$amount." itemnumber=".$itemnum
442 ) if C4::Context->preference("FinesLog");
449 $borrower = &BorType($borrowernumber);
451 Looks up a patron by borrower number.
453 C<$borrower> is a reference-to-hash whose keys are all of the fields
454 from the borrowers and categories tables of the Koha database. Thus,
455 C<$borrower> contains all information about both the borrower and
456 category he or she belongs to.
462 my ($borrowernumber) = @_;
463 my $dbh = C4::Context->dbh;
464 my $sth = $dbh->prepare(
465 "Select * from borrowers,categories where
467 borrowers.categorycode=categories.categorycode"
469 $sth->execute($borrowernumber);
470 my $data = $sth->fetchrow_hashref;
475 =item ReplacementCost
477 $cost = &ReplacementCost($itemnumber);
479 Returns the replacement cost of the item with the given item number.
484 sub ReplacementCost {
486 my $dbh = C4::Context->dbh;
488 $dbh->prepare("Select replacementprice from items where itemnumber=?");
489 $sth->execute($itemnum);
491 # FIXME - Use fetchrow_array or something.
492 my $data = $sth->fetchrow_hashref;
494 return ( $data->{'replacementprice'} );
499 $data->{'sum(amountoutstanding)'} = &GetFine($itemnum,$borrowernumber);
501 return the total of fine
503 C<$itemnum> is item number
505 C<$borrowernumber> is the borrowernumber
511 my ( $itemnum, $borrowernumber ) = @_;
512 my $dbh = C4::Context->dbh();
513 my $query = "SELECT sum(amountoutstanding) FROM accountlines
514 where accounttype like 'F%'
515 AND amountoutstanding > 0 AND itemnumber = ? AND borrowernumber=?";
516 my $sth = $dbh->prepare($query);
517 $sth->execute( $itemnum, $borrowernumber );
518 my $data = $sth->fetchrow_hashref();
521 return ( $data->{'sum(amountoutstanding)'} );
527 =item GetIssuingRules
529 $data = &GetIssuingRules($itemnumber,$categorycode);
531 Looks up for all issuingrules an item info
533 C<$itemnumber> is a reference-to-hash whose keys are all of the fields
534 from the borrowers and categories tables of the Koha database. Thus,
536 C<$categorycode> contains information about borrowers category
538 C<$data> contains all information about both the borrower and
539 category he or she belongs to.
542 sub GetIssuingRules {
543 my ($itemnumber,$categorycode)=@_;
544 my $dbh = C4::Context->dbh();
545 my $query=qq|SELECT *
546 FROM items,biblioitems,itemtypes,issuingrules
547 WHERE items.itemnumber=?
548 AND items.biblioitemnumber=biblioitems.biblioitemnumber
549 AND biblioitems.itemtype=itemtypes.itemtype
550 AND issuingrules.itemtype=itemtypes.itemtype
551 AND issuingrules.categorycode=?
552 AND (items.itemlost <> 1
553 OR items.itemlost is NULL)|;
554 my $sth = $dbh->prepare($query);
556 $sth->execute($itemnumber,$categorycode);
557 my ($data) = $sth->fetchrow_hashref;
564 sub ReplacementCost2 {
565 my ( $itemnum, $borrowernumber ) = @_;
566 my $dbh = C4::Context->dbh();
567 my $query = "SELECT amountoutstanding
569 WHERE accounttype like 'L'
570 AND amountoutstanding > 0
572 AND borrowernumber= ?";
573 my $sth = $dbh->prepare($query);
574 $sth->execute( $itemnum, $borrowernumber );
575 my $data = $sth->fetchrow_hashref();
578 return ( $data->{'amountoutstanding'} );
582 =item GetNextIdNotify
584 ($result) = &GetNextIdNotify($reference);
586 Returns the new file number
588 C<$result> contains the next file number
590 C<$reference> contains the beggining of file number
596 sub GetNextIdNotify {
598 my $query=qq|SELECT max(notify_id)
600 WHERE notify_id like \"$reference%\"
602 # AND borrowernumber=?|;
603 my $dbh = C4::Context->dbh;
604 my $sth=$dbh->prepare($query);
606 my $result=$sth->fetchrow;
611 ($result=$reference."01") ;
614 $count=substr($result,6)+1;
617 ($count = "0".$count);
619 $result=$reference.$count;
627 (@notify) = &AmountNotify($borrowernumber);
629 Returns amount for all file per borrowers
630 C<@notify> array contains all file per borrowers
632 C<$notify_id> contains the file number for the borrower number nad item number
637 my ($borrowernumber)=@_;
638 my $dbh = C4::Context->dbh;
640 my $query=qq| SELECT distinct(notify_id)
642 WHERE borrowernumber=?|;
644 my $sth=$dbh->prepare($query);
645 $sth->execute($borrowernumber);
646 while ( my $numberofotify=$sth->fetchrow_array){
647 push (@notify,$numberofotify);
657 ($totalnotify) = &AmountNotify($notifyid);
659 Returns amount for all file per borrowers
660 C<$notifyid> is the file number
662 C<$totalnotify> contains amount of a file
664 C<$notify_id> contains the file number for the borrower number nad item number
670 my $dbh = C4::Context->dbh;
671 my $query=qq| SELECT sum(amountoutstanding)
674 my $sth=$dbh->prepare($query);
675 $sth->execute($notifyid);
676 my $totalnotify=$sth->fetchrow;
678 return ($totalnotify);
684 ($notify_id) = &GetNotifyId($borrowernumber,$itemnumber);
686 Returns the file number per borrower and itemnumber
688 C<$borrowernumber> is a reference-to-hash whose keys are all of the fields
689 from the items tables of the Koha database. Thus,
691 C<$itemnumber> contains the borrower categorycode
693 C<$notify_id> contains the file number for the borrower number nad item number
698 my ($borrowernumber,$itemnumber)=@_;
699 my $query=qq|SELECT notify_id
701 WHERE borrowernumber=?
703 AND (accounttype='FU' or accounttype='O')|;
704 my $dbh = C4::Context->dbh;
705 my $sth=$dbh->prepare($query);
706 $sth->execute($borrowernumber,$itemnumber);
707 my ($notify_id)=$sth->fetchrow;
713 =item CreateItemAccountLine
715 () = &CreateItemAccountLine($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
717 update the account lines with file number or with file level
719 C<$items> is a reference-to-hash whose keys are all of the fields
720 from the items tables of the Koha database. Thus,
722 C<$itemnumber> contains the item number
724 C<$borrowernumber> contains the borrower number
726 C<$date> contains the date of the day
728 C<$amount> contains item price
730 C<$description> contains the descritpion of accounttype
732 C<$accounttype> contains the account type
734 C<$amountoutstanding> contains the $amountoutstanding
736 C<$timestamp> contains the timestamp with time and the date of the day
738 C<$notify_id> contains the file number
740 C<$level> contains the file level
745 sub CreateItemAccountLine {
746 my ($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level)=@_;
747 my $dbh = C4::Context->dbh;
748 my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh);
749 my $query= qq|INSERT into accountlines
750 (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level)
752 (?,?,?,?,?,?,?,?,?,?,?)|;
755 my $sth=$dbh->prepare($query);
756 $sth->execute($borrowernumber,$nextaccntno,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
760 =item UpdateAccountLines
762 () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber);
764 update the account lines with file number or with file level
766 C<$items> is a reference-to-hash whose keys are all of the fields
767 from the items tables of the Koha database. Thus,
769 C<$itemnumber> contains the item number
771 C<$notify_id> contains the file number
773 C<$notify_level> contains the file level
775 C<$borrowernumber> contains the borrowernumber
779 sub UpdateAccountLines {
780 my ($notify_id,$notify_level,$borrowernumber,$itemnumber)=@_;
782 if ($notify_id eq '')
785 $query=qq|UPDATE accountlines
787 WHERE borrowernumber=? AND itemnumber=?
788 AND (accounttype='FU' or accounttype='O')|;
791 $query=qq|UPDATE accountlines
792 SET notify_id=?, notify_level=?
793 WHERE borrowernumber=?
795 AND (accounttype='FU' or accounttype='O')|;
797 my $dbh = C4::Context->dbh;
798 my $sth=$dbh->prepare($query);
800 if ($notify_id eq '')
802 $sth->execute($notify_level,$borrowernumber,$itemnumber);
805 $sth->execute($notify_id,$notify_level,$borrowernumber,$itemnumber);
814 ($items) = &GetItems($itemnumber);
816 Returns the list of all delays from overduerules.
818 C<$items> is a reference-to-hash whose keys are all of the fields
819 from the items tables of the Koha database. Thus,
821 C<$itemnumber> contains the borrower categorycode
826 my($itemnumber) = @_;
827 my $query=qq|SELECT *
830 my $dbh = C4::Context->dbh;
831 my $sth=$dbh->prepare($query);
832 $sth->execute($itemnumber);
833 my ($items)=$sth->fetchrow_hashref;
838 =item GetOverdueDelays
840 (@delays) = &GetOverdueDelays($categorycode);
842 Returns the list of all delays from overduerules.
844 C<@delays> it's an array contains the three delays from overduerules table
846 C<$categorycode> contains the borrower categorycode
850 sub GetOverdueDelays {
852 my $dbh = C4::Context->dbh;
853 my $query=qq|SELECT delay1,delay2,delay3
855 WHERE categorycode=?|;
856 my $sth=$dbh->prepare($query);
857 $sth->execute($category);
858 my (@delays)=$sth->fetchrow_array;
863 =item CheckAccountLineLevelInfo
865 ($exist) = &CheckAccountLineLevelInfo($borrowernumber,$itemnumber,$accounttype,notify_level);
867 Check and Returns the list of all overdue books.
869 C<$exist> contains number of line in accounlines
870 with the same .biblionumber,itemnumber,accounttype,and notify_level
872 C<$borrowernumber> contains the borrower number
874 C<$itemnumber> contains item number
876 C<$accounttype> contains account type
878 C<$notify_level> contains the accountline level
883 sub CheckAccountLineLevelInfo {
884 my($borrowernumber,$itemnumber,$level) = @_;
885 my $dbh = C4::Context->dbh;
886 my $query= qq|SELECT count(*)
888 WHERE borrowernumber =?
891 my $sth=$dbh->prepare($query);
892 $sth->execute($borrowernumber,$itemnumber,$level);
893 my ($exist)=$sth->fetchrow;
898 =item GetOverduerules
900 ($overduerules) = &GetOverduerules($categorycode);
902 Returns the value of borrowers (debarred or not) with notify level
904 C<$overduerules> return value of debbraed field in overduerules table
906 C<$category> contains the borrower categorycode
908 C<$notify_level> contains the notify level
913 my($category,$notify_level) = @_;
914 my $dbh = C4::Context->dbh;
915 my $query=qq|SELECT debarred$notify_level
917 WHERE categorycode=?|;
918 my $sth=$dbh->prepare($query);
919 $sth->execute($category);
920 my ($overduerules)=$sth->fetchrow;
922 return($overduerules);
926 =item CheckBorrowerDebarred
928 ($debarredstatus) = &CheckBorrowerDebarred($borrowernumber);
930 Check if the borrowers is already debarred
932 C<$debarredstatus> return 0 for not debarred and return 1 for debarred
934 C<$borrowernumber> contains the borrower number
939 sub CheckBorrowerDebarred{
940 my($borrowernumber) = @_;
941 my $dbh = C4::Context->dbh;
942 my $query=qq|SELECT debarred
944 WHERE borrowernumber=?
946 my $sth=$dbh->prepare($query);
947 $sth->execute($borrowernumber);
948 my ($debarredstatus)=$sth->fetchrow;
950 if ($debarredstatus eq '1'){
957 =item UpdateBorrowerDebarred
959 ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
961 update status of borrowers in borrowers table (field debarred)
963 C<$borrowernumber> borrower number
967 sub UpdateBorrowerDebarred{
968 my($borrowernumber) = @_;
969 my $dbh = C4::Context->dbh;
970 my $query=qq|UPDATE borrowers
972 WHERE borrowernumber=?
974 my $sth=$dbh->prepare($query);
975 $sth->execute($borrowernumber);
980 =item CheckExistantNotifyid
982 ($exist) = &CheckExistantNotifyid($borrowernumber,$itemnumber,$accounttype,$notify_id);
984 Check and Returns the notify id if exist else return 0.
986 C<$exist> contains a notify_id
988 C<$borrowernumber> contains the borrower number
990 C<$date_due> contains the date of item return
995 sub CheckExistantNotifyid {
996 my($borrowernumber,$date_due) = @_;
997 my $dbh = C4::Context->dbh;
998 my $query = qq|SELECT notify_id FROM issues,accountlines
999 WHERE accountlines.borrowernumber =?
1000 AND issues.itemnumber= accountlines.itemnumber
1002 my $sth=$dbh->prepare($query);
1003 $sth->execute($borrowernumber,$date_due);
1004 my ($exist)=$sth->fetchrow;
1015 =item CheckAccountLineItemInfo
1017 ($exist) = &CheckAccountLineItemInfo($borrowernumber,$itemnumber,$accounttype,$notify_id);
1019 Check and Returns the list of all overdue items from the same file number(notify_id).
1021 C<$exist> contains number of line in accounlines
1022 with the same .biblionumber,itemnumber,accounttype,notify_id
1024 C<$borrowernumber> contains the borrower number
1026 C<$itemnumber> contains item number
1028 C<$accounttype> contains account type
1030 C<$notify_id> contains the file number
1034 sub CheckAccountLineItemInfo {
1035 my($borrowernumber,$itemnumber,$accounttype,$notify_id) = @_;
1036 my $dbh = C4::Context->dbh;
1037 my $query = qq|SELECT count(*) FROM accountlines
1038 WHERE borrowernumber =?
1042 my $sth=$dbh->prepare($query);
1043 $sth->execute($borrowernumber,$itemnumber,$accounttype,$notify_id);
1044 my ($exist)=$sth->fetchrow;
1057 Koha Developement team <info@koha.org>