From: Cesar Velez Date: Tue, 22 Jan 2019 17:16:54 +0000 (-0500) Subject: LP#1570072: update hold notification methods upon preference changes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7e92293;p=Evergreen.git LP#1570072: update hold notification methods upon preference changes This patch adds a feature where if a patron's hold notification preferences are changed, they are given an opportunity to have notfication methods for their pending hold requests updated to reflect their new prefernces. This feature affects both the public catalog My Account interface and the staff patron registration form. In both cases, the user is presented with a modal (staff-side) or interstitial page (public catalog) asking them whether to update current hold requests. Sponsored-by: MassLNC Additional-work-by: Mike Rylander Additional-work-by: Galen Charlton Signed-off-by: Cesar Velez Signed-off-by: Galen Charlton Signed-off-by: Terran McCanna Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index e19915e75c..11c29f8914 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -4549,6 +4549,282 @@ sub copy_has_holds_count { } __PACKAGE__->register_method( + method => "retrieve_holds_by_usr_notify_value_staff", + api_name => "open-ils.circ.holds.retrieve_by_notify_staff", + signature => { + desc => "Retrieve the hold, for the specified user using the notify value. $ses_is_req_note", + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'User ID', type => 'number' }, + { desc => 'notify value', type => 'string' }, + { desc => 'notify_type', type => 'string' } + ], + return => { + desc => 'Hold objects with transits attached, event on error', + } + } +); + +sub retrieve_holds_by_usr_notify_value_staff { + + my($self, $conn, $auth, $usr_id, $contact, $cType) = @_; + + my $e = new_editor(authtoken=>$auth); + $e->checkauth or return $e->event; + + if ($e->requestor->id != $usr_id){ + $e->allowed('VIEW_HOLD') or return $e->event; + } + + my $q = { + "select" => { "ahr" => ["id", "sms_notify", "phone_notify", "email_notify", "sms_carrier"]}, + "from" => "ahr", + "where" => { + "usr" => $usr_id, + "capture_time" => undef, + "cancel_time" => undef, + "fulfillment_time" => undef, + } + }; + + if ($cType eq "day_phone" or $cType eq "evening_phone" or + $cType eq "other_phone" or $cType eq "default_phone"){ + $q->{where}->{"-not"} = [ + { "phone_notify" => { "=" => $contact} }, + { "phone_notify" => { "<>" => undef } } + ]; + } + + + if ($cType eq "default_sms") { + $q->{where}->{"-not"} = [ + { "sms_notify" => { "=" => $contact} }, + { "sms_notify" => { "<>" => undef } } + ]; + } + + if ($cType eq "default_sms_carrier_id") { + $q->{where}->{"-not"} = [ + { "sms_carrier" => { "=" => int($contact)} }, + { "sms_carrier" => { "<>" => undef } } + ]; + } + + if ($cType =~ /notify/){ + # this is was notification pref change + # we find all unfulfilled holds that match have that pref + my $optr = $contact == 1 ? "<>" : "="; # unless it's email, true val means we want to query for not null + my $conj = $optr eq '=' ? '-or' : '-and'; + if ($cType =~ /sms/) { + $q->{where}->{$conj} = [ { sms_notify => { $optr => undef } }, { sms_notify => { $optr => '' } } ]; + } + if ($cType =~ /phone/) { + $q->{where}->{$conj} = [ { phone_notify => { $optr => undef } }, { phone_notify => { $optr => '' } } ]; + } + if ($cType =~ /email/) { + if ($contact) { + $q->{where}->{'+ahr'} = 'email_notify'; + } else { + $q->{where}->{'-not'} = {'+ahr' => 'email_notify'}; + } + } + } + + my $holds = $e->json_query($q); + #$hold_ids = [ map { $_->{id} } @$hold_ids ]; + + return $holds; +} + +__PACKAGE__->register_method( + method => "batch_update_holds_by_value_staff", + api_name => "open-ils.circ.holds.batch_update_holds_by_notify_staff", + signature => { + desc => "Update a user's specified holds, affected by the contact/notify value change. $ses_is_req_note", + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'User ID', type => 'number' }, + { desc => 'Hold IDs', type => 'array' }, + { desc => 'old notify value', type => 'string' }, + { desc => 'new notify value', type => 'string' }, + { desc => 'field name', type => 'string' }, + { desc => 'SMS carrier ID', type => 'number' } + + ], + return => { + desc => 'Hold objects with transits attached, event on error', + } + } +); + +sub batch_update_holds_by_value_staff { + my($self, $conn, $auth, $usr_id, $hold_ids, $oldval, $newval, $cType, $carrierId) = @_; + + my $e = new_editor(authtoken=>$auth, xact=>1); + $e->checkauth or return $e->event; + if ($e->requestor->id != $usr_id){ + $e->allowed('UPDATE_HOLD') or return $e->event; + } + + my @success; + for my $id (@$hold_ids) { + + my $hold = $e->retrieve_action_hold_request($id); + + if ($cType eq "day_phone" or $cType eq "evening_phone" or + $cType eq "other_phone" or $cType eq "default_phone") { + + if ($newval eq '') { + $hold->clear_phone_notify(); + } + else { + $hold->phone_notify($newval); + } + } + + if ($cType eq "default_sms"){ + if ($newval eq '') { + $hold->clear_sms_notify(); + $hold->clear_sms_carrier(); # TODO: prevent orphan sms_carrier, via db trigger + } + else { + $hold->sms_notify($newval); + $hold->sms_carrier($carrierId); + } + + } + + if ($cType eq "default_sms_carrier_id") { + $hold->sms_carrier($newval); + } + + if ($cType =~ /notify/){ + # this is a notification pref change + if ($cType =~ /email/) { $hold->email_notify($newval); } + if ($cType =~ /sms/ and !$newval) { $hold->clear_sms_notify(); } + if ($cType =~ /phone/ and !$newval) { $hold->clear_phone_notify(); } + # the other case, where x_notify is changed to true, + # is covered by an actual value being assigned + } + + $e->update_action_hold_request($hold) or return $e->die_event; + push @success, $id; + } + + #$e->disconnect; + $e->commit; #unless $U->event_code($res); + return \@success; + +} + + +__PACKAGE__->register_method( + method => "retrieve_holds_by_usr_with_notify", + api_name => "open-ils.circ.holds.retrieve.by_usr.with_notify", + signature => { + desc => "Retrieve the hold, for the specified user using the notify value. $ses_is_req_note", + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'User ID', type => 'number' }, + ], + return => { + desc => 'Lists of holds with notification values, event on error', + } + } +); + +sub retrieve_holds_by_usr_with_notify { + + my($self, $conn, $auth, $usr_id) = @_; + + my $e = new_editor(authtoken=>$auth); + $e->checkauth or return $e->event; + + if ($e->requestor->id != $usr_id){ + $e->allowed('VIEW_HOLD') or return $e->event; + } + + my $q = { + "select" => { "ahr" => ["id", "phone_notify", "email_notify", "sms_carrier", "sms_notify"]}, + "from" => "ahr", + "where" => { + "usr" => $usr_id, + "capture_time" => undef, + "cancel_time" => undef, + "fulfillment_time" => undef, + } + }; + + my $holds = $e->json_query($q); + return $holds; +} + +__PACKAGE__->register_method( + method => "batch_update_holds_by_value", + api_name => "open-ils.circ.holds.batch_update_holds_by_notify", + signature => { + desc => "Update a user's specified holds, affected by the contact/notify value change. $ses_is_req_note", + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'User ID', type => 'number' }, + { desc => 'Hold IDs', type => 'array' }, + { desc => 'old notify value', type => 'string' }, + { desc => 'new notify value', type => 'string' }, + { desc => 'notify_type', type => 'string' } + ], + return => { + desc => 'Hold objects with transits attached, event on error', + } + } +); + +sub batch_update_holds_by_value { + my($self, $conn, $auth, $usr_id, $hold_ids, $oldval, $newval, $cType) = @_; + + my $e = new_editor(authtoken=>$auth, xact=>1); + $e->checkauth or return $e->event; + if ($e->requestor->id != $usr_id){ + $e->allowed('UPDATE_HOLD') or return $e->event; + } + + my @success; + for my $id (@$hold_ids) { + + my $hold = $e->retrieve_action_hold_request(int($id)); + + if ($cType eq "day_phone" or $cType eq "evening_phone" or + $cType eq "other_phone" or $cType eq "default_phone") { + # change phone number value on hold + $hold->phone_notify($newval); + } + if ($cType eq "default_sms") { + # change SMS number value on hold + $hold->sms_notify($newval); + } + + if ($cType eq "default_sms_carrier_id") { + $hold->sms_carrier(int($newval)); + } + + if ($cType =~ /notify/){ + # this is a notification pref change + if ($cType =~ /email/) { $hold->email_notify($newval); } + if ($cType =~ /sms/ and !$newval) { $hold->clear_sms_notify(); } + if ($cType =~ /phone/ and !$newval) { $hold->clear_phone_notify(); } + # the other case, where x_notify is changed to true, + # is covered by an actual value being assigned + } + + $e->update_action_hold_request($hold) or return $e->die_event; + push @success, $id; + } + + #$e->disconnect; + $e->commit; #unless $U->event_code($res); + return \@success; +} + +__PACKAGE__->register_method( method => "hold_metadata", api_name => "open-ils.circ.hold.get_metadata", authoritative => 1, @@ -4573,6 +4849,7 @@ __PACKAGE__->register_method( } ); + sub hold_metadata { my ($self, $client, $hold_type, $hold_targets, $org_id) = @_; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 105c3bd1af..7388d79706 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -225,6 +225,7 @@ sub load { return $self->load_myopac_circ_history_export if $path =~ m|opac/myopac/circ_history/export|; return $self->load_myopac_circ_history if $path =~ m|opac/myopac/circ_history|; return $self->load_myopac_hold_history if $path =~ m|opac/myopac/hold_history|; + return $self->load_myopac_prefs_notify_changed_holds if $path =~ m|opac/myopac/prefs_notify_changed_holds|; return $self->load_myopac_prefs_notify if $path =~ m|opac/myopac/prefs_notify|; return $self->load_myopac_prefs_settings if $path =~ m|opac/myopac/prefs_settings|; return $self->load_myopac_prefs_my_lists if $path =~ m|opac/myopac/prefs_my_lists|; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 5bc2f8b98c..e246bd591c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -235,9 +235,272 @@ sub load_myopac_prefs_notify { # re-fetch user prefs $self->ctx->{updated_user_settings} = \%settings; + + # update holds: check if any changes affect any holds + my @llchgs = $self->_parse_prefs_notify_hold_related(); + my @ffectedChgs; + + if ( $self->cgi->param('hasHoldsChanges') ) { + # propagate pref_notify changes to holds + for my $chset (@llchgs){ + # FIXME is this still needed? + } + + } + else { + my $holds = $U->simplereq('open-ils.circ', 'open-ils.circ.holds.retrieve.by_usr.with_notify', + $e->authtoken, $e->requestor->id); + + if (@$holds > 0) { + + my $default_phone_changes = {}; + my $sms_changes = {}; + my $new_phone; + my $new_carrier; + my $new_sms; + for my $chset (@llchgs) { + next if scalar(@$chset) < 3; + my ($old, $new, $field) = @$chset; + + my $bool = $field =~ /_notify/ ? 1 : 0; + + # find holds that would change + my $affected = []; + foreach my $hold (@$holds) { + if ($field eq 'email_notify') { + my $curr = $hold->{$field} eq 't' ? 'true' : 'false'; + push @$affected, $hold if $curr ne $new; + } elsif ($field eq 'default_phone') { + my $old_phone = $hold->{phone_notify} // ''; + $new_phone = $new // ''; + push @{ $default_phone_changes->{ $old_phone } }, $hold->{id} + if $old_phone ne $new_phone; + } elsif ($field eq 'phone_notify') { + my $curr = ($hold->{$field} // '' ne '') ? 'true' : 'false'; + push @$affected, $hold if $curr ne $new; + } elsif ($field eq 'sms_notify') { + my $curr = ($hold->{$field} // '' ne '') ? 'true' : 'false'; + push @$affected, $hold if $curr ne $new; + } elsif ($field eq 'sms_info') { + my $old_carrier = $hold->{'sms_carrier'} // ''; + my $old_sms = $hold->{'sms_notify'} // ''; + $new_carrier = $new->{carrier} // ''; + $new_sms = $new->{sms} // ''; + if (!($old_carrier eq $new_carrier && $old_sms eq $new_sms)) { + push @{ $sms_changes->{ join("\t", $old_carrier, $old_sms) } }, $hold->{id}; + } + } + } + + # append affected array to chset + if (scalar(@$affected) > 0){ + push(@$chset, [ map { $_->{id} } @$affected ]); + push(@ffectedChgs, $chset); + } + } + + + foreach my $old_phone (keys %$default_phone_changes) { + push(@ffectedChgs, [ $old_phone, $new_phone, 'default_phone', $default_phone_changes->{$old_phone} ]); + } + foreach my $old_sms_info (keys %$sms_changes) { + my ($old_carrier, $old_sms) = split /\t/, $old_sms_info; + push(@ffectedChgs, [ + { carrier => $old_carrier, sms => $old_sms }, + { carrier => $new_carrier, sms => $new_sms }, + 'sms_info', + $sms_changes->{$old_sms_info} + ]); + } + + if ( scalar(@ffectedChgs) ){ + $self->ctx->{affectedChgs} = \@ffectedChgs; + } + } + } + return $self->_load_user_with_prefs || Apache2::Const::OK; } +sub _parse_prefs_notify_hold_related { + + my $self = shift; + my $for_update = shift; + + # create an array of change arrays + my @chgs; + + my @phone_notify = $self->cgi->multi_param('phone_notify[]'); + push(@chgs, \@phone_notify) if scalar(@phone_notify); + + my $turning_on_phone_notify = !$for_update && + scalar(@phone_notify) && + $phone_notify[1] eq 'true'; + my $turning_off_phone_notify = !$for_update && + scalar(@phone_notify) && + $phone_notify[1] eq 'false'; + + my $changing_default_phone = 0; + if (!$turning_off_phone_notify) { + my @default_phone = $self->cgi->multi_param('default_phone[]'); + if ($for_update) { + while (scalar(@default_phone) > 0) { + my $chg = [ splice(@default_phone, 0, 4) ]; + if (scalar(@default_phone) > 0 && $default_phone[0] eq 'on') { + push @$chg, shift(@default_phone); + push(@chgs, $chg); + $changing_default_phone = 1; + } + } + } else { + if (scalar(@default_phone)) { + push @chgs, \@default_phone; + $changing_default_phone = 1; + } + } + } + + if ($turning_on_phone_notify && $changing_default_phone) { + # we don't need to have both the phone_notify and default_phone + # changes; the latter will suffice + @chgs = grep { $_->[2] ne 'phone_notify' } @chgs; + } elsif ($turning_on_phone_notify && !$changing_default_phone) { + # replace the phone_notify change with a default_phone change + @chgs = grep { $_->[2] ne 'phone_notify' } @chgs; + my $default_phone = $self->cgi->param('opac.default_phone'); # we assume this is set + push @chgs, [ '', $default_phone, 'default_phone' ]; + } + + # on to SMS + # ... since both carrier and number are needed to send an SMS notifcation, + # we need to treat the pair as a unit + my @sms_notify = $self->cgi->multi_param('sms_notify[]'); + push(@chgs, \@sms_notify) if scalar(@sms_notify); + + my $turning_on_sms_notify = !$for_update && + scalar(@sms_notify) && + $sms_notify[1] eq 'true'; + my $turning_off_sms_notify = !$for_update && + scalar(@sms_notify) && + $sms_notify[1] eq 'false'; + + my $changing_sms_info = 0; + if (!$turning_off_sms_notify) { + my @sms_carrier = $self->cgi->multi_param('default_sms_carrier_id[]'); + my @sms = $self->cgi->multi_param('default_sms[]'); + + if (scalar(@sms) || scalar(@sms_carrier)) { + my $new_carrier = scalar(@sms_carrier) ? $sms_carrier[1] : $self->cgi->param('sms_carrier'); + my $new_sms = scalar(@sms) ? $sms[1] : $self->cgi->param('opac.default_sms_notify'); + push @chgs, [ + { carrier => '', sms => '' }, + { carrier => $new_carrier, sms => $new_sms }, + 'sms_info' + ]; + $changing_sms_info = 1; + } + } + + my @sms_info = $self->cgi->multi_param('sms_info[]'); # only sent by confirmation page + if (scalar(@sms_info)) { + while (scalar(@sms_info) > 0) { + my $chg = [ splice(@sms_info, 0, 4) ]; + if (scalar(@sms_info) > 0 && $sms_info[0] eq 'on') { + push @$chg, shift(@sms_info); + my ($carrier, $sms) = split /,/, $chg->[0], -1; + $chg->[0] = { carrier => $carrier, sms => $sms }; + ($carrier, $sms) = split /,/, $chg->[1], -1; + $chg->[1] = { carrier => $carrier, sms => $sms }; + push(@chgs, $chg); + $changing_sms_info = 1; + } + } + } + + if ($turning_on_sms_notify && $changing_sms_info) { + # we don't need to have both the sms_notify and sms_info + # changes; the latter will suffice + @chgs = grep { $_->[2] ne 'sms_notify' } @chgs; + } elsif ($turning_on_sms_notify && !$changing_sms_info) { + # replace the sms_notify change with a sms_info change + @chgs = grep { $_->[2] ne 'sms_notify' } @chgs; + my $sms_info = { + carrier => $self->cgi->param('sms_carrier'), + sms => $self->cgi->param('opac.default_sms_notify'), + }; + push @chgs, [ { carrier => '', sms => ''}, $sms_info, 'sms_info' ]; + } + + my @email_notify = $self->cgi->multi_param('email_notify[]'); + push(@chgs, \@email_notify) if scalar(@email_notify); + + if ($for_update) { + # if we're updating, keep only the ones that have been + # explicitly checked by the user + @chgs = grep { scalar(@$_) == 5 && $_->[4] eq 'on' } @chgs; + } + return @chgs; +} + +sub load_myopac_prefs_notify_changed_holds { + my $self = shift; + my $e = $self->editor; + + my $hasChanges = $self->cgi->param('hasHoldsChanges'); + + return $self->_load_user_with_prefs || Apache2::Const::OK unless $hasChanges; + + my @ll = $self->_parse_prefs_notify_hold_related(1); + + my @updates; + for my $chset (@ll){ + my ($old, $new, $type, $holdids, $doit) = @$chset; + next if $doit ne 'on'; + + # parse string list into array list + my @holdids = split(',', $holdids); + + if ($type =~ /_notify/){ + # translate true/false string into 1/0 + $old = $old eq 'true' ? 1 : 0; + $new = $new eq 'true' ? 1 : 0; + } + + my $update; + if ($type eq 'sms_info') { + if ($new->{carrier} eq '' && $new->{sms} eq '') { + # clear SMS number first to avoid check contrainst issue + $update = $U->simplereq('open-ils.circ', "open-ils.circ.holds.batch_update_holds_by_notify", + $e->authtoken, $e->requestor->id, [@holdids], $old->{sms}, $new->{sms}, 'default_sms'); + push (@updates, $update) if (scalar(@$update) > 0); + $update = $U->simplereq('open-ils.circ', "open-ils.circ.holds.batch_update_holds_by_notify", + $e->authtoken, $e->requestor->id, [@holdids], $old->{carrier}, $new->{carrier}, 'default_sms_carrier_id'); + push (@updates, $update) if (scalar(@$update) > 0); + } else { + $update = $U->simplereq('open-ils.circ', "open-ils.circ.holds.batch_update_holds_by_notify", + $e->authtoken, $e->requestor->id, [@holdids], $old->{carrier}, $new->{carrier}, 'default_sms_carrier_id'); + push (@updates, $update) if (scalar(@$update) > 0); + $update = $U->simplereq('open-ils.circ', "open-ils.circ.holds.batch_update_holds_by_notify", + $e->authtoken, $e->requestor->id, [@holdids], $old->{sms}, $new->{sms}, 'default_sms'); + push (@updates, $update) if (scalar(@$update) > 0); + } + } else { + $update = $U->simplereq('open-ils.circ', "open-ils.circ.holds.batch_update_holds_by_notify", + $e->authtoken, $e->requestor->id, [@holdids], $old, $new, $type); + + # append affected array to chset + if (scalar(@$update) > 0){ + push(@updates, $update); + } + } + } + + $self->ctx->{'updated'} = \@updates; + + return $self->_load_user_with_prefs || Apache2::Const::OK; + +} + sub fetch_optin_prefs { my $self = shift; my $e = $self->editor; @@ -959,6 +1222,10 @@ sub handle_hold_update { my $val = {"id" => $_}; $val->{"frozen"} = $self->cgi->param("frozen"); $val->{"pickup_lib"} = $self->cgi->param("pickup_lib"); + $val->{"email_notify"} = $self->cgi->param("email_notify") ? 1 : 0; + $val->{"phone_notify"} = $self->cgi->param("phone_notify"); + $val->{"sms_notify"} = $self->cgi->param("sms_notify"); + $val->{"sms_carrier"} = int($self->cgi->param("sms_carrier")) if $val->{"sms_notify"}; for my $field (qw/expire_time thaw_date/) { # XXX TODO make this support other date formats, not just diff --git a/Open-ILS/src/templates/opac/myopac/holds.tt2 b/Open-ILS/src/templates/opac/myopac/holds.tt2 index d881d9f3a3..9aa0b2a658 100644 --- a/Open-ILS/src/templates/opac/myopac/holds.tt2 +++ b/Open-ILS/src/templates/opac/myopac/holds.tt2 @@ -1,6 +1,7 @@ [% PROCESS "opac/parts/header.tt2"; PROCESS "opac/parts/misc_util.tt2"; PROCESS "opac/parts/hold_status.tt2"; + PROCESS "opac/parts/hold_notify.tt2"; PROCESS "opac/parts/myopac/column_sort_support.tt2"; WRAPPER "opac/parts/myopac/base.tt2"; myopac_page = "holds"; @@ -119,6 +120,7 @@ [% l('Pickup Location') %] [% l('Cancel if not filled by') %] [% l('Status') %] + [% l('Notify Method') %] [% l('Notes') %] @@ -240,6 +242,11 @@ [% PROCESS get_hold_status hold=hold; %] + +
+ [% PROCESS get_hold_notify h=ahr; %] +
+ [%- FOREACH pubnote IN ahr.notes; IF pubnote.pub == 't'; diff --git a/Open-ILS/src/templates/opac/myopac/holds/edit.tt2 b/Open-ILS/src/templates/opac/myopac/holds/edit.tt2 index 6b567a65f1..ab8737339e 100644 --- a/Open-ILS/src/templates/opac/myopac/holds/edit.tt2 +++ b/Open-ILS/src/templates/opac/myopac/holds/edit.tt2 @@ -100,6 +100,26 @@ [% l('Enter date in MM/DD/YYYY format') %] + + [% l('Email Notification') %] + + + + + [% l('Phone Notification') %] + + + + [% l('SMS Notification') %] + + + + [% l('Default Mobile Carrier') %] + [% INCLUDE "opac/parts/sms_carrier_selector.tt2" ahr, sms_carrier_hide_warning="true", sms_carrier_hide_label="true" %] + [% END %] diff --git a/Open-ILS/src/templates/opac/myopac/prefs_notify.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_notify.tt2 index 47b7f72677..7b17ada0f9 100644 --- a/Open-ILS/src/templates/opac/myopac/prefs_notify.tt2 +++ b/Open-ILS/src/templates/opac/myopac/prefs_notify.tt2 @@ -4,103 +4,153 @@ prefs_page = 'prefs_notify' %]

[% l('Notification Preferences') %]

-
- [% setting = 'opac.hold_notify' %] - + [% IF ctx.affectedChgs %] - - - - [% IF ctx.updated_user_settings %] - - [% END %] + [% # get hash of sms carriers keyed by id: + temp = ctx.search_csc('active','t'); + tcos = { '0' => 'None' }; + FOR o IN temp; + id = o.id; + tcos.$id = o; + END; + %] +

[% l('You have updated notification preferences. Those changes only affect future holds. Would you like to update existing holds to use the new information?') %]

+ +
-
- [% l('Account Successfully Updated') %] -
-
+ + [% SET blnk = l('Blank') %] + [% FOR c IN ctx.affectedChgs %] + + + + [% END %] + +
+ [% IF c.2 == 'sms_info' %] + + + [% ELSE %] + + + [% END %] + + + + [% IF c.2 == 'sms_info' %] + [% SET disp_name = l('SMS carrier/number') %] + + [% ELSIF c.2.match('_notify') %] + [% SET f_name = c.2.replace("_", " "); Y = l('YES'); N = l('NO') %] + + [% ELSE %] + [% SET f_name = c.2.replace("_", " ") %] + + [% END %] +
+ + [% l('Continue without updating') %] +
+ [% ELSE %] +
[% setting = 'opac.hold_notify' %] - - [%# WCAG insists that labels for checkboxes contain the input - or directly follow the input, which would not look right - with the rest of the table. As an alternative, we can - repeat the label as a title attr. - http://www.w3.org/TR/WCAG20-TECHS/H44.html %] - [% email_label = l('Notify by Email by default when a hold is ready for pickup?') %] + - - - - - - [%- IF allow_phone_notifications == 'true'; - setting = 'opac.hold_notify'; - -%] - - [% phone_label = l('Notify by Phone by default when a hold is ready for pickup?') %] - - - - - - [% setting = 'opac.default_phone' %] - - - - - - - [%- END %] - [%- IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1; - setting = 'opac.hold_notify'; - -%] - - [% sms_label = l('Notify by Text by default when a hold is ready for pickup?') %] - - - - - - - [% l('Default Mobile Carrier') %] - [% INCLUDE "opac/parts/sms_carrier_selector.tt2" sms_carrier_hide_label="true" %] - - [% setting = 'opac.default_sms_notify' %] - - - - - [% l('Hint: use the full 10 digits of your phone #, no spaces, no dashes'); %] - - - [% END %] - [% FOR optin IN ctx.opt_in_settings %] - - - - - - - [% END %] - - + + + + [% IF ctx.updated_user_settings %] + + [% END %] + + [% setting = 'opac.hold_notify' %] + + [%# WCAG insists that labels for checkboxes contain the input + or directly follow the input, which would not look right + with the rest of the table. As an alternative, we can + repeat the label as a title attr. + http://www.w3.org/TR/WCAG20-TECHS/H44.html %] + [% email_label = l('Notify by Email by default when a hold is ready for pickup?') %] + + + + + [%- IF allow_phone_notifications == 'true'; + setting = 'opac.hold_notify'; + -%] + + [% phone_label = l('Notify by Phone by default when a hold is ready for pickup?') %] + + + + [% setting = 'opac.default_phone' %] + + + + + [%- END %] + [%- IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1; + setting = 'opac.hold_notify'; + -%] + + [% sms_label = l('Notify by Text by default when a hold is ready for pickup?') %] + + + + + + + + [% setting = 'opac.default_sms_notify' %] + + + + + [% END %] + [% FOR optin IN ctx.opt_in_settings %] + + + + + [% END %] + +
+
+ [% l('Account Successfully Updated') %] +
+
+ +
+ +
+ +
+ +
[% l('Default Mobile Carrier') %][% INCLUDE "opac/parts/sms_carrier_selector.tt2" sms_carrier_hide_label="true" %]
+ + [% l('Hint: use the full 10 digits of your phone #, no spaces, no dashes'); %] +
+ +
- -
+ + + [% END %] [% END %] diff --git a/Open-ILS/src/templates/opac/myopac/prefs_notify_changed_holds.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_notify_changed_holds.tt2 new file mode 100644 index 0000000000..0a33c3f2af --- /dev/null +++ b/Open-ILS/src/templates/opac/myopac/prefs_notify_changed_holds.tt2 @@ -0,0 +1,29 @@ +[% PROCESS "opac/parts/header.tt2"; + WRAPPER "opac/parts/myopac/prefs_base.tt2"; + myopac_page = "prefs"; + prefs_page = 'prefs_notify' %] + +

[% l('Affected Holds') %]

+
+ [% IF ctx.updated %] +

[% l('Hold Notification Information Updated.') %]

+ + [% ELSE %] +

[% l('No changes') %].

+ [% END %] + [% l('Continue.') %] + +[% END %] + + diff --git a/Open-ILS/src/templates/opac/parts/hold_notify.tt2 b/Open-ILS/src/templates/opac/parts/hold_notify.tt2 new file mode 100644 index 0000000000..4d755f1e8a --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/hold_notify.tt2 @@ -0,0 +1,28 @@ +[% BLOCK get_hold_notify %] + [% # get hash of sms carriers keyed by id: + temp = ctx.search_csc('active','t'); + tcos = { '0' => 'None' }; + FOR o IN temp; + id = o.id; + tcos.$id = o; + END; + %] + [% SET any_notify = 0 %] +
+ [% IF h.email_notify == 't' %] + [% any_notify = 1 %] + [% l("Email") %]: [% l("Yes") %]
+ [% END %] + [% IF h.phone_notify %] + [% any_notify = 1 %] + [% l("Phone") %]: [% h.phone_notify | html %]
+ [% END %] + [% IF h.sms_notify %] + [% any_notify = 1, cid = h.sms_carrier; %] + [% l("SMS") %]: [% h.sms_notify | html %] ([% tcos.$cid.name() | html %])
+ [% END %] + [% UNLESS any_notify %] + [% l("None") %] + [% END %] +
+[% END %] diff --git a/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2 b/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2 index 95ba8ffc43..3515bc7d23 100644 --- a/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2 @@ -18,11 +18,11 @@ END; %] [% IF NOT sms_carrier_hide_label; ''; END; %] - [% FOR carrier IN carriers.sort('name','region') -%] [% END -%] diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index f61f5eea07..1c66575c1b 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -113,7 +113,7 @@ MACRO draw_form_input(cls, field, path, type, disable) BLOCK; %]
{{user_setting_types['opac.default_phone'].label()}}
-
@@ -773,8 +774,9 @@ within the "form" by name for validation.
-
@@ -785,7 +787,8 @@ within the "form" by name for validation.
- diff --git a/Open-ILS/src/templates/staff/circ/patron/t_hold_notify_update.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_hold_notify_update.tt2 new file mode 100644 index 0000000000..b80891f676 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_hold_notify_update.tt2 @@ -0,0 +1,42 @@ + +