Revision 7e8a6c25
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/Controller/Employee.pm | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use SL::DB::Employee; |
7 | 7 |
use SL::Helper::Flash; |
8 |
use SL::Locale::String qw(t8); |
|
8 | 9 |
|
9 | 10 |
__PACKAGE__->run_before('check_auth'); |
10 | 11 |
__PACKAGE__->run_before('load_all'); |
... | ... | |
23 | 24 |
my ($self, %params) = @_; |
24 | 25 |
|
25 | 26 |
if ($self->{employee}) { |
27 |
$self->setup_edit_action_bar; |
|
26 | 28 |
$self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name)); |
27 | 29 |
} else { |
28 |
flash('error', $::locale->text('Could not load employee')); |
|
30 |
flash_later('error', $::locale->text('Could not load employee'));
|
|
29 | 31 |
$self->redirect_to(action => 'list'); |
30 | 32 |
} |
31 | 33 |
} |
... | ... | |
35 | 37 |
|
36 | 38 |
$self->{employee}->save; |
37 | 39 |
|
38 |
flash('info', $::locale->text('Employee #1 saved!')); |
|
40 |
flash('info', $::locale->text('Employee #1 saved!', $self->{employee}->safe_name));
|
|
39 | 41 |
|
40 | 42 |
$self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id); |
41 | 43 |
} |
... | ... | |
63 | 65 |
return 1; |
64 | 66 |
} |
65 | 67 |
|
68 |
sub setup_edit_action_bar { |
|
69 |
my ($self) = @_; |
|
70 |
|
|
71 |
for my $bar ($::request->layout->get('actionbar')) { |
|
72 |
$bar->add( |
|
73 |
action => [ |
|
74 |
t8('Save'), |
|
75 |
submit => [ '#form', { action => 'Employee/save' } ], |
|
76 |
accesskey => 'enter', |
|
77 |
], |
|
78 |
|
|
79 |
'separator', |
|
80 |
|
|
81 |
link => [ |
|
82 |
t8('Abort'), |
|
83 |
link => $self->url_for(action => 'list'), |
|
84 |
], |
|
85 |
); |
|
86 |
} |
|
87 |
} |
|
66 | 88 |
|
67 | 89 |
######################## behaviour ########################## |
68 | 90 |
|
templates/webpages/employee/_form.html | ||
---|---|---|
1 |
[%- USE HTML %] |
|
2 |
[%- USE LxERP %] |
|
3 |
[%- USE T8 %] |
|
4 |
[%- USE L %] |
|
5 |
|
|
6 |
<form action='controller.pl' method='POST'> |
|
7 |
|
|
8 |
<table> |
|
9 |
<tr> |
|
10 |
<td align='right' class=''>[% 'Login of User' | $T8 %]:</td> |
|
11 |
<td>[% employee.login | html %]</td> |
|
12 |
</tr> |
|
13 |
<tr> |
|
14 |
<td align='right'>[% 'Name' | $T8 %]:</td> |
|
15 |
<td>[% employee.name | html %]</td> |
|
16 |
</tr> |
|
17 |
<tr> |
|
18 |
<td align='right'>[% 'Deleted' | $T8 %]:</td> |
|
19 |
<td> [% L.radio_button_tag('employee.deleted', value=1, checked=employee.deleted, label=LxERP.t8('Yes')) %] |
|
20 |
[% L.radio_button_tag('employee.deleted', value=0, checked=!employee.deleted, label=LxERP.t8('No')) %] |
|
21 |
</td> |
|
22 |
</tr> |
|
23 |
</table> |
|
24 |
|
|
25 |
[%- L.hidden_tag('employee.id', employee.id) %] |
|
26 |
[%- L.hidden_tag('action', 'Employee/dispatch') %] |
|
27 |
[%- L.submit_tag('action_save', LxERP.t8('Save')) %] |
|
28 |
</form> |
|
29 |
|
templates/webpages/employee/edit.html | ||
---|---|---|
1 |
<h1>[% title | html %]</h1> |
|
1 |
[%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% title | html %]</h1>
|
|
2 | 2 |
|
3 |
[% PROCESS 'common/flash.html' %]
|
|
3 |
[% PROCESS "common/flash.html" %]
|
|
4 | 4 |
|
5 |
[% PROCESS 'employee/_form.html' employee=SELF.employee %]
|
|
5 |
<form action="controller.pl" method="POST" id="form">
|
|
6 | 6 |
|
7 |
<hr> |
|
7 |
<table> |
|
8 |
<tr> |
|
9 |
<td align="right" class="">[% "Login of User" | $T8 %]:</td> |
|
10 |
<td>[% SELF.employee.login | html %]</td> |
|
11 |
</tr> |
|
12 |
<tr> |
|
13 |
<td align="right">[% "Name" | $T8 %]:</td> |
|
14 |
<td>[% SELF.employee.name | html %]</td> |
|
15 |
</tr> |
|
16 |
<tr> |
|
17 |
<td align="right">[% "Deleted" | $T8 %]:</td> |
|
18 |
<td> [% L.radio_button_tag("SELF.employee.deleted", value=1, checked=SELF.employee.deleted, label=LxERP.t8("Yes")) %] |
|
19 |
[% L.radio_button_tag("SELF.employee.deleted", value=0, checked=!SELF.employee.deleted, label=LxERP.t8("No")) %] |
|
20 |
</td> |
|
21 |
</tr> |
|
22 |
</table> |
|
8 | 23 |
|
9 |
[% PROCESS 'employee/_list.html' %] |
|
24 |
[%- L.hidden_tag("employee.id", SELF.employee.id) %] |
|
25 |
</form> |
Auch abrufbar als: Unified diff
ActionBar: Verwendung bei »System« → »Benutzer«