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 <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
325980b43f
commit
efd932ad42
1 changed files with 19 additions and 10 deletions
|
@ -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' } );
|
||||
|
|
Loading…
Reference in a new issue