}
# check if it is orphaned
- my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
+ my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
+ my $num_args = 2;
+ my $makemodel = '';
+ if ($form->{db} eq 'vendor') {
+ $makemodel = qq| UNION SELECT mm.make FROM makemodel mm WHERE mm.make = ?|;
+ $num_args++;
+ }
+
$query =
qq|SELECT a.id | .
qq|FROM $arap a | .
qq|SELECT a.id | .
qq|FROM oe a | .
qq|JOIN $cv ct ON (a.${cv}_id = ct.id) | .
- qq|WHERE ct.id = ?|;
- my ($dummy) = selectrow_query($form, $dbh, $query, $form->{id}, $form->{id});
+ qq|WHERE ct.id = ?|
+ . $makemodel;
+ my ($dummy) = selectrow_query($form, $dbh, $query, (conv_i($form->{id})) x $num_args);
+
$form->{status} = "orphaned" unless ($dummy);
$dbh->disconnect;
unless ($form->{item} eq 'service') {
for my $i (1 .. $form->{makemodel_rows}) {
if (($form->{"make_$i"}) || ($form->{"model_$i"})) {
- map { $form->{"${_}_$i"} =~ s/\'/\'\'/g } qw(make model);
$query = qq|INSERT INTO makemodel (parts_id, make, model) | .
qq|VALUES (?, ?, ?)|;
- @values = (conv_i($form->{id}), $form->{"make_$i"}, $form->{"model_$i"});
+ @values = (conv_i($form->{id}), conv_i($form->{"make_$i"}), $form->{"model_$i"});
+
do_query($form, $dbh, $query, @values);
}
}
}
my $placeholders = join ', ', ('?') x scalar(@part_ids);
- my $query = qq|SELECT parts_id, make, model
- FROM makemodel
- WHERE parts_id IN ($placeholders)|;
+ my $query = qq|SELECT mm.parts_id, mm.model, v.name AS make
+ FROM makemodel mm
+ LEFT JOIN vendor v ON (mm.make = v.id)
+ WHERE mm.parts_id IN ($placeholders)|;
+
my %makemodel = ();
my $sth = prepare_execute_query($form, $dbh, $query, @part_ids);
map { $form->{$_} =~ s/"/"/g; } qw(unit);
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS',
- 'partsgroup' => 'all_partsgroup');
+ 'partsgroup' => 'all_partsgroup',
+ 'vendors' => 'ALL_VENDORS',);
+
IC->retrieve_buchungsgruppen(\%myconfig, $form);
@{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} };
$form->{fokus} = "ic.partnumber";
$form->header;
- print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS},
- ALL_UNITS => $form->{ALL_UNITS},
- BUCHUNGSGRUPPEN => $form->{BUCHUNGSGRUPPEN},
- payment_terms => $form->{payment_terms},
- all_partsgroup => $form->{all_partsgroup}});
+ #print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS},
+ # ALL_UNITS => $form->{ALL_UNITS},
+ # BUCHUNGSGRUPPEN => $form->{BUCHUNGSGRUPPEN},
+ # payment_terms => $form->{payment_terms},
+ # all_partsgroup => $form->{all_partsgroup}});
+ print $form->parse_html_template('ic/form_header');
$lxdebug->leave_sub();
}
my ($numrows) = @_;
my @mm_data = grep { any { $_ ne '' } @$_{qw(make model)} } map +{ make => $form->{"make_$_"}, model => $form->{"model_$_"} }, 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 });
$lxdebug->leave_sub();
'MAILED' => 'Gesendet',
'MSG_BROWSER_DOES_NOT_SUPPORT_IFRAMES' => 'Ihr Browser kann leider keine eingebetteten Frames anzeigen. Bitte wählen Sie ein anderes Menü in der Benutzerkonfiguration im Administrationsmenü aus.',
'Main Preferences' => 'Grundeinstellungen',
- 'Make' => 'Hersteller',
+ 'Make' => 'Lieferant',
'Manage license keys' => 'Lizenzschlüssel verwalten',
'Mandantennummer' => 'Mandantennummer',
'Mar' => 'März',
'Mitarbeiter' => 'Mitarbeiter',
'Mobile1' => 'Mobile 1',
'Mobile2' => 'Mobile 2',
- 'Model' => 'Modell',
+ 'Model' => 'Lieferanten-Art-Nr.',
'Module home page' => 'Modul-Webseite',
'Module name' => 'Modulname',
'Monat' => 'Monat',
[%- USE LxERP %]
<tr>
<td>
- <table width=100%>
+ <table>
<tr>
- <th class="listheading">Hersteller</th>
- <th class="listheading">Modell</th>
+ <th class="listheading">Lieferant</th>
+ <th class="listheading">Lieferanten-Art-Nr.</th>
</tr>
[%- FOREACH row = MM_DATA %]
<tr>
- <td width=50%><input name="make_[% loop.count %]" size=30 value="[% HTML.escape(row.make) %]"></td>
- <td width=50%><input name="model_[% loop.count %]" size=30 value="[% HTML.escape(row.model) %]"></td>
+ <td>
+ [%- INCLUDE generic/multibox.html
+ name = "make_$loop.count",
+ default = row.make,
+ DATA = ALL_VENDORS,
+ show_empty = 1,
+ label_key = 'name',
+ id_key = 'id',
+ -%]
+ </td>
+ <td><input name="model_[% loop.count %]" size="30" value="[% HTML.escape(row.model) %]"></td>
</tr>
[%- END %]
</table>
</td>
</tr>
- <input type=hidden name=makemodel_rows value=[% mm_rows %]>
+ <input type="hidden" name="makemodel_rows" value="[% mm_rows %]">
[%- USE LxERP %]
<tr>
<td>
- <table width=100%>
+ <table>
<tr>
<th class="listheading"><translate>Make</translate></th>
<th class="listheading"><translate>Model</translate></th>
</tr>
[%- FOREACH row = MM_DATA %]
<tr>
- <td width=50%><input name="make_[% loop.count %]" size=30 value="[% HTML.escape(row.make) %]"></td>
- <td width=50%><input name="model_[% loop.count %]" size=30 value="[% HTML.escape(row.model) %]"></td>
+ <td>
+ [%- INCLUDE generic/multibox.html
+ name = "make_$loop.count",
+ default = row.make,
+ DATA = ALL_VENDORS,
+ show_empty = 1,
+ label_key = 'name',
+ id_key = 'id',
+ -%]
+ </td>
+ <td><input name="model_[% loop.count %]" size="30" value="[% HTML.escape(row.model) %]"></td>
</tr>
[%- END %]
</table>
</td>
</tr>
- <input type=hidden name=makemodel_rows value=[% mm_rows %]>
+ <input type="hidden" name="makemodel_rows" value="[% mm_rows %]">