Revision 94cb09ab
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
540 | 540 |
$self->js->flash('info', t8("This business has already been added.")); |
541 | 541 |
}; |
542 | 542 |
|
543 |
my $position = scalar @{ $self->businessmodels } + 1; |
|
544 |
|
|
543 | 545 |
my $bm = SL::DB::BusinessModel->new(#parts_id => $::form->{part}->{id}, |
544 | 546 |
business => $business, |
545 | 547 |
model => '', |
546 | 548 |
part_description => '', |
547 | 549 |
part_longdescription => '', |
550 |
position => $position, |
|
548 | 551 |
) or die "Can't create BusinessModel object"; |
549 | 552 |
|
550 | 553 |
my $row_as_html = $self->p->render('part/_businessmodel_row', |
... | ... | |
1023 | 1026 |
|
1024 | 1027 |
$self->part->businessmodels([]); |
1025 | 1028 |
|
1029 |
my $position = 0; |
|
1026 | 1030 |
my $businessmodels = delete($::form->{businessmodels}) || []; |
1027 | 1031 |
foreach my $businessmodel ( @{$businessmodels} ) { |
1028 | 1032 |
next unless $businessmodel->{business_id}; |
1029 | 1033 |
|
1034 |
$position++; |
|
1030 | 1035 |
my $bm = SL::DB::BusinessModel->new( #parts_id => $self->part->id, # will be assigned by row add_businessmodels |
1031 | 1036 |
business_id => $businessmodel->{business_id}, |
1032 | 1037 |
model => $businessmodel->{model} || '', |
1033 | 1038 |
part_description => $businessmodel->{part_description} || '', |
1034 | 1039 |
part_longdescription => $businessmodel->{part_longdescription} || '', |
1040 |
position => $position, |
|
1035 | 1041 |
); |
1036 | 1042 |
|
1037 | 1043 |
$self->part->add_businessmodels($bm); |
SL/DB/BusinessModel.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::BusinessModel; |
9 |
use SL::DB::Helper::ActsAsList(group_by => [ qw(parts_id) ]); |
|
9 | 10 |
|
10 | 11 |
__PACKAGE__->meta->initialize; |
11 | 12 |
|
SL/DB/MetaSetup/BusinessModel.pm | ||
---|---|---|
16 | 16 |
part_description => { type => 'text' }, |
17 | 17 |
part_longdescription => { type => 'text' }, |
18 | 18 |
parts_id => { type => 'integer', not_null => 1 }, |
19 |
position => { type => 'integer' }, |
|
19 | 20 |
); |
20 | 21 |
|
21 | 22 |
__PACKAGE__->meta->primary_key_columns([ 'parts_id', 'business_id' ]); |
SL/DB/Part.pm | ||
---|---|---|
94 | 94 |
__PACKAGE__->attr_html('notes'); |
95 | 95 |
__PACKAGE__->attr_sorted({ unsorted => 'makemodels', position => 'sortorder' }); |
96 | 96 |
__PACKAGE__->attr_sorted({ unsorted => 'customerprices', position => 'sortorder' }); |
97 |
__PACKAGE__->attr_sorted('businessmodels'); |
|
97 | 98 |
|
98 | 99 |
__PACKAGE__->before_save('_before_save_set_partnumber'); |
99 | 100 |
__PACKAGE__->before_save('_before_save_set_assembly_weight'); |
js/kivi.Part.js | ||
---|---|---|
265 | 265 |
}; |
266 | 266 |
|
267 | 267 |
// businessmodel |
268 |
ns.businessmodel_renumber_positions = function() { |
|
269 |
$('.businessmodel_row [name="position"]').each(function(idx, elt) { |
|
270 |
$(elt).html(idx+1); |
|
271 |
}); |
|
272 |
}; |
|
273 |
|
|
268 | 274 |
ns.delete_businessmodel_row = function(clicked) { |
269 | 275 |
var row = $(clicked).closest('tr'); |
270 | 276 |
$(row).remove(); |
277 |
|
|
278 |
ns.businessmodel_renumber_positions(); |
|
271 | 279 |
}; |
272 | 280 |
|
273 | 281 |
ns.add_businessmodel_row = function() { |
... | ... | |
810 | 818 |
kivi.run_once_for('#makemodel_rows', 'makemodel_row_sort_renumber', function(elt) { |
811 | 819 |
$(elt).on('sortstop', kivi.Part.makemodel_renumber_positions); |
812 | 820 |
}); |
821 |
|
|
822 |
kivi.run_once_for('#businessmodel_rows', 'businessmodel_row_sort_renumber', function(elt) { |
|
823 |
$(elt).on('sortstop', kivi.Part.businessmodel_renumber_positions); |
|
824 |
}); |
|
813 | 825 |
}; |
814 | 826 |
|
815 | 827 |
ns.init = function() { |
sql/Pg-upgrade2/add_business_models_position.sql | ||
---|---|---|
1 |
-- @tag: add_business_models_position |
|
2 |
-- @description: Reihenfolge für Kunden-/Lieferantentyp-Artikelnummern |
|
3 |
-- @depends: add_business_models |
|
4 |
|
|
5 |
ALTER TABLE business_models ADD COLUMN position INTEGER; |
templates/design40_webpages/part/_businessmodel_row.html | ||
---|---|---|
7 | 7 |
<td style='display:none'> |
8 | 8 |
[%- L.hidden_tag("businessmodels[+].business_id", businessmodel.business_id) -%] |
9 | 9 |
</td> |
10 |
<td>[%- L.button_tag("kivi.Part.delete_businessmodel_row(this)", LxERP.t8("X"), class="wi-verytiny neutral") %] [% # , confirm=LxERP.t8("Are you sure?")) %]</td> |
|
10 |
<td class="center"> |
|
11 |
[%- L.button_tag("kivi.Part.delete_businessmodel_row(this)", LxERP.t8("X"), class="wi-verytiny neutral") %] [% # , confirm=LxERP.t8("Are you sure?")) %] |
|
12 |
</td> |
|
13 |
<td class="center numeric"><span name="position">[% HTML.escape(businessmodel.position) %]</span></td> |
|
14 |
<td><img src="image/updown.png" alt="[% LxERP.t8('reorder item') %]" class="dragdrop"></td> |
|
15 |
<td></td> |
|
11 | 16 |
<td>[% businessmodel.business.description | html %]</td> |
12 | 17 |
<td>[% L.input_tag('businessmodels[].model', businessmodel.model, class='wi-mediumsmall', size=30) %]</td> |
13 | 18 |
<td>[% L.input_tag('businessmodels[].part_description', businessmodel.part_description, class='wi-mediumsmall', size=10) %]</td> |
templates/design40_webpages/part/_businessmodels.html | ||
---|---|---|
9 | 9 |
<thead> |
10 | 10 |
<tr> |
11 | 11 |
<th class="center"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th> |
12 |
<th class="center">[% 'position' | $T8 %]</th> |
|
13 |
<th class="center"><img src="image/updown.png" alt="[% LxERP.t8('reorder item') %]"></th> |
|
14 |
<th></th> |
|
12 | 15 |
<th>[% 'Business' | $T8 %]</th> |
13 | 16 |
<th>[% 'Business Type Model' | $T8 %]</th> |
14 | 17 |
<th>[% 'Part Description' | $T8 %]</th> |
... | ... | |
22 | 25 |
</tbody> |
23 | 26 |
<tfoot> |
24 | 27 |
<tr> |
28 |
<td></td> |
|
29 |
<td></td> |
|
25 | 30 |
<td></td> |
26 | 31 |
<th class="right"><span class="label">[% 'Business' | $T8 %]</th> |
27 | 32 |
<td>[% P.select_tag('add_businessmodel', SELF.all_businesses, title_key="description", with_empty=1, class='wi-mediumsmall', onchange='kivi.Part.add_businessmodel_row()') %]</td> |
28 | 33 |
<td>[% L.button_tag('kivi.Part.add_businessmodel_row()', LxERP.t8('Add')) %]</td> |
29 | 34 |
<td></td> |
35 |
<td></td> |
|
30 | 36 |
</tr> |
31 | 37 |
</tfoot> |
32 | 38 |
</table> |
39 |
|
|
40 |
[% L.sortable_element('#businessmodel_rows') %] |
templates/webpages/part/_businessmodel_row.html | ||
---|---|---|
8 | 8 |
[%- L.button_tag("kivi.Part.delete_businessmodel_row(this)", |
9 | 9 |
LxERP.t8("X")) %] [% # , confirm=LxERP.t8("Are you sure?")) %] |
10 | 10 |
</td> |
11 |
<td><span name="position" class="numeric">[% HTML.escape(businessmodel.position) %]</span></td> |
|
12 |
<td align="center"> |
|
13 |
<img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"> |
|
14 |
</td> |
|
15 |
<td></td> |
|
11 | 16 |
<td>[% businessmodel.business.description | html %]</td> |
12 | 17 |
<td>[% L.input_tag('businessmodels[].model', businessmodel.model, size=30 ) %]</td> |
13 | 18 |
<td>[% L.input_tag('businessmodels[].part_description', businessmodel.part_description, size=30 ) %]</td> |
templates/webpages/part/_businessmodels.html | ||
---|---|---|
11 | 11 |
<thead> |
12 | 12 |
<tr> |
13 | 13 |
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th> |
14 |
<th class="listheading">[% 'position' | $T8 %]</th> |
|
15 |
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th> |
|
16 |
<th class="listheading"></th> |
|
14 | 17 |
<th class="listheading">[% 'Business' | $T8 %]</th> |
15 | 18 |
<th class="listheading">[% 'Business Type Model' | $T8 %]</th> |
16 | 19 |
<th class="listheading">[% 'Part Description' | $T8 %]</th> |
... | ... | |
18 | 21 |
</tr> |
19 | 22 |
</thead> |
20 | 23 |
<tbody id="businessmodel_rows"> |
21 |
[%- FOREACH businessmodel = SELF.part.businessmodels %] |
|
24 |
[%- FOREACH businessmodel = SELF.part.businessmodels_sorted %]
|
|
22 | 25 |
[% PROCESS 'part/_businessmodel_row.html' businessmodel=businessmodel %] |
23 | 26 |
[%- END %] |
24 | 27 |
</tbody> |
25 | 28 |
<tbody> |
26 | 29 |
<tr> |
30 |
<td></td> |
|
31 |
<td></td> |
|
27 | 32 |
<td></td> |
28 | 33 |
<td align="right">[% 'Business' | $T8 %]</td> |
29 | 34 |
<td>[% P.select_tag('add_businessmodel', SELF.all_businesses, title_key="description", with_empty=1, style='width: 300px', onchange='kivi.Part.add_businessmodel_row()') %]</td> |
... | ... | |
34 | 39 |
</table> |
35 | 40 |
</td> |
36 | 41 |
</tr> |
42 |
[% L.sortable_element('#businessmodel_rows') %] |
Auch abrufbar als: Unified diff
kundentyp-spezifische Artikelnummern: Position/Reihenfolge