Revision 516e618b
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/Auth.pm | ||
---|---|---|
513 | 513 |
|
514 | 514 |
my %user_data; |
515 | 515 |
|
516 |
# Set defaults for options not present in database |
|
517 |
$user_data{follow_up_notify_by_email} = 1; |
|
518 |
|
|
516 | 519 |
while (my $ref = $sth->fetchrow_hashref()) { |
517 | 520 |
$user_data{$ref->{cfg_key}} = $ref->{cfg_value}; |
518 | 521 |
@user_data{qw(id login)} = @{$ref}{qw(id login)}; |
SL/DB/AuthUser.pm | ||
---|---|---|
11 | 11 |
use constant CONFIG_VARS => qw(copies countrycode dateformat timeformat default_media default_printer_id |
12 | 12 |
email favorites fax hide_cvar_search_options mandatory_departments menustyle name |
13 | 13 |
numberformat show_form_details signature stylesheet taxincluded_checked tel |
14 |
template_format focus_position form_cvars_nr_cols item_multiselect); |
|
14 |
template_format focus_position form_cvars_nr_cols item_multiselect |
|
15 |
follow_up_notify_by_email |
|
16 |
); |
|
15 | 17 |
|
16 | 18 |
__PACKAGE__->meta->add_relationship( |
17 | 19 |
groups => { |
SL/FU.pm | ||
---|---|---|
8 | 8 |
use SL::DBUtils; |
9 | 9 |
use SL::DB; |
10 | 10 |
use SL::DB::FollowUpCreatedForEmployee; |
11 |
use SL::Mailer; |
|
11 | 12 |
use SL::Notes; |
13 |
use SL::Template; |
|
14 |
use SL::Template::Simple; |
|
12 | 15 |
|
13 | 16 |
use strict; |
14 | 17 |
|
... | ... | |
16 | 19 |
my ($self, %params) = @_; |
17 | 20 |
$main::lxdebug->enter_sub(); |
18 | 21 |
|
22 |
my $is_new = !$params{id}; |
|
23 |
|
|
19 | 24 |
my $rc = SL::DB->client->with_transaction(\&_save, $self, %params); |
20 | 25 |
|
26 |
FU->send_email_notification(%params) if ($is_new); |
|
27 |
|
|
21 | 28 |
$::lxdebug->leave_sub; |
22 | 29 |
return $rc; |
23 | 30 |
} |
... | ... | |
545 | 552 |
return $access; |
546 | 553 |
} |
547 | 554 |
|
555 |
sub send_email_notification { |
|
556 |
$main::lxdebug->enter_sub(); |
|
557 |
my ($self, %params) = @_; |
|
558 |
|
|
559 |
my $notify_cfg = $main::lx_office_conf{follow_up_notify}; |
|
560 |
if (!$notify_cfg |
|
561 |
|| !$notify_cfg->{email_subject} |
|
562 |
|| !$notify_cfg->{email_from} |
|
563 |
|| !$notify_cfg->{email_template}) { |
|
564 |
$main::lxdebug->leave_sub(); |
|
565 |
return; |
|
566 |
} |
|
567 |
|
|
568 |
my $employee = SL::DB::Manager::Employee->current; |
|
569 |
|
|
570 |
my @for_employees_ids = @{$params{created_for_employees}}; |
|
571 |
|
|
572 |
my $placeholders = join ', ', map {'?'} @for_employees_ids; |
|
573 |
my $query = <<SQL; |
|
574 |
SELECT login |
|
575 |
FROM employee |
|
576 |
WHERE id in ($placeholders) |
|
577 |
SQL |
|
578 |
|
|
579 |
my $dbh = $employee->dbh; |
|
580 |
my $hash_key = 'login'; |
|
581 |
my $hashref = $dbh->selectall_hashref( |
|
582 |
$query, $hash_key, undef, @for_employees_ids |
|
583 |
); |
|
584 |
my @logins = keys %$hashref; |
|
585 |
|
|
586 |
foreach my $login (@logins) { |
|
587 |
my %recipient = $main::auth->read_user( |
|
588 |
login => conv_i($login), |
|
589 |
); |
|
590 |
|
|
591 |
if (!$recipient{follow_up_notify_by_email} || !$recipient{email}) { |
|
592 |
next; |
|
593 |
} |
|
594 |
|
|
595 |
my %template_params = ( |
|
596 |
follow_up_subject => $params{subject}, |
|
597 |
follow_up_body => $params{body}, |
|
598 |
follow_up_date => $params{follow_up_date}, |
|
599 |
creator_name => $employee->name || $::form->{login}, |
|
600 |
recipient_name => $recipient{name} || $recipient{login}, |
|
601 |
); |
|
602 |
|
|
603 |
my $template = Template->new({ENCODING => 'utf8'}); |
|
604 |
|
|
605 |
my $body_file = $notify_cfg->{email_template}; |
|
606 |
my $content_type = $body_file =~ m/.html$/ ? 'text/html' : 'text/plain'; |
|
607 |
|
|
608 |
my $message; |
|
609 |
$template->process($body_file, \%template_params, \$message) |
|
610 |
|| die $template->error; |
|
611 |
|
|
612 |
my $param_form = Form->new(); |
|
613 |
$param_form->{$_} = $template_params{$_} for keys %template_params; |
|
614 |
|
|
615 |
my $mail = Mailer->new(); |
|
616 |
$mail->{from} = $notify_cfg->{email_from}; |
|
617 |
$mail->{to} = $recipient{email}; |
|
618 |
$mail->{subject} = SL::Template::Simple->new(form => $param_form) |
|
619 |
->substitute_vars($notify_cfg->{email_subject}); |
|
620 |
$mail->{content_type} = $content_type; |
|
621 |
$mail->{message} = $message; |
|
622 |
$mail->{charset} = 'UTF-8'; |
|
623 |
|
|
624 |
$mail->send(); |
|
625 |
} |
|
626 |
|
|
627 |
$main::lxdebug->leave_sub(); |
|
628 |
} |
|
629 |
|
|
548 | 630 |
1; |
bin/mozilla/am.pl | ||
---|---|---|
670 | 670 |
$form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password(); |
671 | 671 |
$form->{todo_cfg} = { TODO->get_user_config('login' => $::myconfig{login}) }; |
672 | 672 |
$form->{title} = $locale->text('Edit Preferences for #1', $::myconfig{login}); |
673 |
$form->{follow_up_notify_by_email} = $myconfig{follow_up_notify_by_email}; |
|
673 | 674 |
|
674 | 675 |
$::request->{layout}->use_javascript("${_}.js") for qw(jquery.multiselect2side ckeditor/ckeditor ckeditor/adapters/jquery); |
675 | 676 |
|
config/kivitendo.conf.default | ||
---|---|---|
310 | 310 |
# If empty fu/follow_up_reminder_mail.html will be used. |
311 | 311 |
email_template = |
312 | 312 |
|
313 |
[follow_up_notify] |
|
314 |
# Email notification for new follow ups. |
|
315 |
email_from = kivitendo Daemon <root@localhost> |
|
316 |
email_subject = kivitendo: neue Wiedervorlagen für Sie von <%creator_name%> |
|
317 |
email_template = templates/mail/follow_up_notify/email_body.txt |
|
318 |
|
|
313 | 319 |
[console] |
314 | 320 |
# Automatic login will only work if both "client" and "login" are |
315 | 321 |
# given. "client" can be a client's database ID or its name. "login" |
locale/de/all | ||
---|---|---|
1739 | 1739 |
'Follow-Up saved.' => 'Wiedervorlage gespeichert.', |
1740 | 1740 |
'Follow-Ups' => 'Wiedervorlagen', |
1741 | 1741 |
'Follow-up for' => 'Wiedervorlage für', |
1742 |
'Follow-up options' => 'Wiedervorlageoptionen', |
|
1742 | 1743 |
'Following files are deleted:' => 'Folgende Dateien wurden gelöscht:', |
1743 | 1744 |
'Following files are unimported:' => 'Folgende Dateien sind zur Quelle exportiert:', |
1744 | 1745 |
'Following year' => 'Folgendes Jahr', |
... | ... | |
2528 | 2529 |
'Nothing selected!' => 'Es wurde nichts ausgewählt!', |
2529 | 2530 |
'Nothing stocked yet.' => 'Noch nichts eingelagert.', |
2530 | 2531 |
'Nothing will be created or deleted at this stage!' => 'In diesem Schritt wird nichts angelegt oder gelöscht!', |
2532 |
'Notify me by email for follow-ups' => 'Bei neuen Wiedervorlagen per Email benachrichtigen', |
|
2531 | 2533 |
'Nov' => 'Nov', |
2532 | 2534 |
'November' => 'November', |
2533 | 2535 |
'Number' => 'Nummer', |
locale/en/all | ||
---|---|---|
1735 | 1735 |
'Follow-Up saved.' => '', |
1736 | 1736 |
'Follow-Ups' => '', |
1737 | 1737 |
'Follow-up for' => '', |
1738 |
'Follow-up options' => '', |
|
1738 | 1739 |
'Following files are deleted:' => '', |
1739 | 1740 |
'Following files are unimported:' => '', |
1740 | 1741 |
'Following year' => '', |
... | ... | |
2522 | 2523 |
'Nothing selected!' => '', |
2523 | 2524 |
'Nothing stocked yet.' => '', |
2524 | 2525 |
'Nothing will be created or deleted at this stage!' => '', |
2526 |
'Notify me by email for follow-ups' => '', |
|
2525 | 2527 |
'Nov' => '', |
2526 | 2528 |
'November' => '', |
2527 | 2529 |
'Number' => '', |
templates/design40_webpages/am/config.html | ||
---|---|---|
13 | 13 |
<li><a href="#page_display_options">[% 'Display options' | $T8 %]</a></li> |
14 | 14 |
<li><a href="#page_print_options">[% 'Print options' | $T8 %]</a></li> |
15 | 15 |
<li><a href="#page_todo_list_options">[% 'TODO list options' | $T8 %]</a></li> |
16 |
<li><a href="#page_follow_up_options">[% 'Follow-up options' | $T8 %]</a></li> |
|
16 | 17 |
</ul> |
17 | 18 |
|
18 | 19 |
|
... | ... | |
302 | 303 |
</div><!-- /#page_todo_list_options --> |
303 | 304 |
|
304 | 305 |
|
306 |
<div id="page_follow_up_options"> |
|
307 |
<div class="wrapper"> |
|
308 |
<table class="tbl-horizontal"> |
|
309 |
<caption>[% 'Follow-up options' | $T8 %]</caption> |
|
310 |
<colgroup> <col class="wi-normal"><col class="wi-normal"> </colgroup> |
|
311 |
<tbody> |
|
312 |
<tr> |
|
313 |
<th>[% 'Notify me by email for follow-ups' | $T8 %]</th> |
|
314 |
<td> |
|
315 |
<input type="radio" name="follow_up_notify_by_email" id="follow_up_notify_by_email_1" value="1"[% IF follow_up_notify_by_email %] checked[% END %]> |
|
316 |
<label for="follow_up_notify_by_email_1">[% 'Yes' | $T8 %]</label> |
|
317 |
<input type="radio" name="follow_up_notify_by_email" id="follow_up_notify_by_email_0" value="0"[% IF !follow_up_notify_by_email %] checked[% END %]> |
|
318 |
<label for="follow_up_notify_by_email_0">[% 'No' | $T8 %]</label> |
|
319 |
</td> |
|
320 |
</tr> |
|
321 |
</table> |
|
322 |
</div><!-- /.wrapper --> |
|
323 |
</div><!-- /#page_follow_up_options --> |
|
324 |
|
|
305 | 325 |
</div> |
306 | 326 |
</form> |
307 | 327 |
|
templates/mail/follow_up_notify/email_body.txt | ||
---|---|---|
1 |
Hallo [%recipient_name%], |
|
2 |
|
|
3 |
[%creator_name%] hat eine neue Wiedervorlage für Sie für das |
|
4 |
Datum [%follow_up_date%] mit dem Betreff "[%follow_up_subject%]" |
|
5 |
und dem folgenden Inhalt erstellt: |
|
6 |
|
|
7 |
[%follow_up_body%] |
templates/webpages/am/config.html | ||
---|---|---|
12 | 12 |
<li><a href="#page_display_options">[% 'Display options' | $T8 %]</a></li> |
13 | 13 |
<li><a href="#page_print_options">[% 'Print options' | $T8 %]</a></li> |
14 | 14 |
<li><a href="#page_todo_list_options">[% 'TODO list options' | $T8 %]</a></li> |
15 |
<li><a href="#page_follow_up_options">[% 'Follow-up options' | $T8 %]</a></li> |
|
15 | 16 |
</ul> |
16 | 17 |
|
17 | 18 |
<div id="page_personal_settings"> |
... | ... | |
342 | 343 |
[%- END %] |
343 | 344 |
</table> |
344 | 345 |
</div> |
346 |
|
|
347 |
<div id="page_follow_up_options"> |
|
348 |
<table> |
|
349 |
<tr> |
|
350 |
<th align="right">[% 'Notify me by email for follow-ups' | $T8 %]</th> |
|
351 |
<td colspan="2"> |
|
352 |
<input type="radio" name="follow_up_notify_by_email" id="follow_up_notify_by_email_1" value="1"[% IF follow_up_notify_by_email %] checked[% END %]> |
|
353 |
<label for="follow_up_notify_by_email_1">[% 'Yes' | $T8 %]</label> |
|
354 |
<input type="radio" name="follow_up_notify_by_email" id="follow_up_notify_by_email_0" value="0"[% IF !follow_up_notify_by_email %] checked[% END %]> |
|
355 |
<label for="follow_up_notify_by_email_0">[% 'No' | $T8 %]</label> |
|
356 |
</td> |
|
357 |
</tr> |
|
358 |
</table> |
|
359 |
</div> |
|
360 |
|
|
345 | 361 |
</div> |
346 | 362 |
</form> |
Auch abrufbar als: Unified diff
FU: Email bei neuen Wiedervorlagen