From bc1e9b47fc7883bc3af517f4150e08f710a771a4 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 2 Dec 2015 17:49:01 -0500 Subject: [PATCH] fix various thinkos and syntax errors to get the biz logic working As of now, open-ils.circ.checkin is now starting to emit custom copy alerts. Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Circ/Circulate.pm | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index e8f007f8ba..a270700d16 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -393,6 +393,7 @@ my @AUTOLOAD_FIELDS = qw/ copy copy_id copy_barcode + new_copy_alerts user_copy_alerts system_copy_alerts next_copy_status @@ -639,11 +640,11 @@ sub collect_user_copy_alerts { if($self->copy) { my $alerts = $e->search_asset_copy_alert([ - {copy => $self->copy->id, ack_time => undef} - {flesh => 1, flesh_fields => { ccat => [ qw/ alert_type / ] }} + {copy => $self->copy->id, ack_time => undef}, + {flesh => 1, flesh_fields => { aca => [ qw/ alert_type / ] }} ]); if (ref $alerts eq "ARRAY") { - $logger->info("circulator: found " . scalar(@$alerts) . " alerts for copy" . + $logger->info("circulator: found " . scalar(@$alerts) . " alerts for copy " . $self->copy->id); $self->user_copy_alerts($alerts); } @@ -653,6 +654,8 @@ sub collect_user_copy_alerts { sub filter_user_copy_alerts { my $self = shift; + my $e = $self->editor; + if(my $alerts = $self->user_copy_alerts) { my $suppress_orgs = $U->get_org_descendants($self->circ_lib); @@ -674,7 +677,7 @@ sub filter_user_copy_alerts { # filter on "only at circ lib" if (defined $a->alert_type->at_circ) { - my $copy_circ_lib = (ref $self->copy->circ_lib) ? + my $copy_circ_lib = (ref $self->copy->circ_lib) ? $self->copy->circ_lib->id : $self->copy->circ_lib; my $orgs = $U->get_org_descendants($copy_circ_lib); @@ -687,11 +690,11 @@ sub filter_user_copy_alerts { # filter on "only at owning lib" if (defined $a->alert_type->at_owning) { - my $copy_owning_lib = (ref $self->volume->owning_lib) ? + my $copy_owning_lib = (ref $self->volume->owning_lib) ? $self->volume->owning_lib->id : $self->volume->owning_lib; my $orgs = $U->get_org_descendants($copy_owning_lib); - if ($U->is_true($a-->alert_type>invert_location)) { + if ($U->is_true($a->alert_type->invert_location)) { next if (grep {$_ == $copy_owning_lib} @$orgs); } else { next unless (grep {$_ == $copy_owning_lib} @$orgs); @@ -726,7 +729,7 @@ sub generate_system_copy_alerts { my $alert_orgs = $U->get_org_ancestors($self->circ_lib); my $alert_types = $e->search_config_copy_alert_type({ - active => 't' + active => 't', scope_org => $alert_orgs, event => $event, state => $self->copy_state, @@ -737,7 +740,7 @@ sub generate_system_copy_alerts { foreach my $a (@$alert_types) { # filter on "only at circ lib" if (defined $a->at_circ) { - my $copy_circ_lib = (ref $self->copy->circ_lib) ? + my $copy_circ_lib = (ref $self->copy->circ_lib) ? $self->copy->circ_lib->id : $self->copy->circ_lib; my $orgs = $U->get_org_descendants($copy_circ_lib); @@ -750,7 +753,7 @@ sub generate_system_copy_alerts { # filter on "only at owning lib" if (defined $a->at_owning) { - my $copy_owning_lib = (ref $self->volume->owning_lib) ? + my $copy_owning_lib = (ref $self->volume->owning_lib) ? $self->volume->owning_lib->id : $self->volume->owning_lib; my $orgs = $U->get_org_descendants($copy_owning_lib); @@ -773,7 +776,7 @@ sub generate_system_copy_alerts { foreach my $t (@final_types) { $t->next_status($U->unique_unnested_numbers($t->next_status)); - my $alert = new Fieldmapper::asset::copy_alert; + my $alert = new Fieldmapper::asset::copy_alert (); $alert->alert_type($t->id); $alert->copy($self->copy->id); $alert->temp(1); @@ -1378,10 +1381,10 @@ sub check_copy_alert { if ($self->new_copy_alerts) { my @alerts; - push @alerts, @{$self->user_copy_alerts}) # we have preexisting alerts + push @alerts, @{$self->user_copy_alerts} # we have preexisting alerts if ($self->user_copy_alerts && @{$self->user_copy_alerts}); - push @alerts, @{$self->system_copy_alerts}) # we have new dynamic alerts + push @alerts, @{$self->system_copy_alerts} # we have new dynamic alerts if ($self->system_copy_alerts && @{$self->system_copy_alerts}); if (@alerts) { -- 2.11.0