From fd136dafdaea7c97002f1a91ea9bf8115f62bb60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 13 Feb 2012 18:02:41 +0100 Subject: [PATCH] =?utf8?q?Rudiment=C3=A4re=20Verwaltung=20von=20Benutzern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Employee.pm | 71 ++++++++++++++++++++++++++ locale/de/all | 6 +++ menu.ini | 5 ++ templates/webpages/employee/_form.html | 29 +++++++++++ templates/webpages/employee/_list.html | 15 ++++++ templates/webpages/employee/edit.html | 9 ++++ templates/webpages/employee/list.html | 5 ++ 7 files changed, 140 insertions(+) create mode 100644 SL/Controller/Employee.pm create mode 100644 templates/webpages/employee/_form.html create mode 100644 templates/webpages/employee/_list.html create mode 100644 templates/webpages/employee/edit.html create mode 100644 templates/webpages/employee/list.html diff --git a/SL/Controller/Employee.pm b/SL/Controller/Employee.pm new file mode 100644 index 000000000..265d1db3c --- /dev/null +++ b/SL/Controller/Employee.pm @@ -0,0 +1,71 @@ +package SL::Controller::Employee; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Employee; +use SL::Helper::Flash; + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('load_all'); +__PACKAGE__->run_before('load_from_form'); +__PACKAGE__->run_before('assign_from_form'); + +our @updatable_columns = qw(deleted); + +sub action_list { + my ($self, %params) = @_; + + $self->render('employee/list', title => $::locale->text('Employees')); +} + +sub action_edit { + my ($self, %params) = @_; + + if ($self->{employee}) { + $self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name)); + } else { + flash('error', $::locale->text('Could not load employee')); + $self->redirect_to(action => 'list'); + } +} + +sub action_save { + my ($self, %params) = @_; + + $self->{employee}->save; + + flash('info', $::locale->text('Employee #1 saved!')); + + $self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id); +} + +#################### private stuff ########################## + +sub check_auth { + $::auth->assert('admin'); +} + +sub load_all { + $_[0]{employees} = SL::DB::Manager::Employee->get_all; +} + +sub load_from_form { + $_[0]{employee} = SL::DB::Manager::Employee->find_by(id => delete $::form->{employee}{id}); +} + +sub assign_from_form { + my %data = %{ $::form->{employee} || {} }; + + return 1 unless keys %data; + + $_[0]{employee}->assign_attributes(map { $_ => $data{$_} } @updatable_columns); + return 1; +} + + +######################## behaviour ########################## + +sub delay_flash_on_redirect { 1 } + +1; diff --git a/locale/de/all b/locale/de/all index bcd35dabf..4a921f267 100644 --- a/locale/de/all +++ b/locale/de/all @@ -430,6 +430,7 @@ $self->{texts} = { 'Corrections' => 'Korrekturen', 'Costs' => 'Kosten', 'Could not copy %s to %s. Reason: %s' => 'Die Datei "%s" konnte nicht nach "%s" kopiert werden. Grund: %s', + 'Could not load employee' => 'Konnte Benutzer nicht laden', 'Could not open the file users/members.' => 'Die Datei "users/members" konnte nicht geöffnet werden.', 'Could not open the old memberfile.' => 'Die Datei mit den Benutzerdaten konnte nicht geöffnet werden.', 'Could not print dunning.' => 'Die Mahnungen konnten nicht gedruckt werden.', @@ -578,6 +579,7 @@ $self->{texts} = { 'Delete group' => 'Gruppe löschen', 'Delete profile' => 'Profil löschen', 'Delete transaction' => 'Buchung löschen', + 'Deleted' => 'Gelöscht', 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', @@ -693,6 +695,7 @@ $self->{texts} = { 'Edit Customer' => 'Kunde editieren', 'Edit Dunning' => 'Mahnungen konfigurieren', 'Edit Dunning Process Config' => 'Mahnwesenkonfiguration bearbeiten', + 'Edit Employee #1' => 'Benutzer #1 bearbeiten', 'Edit Follow-Up' => 'Wiedervorlage bearbeiten', 'Edit Follow-Up for #1' => 'Wiedervorlage für #1 bearbeiten', 'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten', @@ -749,6 +752,8 @@ $self->{texts} = { 'Either there are no open invoices, or you have already initiated bank transfers with the open amounts for those that are still open.' => 'Entweder gibt es keine offenen Rechnungen, oder es wurden bereits Überweisungen über die offenen Beträge aller offenen Rechnungen erstellt.', 'Element disabled' => 'Element deaktiviert', 'Employee' => 'Bearbeiter', + 'Employee #1 saved!' => 'Benutzer #1 gespeichert!', + 'Employees' => 'Benutzer', 'Empty transaction!' => 'Buchung ist leer!', 'End date' => 'Enddatum', 'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung für diesen Entwurf ein.', @@ -1078,6 +1083,7 @@ $self->{texts} = { 'Login' => 'Anmelden', 'Login Name' => 'Benutzer', 'Login name missing!' => 'Benutzer - Feld darf nicht leer sein!', + 'Login of User' => 'Login', 'Logout' => 'Abmelden', 'Logout now' => 'Lx-Office jetzt verlassen', 'Long Dates' => 'Lange Monatsnamen', diff --git a/menu.ini b/menu.ini index 427716282..ce2babb31 100644 --- a/menu.ini +++ b/menu.ini @@ -790,6 +790,11 @@ action=audit_control module=am.pl action=show_history_search +[System--Employees] +ACCESS=admin +module=controller.pl +action=Employee/list + [Program] diff --git a/templates/webpages/employee/_form.html b/templates/webpages/employee/_form.html new file mode 100644 index 000000000..841cdc5b2 --- /dev/null +++ b/templates/webpages/employee/_form.html @@ -0,0 +1,29 @@ +[%- USE HTML %] +[%- USE LxERP %] +[%- USE T8 %] +[%- USE L %] + +
+ + + + + + + + + + + + + + +
[% 'Login of User' | $T8 %]:[% employee.login | html %]
[% 'Name' | $T8 %]:[% employee.name | html %]
[% 'Deleted' | $T8 %]: [% 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')) %] +
+ +[%- L.hidden_tag('employee.id', employee.id) %] +[%- L.hidden_tag('action', 'Employee/dispatch') %] +[%- L.submit_tag('action_save', LxERP.t8('Save')) %] +
+ diff --git a/templates/webpages/employee/_list.html b/templates/webpages/employee/_list.html new file mode 100644 index 000000000..5c92d44e8 --- /dev/null +++ b/templates/webpages/employee/_list.html @@ -0,0 +1,15 @@ +[%- USE T8 %] + + + + + + +[%- FOREACH row IN SELF.employees %] + + + + + +[%- END %] +
[% 'Login of User' | $T8 %][% 'Name' | $T8 %][% 'Deleted' | $T8 %]
[% row.login | html %][% row.name | html %][% row.deleted_as_bool_yn | html %]
diff --git a/templates/webpages/employee/edit.html b/templates/webpages/employee/edit.html new file mode 100644 index 000000000..d4b3ed894 --- /dev/null +++ b/templates/webpages/employee/edit.html @@ -0,0 +1,9 @@ +

[% title | html %]

+ +[% PROCESS 'common/flash.html' %] + +[% PROCESS 'employee/_form.html' employee=SELF.employee %] + +
+ +[% PROCESS 'employee/_list.html' %] diff --git a/templates/webpages/employee/list.html b/templates/webpages/employee/list.html new file mode 100644 index 000000000..056a82812 --- /dev/null +++ b/templates/webpages/employee/list.html @@ -0,0 +1,5 @@ +

[% title | html %]

+ +[% PROCESS 'common/flash.html' %] + +[% PROCESS 'employee/_list.html' %] -- 2.20.1