X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FOverdues.pm;h=169b36ccfd36b2a85a4c24279085e3b41ff3a1af;hb=4458ac5764126049d95e115adeacd1f335efdb8f;hp=4fd0b8450f7d0e2fb01bd6658079ef38d70bba4c;hpb=8f20b248e7dd6e10b019b1ec27dfb04796e9b0a5;p=koha_fer diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 4fd0b8450f..169b36ccfd 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -23,6 +23,8 @@ use strict; #use warnings; FIXME - Bug 2505 use Date::Calc qw/Today Date_to_Days/; use Date::Manip qw/UnixDate/; +use List::MoreUtils qw( uniq ); + use C4::Circulation; use C4::Context; use C4::Accounts; @@ -50,6 +52,7 @@ BEGIN { &GetOverduesForBranch &RemoveNotifyLine &AddNotifyLine + &GetOverdueMessageTransportTypes ); # subs to remove push @EXPORT, qw( @@ -62,10 +65,10 @@ BEGIN { push @EXPORT, qw( &GetIssuesIteminfo ); - # subs to move to Members.pm - push @EXPORT, qw( - &CheckBorrowerDebarred - ); + + # &GetIssuingRules - delete. + # use C4::Circulation::GetIssuingRule instead. + # subs to move to Biblio.pm push @EXPORT, qw( &GetItems @@ -759,35 +762,6 @@ sub GetBranchcodesWithOverdueRules { return @branches; } -=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=? - AND debarred > NOW() - |; - my $sth = $dbh->prepare($query); - $sth->execute($borrowernumber); - my $debarredstatus = $sth->fetchrow; - return $debarredstatus; -} - - =head2 CheckItemNotify Sql request to check if the document has alreday been notified @@ -825,6 +799,7 @@ sub GetOverduesForBranch { my $dbh = C4::Context->dbh; my $select = " SELECT + borrowers.cardnumber, borrowers.borrowernumber, borrowers.surname, borrowers.firstname, @@ -934,6 +909,36 @@ sub RemoveNotifyLine { return 1; } +=head2 GetOverdueMessageTransportTypes + + my $message_transport_types = GetOverdueMessageTransportTypes( $branchcode, $categorycode, $letternumber); + + return a arrayref with all message_transport_type for given branchcode, categorycode and letternumber(1,2 or 3) + +=cut + +sub GetOverdueMessageTransportTypes { + my ( $branchcode, $categorycode, $letternumber ) = @_; + return unless $categorycode and $letternumber; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare(" + SELECT message_transport_type FROM overduerules_transport_types + WHERE branchcode = ? AND categorycode = ? AND letternumber = ? + "); + $sth->execute( $branchcode, $categorycode, $letternumber ); + my @mtts; + while ( my $mtt = $sth->fetchrow ) { + push @mtts, $mtt; + } + + # Put 'print' in first if exists + # It avoid to sent a print notice with an email or sms template is no email or sms is defined + @mtts = uniq( 'print', @mtts ) + if grep {/^print$/} @mtts; + + return \@mtts; +} + 1; __END__