-=head2 CheckAccountLineLevelInfo
-
- ($exist) = &CheckAccountLineLevelInfo($borrowernumber,$itemnumber,$accounttype,notify_level);
-
-Check and Returns the list of all overdue books.
-
-C<$exist> contains number of line in accounlines
-with the same .biblionumber,itemnumber,accounttype,and notify_level
-
-C<$borrowernumber> contains the borrower number
-
-C<$itemnumber> contains item number
-
-C<$accounttype> contains account type
-
-C<$notify_level> contains the accountline level
-
-
-=cut
-
-sub CheckAccountLineLevelInfo {
- my ( $borrowernumber, $itemnumber, $level ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT count(*)
- FROM accountlines
- WHERE borrowernumber =?
- AND itemnumber = ?
- AND notify_level=?|;
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber, $itemnumber, $level );
- my ($exist) = $sth->fetchrow;
- return ($exist);
-}
-
-=head2 GetOverduerules
-
- ($overduerules) = &GetOverduerules($categorycode);
-
-Returns the value of borrowers (debarred or not) with notify level
-
-C<$overduerules> return value of debbraed field in overduerules table
-
-C<$category> contains the borrower categorycode
-
-C<$notify_level> contains the notify level
-
-=cut
-
-sub GetOverduerules {
- my ( $category, $notify_level ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT debarred$notify_level
- FROM overduerules
- WHERE categorycode=?|;
- my $sth = $dbh->prepare($query);
- $sth->execute($category);
- my ($overduerules) = $sth->fetchrow;
- return ($overduerules);
-}
-
-
-=head2 CheckBorrowerDebarred
-
- ($debarredstatus) = &CheckBorrowerDebarred($borrowernumber);
-
-Check if the borrowers is already debarred
-
-C<$debarredstatus> return 0 for not debarred and return 1 for debarred
-
-C<$borrowernumber> contains the borrower number
-
-=cut
-
-# FIXME: Shouldn't this be in C4::Members?
-sub CheckBorrowerDebarred {
- my ($borrowernumber) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|
- SELECT debarred
- FROM borrowers
- WHERE borrowernumber=?
- |;
- my $sth = $dbh->prepare($query);
- $sth->execute($borrowernumber);
- my ($debarredstatus) = $sth->fetchrow;
- return ( $debarredstatus eq '1' ? 1 : 0 );
-}
-
-=head2 UpdateBorrowerDebarred
-
- ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
-
-update status of borrowers in borrowers table (field debarred)
-
-C<$borrowernumber> borrower number
-
-=cut
-
-sub UpdateBorrowerDebarred{
- my($borrowernumber) = @_;
- my $dbh = C4::Context->dbh;
- my $query=qq|UPDATE borrowers
- SET debarred='1'
- WHERE borrowernumber=?
- |;
- my $sth=$dbh->prepare($query);
- $sth->execute($borrowernumber);
- $sth->finish;
- return 1;
-}
-
-=head2 CheckExistantNotifyid
-
- ($exist) = &CheckExistantNotifyid($borrowernumber,$itemnumber,$accounttype,$notify_id);
-
-Check and Returns the notify id if exist else return 0.
-
-C<$exist> contains a notify_id
-
-C<$borrowernumber> contains the borrower number
-
-C<$date_due> contains the date of item return
-
-
-=cut
-
-sub CheckExistantNotifyid {
- my ( $borrowernumber, $date_due ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT notify_id FROM accountlines
- LEFT JOIN issues ON issues.itemnumber= accountlines.itemnumber
- WHERE accountlines.borrowernumber =?
- AND date_due = ?|;
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber, $date_due );
- return $sth->fetchrow || 0;
-}
-
-=head2 CheckAccountLineItemInfo
-
- ($exist) = &CheckAccountLineItemInfo($borrowernumber,$itemnumber,$accounttype,$notify_id);
-
-Check and Returns the list of all overdue items from the same file number(notify_id).
-
-C<$exist> contains number of line in accounlines
-with the same .biblionumber,itemnumber,accounttype,notify_id
-
-C<$borrowernumber> contains the borrower number
-
-C<$itemnumber> contains item number
-
-C<$accounttype> contains account type
-
-C<$notify_id> contains the file number
-
-=cut
-
-sub CheckAccountLineItemInfo {
- my ( $borrowernumber, $itemnumber, $accounttype, $notify_id ) = @_;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT count(*) FROM accountlines
- WHERE borrowernumber =?
- AND itemnumber = ?
- AND accounttype= ?
- AND notify_id = ?|;
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber, $itemnumber, $accounttype, $notify_id );
- my ($exist) = $sth->fetchrow;
- return ($exist);
-}
-