Auslagern von Hersteller/Modell-Zeilen in eigene Templates. Hersteller/Modell auch...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 12 Aug 2008 12:42:52 +0000 (12:42 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 12 Aug 2008 12:42:52 +0000 (12:42 +0000)
bin/mozilla/ic.pl
bin/mozilla/invoice_io.pl
templates/webpages/ic/makemodel_de.html [new file with mode: 0644]
templates/webpages/ic/makemodel_master.html [new file with mode: 0644]

index eb31718..93758ec 100644 (file)
@@ -1523,11 +1523,12 @@ sub form_footer {
     . $locale->text('Update') . qq|">
   |;
 
-  unless ($form->{item} eq "service") {
-    print qq|
-      <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
-    |;
-  }
+####### moved into makemodel_row #############
+#  unless ($form->{item} eq "service") {
+#    print qq|
+#      <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
+#    |;
+#  }
 
   print qq|
      <input type=hidden name=price_rows value=$form->{price_rows}>|;
@@ -1594,32 +1595,8 @@ sub makemodel_row {
   $lxdebug->enter_sub();
   my ($numrows) = @_;
   
-  print qq|
-  <tr>
-    <td>
-      <table width=100%>
-       <tr>
-         <th class="listheading">| . $locale->text('Make') . qq|</th>
-         <th class="listheading">| . $locale->text('Model') . qq|</th>
-       </tr>
-|;
-
-  for my $i (1 .. $numrows) {
-    $form->{"make_$i"}  =~ s/\"/&quot;/g;
-    $form->{"model_$i"} =~ s/\"/&quot;/g;
-    print qq|
-       <tr>
-         <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
-         <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
-       </tr>
-|;
-  }
-
-  print qq|
-      </table>
-    </td>
-  </tr>
-|;
+  my @mm_data = grep { $_->{make} ne '' || $_->{model} ne '' } map +{ make => $form->{"make_$_"}, model => $form->{"model_$_"} }, 1 .. $numrows;
+  print $form->parse_html_template('ic/makemodel', { MM_DATA => [ @mm_data, {} ], mm_rows => scalar @mm_data + 1 });
 
   $lxdebug->leave_sub();
 }
index 2f0f8be..011c872 100644 (file)
@@ -661,7 +661,8 @@ sub display_form {
 
     &{$subroutine}($numrows);
 
-    $numrows    = 0;
+    $numrows    = ++$form->{makemodel_rows};
+    $subroutine = "makemodel_row";
   }
   if ($form->{item} eq 'assembly') {
     $numrows    = $form->{price_rows};
diff --git a/templates/webpages/ic/makemodel_de.html b/templates/webpages/ic/makemodel_de.html
new file mode 100644 (file)
index 0000000..f90fba5
--- /dev/null
@@ -0,0 +1,19 @@
+[%- USE HTML %]
+[%- USE LxERP %]
+  <tr>
+    <td>
+      <table width=100%>
+        <tr>
+          <th class="listheading">Hersteller</th>
+          <th class="listheading">Modell</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>
+        </tr>
+      [%- END %]
+      </table>
+    </td>
+  </tr>
+  <input type=hidden name=makemodel_rows value=[% mm_rows %]>
diff --git a/templates/webpages/ic/makemodel_master.html b/templates/webpages/ic/makemodel_master.html
new file mode 100644 (file)
index 0000000..356143d
--- /dev/null
@@ -0,0 +1,19 @@
+[%- USE HTML %]
+[%- USE LxERP %]
+  <tr>
+    <td>
+      <table width=100%>
+        <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>
+        </tr>
+      [%- END %]
+      </table>
+    </td>
+  </tr>
+  <input type=hidden name=makemodel_rows value=[% mm_rows %]>