Bugzilla – Attachment 13176 Details for
Bug 9004
Talking Tech doesn't account for holidays when calculating a holds last pickup date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9004 - Talking Tech doesn't account for holidays when calculating a holds last pickup date.
Bug-9004---Talking-Tech-doesnt-account-for-holiday.patch (text/plain), 8.79 KB, created by
Kyle M Hall (khall)
on 2012-11-01 15:38:46 UTC
(
hide
)
Description:
Bug 9004 - Talking Tech doesn't account for holidays when calculating a holds last pickup date.
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-11-01 15:38:46 UTC
Size:
8.79 KB
patch
obsolete
>From 58b63c56b792866b37abf1e362deb25d74a0183a Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 1 Nov 2012 08:10:32 -0400 >Subject: [PATCH] Bug 9004 - Talking Tech doesn't account for holidays when calculating a holds last pickup date. >Content-Type: text/plain; charset="utf-8" > >--- > .../thirdparty/TalkingTech_itiva_outbound.pl | 97 +++++++------------- > 1 files changed, 34 insertions(+), 63 deletions(-) > >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index b4d4e9c..ea1cc7a 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -44,8 +44,7 @@ sub usage { > exit; > } > >-die >- "TalkingTechItivaPhoneNotification system preference not activated... dying\n" >+die "TalkingTechItivaPhoneNotification system preference not activated... dying\n" > unless ( C4::Context->preference("TalkingTechItivaPhoneNotification") ); > > # Database handle >@@ -92,8 +91,7 @@ pod2usage( -verbose => 1 ) if $help; > my $OUT; > if ( defined $outfile ) { > open( $OUT, '>', "$outfile" ) || die("Cannot open output file"); >-} >-else { >+} else { > print "No output file defined; printing to STDOUT\n" > if ( defined $verbose ); > open( $OUT, '>', "&STDOUT" ) || die("Couldn't duplicate STDOUT: $!"); >@@ -103,21 +101,17 @@ my $format = 'V'; # format for phone notifications > > foreach my $type (@types) { > $type = uc($type); #just in case lower or mixed-case was supplied >- my $module = >- $type_module_map->{$type}; #since the module is required to get the letter >- my $code = $type_notice_map->{$type}; #to get the Koha name of the notice >+ my $module = $type_module_map->{$type}; #since the module is required to get the letter >+ my $code = $type_notice_map->{$type}; #to get the Koha name of the notice > > my @loop; > if ( $type eq 'OVERDUE' ) { > @loop = GetOverdueIssues(); >- } >- elsif ( $type eq 'PREOVERDUE' ) { >+ } elsif ( $type eq 'PREOVERDUE' ) { > @loop = GetPredueIssues(); >- } >- elsif ( $type eq 'RESERVE' ) { >+ } elsif ( $type eq 'RESERVE' ) { > @loop = GetWaitingHolds(); >- } >- else { >+ } else { > print "Unknown or unsupported message type $type; skipping...\n" > if ( defined $verbose ); > next; >@@ -142,20 +136,16 @@ foreach my $type (@types) { > my $message_id = 0; > if ($outfile) { > $message_id = C4::Letters::EnqueueLetter( >- { >- letter => $letter, >+ { letter => $letter, > borrowernumber => $issues->{'borrowernumber'}, > message_transport_type => 'phone', > } > ); > } > >- print $OUT >-"\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\","; >- print $OUT >-"\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\","; >- print $OUT >-"\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n"; >+ print $OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\","; >+ print $OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\","; >+ print $OUT "\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n"; > } > } > >@@ -217,8 +207,7 @@ This field can be blank if all messages are from a single library. > =cut > > sub GetOverdueIssues { >- my $query = >-"SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, >+ my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, > max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3, > issues.branchcode as site, branches.branchname as site_name >@@ -239,14 +228,11 @@ sub GetOverdueIssues { > while ( my $issue = $sth->fetchrow_hashref() ) { > if ( $issue->{'daysoverdue'} == $issue->{'delay1'} ) { > $issue->{'level'} = 1; >- } >- elsif ( $issue->{'daysoverdue'} == $issue->{'delay2'} ) { >+ } elsif ( $issue->{'daysoverdue'} == $issue->{'delay2'} ) { > $issue->{'level'} = 2; >- } >- elsif ( $issue->{'daysoverdue'} == $issue->{'delay3'} ) { >+ } elsif ( $issue->{'daysoverdue'} == $issue->{'delay3'} ) { > $issue->{'level'} = 3; >- } >- else { >+ } else { > > # this shouldn't ever happen, based our SQL criteria > } >@@ -256,8 +242,7 @@ sub GetOverdueIssues { > } > > sub GetPredueIssues { >- my $query = >-"SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, >+ my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, > issues.branchcode as site, branches.branchname as site_name > FROM borrowers JOIN issues USING (borrowernumber) >@@ -282,8 +267,7 @@ sub GetPredueIssues { > } > > sub GetWaitingHolds { >- my $query = >-"SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, >+ my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, > reserves.branchcode AS site, branches.branchname AS site_name, > TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting >@@ -303,40 +287,27 @@ sub GetWaitingHolds { > $sth->execute(); > my @results; > while ( my $issue = $sth->fetchrow_hashref() ) { >- my @waitingdate = split( /-/, $issue->{'waitingdate'} ); >- my @date_due = >- Add_Delta_Days( $waitingdate[0], $waitingdate[1], $waitingdate[2], >- $pickupdelay ); >- $issue->{'date_due'} = >- sprintf( "%04d-%02d-%02d", $date_due[0], $date_due[1], $date_due[2] ); >- $issue->{'level'} = 1; # only one level for Hold Waiting notifications >+ my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} ); >+ >+ my ( $waiting_year, $waiting_month, $waiting_day ) = split( /-/, $issue->{'waitingdate'} ); >+ >+ my ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $pickupdelay ); >+ >+ while ( $calendar->isHoliday( $pickup_day, $pickup_month, $pickup_year ) ) { >+ ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $pickup_year, $pickup_month, $pickup_day, 1 ); >+ } >+ >+ $issue->{'date_due'} = sprintf( "%04d-%02d-%02d", $pickup_year, $pickup_month, $pickup_day ); >+ $issue->{'level'} = 1; ## only one level for Hold Waiting notifications > > my $days_to_subtract = 0; >- my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} ); >- while ( >- $calendar->isHoliday( >- reverse( >- Add_Delta_Days( >- $waitingdate[0], $waitingdate[1], >- $waitingdate[2], $days_to_subtract >- ) >- ) >- ) >- ) >- { >+ while ( $calendar->isHoliday( reverse( Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $days_to_subtract ) ) ) ) { > $days_to_subtract++; > } >- $issue->{'days_since_waiting'} = >- $issue->{'days_since_waiting'} - $days_to_subtract; >- >- if ( >- ( >- grep $_ eq $issue->{'days_since_waiting'}, >- @holds_waiting_days_to_call >- ) >- || !scalar(@holds_waiting_days_to_call) >- ) >- { >+ $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract; >+ >+ if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call ) >+ || !scalar(@holds_waiting_days_to_call) ) { > push @results, $issue; > } > } >-- >1.7.2.5
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 9004
:
13176
|
13212
|
13213
|
50042
|
50043
|
50082
|
50085
|
50086
|
50111
|
50112
|
50113
|
50114