From b360513d624a57f3b48b3038ad22203781f0621e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 20 Sep 2023 13:18:54 -0400 Subject: [PATCH] Bug 34854: Add ability to skip Talking Tech Itiva notifications for a patron if a given field matches a given value Because some notices are mandatory, some libraries would like to allow patrons to opt-in to phone notices. The request is to be able to decide if a patron should get a notice based on the value of a given field ( usually sort1 or sort2 ). Test Plan: 1) Apply this patch 2) Enable TalkingTechItivaPhoneNotification 3) Set up some overdue items for a patron 4) Enable phone notices for overdues in the notice status triggers 5) Run the outbound script for OVERDUE with -t OVERDUE 6) Note the output the output contains a line for that patron 7) Set the sort1 field for that patron to TEST 8) Run the script again, adding in the option "-i sort1:TEST" 9) Note the ouput no longer contains that patron! Signed-off-by: Lucas Gass Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit efd932ad42a9c9cc6f422f5286a278de49b76f60) Signed-off-by: Fridolin Somers --- .../thirdparty/TalkingTech_itiva_outbound.pl | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 5f679a9932..b7deefdfc3 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -53,6 +53,7 @@ my $help; my $outfile; my $skip_patrons_with_email; my $patron_branchcode; +my $if_patron_field_equals; # maps to convert I-tiva terms to Koha terms my $type_module_map = { @@ -68,15 +69,16 @@ my $type_notice_map = { }; GetOptions( - 'o|output:s' => \$outfile, - 'v' => \$verbose, - 'lang:s' => \$language, - 'type:s' => \@types, - 'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, - 'c|code|library-code:s' => \$library_code, - 's|skip-patrons-with-email' => \$skip_patrons_with_email, - 'pb|patron-branchcode:s' => \$patron_branchcode, - 'h|help' => \$help, + 'o|output:s' => \$outfile, + 'v' => \$verbose, + 'lang:s' => \$language, + 'type:s' => \@types, + 'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, + 'c|code|library-code:s' => \$library_code, + 's|skip-patrons-with-email' => \$skip_patrons_with_email, + 'i|if-patron-field-equals:s' => \$if_patron_field_equals, + 'pb|patron-branchcode:s' => \$patron_branchcode, + 'h|help' => \$help, ); $language = uc($language); @@ -101,6 +103,10 @@ if ( defined $outfile ) { my $format = 'V'; # format for phone notifications +my ( $if_patron_field_equals_field, $if_patron_field_equals_value ); +( $if_patron_field_equals_field, $if_patron_field_equals_value ) = split( /:/, $if_patron_field_equals ) + if $if_patron_field_equals; + 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 @@ -122,7 +128,10 @@ foreach my $type (@types) { my $patrons; foreach my $issues (@loop) { $patrons->{$issues->{borrowernumber}} ||= Koha::Patrons->find( $issues->{borrowernumber} ) if $skip_patrons_with_email; - next if $skip_patrons_with_email && $patrons->{$issues->{borrowernumber}}->notice_email_address; + next if $skip_patrons_with_email && $patrons->{ $issues->{borrowernumber} }->notice_email_address; + next + if $if_patron_field_equals + && $patrons->{ $issues->{borrowernumber} }->$if_patron_field_equals_field eq $if_patron_field_equals_value; my $date_dt = dt_from_string ( $issues->{'date_due'} ); my $due_date = output_pref( { dt => $date_dt, dateonly => 1, dateformat =>'metric' } ); -- 2.39.5