__PACKAGE__->meta->table('periodic_invoices_configs');
__PACKAGE__->meta->columns(
- active => { type => 'boolean', default => 'true' },
- ar_chart_id => { type => 'integer', not_null => 1 },
- copies => { type => 'integer' },
- direct_debit => { type => 'boolean', default => 'false', not_null => 1 },
- end_date => { type => 'date' },
- extend_automatically_by => { type => 'integer' },
- first_billing_date => { type => 'date' },
- id => { type => 'integer', not_null => 1, sequence => 'id' },
- oe_id => { type => 'integer', not_null => 1 },
- order_value_periodicity => { type => 'varchar', length => 1, not_null => 1 },
- periodicity => { type => 'varchar', length => 1, not_null => 1 },
- print => { type => 'boolean', default => 'false' },
- printer_id => { type => 'integer' },
- start_date => { type => 'date' },
- terminated => { type => 'boolean', default => 'false' },
+ active => { type => 'boolean', default => 'true' },
+ ar_chart_id => { type => 'integer', not_null => 1 },
+ copies => { type => 'integer' },
+ direct_debit => { type => 'boolean', default => 'false', not_null => 1 },
+ email_body => { type => 'text' },
+ email_recipient_address => { type => 'text' },
+ email_recipient_contact_id => { type => 'integer' },
+ email_sender => { type => 'text' },
+ email_subject => { type => 'text' },
+ end_date => { type => 'date' },
+ extend_automatically_by => { type => 'integer' },
+ first_billing_date => { type => 'date' },
+ id => { type => 'integer', not_null => 1, sequence => 'id' },
+ oe_id => { type => 'integer', not_null => 1 },
+ order_value_periodicity => { type => 'varchar', length => 1, not_null => 1 },
+ periodicity => { type => 'varchar', length => 1, not_null => 1 },
+ print => { type => 'boolean', default => 'false' },
+ printer_id => { type => 'integer' },
+ send_email => { type => 'boolean', default => 'false', not_null => 1 },
+ start_date => { type => 'date' },
+ terminated => { type => 'boolean', default => 'false' },
);
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
key_columns => { ar_chart_id => 'id' },
},
+ email_recipient_contact => {
+ class => 'SL::DB::Contact',
+ key_columns => { email_recipient_contact_id => 'cp_id' },
+ },
+
order => {
class => 'SL::DB::Order',
key_columns => { oe_id => 'id' },
if ($config_obj) {
my $config = { map { $_ => $config_obj->$_ } qw(active terminated periodicity order_value_periodicity start_date_as_date end_date_as_date first_billing_date_as_date extend_automatically_by ar_chart_id
- print printer_id copies direct_debit) };
+ print printer_id copies direct_debit send_email email_recipient_contact_id email_recipient_address email_sender email_subject email_body) };
$form->{periodic_invoices_config} = YAML::Dump($config);
}
}
$::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ];
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
+ if ($::form->{customer_id}) {
+ $::form->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(where => [ cp_cv_id => $::form->{customer_id} ]);
+ }
+
$::form->header(no_layout => 1);
print $::form->parse_html_template('oe/edit_periodic_invoices_config', $config);
copies => $::form->{copies} * 1 ? $::form->{copies} : 1,
extend_automatically_by => $::form->{extend_automatically_by} * 1 || undef,
ar_chart_id => $::form->{ar_chart_id} * 1,
+ send_email => $::form->{send_email} ? 1 : 0,
+ email_recipient_contact_id => $::form->{email_recipient_contact_id} * 1 || undef,
+ email_recipient_address => $::form->{email_recipient_address},
+ email_sender => $::form->{email_sender},
+ email_subject => $::form->{email_subject},
+ email_body => $::form->{email_body},
};
$::form->{periodic_invoices_config} = YAML::Dump($config);
$::form->error($::locale->text('No action defined.'));
}
-
height: 2px;
}
+tr.rule-before th, tr.rule-before td {
+ padding-top: 2px;
+ border-top: 2px solid #EBEBEB;
+}
+
/* I.E. & Chrome können das nicht! */
/* input[type="radio"], input[type="checkbox"]{
width:1.15em;
function edit_periodic_invoices_config() {
- var width = 750;
- var height = 550;
+ var width = 800;
+ var height = 650;
var parm = centerParms(width, height) + ",width=" + width + ",height=" + height + ",status=yes,scrollbars=yes";
var config = $('#periodic_invoices_config').val();
+ var cus_id = $('[name=customer_id]').val();
var transdate = $('#transdate').val();
var url = "oe.pl?" +
"action=edit_periodic_invoices_config&" +
+ "customer_id=" + encodeURIComponent(cus_id) + "&" +
"periodic_invoices_config=" + encodeURIComponent(config) + "&" +
"transdate=" + encodeURIComponent(transdate || '');
'Contact is in use and was flagged invalid.' => 'Die Ansprechperson ist noch in Verwendung und wurde deshalb nur als ungültig markiert.',
'Contact person (surname)' => 'Ansprechperson (Nachname)',
'Contact persons' => 'Ansprechpersonen',
+ 'Contact to send to' => 'An Ansprechperson schicken',
'Contacts' => 'Ansprechpersonen',
'Content' => 'Inhalt',
'Continue' => 'Weiter',
'More than one #1 found matching, please be more specific.' => 'Mehr als ein #1 wurde gefunden, bitte geben Sie den Namen genauer an.',
'More than one control file with the tag \'%s\' exist.' => 'Es gibt mehr als eine Kontrolldatei mit dem Tag \'%s\'.',
'Multi mode not supported.' => 'Multimodus wird nicht unterstützt.',
+ 'Multiple addresses can be entered separated by commas.' => 'Mehrere Adressen können durch Kommata getrennt angegeben werden.',
'MwSt. inkl.' => 'MwSt. inkl.',
'Name' => 'Name',
'Name and Street' => 'Name und Straße',
'Orphaned' => 'Nie benutzt',
'Orphaned currencies' => 'Verwaiste Währungen',
'Other Matches' => 'Andere Treffer',
+ 'Other recipients' => 'Weitere EmpfängerInnen',
'Other users\' follow-ups' => 'Wiedervorlagen anderer Benutzer',
'Other values are ignored.' => 'Andere Eingaben werden ignoriert.',
'Others' => 'Andere',
'Sellprice for price group \'#1\'' => 'Verkaufspreis für Preisgruppe \'#1\'',
'Sellprice significant places' => 'Verkaufspreis: Nachkommastellen',
'Semicolon' => 'Semikolon',
+ 'Send invoice via email' => 'Rechnung via E-Mail verschicken',
'Send letter via e-mail' => 'Brief via E-Mail verschicken',
'Sender' => 'AbsenderIn',
'Sending E-mail: ' => 'E-Mail versenden: ',
follow_ups => { created_for_user => 'created_for_employee', created_by => 'created_by_employee', },
follow_up_access => { who => 'with_access', what => 'to_follow_ups_by', },
- periodic_invoices_configs => { oe_id => 'order' },
+ periodic_invoices_configs => { oe_id => 'order', email_recipient_contact_id => 'email_recipient_contact' },
reconciliation_links => { acc_trans_id => 'acc_trans' },
},
);
--- /dev/null
+-- @tag: periodic_invoices_send_email
+-- @description: Wiederkehrende Rechnungen automatisch per E-Mail verschicken
+-- @depends: release_3_4_0
+ALTER TABLE periodic_invoices_configs ADD COLUMN send_email BOOLEAN;
+ALTER TABLE periodic_invoices_configs ADD COLUMN email_recipient_contact_id INTEGER;
+ALTER TABLE periodic_invoices_configs ADD COLUMN email_recipient_address TEXT;
+ALTER TABLE periodic_invoices_configs ADD COLUMN email_sender TEXT;
+ALTER TABLE periodic_invoices_configs ADD COLUMN email_subject TEXT;
+ALTER TABLE periodic_invoices_configs ADD COLUMN email_body TEXT;
+
+UPDATE periodic_invoices_configs SET send_email = FALSE;
+
+ALTER TABLE periodic_invoices_configs ALTER COLUMN send_email SET DEFAULT FALSE;
+ALTER TABLE periodic_invoices_configs ALTER COLUMN send_email SET NOT NULL;
+
+ALTER TABLE periodic_invoices_configs
+ADD FOREIGN KEY (email_recipient_contact_id) REFERENCES contacts (cp_id)
+ON DELETE SET NULL;
<td valign="top">[% L.checkbox_tag("direct_debit", checked=direct_debit) %]</td>
</tr>
- <tr>
+ <tr class="rule-before">
<th align="right">[%- LxERP.t8('Print automatically') %]</th>
<td valign="top">
[% L.checkbox_tag("print", onclick => "toggle_printer_id_ctrl()", checked => print) %]
<th align="right">[%- LxERP.t8('Copies') %]</th>
<td valign="top">[% L.input_tag("copies", copies, size => 6, disabled => !print) %]</td>
</tr>
+
+ <tr class="rule-before">
+ <th align="right">[%- LxERP.t8("Send invoice via email") %]</th>
+ <td>[% L.checkbox_tag("send_email", onclick => "toggle_send_email_ctrl()", checked=send_email) %]</td>
+ </tr>
+
+ <tr>
+ <th align="right">[%- LxERP.t8("Contact to send to") %]</th>
+ <td>[% L.select_tag("email_recipient_contact_id", ALL_CONTACTS, title_key="full_name_dep", value_key="cp_id", default=email_recipient_contact_id, with_empty=1, disabled=!send_email, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <th align="right">[%- LxERP.t8("Other recipients") %]<sup>3</sup></th>
+ <td>[% L.input_tag("email_recipient_address", email_recipient_address, disabled=!send_email, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <th align="right">[%- LxERP.t8("Sender") %]</th>
+ <td>[% L.input_tag("email_sender", email_sender, disabled=!send_email, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <th align="right">[%- LxERP.t8("Subject") %]</th>
+ <td>[% L.input_tag("email_subject", email_subject, disabled=!send_email, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <th align="right" valign="top">[%- LxERP.t8("Message") %]</th>
+ <td valign="top">[% L.textarea_tag("email_body", email_body, disabled=!send_email, rows=8, style=style) %]</td>
+ </tr>
</table>
</p>
<p>(1): [%- LxERP.t8('The end date is the last day for which invoices will possibly be created.') %]</p>
<p>(2): [% LxERP.t8("If missing then the start date will be used.") %]</p>
+ <p>(3): [% LxERP.t8("Multiple addresses can be entered separated by commas.") %]</p>
[% L.hidden_tag('action', 'save_periodic_invoices_config') %]
$('#printer_id').prop('disabled', disabled);
$('#copies').prop('disabled', disabled);
}
+
+ function toggle_send_email_ctrl() {
+ var disabled = !$('#send_email').prop('checked');
+ $('#email_recipient_contact_id').prop('disabled', disabled);
+ $('#email_recipient_address').prop('disabled', disabled);
+ $('#email_from').prop('disabled', disabled);
+ $('#email_subject').prop('disabled', disabled);
+ $('#email_body').prop('disabled', disabled);
+ }
-->
</script>