Revision ab80e40b
Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
15 | 15 |
|
16 | 16 |
use SL::CVar; |
17 | 17 |
use SL::Controller::Helper::GetModels; |
18 |
use SL::DB::Business; |
|
19 |
use SL::DB::BusinessModel; |
|
18 | 20 |
use SL::DB::Helper::ValidateAssembly qw(validate_assembly); |
19 | 21 |
use SL::DB::History; |
20 | 22 |
use SL::DB::Part; |
... | ... | |
31 | 33 |
|
32 | 34 |
use Rose::Object::MakeMethods::Generic ( |
33 | 35 |
'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models |
34 |
makemodels shops_not_assigned |
|
36 |
makemodels businessmodels shops_not_assigned
|
|
35 | 37 |
customerprices |
36 | 38 |
orphaned |
37 | 39 |
assortment assortment_items assembly assembly_items |
38 | 40 |
all_pricegroups all_translations all_partsgroups all_units |
39 | 41 |
all_buchungsgruppen all_payment_terms all_warehouses |
40 | 42 |
parts_classification_filter |
41 |
all_languages all_units all_price_factors) ], |
|
43 |
all_languages all_units all_price_factors |
|
44 |
all_businesses) ], |
|
42 | 45 |
'scalar' => [ qw(warehouse bin stock_amounts journal) ], |
43 | 46 |
); |
44 | 47 |
|
... | ... | |
525 | 528 |
->render; |
526 | 529 |
} |
527 | 530 |
|
531 |
sub action_add_businessmodel_row { |
|
532 |
my ($self) = @_; |
|
533 |
|
|
534 |
my $business_id = $::form->{add_businessmodel}; |
|
535 |
|
|
536 |
my $business = SL::DB::Manager::Business->find_by(id => $business_id) or |
|
537 |
return $self->js->error(t8("No business selected or found!"))->render; |
|
538 |
|
|
539 |
if ( grep { $business_id == $_->business_id } @{ $self->businessmodels } ) { |
|
540 |
$self->js->flash('info', t8("This business has already been added.")); |
|
541 |
}; |
|
542 |
|
|
543 |
my $bm = SL::DB::BusinessModel->new(#parts_id => $::form->{part}->{id}, |
|
544 |
business => $business, |
|
545 |
model => '', |
|
546 |
part_description => '', |
|
547 |
part_longdescription => '', |
|
548 |
) or die "Can't create BusinessModel object"; |
|
549 |
|
|
550 |
my $row_as_html = $self->p->render('part/_businessmodel_row', |
|
551 |
businessmodel => $bm); |
|
552 |
|
|
553 |
# after selection focus on the model field in the row that was just added |
|
554 |
$self->js |
|
555 |
->append('#businessmodel_rows', $row_as_html) # append in tbody |
|
556 |
->val('#add_businessmodel', '') |
|
557 |
->run('kivi.Part.focus_last_businessmodel_input') |
|
558 |
->render; |
|
559 |
} |
|
560 |
|
|
528 | 561 |
sub action_add_customerprice_row { |
529 | 562 |
my ($self) = @_; |
530 | 563 |
|
... | ... | |
906 | 939 |
|
907 | 940 |
$self->parse_form_customerprices; |
908 | 941 |
$self->parse_form_makemodels; |
942 |
$self->parse_form_businessmodels; |
|
909 | 943 |
} |
910 | 944 |
|
911 | 945 |
sub parse_form_prices { |
... | ... | |
977 | 1011 |
}; |
978 | 1012 |
} |
979 | 1013 |
|
1014 |
sub parse_form_businessmodels { |
|
1015 |
my ($self) = @_; |
|
1016 |
|
|
1017 |
my $make_key = sub { return $_[0]->parts_id . '+' . $_[0]->business_id; }; |
|
1018 |
|
|
1019 |
my $businessmodels_map; |
|
1020 |
if ( $self->part->businessmodels ) { # check for new parts or parts without businessmodels |
|
1021 |
$businessmodels_map = { map { $make_key->($_) => Rose::DB::Object::Helpers::clone($_) } @{$self->part->businessmodels} }; |
|
1022 |
}; |
|
1023 |
|
|
1024 |
$self->part->businessmodels([]); |
|
1025 |
|
|
1026 |
my $businessmodels = delete($::form->{businessmodels}) || []; |
|
1027 |
foreach my $businessmodel ( @{$businessmodels} ) { |
|
1028 |
next unless $businessmodel->{business_id}; |
|
1029 |
|
|
1030 |
my $bm = SL::DB::BusinessModel->new( #parts_id => $self->part->id, # will be assigned by row add_businessmodels |
|
1031 |
business_id => $businessmodel->{business_id}, |
|
1032 |
model => $businessmodel->{model} || '', |
|
1033 |
part_description => $businessmodel->{part_description} || '', |
|
1034 |
part_longdescription => $businessmodel->{part_longdescription} || '', |
|
1035 |
); |
|
1036 |
|
|
1037 |
$self->part->add_businessmodels($bm); |
|
1038 |
}; |
|
1039 |
} |
|
1040 |
|
|
980 | 1041 |
sub parse_form_customerprices { |
981 | 1042 |
my ($self) = @_; |
982 | 1043 |
|
... | ... | |
1044 | 1105 |
# used by edit, save, delete and add |
1045 | 1106 |
|
1046 | 1107 |
if ( $::form->{part}{id} ) { |
1047 |
return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels customerprices prices translations partsgroup shop_parts shop_parts.shop) ]); |
|
1108 |
return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels businessmodels customerprices prices translations partsgroup shop_parts shop_parts.shop) ]);
|
|
1048 | 1109 |
} elsif ( $::form->{id} ) { |
1049 | 1110 |
return SL::DB::Part->new(id => $::form->{id})->load; # used by inventory tab |
1050 | 1111 |
} else { |
... | ... | |
1127 | 1188 |
return \@makemodel_array; |
1128 | 1189 |
} |
1129 | 1190 |
|
1191 |
sub init_businessmodels { |
|
1192 |
my ($self) = @_; |
|
1193 |
|
|
1194 |
my @businessmodel_array = (); |
|
1195 |
my $businessmodels = delete($::form->{businessmodels}) || []; |
|
1196 |
|
|
1197 |
foreach my $businessmodel ( @{$businessmodels} ) { |
|
1198 |
next unless $businessmodel->{business_id}; |
|
1199 |
|
|
1200 |
my $bm = SL::DB::BusinessModel->new(#parts_id => $self->part->id, # will be assigned by row add_businessmodels |
|
1201 |
business_id => $businessmodel->{business_id}, |
|
1202 |
model => $businessmodel->{model} || '', |
|
1203 |
part_description => $businessmodel->{part_description} || '', |
|
1204 |
part_longdescription => $businessmodel->{part_longdescription} || '', |
|
1205 |
) or die "Can't create bm"; |
|
1206 |
|
|
1207 |
push(@businessmodel_array, $bm); |
|
1208 |
}; |
|
1209 |
|
|
1210 |
return \@businessmodel_array; |
|
1211 |
} |
|
1212 |
|
|
1130 | 1213 |
sub init_customerprices { |
1131 | 1214 |
my ($self) = @_; |
1132 | 1215 |
|
... | ... | |
1235 | 1318 |
SL::DB::Manager::Pricegroup->get_all_sorted(query => [ obsolete => 0 ]); |
1236 | 1319 |
} |
1237 | 1320 |
|
1321 |
sub init_all_businesses { |
|
1322 |
SL::DB::Manager::Business->get_all_sorted; |
|
1323 |
} |
|
1324 |
|
|
1238 | 1325 |
# model used to filter/display the parts in the multi-items dialog |
1239 | 1326 |
sub init_multi_items_models { |
1240 | 1327 |
SL::Controller::Helper::GetModels->new( |
SL/DB/BusinessModel.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::BusinessModel; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::BusinessModel; |
|
9 |
|
|
10 |
__PACKAGE__->meta->initialize; |
|
11 |
|
|
12 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
13 |
__PACKAGE__->meta->make_manager_class; |
|
14 |
|
|
15 |
1; |
SL/DB/Helper/ALL.pm | ||
---|---|---|
27 | 27 |
use SL::DB::Bin; |
28 | 28 |
use SL::DB::Buchungsgruppe; |
29 | 29 |
use SL::DB::Business; |
30 |
use SL::DB::BusinessModel; |
|
30 | 31 |
use SL::DB::Chart; |
31 | 32 |
use SL::DB::Contact; |
32 | 33 |
use SL::DB::ContactDepartment; |
SL/DB/Helper/Mappings.pm | ||
---|---|---|
110 | 110 |
buchungsgruppen => 'buchungsgruppe', |
111 | 111 |
bin => 'bin', |
112 | 112 |
business => 'business', |
113 |
business_models => 'business_model', |
|
113 | 114 |
chart => 'chart', |
114 | 115 |
contact_departments => 'contact_department', |
115 | 116 |
contact_titles => 'contact_title', |
SL/DB/MetaSetup/BusinessModel.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::BusinessModel; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use parent qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->table('business_models'); |
|
10 |
|
|
11 |
__PACKAGE__->meta->columns( |
|
12 |
business_id => { type => 'integer', not_null => 1 }, |
|
13 |
itime => { type => 'timestamp', default => 'now()' }, |
|
14 |
model => { type => 'text' }, |
|
15 |
mtime => { type => 'timestamp' }, |
|
16 |
part_description => { type => 'text' }, |
|
17 |
part_longdescription => { type => 'text' }, |
|
18 |
parts_id => { type => 'integer', not_null => 1 }, |
|
19 |
); |
|
20 |
|
|
21 |
__PACKAGE__->meta->primary_key_columns([ 'parts_id', 'business_id' ]); |
|
22 |
|
|
23 |
__PACKAGE__->meta->allow_inline_column_values(1); |
|
24 |
|
|
25 |
__PACKAGE__->meta->foreign_keys( |
|
26 |
business => { |
|
27 |
class => 'SL::DB::Business', |
|
28 |
key_columns => { business_id => 'id' }, |
|
29 |
}, |
|
30 |
|
|
31 |
parts => { |
|
32 |
class => 'SL::DB::Part', |
|
33 |
key_columns => { parts_id => 'id' }, |
|
34 |
}, |
|
35 |
); |
|
36 |
|
|
37 |
1; |
|
38 |
; |
SL/DB/Part.pm | ||
---|---|---|
47 | 47 |
manager_args => { sort_by => 'sortorder' }, |
48 | 48 |
column_map => { id => 'parts_id' }, |
49 | 49 |
}, |
50 |
businessmodels => { |
|
51 |
type => 'one to many', |
|
52 |
class => 'SL::DB::BusinessModel', |
|
53 |
column_map => { id => 'parts_id' }, |
|
54 |
}, |
|
50 | 55 |
customerprices => { |
51 | 56 |
type => 'one to many', |
52 | 57 |
class => 'SL::DB::PartCustomerPrice', |
SL/IC.pm | ||
---|---|---|
909 | 909 |
|
910 | 910 |
$sth->finish(); |
911 | 911 |
|
912 |
|
|
913 |
$query = qq|SELECT bm.parts_id, |
|
914 |
bm.model AS business_model, |
|
915 |
bm.part_description AS bm_part_description, |
|
916 |
bm.part_longdescription AS bm_part_longdescription, |
|
917 |
b.description AS business_make |
|
918 |
FROM business_models bm |
|
919 |
LEFT JOIN business b ON (bm.business_id = b.id) |
|
920 |
WHERE bm.parts_id IN ($placeholders)|; |
|
921 |
|
|
922 |
my %businessmodel = (); |
|
923 |
|
|
924 |
$sth = prepare_execute_query($form, $dbh, $query, @part_ids); |
|
925 |
|
|
926 |
while (my $ref = $sth->fetchrow_hashref()) { |
|
927 |
$businessmodel{$ref->{parts_id}} ||= []; |
|
928 |
push @{ $businessmodel{$ref->{parts_id}} }, $ref; |
|
929 |
} |
|
930 |
|
|
931 |
$sth->finish(); |
|
932 |
|
|
912 | 933 |
$query = qq|SELECT |
913 | 934 |
cp.parts_id, |
914 | 935 |
cp.customer_partnumber AS customer_model, |
... | ... | |
939 | 960 |
my %data = selectall_as_map($form, $dbh, $query, 'id', \@columns, @part_ids); |
940 | 961 |
|
941 | 962 |
my %template_arrays; |
942 |
map { $template_arrays{$_} = [] } (qw(make model mm_part_description mm_part_longdescription customer_make customer_model cm_part_description cm_part_longdescription), @columns); |
|
963 |
map { $template_arrays{$_} = [] } (qw(make model mm_part_description mm_part_longdescription business_make business_model bm_part_description bm_part_longdescription customer_make customer_model cm_part_description cm_part_longdescription), @columns);
|
|
943 | 964 |
|
944 | 965 |
foreach my $i (1 .. $rowcount) { |
945 | 966 |
my $id = $form->{"${prefix}${i}"}; |
... | ... | |
961 | 982 |
} |
962 | 983 |
} |
963 | 984 |
|
985 |
push @{ $template_arrays{business_make} }, []; |
|
986 |
push @{ $template_arrays{business_model} }, []; |
|
987 |
push @{ $template_arrays{bm_part_description} }, []; |
|
988 |
push @{ $template_arrays{bm_part_longdescription} }, []; |
|
989 |
|
|
990 |
if ($businessmodel{$id}) { |
|
991 |
foreach my $ref (@{ $businessmodel{$id} }) { |
|
992 |
map { push @{ $template_arrays{$_}->[-1] }, $ref->{$_} } qw(business_make business_model bm_part_description bm_part_longdescription); |
|
993 |
} |
|
994 |
} |
|
995 |
|
|
964 | 996 |
push @{ $template_arrays{customer_make} }, []; |
965 | 997 |
push @{ $template_arrays{customer_model} }, []; |
966 | 998 |
push @{ $template_arrays{cm_part_description} }, []; |
js/kivi.Part.js | ||
---|---|---|
264 | 264 |
$("#makemodel_rows tr:last").find('input[type=text]').filter(':visible:first').focus(); |
265 | 265 |
}; |
266 | 266 |
|
267 |
// businessmodel |
|
268 |
ns.delete_businessmodel_row = function(clicked) { |
|
269 |
var row = $(clicked).closest('tr'); |
|
270 |
$(row).remove(); |
|
271 |
}; |
|
272 |
|
|
273 |
ns.add_businessmodel_row = function() { |
|
274 |
if ($('#add_businessmodel').val() === '') return; |
|
275 |
|
|
276 |
var data = $('#businessmodel_table :input').serializeArray(); |
|
277 |
data.push({ name: 'action', value: 'Part/add_businessmodel_row' }); |
|
278 |
|
|
279 |
$.post("controller.pl", data, kivi.eval_json_result); |
|
280 |
}; |
|
281 |
|
|
282 |
ns.focus_last_businessmodel_input = function () { |
|
283 |
$("#businessmodel_rows tr:last").find('input[type=text]').filter(':visible:first').focus(); |
|
284 |
}; |
|
267 | 285 |
|
268 | 286 |
// customerprice |
269 | 287 |
ns.customerprice_renumber_positions = function() { |
locale/de/all | ||
---|---|---|
569 | 569 |
'Business' => 'Kunden-/Lieferantentyp', |
570 | 570 |
'Business Discount' => 'Kunden-/Lieferantentyp-Rabatt', |
571 | 571 |
'Business Number' => 'Firmennummer', |
572 |
'Business Type' => 'Kunden-/Lieferantentyp', |
|
573 |
'Business Type Model' => 'Kunden-/Lieferantentyp-Art.-Nr.', |
|
572 | 574 |
'Business Volume' => 'Geschäftsvolumen', |
573 | 575 |
'Business evaluation' => 'Betriebswirtschaftliche Auswertung', |
574 | 576 |
'Business type (database ID)' => 'Kunden-/Lieferantentyp (Datenbank-ID)', |
locale/en/all | ||
---|---|---|
569 | 569 |
'Business' => '', |
570 | 570 |
'Business Discount' => '', |
571 | 571 |
'Business Number' => '', |
572 |
'Business Type' => '', |
|
573 |
'Business Type Model' => '', |
|
572 | 574 |
'Business Volume' => '', |
573 | 575 |
'Business evaluation' => '', |
574 | 576 |
'Business type (database ID)' => '', |
sql/Pg-upgrade2/add_business_models.sql | ||
---|---|---|
1 |
-- @tag: add_business_models |
|
2 |
-- @description: Tabelle für Kunden-/Lieferantentyp-Artikelnummern und Beschreibung |
|
3 |
-- @depends: release_3_8_0 |
|
4 |
|
|
5 |
CREATE TABLE business_models ( |
|
6 |
parts_id integer NOT NULL, |
|
7 |
business_id integer NOT NULL, |
|
8 |
model text, |
|
9 |
part_description text, |
|
10 |
part_longdescription text, |
|
11 |
|
|
12 |
itime timestamp DEFAULT now(), |
|
13 |
mtime timestamp, |
|
14 |
|
|
15 |
FOREIGN KEY (parts_id) REFERENCES parts(id), |
|
16 |
FOREIGN KEY (business_id) REFERENCES business(id), |
|
17 |
|
|
18 |
PRIMARY KEY(parts_id, business_id) |
|
19 |
); |
|
20 |
|
|
21 |
CREATE TRIGGER mtime_business_models BEFORE UPDATE ON business_models |
|
22 |
FOR EACH ROW EXECUTE PROCEDURE set_mtime(); |
templates/webpages/part/_basic_data.html | ||
---|---|---|
236 | 236 |
[%- UNLESS SELF.part.is_assembly %] |
237 | 237 |
[% PROCESS 'part/_makemodel.html' %] |
238 | 238 |
[% END %] |
239 |
[% PROCESS 'part/_businessmodels.html' %] |
|
239 | 240 |
|
240 | 241 |
<tr> |
241 | 242 |
<td><hr size="3" noshade></td> |
templates/webpages/part/_businessmodel_row.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE L %] |
|
3 |
[%- USE HTML %] |
|
4 |
[%- USE LxERP %] |
|
5 |
<tr class="listrow businessmodel_row"> |
|
6 |
<td align="center"> |
|
7 |
[%- L.hidden_tag("businessmodels[+].business_id", businessmodel.business_id) -%] |
|
8 |
[%- L.button_tag("kivi.Part.delete_businessmodel_row(this)", |
|
9 |
LxERP.t8("X")) %] [% # , confirm=LxERP.t8("Are you sure?")) %] |
|
10 |
</td> |
|
11 |
<td>[% businessmodel.business.description | html %]</td> |
|
12 |
<td>[% L.input_tag('businessmodels[].model', businessmodel.model, size=30 ) %]</td> |
|
13 |
<td>[% L.input_tag('businessmodels[].part_description', businessmodel.part_description, size=30 ) %]</td> |
|
14 |
<td>[% L.areainput_tag('businessmodels[].part_longdescription', businessmodel.part_longdescription, size=30 ) %] |
|
15 |
</tr> |
templates/webpages/part/_businessmodels.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE L %] |
|
3 |
[%- USE P %] |
|
4 |
[%- USE HTML %] |
|
5 |
[%- USE LxERP %] |
|
6 |
<tr> |
|
7 |
</tr> |
|
8 |
<tr> |
|
9 |
<td> |
|
10 |
<table id="businessmodel_table"> |
|
11 |
<thead> |
|
12 |
<tr> |
|
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">[% 'Business' | $T8 %]</th> |
|
15 |
<th class="listheading">[% 'Business Type Model' | $T8 %]</th> |
|
16 |
<th class="listheading">[% 'Part Description' | $T8 %]</th> |
|
17 |
<th class="listheading">[% 'Long Description' | $T8 %]</th> |
|
18 |
</tr> |
|
19 |
</thead> |
|
20 |
<tbody id="businessmodel_rows"> |
|
21 |
[%- FOREACH businessmodel = SELF.part.businessmodels %] |
|
22 |
[% PROCESS 'part/_businessmodel_row.html' businessmodel=businessmodel %] |
|
23 |
[%- END %] |
|
24 |
</tbody> |
|
25 |
<tbody> |
|
26 |
<tr> |
|
27 |
<td></td> |
|
28 |
<td align="right">[% 'Business' | $T8 %]</td> |
|
29 |
<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> |
|
30 |
<td align="right">[% L.button_tag('kivi.Part.add_businessmodel_row()', LxERP.t8('Add')) %]</td> |
|
31 |
<td></td> |
|
32 |
</tr> |
|
33 |
</tbody> |
|
34 |
</table> |
|
35 |
</td> |
|
36 |
</tr> |
Auch abrufbar als: Unified diff
Erweiterung für Artikelnummern nach Kunden-/Lieferanten-Typ (business).
Suche im Bericht und Import sind (noch) nicht implementiert.