use SL::DB::Employee;
use SL::Helper::Flash;
+use SL::Locale::String qw(t8);
__PACKAGE__->run_before('check_auth');
__PACKAGE__->run_before('load_all');
my ($self, %params) = @_;
if ($self->{employee}) {
+ $self->setup_edit_action_bar;
$self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name));
} else {
- flash('error', $::locale->text('Could not load employee'));
+ flash_later('error', $::locale->text('Could not load employee'));
$self->redirect_to(action => 'list');
}
}
$self->{employee}->save;
- flash('info', $::locale->text('Employee #1 saved!'));
+ flash('info', $::locale->text('Employee #1 saved!', $self->{employee}->safe_name));
$self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id);
}
return 1;
}
+sub setup_edit_action_bar {
+ my ($self) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'Employee/save' } ],
+ accesskey => 'enter',
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Abort'),
+ link => $self->url_for(action => 'list'),
+ ],
+ );
+ }
+}
######################## behaviour ##########################
+++ /dev/null
-[%- USE HTML %]
-[%- USE LxERP %]
-[%- USE T8 %]
-[%- USE L %]
-
-<form action='controller.pl' method='POST'>
-
-<table>
-<tr>
- <td align='right' class=''>[% 'Login of User' | $T8 %]:</td>
- <td>[% employee.login | html %]</td>
-</tr>
-<tr>
- <td align='right'>[% 'Name' | $T8 %]:</td>
- <td>[% employee.name | html %]</td>
-</tr>
-<tr>
- <td align='right'>[% 'Deleted' | $T8 %]:</td>
- <td> [% L.radio_button_tag('employee.deleted', value=1, checked=employee.deleted, label=LxERP.t8('Yes')) %]
- [% L.radio_button_tag('employee.deleted', value=0, checked=!employee.deleted, label=LxERP.t8('No')) %]
- </td>
-</tr>
-</table>
-
-[%- L.hidden_tag('employee.id', employee.id) %]
-[%- L.hidden_tag('action', 'Employee/dispatch') %]
-[%- L.submit_tag('action_save', LxERP.t8('Save')) %]
-</form>
-
-<h1>[% title | html %]</h1>
+[%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% title | html %]</h1>
-[% PROCESS 'common/flash.html' %]
+[% PROCESS "common/flash.html" %]
-[% PROCESS 'employee/_form.html' employee=SELF.employee %]
+<form action="controller.pl" method="POST" id="form">
-<hr>
+ <table>
+ <tr>
+ <td align="right" class="">[% "Login of User" | $T8 %]:</td>
+ <td>[% SELF.employee.login | html %]</td>
+ </tr>
+ <tr>
+ <td align="right">[% "Name" | $T8 %]:</td>
+ <td>[% SELF.employee.name | html %]</td>
+ </tr>
+ <tr>
+ <td align="right">[% "Deleted" | $T8 %]:</td>
+ <td> [% L.radio_button_tag("SELF.employee.deleted", value=1, checked=SELF.employee.deleted, label=LxERP.t8("Yes")) %]
+ [% L.radio_button_tag("SELF.employee.deleted", value=0, checked=!SELF.employee.deleted, label=LxERP.t8("No")) %]
+ </td>
+ </tr>
+ </table>
-[% PROCESS 'employee/_list.html' %]
+ [%- L.hidden_tag("employee.id", SELF.employee.id) %]
+</form>