Einige Browser (Opera) mögen es nicht, wenn "checked" bei Checkboxen in Anführungszei...
[kivitendo-erp.git] / bin / mozilla / io.pl
index db50d4a..de350c5 100644 (file)
@@ -33,6 +33,7 @@
 #
 #######################################################################
 
+use SL::Common;
 use SL::CT;
 use SL::IC;
 use CGI::Ajax;
@@ -91,6 +92,11 @@ sub display_row {
   $lxdebug->enter_sub();
   my $numrows = shift;
 
+  my $is_sales =
+    (substr($form->{type}, 0, 6) eq "sales_")
+    || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
+    || ($form->{type} eq 'credit_note');
+
   if ($lizenzen && $form->{vc} eq "customer") {
     if ($form->{type} =~ /sales_order/) {
       @column_index = (runningnumber, partnumber, description, ship, qty);
@@ -324,7 +330,8 @@ sub display_row {
       $form->{"marge_percent_$i"} = 0;
     }
 
-    $form->{"marge_absolut_$i"}  = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"};
+    my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
+    $form->{"marge_absolut_$i"}  = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"} * $marge_adjust_credit_note;
     $form->{"marge_total"}      += $form->{"marge_absolut_$i"};
     $form->{"lastcost_total"}   += $form->{"lastcost_$i"} * $form->{"qty_$i"};
     $form->{"sellprice_total"}  += $real_sellprice * $form->{"qty_$i"};
@@ -361,9 +368,10 @@ sub display_row {
         qq|<td align="right"><input name="qty_$i" size="5" value="|
       . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|;
     if ($form->{"formel_$i"}) {
-    $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>| .
-          $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"}). qq|</td>|;
+      $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>|
+        . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
     }
+    $column_data{qty} .= qq|</td>|;
     $column_data{ship} =
         qq|<td align="right"><input name="ship_$i" size=5 value="|
       . $form->format_amount(\%myconfig, $form->{"ship_$i"})
@@ -521,13 +529,17 @@ sub display_row {
     }
     my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
     print qq|
-          <b>|.$locale->text('Subtotal').qq|</b>&nbsp;<input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
+          <b>|.$locale->text('Subtotal').qq|</b>&nbsp;<input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked>
 |;
 
+    if ($form->{"id_$i"} && $is_sales) {
+      print qq|
+          ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b>&nbsp;$form->{"marge_absolut_$i"} &nbsp;$form->{"marge_percent_$i"} % ${marge_font_end}
+          &nbsp;<b>| . $locale->text('LP') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
+          &nbsp;<b>| . $locale->text('EK') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2);
+    }
+
     print qq|
-          ${marge_font_start}<b>|.$locale->text('Ertrag').qq|</b>&nbsp;$form->{"marge_absolut_$i"} &nbsp;$form->{"marge_percent_$i"} % ${marge_font_end}
-          &nbsp;<b>|.$locale->text('LP').qq|</b>&nbsp;|.$form->format_amount(\%myconfig,$form->{"listprice_$i"},2).qq|
-          &nbsp;<b>|.$locale->text('EK').qq|</b>&nbsp;|.$form->format_amount(\%myconfig,$form->{"lastcost_$i"},2).qq|
          </td>
        </tr>
 |;
@@ -859,12 +871,11 @@ sub new_item {
     . $locale->text('Part') . qq|<br>
   <input class="radio" type="radio" name="item" value="service">&nbsp;|
     . $locale->text('Service');
-print $cgi->hidden("-name" => "previousform", "-value" => $previousform);
-map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } 
-     qw(rowcount vc login password));
-     map({ print($cgi->hidden("-name" => $_, "-value" => $form->{"$__$i"})); }
-     ("partnumber", "description"));
-print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts});
+
+  print $cgi->hidden("-name" => "previousform", "-value" => $previousform);
+  map { print $cgi->hidden("-name" => $_, "-value" => $form->{$_}); }        qw(rowcount vc login password);
+  map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice);
+  print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts});
 
 print qq|
 <input type="hidden" name="nextsub" value="add">
@@ -1057,6 +1068,9 @@ sub check_form {
     $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
     $form->{makemodel_rows} = $count;
 
+  } elsif ($form->{item} eq 'service') {
+    map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost);
+
   } else {
 
     # this section applies to invoices and orders
@@ -1306,8 +1320,7 @@ sub edit_e_mail {
     $form->{"email"} = $form->{"cp_email"};
   }
 
-  $form->{ $form->{vc} } =~ /--/;
-  $title = $locale->text('E-mail') . " $`";
+  $title = $locale->text('E-mail') . " " . $form->get_formname_translation();
 
   $form->{oldmedia} = $form->{media};
   $form->{media}    = "email";
@@ -1341,6 +1354,8 @@ sub send_email {
 
   print_form("return");
 
+  Common->save_email_status(\%myconfig, $form);
+
   $form->{callback} = $callback;
   $form->redirect();
 
@@ -1434,7 +1449,7 @@ sub print_options {
       opthash("opendocument", $form->{DF}{opendocument}, $locale->text("OpenDocument/OASIS")) : undef;
 
   push @LANGUAGE_ID, 
-    map { opthash($_->{id}, ($_->{id} eq $form->{language} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{languages} }
+    map { opthash($_->{id}, ($_->{id} eq $form->{language_id} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{languages} }
       if (ref $form->{languages} eq 'ARRAY');
 
   push @PRINTER_ID, 
@@ -1525,7 +1540,7 @@ sub print_form {
     $inv                  = "ord";
     $due                  = "req";
     $form->{"${inv}date"} = $form->{transdate};
-    $form->{label}        = $locale->text('Sales Order');
+    $form->{label}        = $locale->text('Confirmation');
     $numberfld            = "sonumber";
     $order                = 1;
   }
@@ -1607,7 +1622,7 @@ sub print_form {
     $inv                  = "quo";
     $due                  = "req";
     $form->{"${inv}date"} = $form->{transdate};
-    $form->{label}        = $locale->text('Quotation');
+    $form->{label}        = $locale->text('RFQ');
     $numberfld            = "rfqnumber";
     $order                = 1;
   }