city => { type => 'text' },
commercial_court => { type => 'text' },
contact => { type => 'text' },
+ contact_origin => { type => 'text' },
country => { type => 'text' },
creditlimit => { type => 'numeric', default => '0', precision => 15, scale => 5 },
currency_id => { type => 'integer', not_null => 1 },
customernumber => { type => 'text' },
- contact_origin => { type => 'text' },
+ delivery_order_mail => { type => 'text' },
delivery_term_id => { type => 'integer' },
department_1 => { type => 'text' },
department_2 => { type => 'text' },
depositor => { type => 'text' },
direct_debit => { type => 'boolean', default => 'false' },
- discount => { type => 'float', scale => 4 },
+ discount => { type => 'float', precision => 4, scale => 4 },
email => { type => 'text' },
fax => { type => 'text' },
gln => { type => 'text' },
hourly_rate => { type => 'numeric', precision => 8, scale => 2 },
iban => { type => 'text' },
id => { type => 'integer', not_null => 1, sequence => 'id' },
- itime => { type => 'timestamp', default => 'now()' },
invoice_mail => { type => 'text' },
+ itime => { type => 'timestamp', default => 'now()' },
language => { type => 'text' },
language_id => { type => 'integer' },
mandate_date_of_signature => { type => 'date' },
sub show_sales_purchase_email_dialog {
my $email = '';
my $email_cc = '';
- my $inv_email;
+ my $record_email;
if ($::form->{cp_id}) {
$email = SL::DB::Contact->load_cached($::form->{cp_id})->cp_email;
}
+ # write a dispatch table if a third type enters
+ # check record mail for sales_invoice
if ($::form->{type} eq 'invoice' && (!$email || $::instance_conf->get_invoice_mail_settings ne 'cp')) {
# check for invoice_mail if defined (vc.invoice_email)
- $inv_email = SL::DB::Customer->load_cached($::form->{vc_id})->invoice_mail;
- if ($inv_email) {
+ $record_email = SL::DB::Customer->load_cached($::form->{vc_id})->invoice_mail;
+ if ($record_email) {
# check if cc for contact is also wanted
$email_cc = $email if ($::instance_conf->get_invoice_mail_settings eq 'invoice_mail_cc_cp');
- $email = $inv_email;
+ $email = $record_email;
+ }
+ }
+ # check record mail for sales_delivery_order
+ if ($::form->{type} eq 'sales_delivery_order') {
+ # check for deliver_order_mail if defined (vc.delivery_order_mail)
+ $record_email = SL::DB::Customer->load_cached($::form->{vc_id})->delivery_order_mail;
+ if ($record_email) {
+ # check if cc for contact is also wanted
+ $email_cc = $email; # always cc to cp
+ $email = $record_email;
}
}
# still no email? use general mail (vc.email)
to => $email,
cc => $email_cc,
subject => $::form->generate_email_subject,
- message => $::form->generate_email_body('inv_email' => $inv_email),
+ message => $::form->generate_email_body('record_email' => $record_email),
attachment_filename => $::form->generate_attachment_filename,
js_send_function => 'kivi.SalesPurchase.send_email()',
};
show_bcc => $::auth->assert('email_bcc', 'may fail'),
FILES => \%files,
is_customer => $::form->{vc} eq 'customer',
- is_invoice_mail => $inv_email,
+ is_invoice_mail => ($record_email && $::form->{type} eq 'invoice'),
});
print $::form->ajax_response_header, $html;