[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug/Patch: email form not populated with emails from account
- Subject: Bug/Patch: email form not populated with emails from account
- From: John Locke <..hidden..>
- Date: Sun, 19 Jun 2011 08:16:45 -0700
When using the "Email" button to send an invoice to a customer, the
email form does not populate the email/cc/bcc fields from the customer
account.
Here's at least a partial patch to accomplish this (partial because I'm
not sure if I have all of the areas I patched to make this happen -- it
does work correctly on my system.). This patch is against svn #3281, let
me know if I need to re-roll against an updated trunk.
Cheers,
John Locke
http://freelock.com
diff --git LedgerSMB/Form.pm LedgerSMB/Form.pm
index 21a6cac..fec0301 100644
--- LedgerSMB/Form.pm
+++ LedgerSMB/Form.pm
@@ -2432,6 +2431,18 @@ sub create_links {
$self->{queued} .= "$ref->{formname} " . "$ref->{spoolfile} "
if $ref->{spoolfile};
}
+
+ # get email accounts
+ $query = qq|
+ SELECT * FROM eca__list_contacts(?)|;
+ $sth = $dbh->prepare($query);
+ $sth->execute( $self->{entity_id} ) || $self->dberror($query);
+
+ my $ctype;
+ while ( $ref = $sth->fetchrow_hashref('NAME_lc') ) {
+ $ctype = lc $ref->{class};
+ $self->{$ctype} .= "$ref->{contact} ";
+ }
$sth->finish;
for (qw(printed emailed queued)) { $self->{$_} =~ s/ +$//g }
@@ -2802,7 +2813,7 @@ sub update_status {
$sth = $dbh->prepare($query);
$sth->execute( $self->{id}, $printed, $emailed, $spoolfile,
- $self->{formname} );
+ $self->{formname} ) || $self->dberror($query);
$sth->finish;
}
@@ -2829,7 +2840,7 @@ sub save_status {
WHERE trans_id = ?|;
my $sth = $dbh->prepare($query);
- $sth->execute( $self->{id} );
+ $sth->execute( $self->{id} ) || $self->dberror($query);
$sth->finish;
my %queued;
diff --git LedgerSMB/Mailer.pm LedgerSMB/Mailer.pm
index 29c8bd4..f294575 100644
--- LedgerSMB/Mailer.pm
+++ LedgerSMB/Mailer.pm
@@ -160,11 +160,11 @@ sub attach {
my %args = @_;
carp "Message not prepared" unless ref $self->{_message};
- if (defined $args{filename}) {
- if (!$args{filename}){
+ if (defined $args{file}) {
+ if (!$args{file}){
carp "Invalid filename provided";
- } elsif (!defined $args{data} and !(-f $args{filename} and -r $args{filename})){
- carp "Cannot access file: $args{filename}";
+ } elsif (!defined $args{data} and !(-f $args{file} and -r $args{file})){
+ carp "Cannot access file: $args{file}";
}
} else {
carp "No attachement supplied" unless defined $args{data};
diff --git LedgerSMB/Template.pm LedgerSMB/Template.pm
index d368356..03e2182 100755
--- LedgerSMB/Template.pm
+++ LedgerSMB/Template.pm
@@ -270,7 +270,7 @@ sub render {
my $post = $format->can('postprocess')->($self);
if (!$self->{'noauto'}) {
# Clean up
- $self->output;
+ $self->output(%$vars);
if ($self->{rendered}) {
unlink($self->{rendered}) or
throw Error::Simple 'Unable to delete output file';
@@ -361,7 +361,7 @@ sub _email_output {
my @mailmime;
if (!$self->{rendered} and !$args->{attach}) {
$args->{message} .= $self->{output};
- @mailmime = ('contenttype', $self->{mimeytype});
+ @mailmime = ('contenttype', $self->{mimetype});
}
# User default for email from