use POSIX qw(strftime);
use SL::FU;
+use SL::Locale::String qw(t8);
use SL::ReportGenerator;
require "bin/mozilla/reportgenerator.pl";
sub _collect_links {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $dest = shift;
my $form = $main::form;
sub add {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
$form->get_employee($form->get_standard_dbh(\%myconfig));
$form->{created_for_user} = $form->{employee_id};
+ $form->{subject} = $form->{trans_subject_1} if $form->{trans_subject_1};
+
my $link_details;
if (0 < scalar @{ $form->{LINKS} }) {
sub edit {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
sub display_form {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
$form->get_lists("employees" => "EMPLOYEES");
my %params;
$params{not_id} = $form->{id} if ($form->{id});
$params{trans_id} = $form->{LINKS}->[0]->{trans_id} if (@{ $form->{LINKS} });
- $form->{FOLLOW_UPS} = FU->follow_ups(%params);
- $form->{jsscript} = 1;
+ $form->{sort} = 'follow_up_date';
+ $form->{FOLLOW_UPS_DONE} = FU->follow_ups(%params, done => 1);
+ $form->{FOLLOW_UPS_PENDING} = FU->follow_ups(%params, not_done => 1);
- $form->header();
+ setup_fu_display_form_action_bar() unless $::form->{POPUP_MODE};
+
+ $form->header(no_layout => $::form->{POPUP_MODE});
print $form->parse_html_template('fu/add_edit');
$main::lxdebug->leave_sub();
sub save_follow_up {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ $::dispatcher->end_request;
}
$form->{SAVED_MESSAGE} = $locale->text('Follow-Up saved.');
sub finish {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ $::dispatcher->end_request;
}
$form->redirect() if ($form->{callback});
sub delete {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ $::dispatcher->end_request;
}
$form->redirect() if ($form->{callback});
sub search {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
$form->get_lists("employees" => "EMPLOYEES");
- $form->{jsscript} = 1;
$form->{title} = $locale->text('Follow-Ups');
+ setup_fu_search_action_bar();
$form->header();
print $form->parse_html_template('fu/search');
sub report {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done);
'attachment_basename' => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time),
);
$report->set_options_from_form();
+ $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
my $idx = 0;
my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params);
$report->add_data($row);
}
+ setup_fu_report_action_bar();
$report->generate_with_headers();
$main::lxdebug->leave_sub();
sub report_for_todo_list {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done);
my %params = (
'due_only' => 1,
'not_done' => 1,
- 'created_for_login' => $form->{login},
+ 'created_for_login' => $::myconfig{login},
);
my $follow_ups = FU->follow_ups(%params);
sub edit_access_rights {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
my $access = FU->retrieve_access_rights();
- $form->get_lists("employees" => "EMPLOYEES");
+ $form->{EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
map { $_->{access} = $access->{$_->{id}} } @{ $form->{EMPLOYEES} };
$form->{title} = $locale->text('Edit Access Rights for Follow-Ups');
+ setup_fu_edit_access_rights_action_bar();
+
$form->header();
print $form->parse_html_template('fu/edit_access_rights');
sub save_access_rights {
$main::lxdebug->enter_sub();
+ $main::auth->assert('productivity');
+
my $form = $main::form;
my $locale = $main::locale;
}
sub save {
+ $main::auth->assert('productivity');
+
if ($main::form->{save_nextsub}) {
call_sub($main::form->{save_nextsub});
} else {
$form->error($locale->text('No action defined.'));
}
+sub setup_fu_search_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Show'),
+ submit => [ '#form', { action => "report" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_fu_display_form_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => "save" } ],
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Finish'),
+ submit => [ '#form', { action => "finish" } ],
+ disabled => !$::form->{id} ? t8('The object has not been saved yet.') : undef,
+ ],
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => "delete" } ],
+ disabled => !$::form->{id} ? t8('The object has not been saved yet.') : undef,
+ confirm => t8('Do you really want to delete this object?'),
+ ],
+ );
+ }
+}
+
+sub setup_fu_report_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Finish'),
+ submit => [ '#form', { action => "finish" } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
+ ],
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => "delete" } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
+ confirm => t8('Do you really want to delete the selected objects?'),
+ ],
+ );
+ }
+}
+
+sub setup_fu_edit_access_rights_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => "save_access_rights" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
1;