Bugzilla – Attachment 1275 Details for
Bug 3393
Default branches and overdues notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bugfix
0001--bug-3393-take-care-of-default-rules-in-overdues.patch (text/plain), 4.10 KB, created by
Chris Cormack
on 2009-07-06 08:20:00 UTC
(
hide
)
Description:
bugfix
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2009-07-06 08:20:00 UTC
Size:
4.10 KB
patch
obsolete
>From 604617fdbe02222d3a6035c60c641dd06b761b91 Mon Sep 17 00:00:00 2001 >From: Nahuel ANGELINETTI <nahuel.angelinetti@biblibre.com> >Date: Mon, 6 Jul 2009 10:13:54 +0200 >Subject: [PATCH] (bug #3393) take care of default rules in overdues >Content-Type: text/plain; charset="utf-8" > >This fix the overdues notices script, that doesn't take care of default rules. >Now if there is no specific rules for a branchcode, the script use the default rule if it exists. >--- > C4/Overdues.pm | 12 ++++++++++++ > misc/cronjobs/overdue_notices.pl | 24 +++++++++++++++--------- > 2 files changed, 27 insertions(+), 9 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 06cf37a..3f167b0 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -978,8 +978,20 @@ returns a list of branch codes for branches with overdue rules defined. > sub GetBranchcodesWithOverdueRules { > my $dbh = C4::Context->dbh; > my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> ''"); >+ my $availbranches = C4::Branch::GetBranches(); >+ > $rqoverduebranches->execute; > my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref }; >+ >+ my $defaultbranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ''"); >+ $defaultbranches->execute(); >+ if($defaultbranches->rows > 0){ >+ foreach my $branch (keys %$availbranches){ >+ if(not grep{/^$branch$/} @branches){ >+ push @branches, $branch; >+ } >+ } >+ } > $rqoverduebranches->finish; > return @branches; > } >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 23ce459..1312db9 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -298,7 +298,6 @@ if ( defined $csvfilename ) { > } > > foreach my $branchcode (@branches) { >- > my $branch_details = C4::Branch::GetBranchDetail($branchcode); > my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); > my @output_chunks; # may be sent to mail or stdout or csv file. >@@ -307,19 +306,25 @@ foreach my $branchcode (@branches) { > > my $sth2 = $dbh->prepare( <<'END_SQL' ); > SELECT biblio.*, items.*, issues.*, TO_DAYS(NOW())-TO_DAYS(date_due) AS days_overdue >- FROM issues,items,biblio >- WHERE items.itemnumber=issues.itemnumber >- AND biblio.biblionumber = items.biblionumber >- AND issues.borrowernumber = ? >+ FROM issues >+ LEFT JOIN items USING(itemnumber) >+ LEFT JOIN biblio USING(biblionumber) >+ WHERE issues.borrowernumber = ? > AND TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ? > END_SQL > > my $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? "); > $rqoverduerules->execute($branchcode); >+ >+ # We get default rules is there is no rule for this branch >+ if($rqoverduerules->rows == 0){ >+ $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' "); >+ $rqoverduerules->execute(); >+ } >+ > # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' ); > while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) { > PERIOD: foreach my $i ( 1 .. 3 ) { >- > $verbose and warn "branch '$branchcode', pass $i\n"; > my $mindays = $overdue_rules->{"delay$i"}; # the notice will be sent after mindays days (grace period) > my $maxdays = ( >@@ -341,9 +346,10 @@ END_SQL > > my $borrower_sql = <<'END_SQL'; > SELECT COUNT(*), issues.borrowernumber, firstname, surname, address, address2, city, zipcode, email, MIN(date_due) as longest_issue >-FROM issues,borrowers,categories >-WHERE issues.borrowernumber=borrowers.borrowernumber >-AND borrowers.categorycode=categories.categorycode >+FROM issues >+LEFT JOIN borrowers USING (borrowernumber) >+LEFT JOIN categories ON (borrowers.categorycode=categories.categorycode) >+WHERE 1 > END_SQL > my @borrower_parameters; > if ($branchcode) { >-- >1.6.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3393
: 1275 |
2613