$form->{snumber} durch $form->{snumbers} ersetzt, da dies eigentlich so vorgesehen...
[kivitendo-erp.git] / bin / mozilla / io.pl
index 1912776..01f290b 100644 (file)
@@ -368,9 +368,9 @@ sub display_row {
       }
 
       $column_data{sellprice_pg} =
-        qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
+      qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
       $column_data{sellprice} =
-        qq|<td><input name="sellprice_$i" size="10" value="$price_tmp"></td>|;
+      qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|;
     } else {
 
       # for last row and report
@@ -388,10 +388,10 @@ sub display_row {
 
         # for last row
         $column_data{sellprice_pg} = qq|<td align="right">&nbsp;</td>|;
-      }
-
+        }
+        
       $column_data{sellprice} =
-        qq|<td><input name="sellprice_$i" size="10" value="|
+      qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="|
         . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
                                $decimalplaces)
         . qq|"></td>|;
@@ -427,17 +427,19 @@ sub display_row {
 
     map { print "\n$column_data{$_}" } @column_index;
 
-    print qq|
-        </tr>
-|;
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } 
-       ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i", "selected_unit_$i", "id_$i", "inventory_accno_$i", "bin_$i",
-          "partsgroup_$i", "partnotes_$i", "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i", "taxaccounts_$i",
-          "ordnumber_$i", "transdate_$i", "cusordnumber_$i", "longdescription_$i", "basefactor_$i"));
-print qq|
-<input type="hidden" name="price_new_$i" value="|
-      . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|">
-|;
+    print("</tr>\n" .
+          $cgi->hidden("-name" => "unit_old_$i",
+                       "-value" => $form->{"selected_unit_$i"})
+          . "\n" .
+          $cgi->hidden("-name" => "price_new_$i",
+                       "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"}))
+          . "\n");
+    map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); }
+        ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i",
+         "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
+         "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
+         "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
+         "longdescription_$i", "basefactor_$i"));
 
 ########################################
     # Eintrag fuer Version 2.2.0 geaendert #
@@ -484,7 +486,7 @@ print qq|
         ? 'deliverydate'
         : 'reqdate';    # invoice uses a different term for the same thing.
       print qq|
-        <b>${$reqdate_term}</b>&nbsp;<input name="${reqdate_term}_$i" size="11" value="$form->{"${reqdate_term}_$i"}">
+        <b>${$reqdate_term}</b>&nbsp;<input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}">
 |;
     }
     my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
@@ -581,7 +583,7 @@ sub select_item {
   $colspan = $#column_index + 1;
 
   print qq|
-<body>
+  <body>
 
 <form method="post" action="$form->{script}">
 
@@ -622,7 +624,7 @@ sub select_item {
     $column_data{partnumber} =
       qq|<td><input name="new_partnumber_$i" type="hidden" value="$ref->{partnumber}">$ref->{partnumber}</td>|;
     $column_data{description} =
-      qq|<td><input name="new_description_$i" type="hidden" value=$ref->{description}>$ref->{description}</td>|;
+      qq|<td><input name="new_description_$i" type="hidden" value="$ref->{description}">$ref->{description}</td>|;
     $column_data{sellprice} =
       qq|<td align="right"><input name="new_sellprice_$i" type="hidden" value="$ref->{sellprice}">|
       . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, "&nbsp;")
@@ -640,18 +642,16 @@ sub select_item {
 
     map { print "\n$column_data{$_}" } @column_index;
 
-    print qq|
-</tr>
-|;
-map({ print($cgi->hidden("-name" => "new_$__$i", "-value" => $ref->{$_})); } 
-        qw(bin listprice inventory_accno income_accno expense_accno unit weight assembly taxaccounts partsgroup 
-           formel logdescription not_discountable part_payment_id partnodes id));
-if ($lizenzen) {
-      print qq|
-<input name="new_lizenzen_$i" type="hidden" value="$ref->{lizenzen}">
-|;
-    }
+    print("</tr>\n");
+
+    my @new_fields =
+      qw(bin listprice inventory_accno income_accno expense_accno unit weight
+         assembly taxaccounts partsgroup formel logdescription not_discountable
+         part_payment_id partnodes id);
+    push(@new_fields, "lizenzen") if ($lizenzen);
 
+    map({ print($cgi->hidden("-name" => "new_${_}_$i",
+                             "-value" => $ref->{$_})); } @new_fields);
   }
 
   print qq|
@@ -822,17 +822,10 @@ sub new_item {
     . $locale->text('Service');
 print $cgi->hidden("-name" => "previousform", "-value" => $previousform);
 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } 
-     ("partnumber_$i", "description_$i", "rowcount", "taxaccounts", "vc", "path", "login", "password"));
-
-#<input type="hidden" name="partnumber" value="$form->{"partnumber_$i"}">
-#<input type="hidden" name="description" value="$form->{"description_$i"}">
-#<input type="hidden" name="rowcount" value="$form->{rowcount}">
-#<input type="hidden" name="taxaccount2" value="$form->{taxaccounts}">
-#<input type="hidden" name="vc" value="$form->{vc}">
-#
-#<input type="hidden" name="path" value="$form->{path}">
-#<input type="hidden" name="login" value="$form->{login}">
-#<input type="hidden" name="password" value="$form->{password}">
+     ("rowcount", "vc", "path", "login", "password"));
+     map({ print($cgi->hidden("-name" => $_, "-value" => $form->{"$__$i"})); }
+     ("partnumber", "description"));
+print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts});
 
 print qq|
 <input type="hidden" name="nextsub" value="add">
@@ -861,7 +854,7 @@ sub display_form {
 
   # if we have a display_form
   if ($form->{display_form}) {
-    &{"$form->{display_form}"};
+    call_sub($form->{"display_form"});
     exit;
   }
 
@@ -1394,7 +1387,7 @@ sub edit_e_mail {
     <td>
 |;
 
-  &print_options;
+  print_options();
 
   map { delete $form->{$_} }
     qw(action email cc bcc subject message formname sendmode format header override);
@@ -1505,7 +1498,7 @@ sub print_options {
 
   push @MEDIA, grep $_,
       opthash("screen", $form->{OP}{screen}, $locale->text('Screen')),
-    (scalar keys %{ $form->{printers} } && $latex_templates) ?
+    (scalar @{ $form->{printers} } && $latex_templates) ?
       opthash("printer", $form->{OP}{printer}, $locale->text('Printer')) : undef,
     ($latex_templates) ? 
       opthash("queue", $form->{OP}{queue}, $locale->text('Queue')) : undef
@@ -1527,13 +1520,13 @@ sub print_options {
       if (ref $form->{languages} eq 'ARRAY');
 
   push @PRINTER_ID, 
-    map { opthash($_->{id}, ($_->{id} eq $form->{printer_id} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{printers} }
-      if (ref $form->{printers} eq 'ARRAY');
+    map { opthash($_->{id}, ($_->{id} eq $form->{printer_id} ? 'selected' : ''), $_->{printer_description}) } +{}, @{ $form->{printers} }
+      if ((ref $form->{printers} eq 'ARRAY') && scalar @{ $form->{printers } });
 
   @SELECTS = map { sname => lc $_, DATA => \@$_, show => scalar @$_ }, qw(FORMNAME LANGUAGE_ID FORMAT SENDMODE MEDIA PRINTER_ID);
 
   %template_vars = (
-    display_copies       => scalar keys %{ $form->{printers} } && $latex_templates && $form->{media} ne 'email',
+    display_copies       => scalar @{ $form->{printers} } && $latex_templates && $form->{media} ne 'email',
     display_remove_draft => (!$form->{id} && $form->{draft_id}),
     groupitems_checked   => $form->{groupitems} ? "checked" : '',
     remove_draft_checked => $form->{remove_draft} ? "checked" : ''
@@ -1720,9 +1713,10 @@ sub print_form {
 
       $form->{rowcount}--;
 
-      &{"$display_form"};
+      call_sub($display_form);
       # saving the history
          if(!exists $form->{addition}) {
+        $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; 
            $form->{addition} = "PRINTED";
            $form->save_history($form->dbconnect(\%myconfig));
       }
@@ -1742,7 +1736,7 @@ sub print_form {
   $salesman_id_saved = $form->{salesman_id};
   $cp_id_saved = $form->{cp_id};
 
-  &{"$form->{vc}_details"}();
+  call_sub("$form->{vc}_details");
 
   $form->{language_id} = $language_saved;
   $form->{payment_id} = $payment_id_saved;
@@ -1915,6 +1909,7 @@ sub print_form {
 
 # saving the history
   if(!exists $form->{addition}) {
+    $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
     if($form->{media} =~ /printer/) {
        $form->{addition} = "PRINTED";
     }
@@ -1971,7 +1966,7 @@ sub print_form {
         } qw(paid exchangerate);
       }
 
-      &{"$display_form"};
+      call_sub($display_form);
       exit;
     }
 
@@ -1982,7 +1977,7 @@ sub print_form {
     $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
   }
   if ($form->{printing}) {
-   &{"$display_form"};
+   call_sub($display_form);
    exit; 
   }
 
@@ -2036,7 +2031,7 @@ sub ship_to {
         contact email phone fax));
 
   # get details for name
-  &{"$form->{vc}_details"}(@addr_vars);
+  call_sub("$form->{vc}_details", @addr_vars);
 
   $number =
     ($form->{vc} eq 'customer')
@@ -2113,7 +2108,7 @@ sub ship_to {
        <tr>
          <th align="right" nowrap>| . $locale->text('Contact') . qq|</th>
          <td>$form->{contact}</td>
-         <td><input name="shiptocontac"t size="35" value="$form->{shiptocontact}"></td>
+         <td><input name="shiptocontact" size="35" value="$form->{shiptocontact}"></td>
        </tr>
        <tr>
          <th align="right" nowrap>| . $locale->text('Phone') . qq|</th>
@@ -2134,7 +2129,7 @@ sub ship_to {
     </td>
   </tr>
 </table>
-| . $cgi->hidden("-name" => "nexsub", "-value" => $nextsub);
+| . $cgi->hidden("-name" => "nextsub", "-value" => $nextsub);
 ;