From c9ff0f7a1dd213d610bc1d682df2105ed7d9c739 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 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 cb124fe37b..ea665887e7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -403,6 +403,7 @@ my @AUTOLOAD_FIELDS = qw/ copy copy_id copy_barcode + new_copy_alerts user_copy_alerts system_copy_alerts next_copy_status @@ -649,11 +650,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); } @@ -663,6 +664,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); @@ -684,7 +687,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); @@ -697,11 +700,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); @@ -736,7 +739,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, @@ -747,7 +750,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); @@ -760,7 +763,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); @@ -783,7 +786,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); @@ -1390,10 +1393,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