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
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 *
341 AND returndate IS NULL|;
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($borrowernumber);
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;
658 my $query=qq| SELECT distinct(notify_id)
660 WHERE borrowernumber=?
662 AND notify_id != 1 |;
664 my $sth=$dbh->prepare($query);
665 $sth->execute($borrowernumber);
666 while ( my $numberofotify=$sth->fetchrow_array){
667 push (@notify,$numberofotify);
677 ($totalnotify) = &AmountNotify($notifyid);
679 Returns amount for all file per borrowers
680 C<$notifyid> is the file number
682 C<$totalnotify> contains amount of a file
684 C<$notify_id> contains the file number for the borrower number nad item number
690 my $dbh = C4::Context->dbh;
691 my $query=qq| SELECT sum(amountoutstanding)
694 my $sth=$dbh->prepare($query);
695 $sth->execute($notifyid);
696 my $totalnotify=$sth->fetchrow;
698 return ($totalnotify);
704 ($notify_id) = &GetNotifyId($borrowernumber,$itemnumber);
706 Returns the file number per borrower and itemnumber
708 C<$borrowernumber> is a reference-to-hash whose keys are all of the fields
709 from the items tables of the Koha database. Thus,
711 C<$itemnumber> contains the borrower categorycode
713 C<$notify_id> contains the file number for the borrower number nad item number
718 my ($borrowernumber,$itemnumber)=@_;
719 my $query=qq|SELECT notify_id
721 WHERE borrowernumber=?
723 AND (accounttype='FU' or accounttype='O')|;
724 my $dbh = C4::Context->dbh;
725 my $sth=$dbh->prepare($query);
726 $sth->execute($borrowernumber,$itemnumber);
727 my ($notify_id)=$sth->fetchrow;
733 =item CreateItemAccountLine
735 () = &CreateItemAccountLine($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
737 update the account lines with file number or with file level
739 C<$items> is a reference-to-hash whose keys are all of the fields
740 from the items tables of the Koha database. Thus,
742 C<$itemnumber> contains the item number
744 C<$borrowernumber> contains the borrower number
746 C<$date> contains the date of the day
748 C<$amount> contains item price
750 C<$description> contains the descritpion of accounttype
752 C<$accounttype> contains the account type
754 C<$amountoutstanding> contains the $amountoutstanding
756 C<$timestamp> contains the timestamp with time and the date of the day
758 C<$notify_id> contains the file number
760 C<$level> contains the file level
765 sub CreateItemAccountLine {
766 my ($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level)=@_;
767 my $dbh = C4::Context->dbh;
768 my $nextaccntno = getnextacctno($borrowernumber);
769 my $query= "INSERT into accountlines
770 (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level)
772 (?,?,?,?,?,?,?,?,?,?,?)";
775 my $sth=$dbh->prepare($query);
776 $sth->execute($borrowernumber,$nextaccntno,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level);
780 =item UpdateAccountLines
782 () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber);
784 update the account lines with file number or with file level
786 C<$items> is a reference-to-hash whose keys are all of the fields
787 from the items tables of the Koha database. Thus,
789 C<$itemnumber> contains the item number
791 C<$notify_id> contains the file number
793 C<$notify_level> contains the file level
795 C<$borrowernumber> contains the borrowernumber
799 sub UpdateAccountLines {
800 my ($notify_id,$notify_level,$borrowernumber,$itemnumber)=@_;
802 if ($notify_id eq '')
805 $query=qq|UPDATE accountlines
807 WHERE borrowernumber=? AND itemnumber=?
808 AND (accounttype='FU' or accounttype='O')|;
811 $query=qq|UPDATE accountlines
812 SET notify_id=?, notify_level=?
813 WHERE borrowernumber=?
815 AND (accounttype='FU' or accounttype='O')|;
817 my $dbh = C4::Context->dbh;
818 my $sth=$dbh->prepare($query);
820 if ($notify_id eq '')
822 $sth->execute($notify_level,$borrowernumber,$itemnumber);
825 $sth->execute($notify_id,$notify_level,$borrowernumber,$itemnumber);
834 ($items) = &GetItems($itemnumber);
836 Returns the list of all delays from overduerules.
838 C<$items> is a reference-to-hash whose keys are all of the fields
839 from the items tables of the Koha database. Thus,
841 C<$itemnumber> contains the borrower categorycode
846 my($itemnumber) = @_;
847 my $query=qq|SELECT *
850 my $dbh = C4::Context->dbh;
851 my $sth=$dbh->prepare($query);
852 $sth->execute($itemnumber);
853 my ($items)=$sth->fetchrow_hashref;
858 =item GetOverdueDelays
860 (@delays) = &GetOverdueDelays($categorycode);
862 Returns the list of all delays from overduerules.
864 C<@delays> it's an array contains the three delays from overduerules table
866 C<$categorycode> contains the borrower categorycode
870 sub GetOverdueDelays {
872 my $dbh = C4::Context->dbh;
873 my $query=qq|SELECT delay1,delay2,delay3
875 WHERE categorycode=?|;
876 my $sth=$dbh->prepare($query);
877 $sth->execute($category);
878 my (@delays)=$sth->fetchrow_array;
883 =item CheckAccountLineLevelInfo
885 ($exist) = &CheckAccountLineLevelInfo($borrowernumber,$itemnumber,$accounttype,notify_level);
887 Check and Returns the list of all overdue books.
889 C<$exist> contains number of line in accounlines
890 with the same .biblionumber,itemnumber,accounttype,and notify_level
892 C<$borrowernumber> contains the borrower number
894 C<$itemnumber> contains item number
896 C<$accounttype> contains account type
898 C<$notify_level> contains the accountline level
903 sub CheckAccountLineLevelInfo {
904 my($borrowernumber,$itemnumber,$level,$datedue) = @_;
906 @formatdate=split('-',$datedue);
907 $datedue=$formatdate[2]."/".$formatdate[1]."/".$formatdate[0];
908 my $dbh = C4::Context->dbh;
909 my $query= qq|SELECT count(*)
911 WHERE borrowernumber =?
914 AND description like ?|;
915 my $sth=$dbh->prepare($query);
916 $sth->execute($borrowernumber,$itemnumber,$level,"%$datedue%");
917 my ($exist)=$sth->fetchrow;
922 =item GetOverduerules
924 ($overduerules) = &GetOverduerules($categorycode);
926 Returns the value of borrowers (debarred or not) with notify level
928 C<$overduerules> return value of debbraed field in overduerules table
930 C<$category> contains the borrower categorycode
932 C<$notify_level> contains the notify level
937 my($category,$notify_level) = @_;
938 my $dbh = C4::Context->dbh;
939 my $query=qq|SELECT debarred$notify_level
941 WHERE categorycode=?|;
942 my $sth=$dbh->prepare($query);
943 $sth->execute($category);
944 my ($overduerules)=$sth->fetchrow;
946 return($overduerules);
950 =item CheckBorrowerDebarred
952 ($debarredstatus) = &CheckBorrowerDebarred($borrowernumber);
954 Check if the borrowers is already debarred
956 C<$debarredstatus> return 0 for not debarred and return 1 for debarred
958 C<$borrowernumber> contains the borrower number
963 sub CheckBorrowerDebarred{
964 my($borrowernumber) = @_;
965 my $dbh = C4::Context->dbh;
966 my $query=qq|SELECT debarred
968 WHERE borrowernumber=?
970 my $sth=$dbh->prepare($query);
971 $sth->execute($borrowernumber);
972 my ($debarredstatus)=$sth->fetchrow;
974 if ($debarredstatus eq '1'){
981 =item UpdateBorrowerDebarred
983 ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
985 update status of borrowers in borrowers table (field debarred)
987 C<$borrowernumber> borrower number
991 sub UpdateBorrowerDebarred{
992 my($borrowernumber) = @_;
993 my $dbh = C4::Context->dbh;
994 my $query=qq|UPDATE borrowers
996 WHERE borrowernumber=?
998 my $sth=$dbh->prepare($query);
999 $sth->execute($borrowernumber);
1004 =item CheckExistantNotifyid
1006 ($exist) = &CheckExistantNotifyid($borrowernumber,$itemnumber,$accounttype,$notify_id);
1008 Check and Returns the notify id if exist else return 0.
1010 C<$exist> contains a notify_id
1012 C<$borrowernumber> contains the borrower number
1014 C<$date_due> contains the date of item return
1019 sub CheckExistantNotifyid {
1020 my($borrowernumber,$date_due) = @_;
1021 my $dbh = C4::Context->dbh;
1023 @formatdate=split('-',$date_due);
1024 $date_due=$formatdate[2]."/".$formatdate[1]."/".$formatdate[0];
1025 my $query = qq|SELECT notify_id FROM accountlines
1026 WHERE description like ?
1027 AND borrowernumber =?
1028 AND( accounttype='FU' OR accounttype='F' )
1030 AND notify_id != 1|;
1031 my $sth=$dbh->prepare($query);
1032 $sth->execute("%$date_due%",$borrowernumber);
1033 my ($exist)=$sth->fetchrow;
1044 =item CheckAccountLineItemInfo
1046 ($exist) = &CheckAccountLineItemInfo($borrowernumber,$itemnumber,$accounttype,$notify_id);
1048 Check and Returns the list of all overdue items from the same file number(notify_id).
1050 C<$exist> contains number of line in accounlines
1051 with the same .biblionumber,itemnumber,accounttype,notify_id
1053 C<$borrowernumber> contains the borrower number
1055 C<$itemnumber> contains item number
1057 C<$accounttype> contains account type
1059 C<$notify_id> contains the file number
1063 sub CheckAccountLineItemInfo {
1064 my($borrowernumber,$itemnumber,$accounttype,$notify_id) = @_;
1065 my $dbh = C4::Context->dbh;
1066 my $query = qq|SELECT count(*) FROM accountlines
1067 WHERE borrowernumber =?
1071 my $sth=$dbh->prepare($query);
1072 $sth->execute($borrowernumber,$itemnumber,$accounttype,$notify_id);
1073 my ($exist)=$sth->fetchrow;
1086 Koha Developement team <info@koha.org>