diff --git a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm index d4f3999..4ce41b6 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm @@ -86,10 +86,14 @@ sub valid_read { }, ); my $associations = $valid_org->entity->associations; + my $assoc = { + lis => defined $associations ? $associations->lis : 0, + }; + $c->stash( valid_org => $valid_org, transactions => $transactions, - associations => $associations, + associations => $assoc, ); } @@ -104,6 +108,7 @@ sub valid_edit { $validation->required('postcode')->postcode; $validation->optional('pending'); $validation->optional('is_local'); + $validation->optional('is_lis'); if ( $validation->has_error ) { $c->flash( error => 'The validation has failed' ); @@ -123,9 +128,12 @@ sub valid_edit { pending => defined $validation->param('pending') ? 0 : 1, is_local => $validation->param('is_local'), }); + $valid_org->entity->update_or_create_related( 'associations', { + lis => $validation->param('is_lis'), + }); } ); } finally { - if ( @_ ) { + if ( @_ ) {use Devel::Dwarn; Dwarn \@_; $c->flash( error => 'Something went wrong Updating the Organisation' ); } else { $c->flash( success => 'Updated Organisation' ); diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm index 5b5187d..08e8601 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm @@ -126,10 +126,14 @@ sub lis_load { my $entity = $c->stash->{api_user}->entity; my $entity_type_object = $entity->type_object; - my $orgs_lis = $valid_org = $c->schema->resultset('Entity')->find( $c->param('lis') ); + my $orgs_lis = $c->schema->resultset('EntityAssociation')->search( + { + 'lis' => 1, + }, + ); # need: organisations only, with name, latitude, and longitude - my $org_rs = $orgs_lis->associations->search_related('entity', + my $org_rs = $orgs_lis->search_related('entity', { 'entity.type' => 'organisation', 'organisation.latitude' => { -between => [ @@ -154,7 +158,7 @@ sub lis_load { $org_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); - my $suppliers = [ map { + my $locations = [ map { { latitude => $_->{organisation}->{latitude} * 1, longitude => $_->{organisation}->{longitude} * 1, diff --git a/templates/admin/organisations/valid_read.html.ep b/templates/admin/organisations/valid_read.html.ep index e605fa8..9f590e8 100644 --- a/templates/admin/organisations/valid_read.html.ep +++ b/templates/admin/organisations/valid_read.html.ep @@ -100,11 +100,11 @@ function initMap() {
- +
- + +