Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fd136daf

Von Sven Schöling vor fast 13 Jahren hinzugefügt

  • ID fd136dafdaea7c97002f1a91ea9bf8115f62bb60
  • Vorgänger 4347f0df
  • Nachfolger 0feb0348

Rudimentäre Verwaltung von Benutzern

Unterschiede anzeigen:

SL/Controller/Employee.pm
1
package SL::Controller::Employee;
2

  
3
use strict;
4
use parent qw(SL::Controller::Base);
5

  
6
use SL::DB::Employee;
7
use SL::Helper::Flash;
8

  
9
__PACKAGE__->run_before('check_auth');
10
__PACKAGE__->run_before('load_all');
11
__PACKAGE__->run_before('load_from_form');
12
__PACKAGE__->run_before('assign_from_form');
13

  
14
our @updatable_columns = qw(deleted);
15

  
16
sub action_list {
17
  my ($self, %params) = @_;
18

  
19
  $self->render('employee/list', title => $::locale->text('Employees'));
20
}
21

  
22
sub action_edit {
23
  my ($self, %params) = @_;
24

  
25
  if ($self->{employee}) {
26
    $self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name));
27
  } else {
28
    flash('error', $::locale->text('Could not load employee'));
29
    $self->redirect_to(action => 'list');
30
  }
31
}
32

  
33
sub action_save {
34
  my ($self, %params) = @_;
35

  
36
  $self->{employee}->save;
37

  
38
  flash('info', $::locale->text('Employee #1 saved!'));
39

  
40
  $self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id);
41
}
42

  
43
#################### private stuff ##########################
44

  
45
sub check_auth {
46
  $::auth->assert('admin');
47
}
48

  
49
sub load_all {
50
  $_[0]{employees} = SL::DB::Manager::Employee->get_all;
51
}
52

  
53
sub load_from_form {
54
  $_[0]{employee} = SL::DB::Manager::Employee->find_by(id => delete $::form->{employee}{id});
55
}
56

  
57
sub assign_from_form {
58
  my %data = %{ $::form->{employee} || {} };
59

  
60
  return 1 unless keys %data;
61

  
62
  $_[0]{employee}->assign_attributes(map { $_ => $data{$_} } @updatable_columns);
63
  return 1;
64
}
65

  
66

  
67
######################## behaviour ##########################
68

  
69
sub delay_flash_on_redirect { 1 }
70

  
71
1;
locale/de/all
430 430
  'Corrections'                 => 'Korrekturen',
431 431
  'Costs'                       => 'Kosten',
432 432
  'Could not copy %s to %s. Reason: %s' => 'Die Datei "%s" konnte nicht nach "%s" kopiert werden. Grund: %s',
433
  'Could not load employee'     => 'Konnte Benutzer nicht laden',
433 434
  'Could not open the file users/members.' => 'Die Datei "users/members" konnte nicht geöffnet werden.',
434 435
  'Could not open the old memberfile.' => 'Die Datei mit den Benutzerdaten konnte nicht geöffnet werden.',
435 436
  'Could not print dunning.'    => 'Die Mahnungen konnten nicht gedruckt werden.',
......
578 579
  'Delete group'                => 'Gruppe löschen',
579 580
  'Delete profile'              => 'Profil löschen',
580 581
  'Delete transaction'          => 'Buchung löschen',
582
  'Deleted'                     => 'Gelöscht',
581 583
  'Delivered'                   => 'Geliefert',
582 584
  'Delivery Date'               => 'Lieferdatum',
583 585
  'Delivery Order'              => 'Lieferschein',
......
693 695
  'Edit Customer'               => 'Kunde editieren',
694 696
  'Edit Dunning'                => 'Mahnungen konfigurieren',
695 697
  'Edit Dunning Process Config' => 'Mahnwesenkonfiguration bearbeiten',
698
  'Edit Employee #1'            => 'Benutzer #1 bearbeiten',
696 699
  'Edit Follow-Up'              => 'Wiedervorlage bearbeiten',
697 700
  'Edit Follow-Up for #1'       => 'Wiedervorlage für #1 bearbeiten',
698 701
  'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten',
......
749 752
  '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.',
750 753
  'Element disabled'            => 'Element deaktiviert',
751 754
  'Employee'                    => 'Bearbeiter',
755
  'Employee #1 saved!'          => 'Benutzer #1 gespeichert!',
756
  'Employees'                   => 'Benutzer',
752 757
  'Empty transaction!'          => 'Buchung ist leer!',
753 758
  'End date'                    => 'Enddatum',
754 759
  'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung für diesen Entwurf ein.',
......
1078 1083
  'Login'                       => 'Anmelden',
1079 1084
  'Login Name'                  => 'Benutzer',
1080 1085
  'Login name missing!'         => 'Benutzer - Feld darf nicht leer sein!',
1086
  'Login of User'               => 'Login',
1081 1087
  'Logout'                      => 'Abmelden',
1082 1088
  'Logout now'                  => 'Lx-Office jetzt verlassen',
1083 1089
  'Long Dates'                  => 'Lange Monatsnamen',
menu.ini
790 790
module=am.pl
791 791
action=show_history_search
792 792

  
793
[System--Employees]
794
ACCESS=admin
795
module=controller.pl
796
action=Employee/list
797

  
793 798

  
794 799
[Program]
795 800

  
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/_list.html
1
[%- USE T8 %]
2
<table>
3
 <tr class='listheading'>
4
  <th>[% 'Login of User' | $T8 %]</th>
5
  <th>[% 'Name' | $T8 %]</th>
6
  <th>[% 'Deleted' | $T8 %]</th>
7
 </tr>
8
[%- FOREACH row IN SELF.employees %]
9
 <tr class='listrow[% loop.count % 2 %]'>
10
  <td><a href='[% SELF.url_for(action="edit", "employee.id"=row.id) %]'>[% row.login | html %]</a></td>
11
  <td>[% row.name | html %]</td>
12
  <td>[% row.deleted_as_bool_yn | html %]</td>
13
 </tr>
14
[%- END %]
15
 </table>
templates/webpages/employee/edit.html
1
<h1>[% title | html %]</h1>
2

  
3
[% PROCESS 'common/flash.html' %]
4

  
5
[% PROCESS 'employee/_form.html' employee=SELF.employee %]
6

  
7
<hr>
8

  
9
[% PROCESS 'employee/_list.html' %]
templates/webpages/employee/list.html
1
<h1>[% title | html %]</h1>
2

  
3
[% PROCESS 'common/flash.html' %]
4

  
5
[% PROCESS 'employee/_list.html' %]

Auch abrufbar als: Unified diff