From 85ffde7a577589762b70de99ca08b6f25e9e9d1b Mon Sep 17 00:00:00 2001 From: Holger Lindemann Date: Wed, 3 Nov 2010 14:56:38 +0100 Subject: [PATCH] =?utf8?q?EK-Preise=20in=20der=20makemodel=20hinterlegen?= =?utf8?q?=20mit=20Datum=20der=20letzten=20=C3=84nderung.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reihenfolge der Lieferanten nach Wichtigkeit. --- SL/IC.pm | 28 +++++++++++++++++------- bin/mozilla/ic.pl | 4 ++-- sql/Pg-upgrade2/add_makemodel_prices.sql | 12 ++++++++++ templates/webpages/ic/makemodel.html | 7 ++++++ 4 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 sql/Pg-upgrade2/add_makemodel_prices.sql diff --git a/SL/IC.pm b/SL/IC.pm index b9ad62c58..35718f602 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -167,14 +167,17 @@ sub get_part { # get makes if ($form->{makemodel}) { - $query = qq|SELECT m.make, m.model FROM makemodel m | . - qq|WHERE m.parts_id = ?|; + #hli + $query = qq|SELECT m.make, m.model,m.lastcost,m.lastcost,m.lastupdate,m.sortorder FROM makemodel m | . + qq|WHERE m.parts_id = ? order by m.sortorder asc|; my @values = ($form->{id}); $sth = $dbh->prepare($query); $sth->execute(@values) || $form->dberror("$query (" . join(', ', @values) . ")"); my $i = 1; - while (($form->{"make_$i"}, $form->{"model_$i"}) = $sth->fetchrow_array) + + while (($form->{"make_$i"}, $form->{"model_$i"}, $form->{"old_lastcost_$i"}, + $form->{"lastcost_$i"}, $form->{"lastupdate_$i"}, $form->{"sortorder_$i"}) = $sth->fetchrow_array) { $i++; } @@ -493,12 +496,21 @@ sub save { # insert makemodel records unless ($form->{item} eq 'service') { + my $lastupdate = ''; + my $value = 0; for my $i (1 .. $form->{makemodel_rows}) { if (($form->{"make_$i"}) || ($form->{"model_$i"})) { - - $query = qq|INSERT INTO makemodel (parts_id, make, model) | . - qq|VALUES (?, ?, ?)|; - @values = (conv_i($form->{id}), conv_i($form->{"make_$i"}), $form->{"model_$i"}); + #hli + $value = $form->parse_amount($myconfig, $form->{"lastcost_$i"}); + if ($value == $form->{"old_lastcost_$i"}) + { + $lastupdate = $dbh->quote($form->{"lastupdate_$i"}); + } else { + $lastupdate = 'now()'; + } + $query = qq|INSERT INTO makemodel (parts_id, make, model, lastcost, lastupdate, sortorder) | . + qq|VALUES (?, ?, ?, ?, ?, ?)|; + @values = (conv_i($form->{id}), conv_i($form->{"make_$i"}), $form->{"model_$i"}, $value, $lastupdate, conv_i($form->{"sortorder_$i"}) ); do_query($form, $dbh, $query, @values); } @@ -818,7 +830,7 @@ sub all_parts { ordnumber => 'apoe.', make => 'mm.', quonumber => 'apoe.', model => 'mm.', invnumber => 'apoe.', partsgroup => 'pg.', - lastcost => ' ', , soldtotal => ' ', + lastcost => 'p.', , soldtotal => ' ', factor => 'pfac.', 'SUM(ioi.qty)' => ' ', description => 'p.', diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 3fa0da5cd..5a012b7a3 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1579,8 +1579,8 @@ sub form_footer { sub makemodel_row { $lxdebug->enter_sub(); my ($numrows) = @_; - - my @mm_data = grep { any { $_ ne '' } @$_{qw(make model)} } map +{ make => $form->{"make_$_"}, model => $form->{"model_$_"} }, 1 .. $numrows; + #hli + my @mm_data = grep { any { $_ ne '' } @$_{qw(make model)} } map +{ make => $form->{"make_$_"}, model => $form->{"model_$_"}, lastcost => $form->{"lastcost_$_"}, lastupdate => $form->{"lastupdate_$_"}, sortorder => $form->{"sortorder_$_"} }, 1 .. $numrows; delete @{$form}{grep { m/^make_\d+/ || m/^model_\d+/ } keys %{ $form }}; print $form->parse_html_template('ic/makemodel', { MM_DATA => [ @mm_data, {} ], mm_rows => scalar @mm_data + 1 }); diff --git a/sql/Pg-upgrade2/add_makemodel_prices.sql b/sql/Pg-upgrade2/add_makemodel_prices.sql new file mode 100644 index 000000000..0fffafc57 --- /dev/null +++ b/sql/Pg-upgrade2/add_makemodel_prices.sql @@ -0,0 +1,12 @@ +-- @tag: add_makemodel_prices +-- @description: EK-Preis zu jedem Lieferanten speichern und das Datum der Eingabe +-- @depends: release_2_6_1 +ALTER TABLE makemodel ADD COLUMN lastcost numeric(15,5) ; +ALTER TABLE makemodel ADD COLUMN lastupdate date; +ALTER TABLE makemodel ADD COLUMN sortorder integer; + +UPDATE makemodel SET sortorder = 1; + +--# Da noch keine Daten vorhanden, den Wert "veralten" +UPDATE makemodel SET lastupdate = '1999-01-01'; + diff --git a/templates/webpages/ic/makemodel.html b/templates/webpages/ic/makemodel.html index 641212417..d610c3956 100644 --- a/templates/webpages/ic/makemodel.html +++ b/templates/webpages/ic/makemodel.html @@ -7,6 +7,9 @@ [% 'Make' | $T8 %] [% 'Model' | $T8 %] + [% 'Last Cost' | $T8 %] + [% 'Updated' | $T8 %] + [% 'order' | $T8 %] [%- FOREACH row = MM_DATA %] @@ -21,6 +24,10 @@ -%] + + + + [%- END %] -- 2.20.1