Backport von Revision 7581 von XPlace. Hintergrund: Hersteller und Modell sind derzei...
authorJan Büren <information@richardson-bueren.de>
Mon, 11 May 2009 20:18:47 +0000 (20:18 +0000)
committerJan Büren <information@richardson-bueren.de>
Mon, 11 May 2009 20:18:47 +0000 (20:18 +0000)
SL/CT.pm
SL/IC.pm
bin/mozilla/ic.pl
locale/de/all
templates/webpages/ic/makemodel_de.html
templates/webpages/ic/makemodel_master.html

index f2745fb..79169b5 100644 (file)
--- a/SL/CT.pm
+++ b/SL/CT.pm
@@ -123,7 +123,14 @@ sub get_tuple {
   }
 
   # 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 | .
@@ -133,8 +140,10 @@ sub get_tuple {
     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;
index f025663..c84365f 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -491,11 +491,11 @@ sub save {
   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);
       }
     }
@@ -1818,9 +1818,11 @@ sub prepare_parts_for_printing {
   }
 
   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);
index 547acf7..195a72c 100644 (file)
@@ -1464,7 +1464,9 @@ sub form_header {
   map { $form->{$_}       =~ s/"/&quot;/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} };
@@ -1478,11 +1480,12 @@ sub form_header {
   $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();
 }
 
@@ -1501,6 +1504,7 @@ sub makemodel_row {
   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();
index 87c08fd..2aa5899 100644 (file)
@@ -916,7 +916,7 @@ $self->{texts} = {
   'MAILED'                      => 'Gesendet',
   'MSG_BROWSER_DOES_NOT_SUPPORT_IFRAMES' => 'Ihr Browser kann leider keine eingebetteten Frames anzeigen. Bitte w&auml;hlen Sie ein anderes Men&uuml; in der Benutzerkonfiguration im Administrationsmen&uuml; aus.',
   'Main Preferences'            => 'Grundeinstellungen',
-  'Make'                        => 'Hersteller',
+  'Make'                        => 'Lieferant',
   'Manage license keys'         => 'Lizenzschl&uuml;ssel verwalten',
   'Mandantennummer'             => 'Mandantennummer',
   'Mar'                         => 'März',
@@ -948,7 +948,7 @@ $self->{texts} = {
   'Mitarbeiter'                 => 'Mitarbeiter',
   'Mobile1'                     => 'Mobile 1',
   'Mobile2'                     => 'Mobile 2',
-  'Model'                       => 'Modell',
+  'Model'                       => 'Lieferanten-Art-Nr.',
   'Module home page'            => 'Modul-Webseite',
   'Module name'                 => 'Modulname',
   'Monat'                       => 'Monat',
index f90fba5..dd4d038 100644 (file)
@@ -2,18 +2,27 @@
 [%- 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 %]">
index 356143d..696080e 100644 (file)
@@ -2,18 +2,27 @@
 [%- 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 %]">