epic-ts
[kivitendo-erp.git] / bin / mozilla / fu.pl
index ef80a73..d9001e3 100644 (file)
@@ -1,6 +1,7 @@
 use POSIX qw(strftime);
 
 use SL::FU;
+use SL::Locale::String qw(t8);
 use SL::ReportGenerator;
 
 require "bin/mozilla/reportgenerator.pl";
@@ -41,6 +42,8 @@ sub add {
   $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} }) {
@@ -99,7 +102,7 @@ sub display_form {
   $params{trans_id}   = $form->{LINKS}->[0]->{trans_id} if (@{ $form->{LINKS} });
   $form->{FOLLOW_UPS} = FU->follow_ups(%params);
 
-  $form->{jsscript}   = 1;
+  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');
@@ -128,7 +131,7 @@ sub save_follow_up {
   if ($form->{POPUP_MODE}) {
     $form->header();
     print $form->parse_html_template('fu/close_window');
-    ::end_of_request();
+    $::dispatcher->end_request;
   }
 
   $form->{SAVED_MESSAGE} = $locale->text('Follow-Up saved.');
@@ -174,7 +177,7 @@ sub finish {
   if ($form->{POPUP_MODE}) {
     $form->header();
     print $form->parse_html_template('fu/close_window');
-    ::end_of_request();
+    $::dispatcher->end_request;
   }
 
   $form->redirect() if ($form->{callback});
@@ -212,7 +215,7 @@ sub delete {
   if ($form->{POPUP_MODE}) {
     $form->header();
     print $form->parse_html_template('fu/close_window');
-    ::end_of_request();
+    $::dispatcher->end_request;
   }
 
   $form->redirect() if ($form->{callback});
@@ -232,9 +235,9 @@ sub search {
 
   $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');
 
@@ -350,6 +353,7 @@ sub report {
     $report->add_data($row);
   }
 
+  setup_fu_report_action_bar();
   $report->generate_with_headers();
 
   $main::lxdebug->leave_sub();
@@ -367,7 +371,7 @@ sub report_for_todo_list {
   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);
@@ -406,12 +410,14 @@ sub edit_access_rights {
 
   my $access = FU->retrieve_access_rights();
 
-  $form->{EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
+  $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');
 
@@ -478,4 +484,77 @@ sub dispatcher {
   $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;