Revision 516e618b
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/Auth.pm | ||
---|---|---|
|
||
my %user_data;
|
||
|
||
# Set defaults for options not present in database
|
||
$user_data{follow_up_notify_by_email} = 1;
|
||
|
||
while (my $ref = $sth->fetchrow_hashref()) {
|
||
$user_data{$ref->{cfg_key}} = $ref->{cfg_value};
|
||
@user_data{qw(id login)} = @{$ref}{qw(id login)};
|
SL/DB/AuthUser.pm | ||
---|---|---|
use constant CONFIG_VARS => qw(copies countrycode dateformat timeformat default_media default_printer_id
|
||
email favorites fax hide_cvar_search_options mandatory_departments menustyle name
|
||
numberformat show_form_details signature stylesheet taxincluded_checked tel
|
||
template_format focus_position form_cvars_nr_cols item_multiselect);
|
||
template_format focus_position form_cvars_nr_cols item_multiselect
|
||
follow_up_notify_by_email
|
||
);
|
||
|
||
__PACKAGE__->meta->add_relationship(
|
||
groups => {
|
SL/FU.pm | ||
---|---|---|
use SL::DBUtils;
|
||
use SL::DB;
|
||
use SL::DB::FollowUpCreatedForEmployee;
|
||
use SL::Mailer;
|
||
use SL::Notes;
|
||
use SL::Template;
|
||
use SL::Template::Simple;
|
||
|
||
use strict;
|
||
|
||
... | ... | |
my ($self, %params) = @_;
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $is_new = !$params{id};
|
||
|
||
my $rc = SL::DB->client->with_transaction(\&_save, $self, %params);
|
||
|
||
FU->send_email_notification(%params) if ($is_new);
|
||
|
||
$::lxdebug->leave_sub;
|
||
return $rc;
|
||
}
|
||
... | ... | |
return $access;
|
||
}
|
||
|
||
sub send_email_notification {
|
||
$main::lxdebug->enter_sub();
|
||
my ($self, %params) = @_;
|
||
|
||
my $notify_cfg = $main::lx_office_conf{follow_up_notify};
|
||
if (!$notify_cfg
|
||
|| !$notify_cfg->{email_subject}
|
||
|| !$notify_cfg->{email_from}
|
||
|| !$notify_cfg->{email_template}) {
|
||
$main::lxdebug->leave_sub();
|
||
return;
|
||
}
|
||
|
||
my $employee = SL::DB::Manager::Employee->current;
|
||
|
||
my @for_employees_ids = @{$params{created_for_employees}};
|
||
|
||
my $placeholders = join ', ', map {'?'} @for_employees_ids;
|
||
my $query = <<SQL;
|
||
SELECT login
|
||
FROM employee
|
||
WHERE id in ($placeholders)
|
||
SQL
|
||
|
||
my $dbh = $employee->dbh;
|
||
my $hash_key = 'login';
|
||
my $hashref = $dbh->selectall_hashref(
|
||
$query, $hash_key, undef, @for_employees_ids
|
||
);
|
||
my @logins = keys %$hashref;
|
||
|
||
foreach my $login (@logins) {
|
||
my %recipient = $main::auth->read_user(
|
||
login => conv_i($login),
|
||
);
|
||
|
||
if (!$recipient{follow_up_notify_by_email} || !$recipient{email}) {
|
||
next;
|
||
}
|
||
|
||
my %template_params = (
|
||
follow_up_subject => $params{subject},
|
||
follow_up_body => $params{body},
|
||
follow_up_date => $params{follow_up_date},
|
||
creator_name => $employee->name || $::form->{login},
|
||
recipient_name => $recipient{name} || $recipient{login},
|
||
);
|
||
|
||
my $template = Template->new({ENCODING => 'utf8'});
|
||
|
||
my $body_file = $notify_cfg->{email_template};
|
||
my $content_type = $body_file =~ m/.html$/ ? 'text/html' : 'text/plain';
|
||
|
||
my $message;
|
||
$template->process($body_file, \%template_params, \$message)
|
||
|| die $template->error;
|
||
|
||
my $param_form = Form->new();
|
||
$param_form->{$_} = $template_params{$_} for keys %template_params;
|
||
|
||
my $mail = Mailer->new();
|
||
$mail->{from} = $notify_cfg->{email_from};
|
||
$mail->{to} = $recipient{email};
|
||
$mail->{subject} = SL::Template::Simple->new(form => $param_form)
|
||
->substitute_vars($notify_cfg->{email_subject});
|
||
$mail->{content_type} = $content_type;
|
||
$mail->{message} = $message;
|
||
$mail->{charset} = 'UTF-8';
|
||
|
||
$mail->send();
|
||
}
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
1;
|
bin/mozilla/am.pl | ||
---|---|---|
$form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
|
||
$form->{todo_cfg} = { TODO->get_user_config('login' => $::myconfig{login}) };
|
||
$form->{title} = $locale->text('Edit Preferences for #1', $::myconfig{login});
|
||
$form->{follow_up_notify_by_email} = $myconfig{follow_up_notify_by_email};
|
||
|
||
$::request->{layout}->use_javascript("${_}.js") for qw(jquery.multiselect2side ckeditor/ckeditor ckeditor/adapters/jquery);
|
||
|
config/kivitendo.conf.default | ||
---|---|---|
# If empty fu/follow_up_reminder_mail.html will be used.
|
||
email_template =
|
||
|
||
[follow_up_notify]
|
||
# Email notification for new follow ups.
|
||
email_from = kivitendo Daemon <root@localhost>
|
||
email_subject = kivitendo: neue Wiedervorlagen für Sie von <%creator_name%>
|
||
email_template = templates/mail/follow_up_notify/email_body.txt
|
||
|
||
[console]
|
||
# Automatic login will only work if both "client" and "login" are
|
||
# given. "client" can be a client's database ID or its name. "login"
|
locale/de/all | ||
---|---|---|
'Follow-Up saved.' => 'Wiedervorlage gespeichert.',
|
||
'Follow-Ups' => 'Wiedervorlagen',
|
||
'Follow-up for' => 'Wiedervorlage für',
|
||
'Follow-up options' => 'Wiedervorlageoptionen',
|
||
'Following files are deleted:' => 'Folgende Dateien wurden gelöscht:',
|
||
'Following files are unimported:' => 'Folgende Dateien sind zur Quelle exportiert:',
|
||
'Following year' => 'Folgendes Jahr',
|
||
... | ... | |
'Nothing selected!' => 'Es wurde nichts ausgewählt!',
|
||
'Nothing stocked yet.' => 'Noch nichts eingelagert.',
|
||
'Nothing will be created or deleted at this stage!' => 'In diesem Schritt wird nichts angelegt oder gelöscht!',
|
||
'Notify me by email for follow-ups' => 'Bei neuen Wiedervorlagen per Email benachrichtigen',
|
||
'Nov' => 'Nov',
|
||
'November' => 'November',
|
||
'Number' => 'Nummer',
|
locale/en/all | ||
---|---|---|
'Follow-Up saved.' => '',
|
||
'Follow-Ups' => '',
|
||
'Follow-up for' => '',
|
||
'Follow-up options' => '',
|
||
'Following files are deleted:' => '',
|
||
'Following files are unimported:' => '',
|
||
'Following year' => '',
|
||
... | ... | |
'Nothing selected!' => '',
|
||
'Nothing stocked yet.' => '',
|
||
'Nothing will be created or deleted at this stage!' => '',
|
||
'Notify me by email for follow-ups' => '',
|
||
'Nov' => '',
|
||
'November' => '',
|
||
'Number' => '',
|
templates/design40_webpages/am/config.html | ||
---|---|---|
<li><a href="#page_display_options">[% 'Display options' | $T8 %]</a></li>
|
||
<li><a href="#page_print_options">[% 'Print options' | $T8 %]</a></li>
|
||
<li><a href="#page_todo_list_options">[% 'TODO list options' | $T8 %]</a></li>
|
||
<li><a href="#page_follow_up_options">[% 'Follow-up options' | $T8 %]</a></li>
|
||
</ul>
|
||
|
||
|
||
... | ... | |
</div><!-- /#page_todo_list_options -->
|
||
|
||
|
||
<div id="page_follow_up_options">
|
||
<div class="wrapper">
|
||
<table class="tbl-horizontal">
|
||
<caption>[% 'Follow-up options' | $T8 %]</caption>
|
||
<colgroup> <col class="wi-normal"><col class="wi-normal"> </colgroup>
|
||
<tbody>
|
||
<tr>
|
||
<th>[% 'Notify me by email for follow-ups' | $T8 %]</th>
|
||
<td>
|
||
<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 %]>
|
||
<label for="follow_up_notify_by_email_1">[% 'Yes' | $T8 %]</label>
|
||
<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 %]>
|
||
<label for="follow_up_notify_by_email_0">[% 'No' | $T8 %]</label>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div><!-- /.wrapper -->
|
||
</div><!-- /#page_follow_up_options -->
|
||
|
||
</div>
|
||
</form>
|
||
|
templates/mail/follow_up_notify/email_body.txt | ||
---|---|---|
Hallo [%recipient_name%],
|
||
|
||
[%creator_name%] hat eine neue Wiedervorlage für Sie für das
|
||
Datum [%follow_up_date%] mit dem Betreff "[%follow_up_subject%]"
|
||
und dem folgenden Inhalt erstellt:
|
||
|
||
[%follow_up_body%]
|
templates/webpages/am/config.html | ||
---|---|---|
<li><a href="#page_display_options">[% 'Display options' | $T8 %]</a></li>
|
||
<li><a href="#page_print_options">[% 'Print options' | $T8 %]</a></li>
|
||
<li><a href="#page_todo_list_options">[% 'TODO list options' | $T8 %]</a></li>
|
||
<li><a href="#page_follow_up_options">[% 'Follow-up options' | $T8 %]</a></li>
|
||
</ul>
|
||
|
||
<div id="page_personal_settings">
|
||
... | ... | |
[%- END %]
|
||
</table>
|
||
</div>
|
||
|
||
<div id="page_follow_up_options">
|
||
<table>
|
||
<tr>
|
||
<th align="right">[% 'Notify me by email for follow-ups' | $T8 %]</th>
|
||
<td colspan="2">
|
||
<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 %]>
|
||
<label for="follow_up_notify_by_email_1">[% 'Yes' | $T8 %]</label>
|
||
<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 %]>
|
||
<label for="follow_up_notify_by_email_0">[% 'No' | $T8 %]</label>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
</form>
|
Auch abrufbar als: Unified diff
FU: Email bei neuen Wiedervorlagen