Noch ein Fallback, falls $language wirklich nicht definiert sein sollte.
[kivitendo-erp.git] / bin / mozilla / io.pl
index 785c3d5..6a57794 100644 (file)
@@ -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 #
@@ -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">
@@ -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);
@@ -1430,12 +1423,14 @@ sub edit_e_mail {
 sub send_email {
   $lxdebug->enter_sub();
 
-  $old_form = new Form;
+  my $callback = $form->{script} . "?action=edit";
+  map({ $callback .= "\&${_}=" . E($form->{$_}); }
+      qw(login password path type id));
 
-  map { $old_form->{$_} = $form->{$_} } keys %$form;
-  $old_form->{media} = $form->{oldmedia};
+  print_form("return");
 
-  &print_form($old_form);
+  $form->{callback} = $callback;
+  $form->redirect();
 
   $lxdebug->leave_sub();
 }
@@ -1503,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
@@ -1525,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" : ''
@@ -1738,6 +1733,7 @@ sub print_form {
   $language_saved = $form->{language_id};
   $payment_id_saved = $form->{payment_id};
   $salesman_id_saved = $form->{salesman_id};
+  $cp_id_saved = $form->{cp_id};
 
   &{"$form->{vc}_details"}();
 
@@ -1748,6 +1744,13 @@ sub print_form {
   $form->{"cc"}    = $saved_cc    if ($saved_cc);
   $form->{"bcc"}   = $saved_bcc   if ($saved_bcc);
 
+  if (!$cp_id_saved) {
+    # No contact was selected. Delete all contact variables because
+    # IS->customer_details() and IR->vendor_details() get the default
+    # contact anyway.
+    map({ delete($form->{$_}); } grep(/^cp_/, keys(%{ $form })));
+  }
+
   my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
   if ($form->{"language_id"}) {
     ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
@@ -1936,6 +1939,8 @@ sub print_form {
     $form->update_status(\%myconfig)
       if ($form->{media} eq 'queue' && $form->{id});
 
+    return $lxdebug->leave_sub() if ($old_form eq "return");
+
     if ($old_form) {
 
       $old_form->{"${inv}number"} = $form->{"${inv}number"};
@@ -2101,7 +2106,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>
@@ -2122,7 +2127,7 @@ sub ship_to {
     </td>
   </tr>
 </table>
-| . $cgi->hidden("-name" => "nexsub", "-value" => $nextsub);
+| . $cgi->hidden("-name" => "nextsub", "-value" => $nextsub);
 ;