Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cd07d289

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID cd07d28992bd8778f0702a9ea0dc937c6d93fd54
  • Vorgänger 9c194331
  • Nachfolger 5e1de2f8

SimpleSystemSetting: Umstellung von »Artikel-Klassifizierungen«

Unterschiede anzeigen:

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

  
3
use strict;
4

  
5
use parent qw(SL::Controller::Base);
6

  
7
use SL::DB::PartClassification;
8
use SL::Helper::Flash;
9

  
10
use Rose::Object::MakeMethods::Generic
11
(
12
 scalar => [ qw(part_classification) ],
13
);
14

  
15
__PACKAGE__->run_before('check_auth');
16
__PACKAGE__->run_before('load_part_classification', only => [ qw(edit update destroy) ]);
17

  
18
#
19
# This Controller is responsible for creating,editing or deleting
20
# Part Classifications.
21
#
22
# The use of Part Classifications is described in SL::DB::PartClassification
23
#
24
#
25

  
26
# List all available part classifications
27
#
28

  
29
sub action_list {
30
  my ($self) = @_;
31

  
32
  $self->render('part_classification/list',
33
                title                => $::locale->text('Parts Classifications'),
34
                PART_CLASSIFICATIONS => SL::DB::Manager::PartClassification->get_all_sorted);
35
}
36

  
37
# A Form for a new creatable part classifications is generated
38
#
39
sub action_new {
40
  my ($self) = @_;
41

  
42
  $self->{part_classification} = SL::DB::PartClassification->new;
43
  $self->render('part_classification/form', title => $::locale->text('Create a new parts classification'));
44
}
45

  
46
# Edit an existing part classifications
47
#
48
sub action_edit {
49
  my ($self) = @_;
50
  $self->render('part_classification/form', title => $::locale->text('Edit parts classification'));
51
}
52

  
53
# A new part classification is saved
54
#
55
sub action_create {
56
  my ($self) = @_;
57

  
58
  $self->{part_classification} = SL::DB::PartClassification->new;
59
  $self->create_or_update;
60
}
61

  
62
# An existing part classification is saved
63
#
64
sub action_update {
65
  my ($self) = @_;
66
  $self->create_or_update;
67
}
68

  
69
# An existing part classification is deleted
70
#
71
# The basic classifications cannot be deleted, also classifications which are in use
72
#
73
sub action_destroy {
74
  my ($self) = @_;
75

  
76
  if ( $self->{part_classification}->id < 5 ) {
77
    flash_later('error', $::locale->text('The basic parts classification cannot be deleted.'));
78
  }
79
  elsif (eval { $self->{part_classification}->delete; 1; }) {
80
    flash_later('info',  $::locale->text('The parts classification has been deleted.'));
81
  } else {
82
    flash_later('error', $::locale->text('The parts classification is in use and cannot be deleted.'));
83
  }
84

  
85
  $self->redirect_to(action => 'list');
86
}
87
# reordering the lines
88
#
89
sub action_reorder {
90
  my ($self) = @_;
91

  
92
  SL::DB::PartClassification->reorder_list(@{ $::form->{part_classification_id} || [] });
93

  
94
  $self->render(\'', { type => 'json' });
95
}
96

  
97
#
98
# filters
99
#
100

  
101
# check authentication, only "config" is allowed
102
#
103
sub check_auth {
104
  $::auth->assert('config');
105
}
106

  
107
#
108
# helpers
109
#
110

  
111
# submethod for update the database
112
#
113
sub create_or_update {
114
  my $self   = shift;
115
  my $is_new = !$self->{part_classification}->id;
116

  
117
  $::form->{part_classification}->{used_for_purchase} = 0 if ! $::form->{part_classification}->{used_for_purchase};
118
  $::form->{part_classification}->{used_for_sale}     = 0 if ! $::form->{part_classification}->{used_for_sale};
119
  $::form->{part_classification}->{report_separate}   = 0 if ! $::form->{part_classification}->{report_separate};
120

  
121
  my $params = delete($::form->{part_classification}) || { };
122

  
123
  $self->{part_classification}->assign_attributes(%{ $params });
124

  
125
  my @errors = $self->{part_classification}->validate;
126

  
127
  if (@errors) {
128
    flash('error', @errors);
129
    $self->render('part_classification/form', title => $is_new ? $::locale->text('Create a new parts classification') : $::locale->text('Edit parts classification'));
130
    return;
131
  }
132

  
133
  $self->{part_classification}->save;
134

  
135
  flash_later('info', $is_new ? $::locale->text('The parts classification has been created.') : $::locale->text('The parts classification has been saved.'));
136
  $self->redirect_to(action => 'list');
137
}
138

  
139
# submethod for loading one item from the database
140
#
141
sub load_part_classification {
142
  my ($self) = @_;
143
  $self->{part_classification} = SL::DB::PartClassification->new(id => $::form->{id})->load;
144
}
145

  
146
1;
147

  
148

  
149

  
150
__END__
151

  
152
=encoding utf-8
153

  
154
=head1 NAME
155

  
156
SL::Controller::PartClassification
157

  
158
=head1 SYNOPSIS
159

  
160
This Controller is responsible for creating,editing or deleting
161
Part Classifications.
162

  
163
=head1 DESCRIPTION
164

  
165
The use of Part Classifications is described in L<SL::DB::PartClassification>
166

  
167
=head1 METHODS
168

  
169
=head2 action_create
170

  
171
 $self->action_create();
172

  
173
A new part classification is saved
174

  
175

  
176

  
177
=head2 action_destroy
178

  
179
 $self->action_destroy();
180

  
181
An existing part classification is deleted
182

  
183
The basic classifications cannot be deleted, also classifications which are in use
184

  
185

  
186

  
187
=head2 action_edit
188

  
189
 $self->action_edit();
190

  
191
Edit an existing part classifications
192

  
193

  
194

  
195
=head2 action_list
196

  
197
 $self->action_list();
198

  
199
List all available part classifications
200

  
201

  
202

  
203
=head2 action_new
204

  
205
 $self->action_new();
206

  
207
A Form for a new creatable part classifications is generated
208

  
209

  
210

  
211
=head2 action_reorder
212

  
213
 $self->action_reorder();
214

  
215
reordering the lines
216

  
217

  
218

  
219
=head2 action_update
220

  
221
 $self->action_update();
222

  
223
An existing part classification is saved
224

  
225

  
226
=head1 AUTHOR
227

  
228
Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
229

  
230
=cut
SL/Controller/SimpleSystemSetting.pm
40 40
    ],
41 41
  },
42 42

  
43
  part_classification => {
44
    # Make locales.pl happy: $self->render("simple_system_setting/_part_classification_form")
45
    class  => 'PartClassification',
46
    titles => {
47
      list => t8('Part classifications'),
48
      add  => t8('Add part classification'),
49
      edit => t8('Edit part classification'),
50
    },
51
    list_attributes => [
52
      { title => t8('Description'),       formatter => sub { t8($_[0]->description) } },
53
      { title => t8('Type abbreviation'), formatter => sub { t8($_[0]->abbreviation) } },
54
      { title => t8('Used for Purchase'), formatter => sub { $_[0]->used_for_purchase ? t8('yes') : t8('no') } },
55
      { title => t8('Used for Sale'),     formatter => sub { $_[0]->used_for_sale     ? t8('yes') : t8('no') } },
56
      { title => t8('Report separately'), formatter => sub { $_[0]->report_separate   ? t8('yes') : t8('no') } },
57
    ],
58
  },
59

  
43 60
  parts_group => {
44 61
    # Make locales.pl happy: $self->render("simple_system_setting/_parts_group_form")
45 62
    class  => 'PartsGroup',
locale/de/all
206 206
  'Add new record template'     => 'Neue Belegvorlage hinzufügen',
207 207
  'Add note'                    => 'Notiz erfassen',
208 208
  'Add part'                    => 'Artikel hinzufügen',
209
  'Add part classification'     => 'Artikel-Klassifizierung hinzufügen',
209 210
  'Add partsgroup'              => 'Warengruppe hinzufügen',
210 211
  'Add picture'                 => 'Bild hinzufügen',
211 212
  'Add picture to text block'   => 'Bild dem Textblock hinzufügen',
......
667 668
  'Create a new delivery term'  => 'Neue Lieferbedingungen anlegen',
668 669
  'Create a new department'     => 'Eine neue Abteilung erfassen',
669 670
  'Create a new group'          => 'Neue Benutzergruppe erfassen',
670
  'Create a new parts classification' => 'Erzeuge eine neue Artikel-Klassifizierung',
671 671
  'Create a new payment term'   => 'Neue Zahlungsbedingungen anlegen',
672 672
  'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen',
673 673
  'Create a new price rule'     => 'Neue Preisregel anlegen',
......
1126 1126
  'Edit general settings'       => 'Grundeinstellungen bearbeiten',
1127 1127
  'Edit greetings'              => 'Anreden bearbeiten',
1128 1128
  'Edit note'                   => 'Notiz bearbeiten',
1129
  'Edit parts classification'   => 'Bearbeite eine Artikel-Klassifizierung',
1129
  'Edit part classification'    => 'Artikel-Klassifizierung bearbeiten',
1130 1130
  'Edit partsgroup'             => 'Warengruppe bearbeiten',
1131 1131
  'Edit payment term'           => 'Zahlungsbedingungen bearbeiten',
1132 1132
  'Edit picture'                => 'Bild bearbeiten',
......
1885 1885
  'No invoices have been selected.' => 'Es wurden keine Rechnungen ausgewählt.',
1886 1886
  'No or an unknown authenticantion module specified in "config/kivitendo.conf".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/kivitendo.conf" angegeben.',
1887 1887
  'No part was selected.'       => 'Es wurde kein Artikel ausgewählt',
1888
  'No parts classification has been created yet.' => 'Keine Artikel-Klassifizierung erzeugt.',
1889 1888
  'No payment term has been created yet.' => 'Es wurden noch keine Zahlungsbedingungen angelegt.',
1890 1889
  'No picture has been uploaded' => 'Es wurde kein Bild hochgeladen',
1891 1890
  'No picture uploaded yet'     => 'Noch kein Bild hochgeladen',
......
2075 2074
  'Part Number missing!'        => 'Artikelnummer fehlt!',
2076 2075
  'Part Type'                   => 'Artikel-Typ',
2077 2076
  'Part Unit'                   => 'Einheit des Artikels',
2077
  'Part classifications'        => 'Artikel-Klassifizierungen',
2078 2078
  'Part picker'                 => 'Artikelauswahl',
2079 2079
  'PartClassAbbreviation'       => 'Abkürzung der Artikel-Klassifizierung',
2080 2080
  'Part_br_Description'         => 'Beschreibung',
......
2082 2082
  'Partnumber'                  => 'Artikelnummer',
2083 2083
  'Parts'                       => 'Waren',
2084 2084
  'Parts Classification'        => 'Artikel-Klassifizierung',
2085
  'Parts Classifications'       => 'Artikel-Klassifizierung',
2086 2085
  'Parts Inventory'             => 'Warenliste',
2087 2086
  'Parts Master Data'           => 'Artikelstammdaten',
2088 2087
  'Parts with existing part numbers' => 'Artikel mit existierender Artikelnummer',
......
2924 2923
  'The base unit does not exist.' => 'Die Basiseinheit existiert nicht.',
2925 2924
  'The base unit relations must not contain loops (e.g. by saying that unit A\'s base unit is B, B\'s base unit is C and C\'s base unit is A) in row %d.' => 'Die Beziehungen der Einheiten d&uuml;rfen keine Schleifen beinhalten (z.B. wenn gesagt wird, dass Einheit As Basiseinheit B, Bs Basiseinheit C und Cs Basiseinheit A ist) in Zeile %d.',
2926 2925
  'The basic client tables have not been created for this client\'s database yet.' => 'Die grundlegenden Mandantentabellen wurden in der für diesen Mandanten konfigurierten Datenbank noch nicht angelegt.',
2927
  'The basic parts classification cannot be deleted.' => 'Eine Basis Artikel-Klassifizierung darf nicht gelöscht werden.',
2928 2926
  'The body is missing.'        => 'Der Text fehlt',
2929 2927
  'The booking group has been created.' => 'Die Buchungsgruppe wurde erstellt.',
2930 2928
  'The booking group has been deleted.' => 'Die Buchungsgruppe wurde gelöscht.',
......
3066 3064
  'The partnumber already exists!' => 'Die Artikelnummer wird bereits verwendet.',
3067 3065
  'The partnumber already exists.' => 'Die Artikelnummer wird bereits verwndet.',
3068 3066
  'The partnumber is missing.'  => 'Die Artikelnummer fehlt.',
3069
  'The parts classification has been created.' => 'Die Artikel-Klassifizierung ist erzeugt',
3070
  'The parts classification has been deleted.' => 'Die Artikel-Klassifizierung ist gelöscht',
3071
  'The parts classification has been saved.' => 'Die Artikel-Klassifizierung ist gespeichert',
3072
  'The parts classification is in use and cannot be deleted.' => 'Die Artikel-Klassifizierung ist in Verwendung, kann deshalb nicht gelöscht werden.',
3073 3067
  'The parts for this delivery order have already been transferred in.' => 'Die Artikel dieses Lieferscheins wurden bereits eingelagert.',
3074 3068
  'The parts for this delivery order have already been transferred out.' => 'Die Artikel dieses Lieferscheins wurden bereits ausgelagert.',
3075 3069
  'The parts have been removed.' => 'Die Waren wurden aus dem Lager entnommen.',
......
3378 3372
  'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
3379 3373
  'TypAbbreviation'             => 'Abkürzung des Artikel-Typs',
3380 3374
  'Type'                        => 'Typ',
3375
  'Type abbreviation'           => 'Typen-Abkürzung',
3381 3376
  'Type can be either \'part\', \'service\' or \'assembly\'.' => 'Der Typ kann entweder \'part\' (für Waren), \'service\' (für Dienstleistungen) oder \'assembly\' (für Erzeugnisse) enthalten.',
3382 3377
  'Type of Business'            => 'Kunden-/Lieferantentyp',
3383 3378
  'Type of Customer'            => 'Kundentyp',
menus/user/00-erp.yaml
1080 1080
  icon: partsclassific
1081 1081
  order: 1100
1082 1082
  params:
1083
    action: PartClassification/list
1083
    action: SimpleSystemSetting/list
1084
    type: part_classification
1084 1085
- parent: system
1085 1086
  id: system_pricegroups
1086 1087
  name: Pricegroups
templates/webpages/part_classification/form.html
1
[% USE HTML %][% USE L %][% USE LxERP %]
2
<h1>[% FORM.title %]</h1>
3

  
4
 <form method="post" action="controller.pl">
5

  
6
[%- INCLUDE 'common/flash.html' %]
7

  
8
  <table>
9
   <tr>
10
    <td>[% LxERP.t8('Description') %]</td>
11
    <td>[% L.input_tag("part_classification.description",  LxERP.t8(SELF.part_classification.description)) %]</td>
12
   </tr>
13
   <tr>
14
    <td>[% LxERP.t8('TypeAbbreviation') %]</td>
15
    <td>[% L.input_tag("part_classification.abbreviation",  LxERP.t8(SELF.part_classification.abbreviation),size=>"2",maxlength=>"2" ) %]</td>
16
   </tr>
17
   <tr>
18
    <td>[% LxERP.t8('Used for Purchase') %]</td>
19
    <td>[% L.checkbox_tag("part_classification.used_for_purchase", checked=(SELF.part_classification.used_for_purchase ? 1:'')) %]</td>
20
   </tr>
21
   <tr>
22
    <td>[% LxERP.t8('Used for Sale') %]</td>
23
    <td>[% L.checkbox_tag("part_classification.used_for_sale", checked=(SELF.part_classification.used_for_sale ? 1:'')) %]</td>
24
   </tr>
25
   <tr>
26
    <td>[% LxERP.t8('Report separately') %]</td>
27
    <td>[% L.checkbox_tag("part_classification.report_separate", checked=(SELF.part_classification.report_separate ? 1:'')) %]</td>
28
   </tr>
29
  </table>
30

  
31
  <p>
32
   [% L.hidden_tag("id", SELF.part_classification.id) %]
33
   [% L.hidden_tag("action", "PartClassification/dispatch") %]
34
   [% L.submit_tag("action_" _ (SELF.part_classification.id ? 'update' : 'create'), LxERP.t8('Save')) %]
35
   [%- IF SELF.part_classification.id %]
36
    [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %]
37
   [%- END %]
38
   <a href="[% SELF.url_for(action => 'list') %]">[% LxERP.t8('Abort') %]</a>
39
  </p>
40

  
41
 </form>
templates/webpages/part_classification/list.html
1
[% USE HTML %][% USE L %][% USE LxERP %]
2
<h1>[% FORM.title %]</h1>
3

  
4
[%- INCLUDE 'common/flash.html' %]
5

  
6
 <form method="post" action="controller.pl">
7
  [% IF !PART_CLASSIFICATIONS.size %]
8
   <p>
9
    [%-  LxERP.t8('No parts classification has been created yet.') %]
10
   </p>
11

  
12
  [%- ELSE %]
13
   <table id="part_classification_list">
14
    <thead>
15
    <tr class="listheading">
16
     <th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
17
     <th>[%- LxERP.t8('Description') %]</th>
18
     <th>[%- LxERP.t8('TypeAbbreviation') %]</th>
19
     <th>[%- LxERP.t8('Used for Purchase') %]</th>
20
     <th>[%- LxERP.t8('Used for Sale') %]</th>
21
     <th>[%- LxERP.t8('Report separately') %]</th>
22
    </tr>
23
    </thead>
24

  
25
    <tbody>
26
    [%- FOREACH part_classification = PART_CLASSIFICATIONS %]
27
    <tr class="listrow[% loop.count % 2 %]" id="part_classification_id_[% part_classification.id %]">
28
     <td align="center" class="dragdrop"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></td>
29
     <td>
30
      <a href="[% SELF.url_for(action => 'edit', id => part_classification.id) %]">
31
       [%- HTML.escape(LxERP.t8(part_classification.description)) %]
32
      </a>
33
     </td>
34
     <td>[%- HTML.escape(LxERP.t8(part_classification.abbreviation)) %]</td>
35
     <td>[% IF part_classification.used_for_purchase %][% LxERP.t8('Yes') %][% ELSE %][%  LxERP.t8('No') %][% END %]</td>
36
     <td>[% IF part_classification.used_for_sale     %][% LxERP.t8('Yes') %][% ELSE %][%  LxERP.t8('No') %][% END %]</td>
37
     <td>[% IF part_classification.report_separate   %][% LxERP.t8('Yes') %][% ELSE %][%  LxERP.t8('No') %][% END %]</td>
38
    </tr>
39
    [%- END %]
40
    </tbody>
41
   </table>
42
  [%- END %]
43

  
44
  <p>
45
   <a href="[% SELF.url_for(action => 'new') %]">[%- LxERP.t8('Create a new parts classification') %]</a>
46
  </p>
47
 </form>
48

  
49
 [% L.sortable_element('#part_classification_list tbody', url => 'controller.pl?action=PartClassification/reorder', with => 'part_classification_id') %]
templates/webpages/simple_system_setting/_part_classification_form.html
1
[%- USE LxERP -%][%- USE L -%]
2
<table>
3
 <tr>
4
  <th align="right">[% LxERP.t8('Description') %]</th>
5
  <td>[% L.input_tag("object.description",  LxERP.t8(SELF.object.description), "data-validate"="required", "data-title"=LxERP.t8("Description")) %]</td>
6
 </tr>
7
 <tr>
8
  <th align="right">[% LxERP.t8('TypeAbbreviation') %]</th>
9
  <td>[% L.input_tag("object.abbreviation",  LxERP.t8(SELF.object.abbreviation), size="2", maxlength="2" ) %]</td>
10
 </tr>
11
 <tr>
12
  <th align="right">[% LxERP.t8('Used for Purchase') %]</th>
13
  <td>[% L.checkbox_tag("object.used_for_purchase", checked=(SELF.object.used_for_purchase ? 1:''), for_submit=1) %]</td>
14
 </tr>
15
 <tr>
16
  <th align="right">[% LxERP.t8('Used for Sale') %]</th>
17
  <td>[% L.checkbox_tag("object.used_for_sale", checked=(SELF.object.used_for_sale ? 1:''), for_submit=1) %]</td>
18
 </tr>
19
 <tr>
20
  <th align="right">[% LxERP.t8('Report separately') %]</th>
21
  <td>[% L.checkbox_tag("object.report_separate", checked=(SELF.object.report_separate ? 1:''), for_submit=1) %]</td>
22
 </tr>
23
</table>

Auch abrufbar als: Unified diff