package Platform::Attendee;
use strict;
use warnings;
use base 'Platform::DBI';

__PACKAGE__->table('attendee');
__PACKAGE__->columns(Primary => qw / event account / );
__PACKAGE__->columns( Essential => qw / 
  created_at
/ );

__PACKAGE__->has_a( event => 'Platform::Event' );
__PACKAGE__->has_a( account => 'Platform::Account' );
__PACKAGE__->has_a( created_at => 'Class::Date' );

sub send_confirm_email {
  my ($attendee) = @_;
  my $buffer;
  my $TT = Template->new({
    INCLUDE_PATH => Platform::path_from_config('common.email_path'),
    ENCODING => 'utf8',
  });

  if ($TT->process('attendee_confirm.tt', { attendee => $attendee }, \$buffer, {binmode => ':utf8'})) {
    my %email = (
      From => $Platform::CONFIG->{common}{email_from},
      'Reply-To' => $Platform::CONFIG->{common}{reply_to},
      To => $attendee->account->email,
      Subject => 'SILIQ™ (brodalumab) Injection 210 mg/ 1.5 ml Peer to Peer Speaker Training Confirmation',
      Type => 'text/html; charset="UTF-8"',
      Data => $buffer
    );
    my $message = Platform::Email->new(%email);

    $message->send();
  }
}
