App-Office-Contacts

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts/View/Organization.pm  view on Meta::CPAN

	$template =~ s/\n//g;

	return $template;

} # End of build_update_html.

# -----------------------------------------------

sub format_search_result
{
	my($self, $name, $organizations) = @_;

	$self -> db -> logger -> log(debug => "View::Org.format_search_result($name, @{[scalar @$organizations]})");

	my(@row);

	if ($name && ($#$organizations >= 0) )
	{
		my($sid) = $self -> db -> session -> id;

		my($email, $email_address);
		my($i);
		my($organization);
		my($phone);

		for $organization (@$organizations)
		{
			$name = $$organization{name};

			for $i (0 .. $#{$$organization{email_phone} })
			{
				$email         = $$organization{email_phone}[$i]{email};
				$email_address = $$email{address} ? mark_raw(qq|<a href="mailto:$$email{address}">$$email{address}</a>|) : '';
				$phone         = $$organization{email_phone}[$i]{phone};

				push @row,
				{
					email      => $email_address,
					email_type => $$email{type_name},
					id         => $$organization{id},
					name       => $name ? mark_raw(qq|<a href="#" onClick="display_organization($$organization{id}, '$sid')">$name</a>|) : '-',
					phone      => $$phone{number},
					phone_type => $$phone{type_name},
					role       => $name ? mark_raw($self -> db -> library -> get_role_via_id($$organization{role_id}) ) : '-',
					type       => 'Organization',
				};

				# Blanking out the name means it is not repeated in the output (HTML) table.

				$name = '';
			}
		}
	}

	return [@row];

} # End of format_search_result.

# -----------------------------------------------

sub update
{
	my($self, $user_id, $result) = @_;

	$self -> db -> logger -> log(debug => "View::Organization.update($user_id, ...)");

	# Force the user_id into the person's record, so it is available elsewhere.
	# Note: This is the user_id of the person logged on.

	my($organization)          = {};
	$$organization{creator_id} = $user_id;
	$$organization{id}         = $result -> get_value('organization_id');

	for my $field_name ($result -> valids)
	{
		$$organization{$field_name} = $result -> get_value($field_name) || '';
	}

	$self -> db -> logger -> log(debug => '-' x 50);
	$self -> db -> logger -> log(debug => "Updating organization $$organization{name}...");
	$self -> db -> logger -> log(debug => "$_ => $$organization{$_}") for sort keys %$organization;
	$self -> db -> logger -> log(debug => '-' x 50);

	return $self -> db -> organization -> update($organization);

} # End of update.

# -----------------------------------------------

1;

=head1 NAME

App::Office::Contacts::View::Organization - A web-based contacts manager

=head1 Synopsis

See L<App::Office::Contacts/Synopsis>.

=head1 Description

L<App::Office::Contacts> implements a utf8-aware, web-based, private and group contacts manager.

=head1 Distributions

See L<App::Office::Contacts/Distributions>.

=head1 Installation

See L<App::Office::Contacts/Installation>.

=head1 Object attributes

Each instance of this class extends L<App::Office::Contacts::View::Base>, with these attributes:

=over 4

=item o (None)

=back



( run in 0.477 second using v1.01-cache-2.11-cpan-99c4e6809bf )