+
+ if ($form->{emailed} !~ /$form->{formname}/) {
+ $form->{emailed} .= " $form->{formname}";
+ $form->{emailed} =~ s/^ //;
+
+ # save status
+ $form->update_status(\%myconfig);
+ }
+
+ $now = scalar localtime;
+ $cc = $locale->text('Cc').qq|: $form->{cc}\n| if $form->{cc};
+ $bcc = $locale->text('Bcc').qq|: $form->{bcc}\n| if $form->{bcc};
+
+ $old_form->{intnotes} = qq|$old_form->{intnotes}\n\n| if $old_form->{intnotes};
+ $old_form->{intnotes} .= qq|[email]
+|.$locale->text('Date').qq|: $now
+|.$locale->text('To').qq|: $form->{email}
+$cc${bcc}|.$locale->text('Subject').qq|: $form->{subject}\n|;
+
+ $old_form->{intnotes} .= qq|\n|.$locale->text('Message').qq|: |;
+ $old_form->{intnotes} .= ($form->{message}) ? $form->{message} : $locale->text('sent');
+
+ $old_form->{message} = $form->{message};
+ $old_form->{emailed} = $form->{emailed};
+
+ $old_form->{format} = "postscript" if $myconfig{printer};
+ $old_form->{media} = $myconfig{printer};
+
+ $old_form->save_intnotes(\%myconfig, ($order) ? 'oe' : lc $ARAP);
+
+ %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
+ reference => $form->{"${inv}number"},
+ formname => $form->{formname},
+ action => 'emailed',
+ id => $form->{id} );
+
+ $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
+ }
+
+
+ if ($form->{media} eq 'queue') {
+ %queued = split / /, $form->{queued};
+
+ if ($filename = $queued{$form->{formname}}) {
+ $form->{queued} =~ s/$form->{formname} $filename//;
+ unlink "$spool/$filename";
+ $filename =~ s/\..*$//g;
+ } else {
+ $filename = time;
+ $filename .= $$;
+ }
+
+ $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
+ $form->{OUT} = ">$spool/$filename";
+
+ $form->{queued} .= " $form->{formname} $filename";
+ $form->{queued} =~ s/^ //;
+
+ # save status
+ $form->update_status(\%myconfig);
+
+ $old_form->{queued} = $form->{queued};
+
+ %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
+ reference => $form->{"${inv}number"},
+ formname => $form->{formname},
+ action => 'queued',
+ id => $form->{id} );
+
+ $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
+