- }
- }
- return (@getoverdues);
- $sth->finish;
- }
- else {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare( "
- SELECT borrowers.surname,
- borrowers.firstname,
- biblio.title,
- itemtypes.description,
- issues.date_due,
- issues.returndate,
- branches.branchname,
- items.barcode,
- borrowers.phone,
- borrowers.email,
- items.itemcallnumber,
- borrowers.borrowernumber,
- items.itemnumber,
- biblio.biblionumber,
- issues.branchcode,
- accountlines.notify_id,
- accountlines.notify_level,
- items.location,
- accountlines.amountoutstanding
- FROM accountlines
- LEFT JOIN issues ON issues.itemnumber = accountlines.itemnumber AND issues.borrowernumber = accountlines.borrowernumber
- LEFT JOIN borrowers ON borrowers.borrowernumber = accountlines.borrowernumber
- LEFT JOIN items ON items.itemnumber = issues.itemnumber
- LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
- LEFT JOIN biblioitems ON biblioitems.biblioitemnumber=items.biblioitemnumber
- LEFT JOIN itemtypes ON itemtypes.itemtype = $itype_link
- LEFT JOIN branches ON branches.branchcode = issues.branchcode
- WHERE ( accountlines.amountoutstanding != '0.000000')
- AND ( accountlines.accounttype = 'FU')
- AND (issues.branchcode = ? AND items.location = ?)
- AND (issues.date_due <= NOW())
- ORDER BY borrowers.surname
- " );
- $sth->execute( $branch, $location);
- my @getoverdues;
- my $i = 0;
- while ( my $data = $sth->fetchrow_hashref ) {
- #check if the document has already been notified
- my $countnotify = CheckItemNotify($data->{'notify_id'},$data->{'notify_level'},$data->{'itemnumber'});
- if ($countnotify eq '0'){
- $getoverdues[$i] = $data;
- $i++;
- }