# 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++;
}
# 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);
}
ordnumber => 'apoe.', make => 'mm.',
quonumber => 'apoe.', model => 'mm.',
invnumber => 'apoe.', partsgroup => 'pg.',
- lastcost => ' ', , soldtotal => ' ',
+ lastcost => 'p.', , soldtotal => ' ',
factor => 'pfac.',
'SUM(ioi.qty)' => ' ',
description => 'p.',
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 });
--- /dev/null
+-- @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';
+
<tr>
<th class="listheading">[% 'Make' | $T8 %]</th>
<th class="listheading">[% 'Model' | $T8 %]</th>
+ <th class="listheading">[% 'Last Cost' | $T8 %]</th>
+ <th class="listheading">[% 'Updated' | $T8 %]</th>
+ <th class="listheading">[% 'order' | $T8 %]</th>
</tr>
[%- FOREACH row = MM_DATA %]
<tr>
-%]
</td>
<td><input name="model_[% loop.count %]" size="30" value="[% HTML.escape(row.model) %]"></td>
+ <td><input type="hidden" name="old_lastcost_[% loop.count %]" value="[% LxERP.format_amount(row.lastcost, -2) %]">
+ <input name="lastcost_[% loop.count %]" size="10" value="[% LxERP.format_amount(row.lastcost, -2) %]"></td>
+ <td><input name="lastupdate_[% loop.count %]" size="10" value="[% HTML.escape(row.lastupdate) %]"></td>
+ <td><input name="sortorder_[% loop.count %]" size="3" value="[% HTML.escape(row.sortorder) %]"></td>
</tr>
[%- END %]
</table>