IS: Departments anzeigen.
[kivitendo-erp.git] / bin / mozilla / is.pl
index 8490d05..3aa93b6 100644 (file)
@@ -147,54 +147,30 @@ sub invoice_links {
     }
   }
 
-  my $payment_id;
-  if ($form->{payment_id}) {
-    $payment_id = $form->{payment_id};
-  }
-  my $language_id;
-  if ($form->{language_id}) {
-    $language_id = $form->{language_id};
-  }
-  my $taxzone_id;
-  if ($form->{taxzone_id}) {
-    $taxzone_id = $form->{taxzone_id};
-  }
-  my $id;
-  if ($form->{id}) {
-    $id = $form->{id};
-  }
-  my $shipto_id;
-  if ($form->{shipto_id}) {
-    $shipto_id = $form->{shipto_id};
-  }
+  $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes id shipto_id));
 
-  my $cp_id = $form->{cp_id};
   IS->get_customer(\%myconfig, \%$form);
 
   #quote all_customer Bug 133
   foreach my $ref (@{ $form->{all_customer} }) {
     $ref->{name} = $form->quote($ref->{name});
   }
-  if ($id) {
-    $form->{id} = $id;
-  }
-  IS->retrieve_invoice(\%myconfig, \%$form);
-  $form->{cp_id} = $cp_id;
 
-  if ($payment_id) {
-    $form->{payment_id} = $payment_id;
-  }
-  if ($language_id) {
-    $form->{language_id} = $language_id;
-  }
-  if ($taxzone_id) {
-    $form->{taxzone_id} = $taxzone_id;
-  }
-  if ($shipto_id) {
-    $form->{shipto_id} = $shipto_id;
+  $form->restore_vars(qw(id));
+
+  IS->retrieve_invoice(\%myconfig, \%$form);
+  $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id shipto_id));
+  $form->restore_vars(qw(taxincluded)) if $form->{id};
+  $form->restore_vars(qw(salesman_id)) if $main::editing;
+
+  # build vendor/customer drop down comatibility... don't ask
+  if (@{ $form->{"all_customer"} }) {
+    $form->{"selectcustomer"} = 1;
+    $form->{customer}         = qq|$form->{customer}--$form->{"customer_id"}|;
   }
 
   $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
+  $form->{selectcustomer} = 1;
 
   # departments
   if ($form->{all_departments}) {
@@ -356,10 +332,10 @@ sub form_header {
   # customer
   $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
   $TMPL_VAR{vclimit} = $myconfig{vclimit};
-  $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('$form->{vc}', '', @{[ $form->{vc} eq 'vendor' ? 1 : 0 ]}, 0)";
-  push @custom_hiddens, "$form->{vc}_id";
-  push @custom_hiddens, "old$form->{vc}";
-  push @custom_hiddens, "select$form->{vc}";
+  $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('customer', '', 0, 0)";
+  push @custom_hiddens, "customer_id";
+  push @custom_hiddens, "oldcustomer";
+  push @custom_hiddens, "selectcustomer";
 
   # currencies and exchangerate
   my @values = map { $_       } @{ $form->{ALL_CURRENCIES} };
@@ -392,9 +368,9 @@ sub form_header {
   $TMPL_VAR{numberformat}        = $myconfig{numberformat};
 
   # hiddens
-  $TMPL_VAR{HIDDEN} = [qw(
+  $TMPL_VAR{HIDDENS} = [qw(
     id action type media format queued printed emailed title vc discount
-    creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
+    title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
     max_dunning_level dunning_amount
     shiptoname shiptostreet shiptozipcode shiptocity shiptocountry  shiptocontact shiptophone shiptofax
     shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus
@@ -430,18 +406,14 @@ sub form_footer {
     $introws = 2;
   }
   $rows = ($rows > $introws) ? $rows : $introws;
-  my $notes =
-    qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
-  my $intnotes =
-    qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
+  my $notes = qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
+  my $intnotes = qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
 
   $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
 
   my $taxincluded = "";
   if ($form->{taxaccounts}) {
-    $taxincluded = qq|
-               <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
-      . $locale->text('Tax Included') . qq|</b><br><br>|;
+    $taxincluded = qq| <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>| . $locale->text('Tax Included') . qq|</b><br><br>|;
   }
 
   my ($tax, $subtotal);
@@ -449,26 +421,20 @@ sub form_footer {
 
     foreach my $item (split / /, $form->{taxaccounts}) {
       if ($form->{"${item}_base"}) {
-        $form->{"${item}_total"} =
-          $form->round_amount(
-                             $form->{"${item}_base"} * $form->{"${item}_rate"},
-                             2);
+        $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
         $form->{invtotal} += $form->{"${item}_total"};
-        $form->{"${item}_total"} =
-          $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
+        $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
 
         $tax .= qq|
              <tr>
-                <th align="right">$form->{"${item}_description"}&nbsp;|
-                                    . $form->{"${item}_rate"} * 100 .qq|%</th>
-               <td align="right">$form->{"${item}_total"}</td>
+                <th align="right">$form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
+                <td align="right">$form->{"${item}_total"}</td>
              </tr>
 |;
       }
     }
 
-    $form->{invsubtotal} =
-      $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
+    $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
 
     $subtotal = qq|
              <tr>
@@ -482,20 +448,10 @@ sub form_footer {
   if ($form->{taxincluded}) {
     foreach my $item (split / /, $form->{taxaccounts}) {
       if ($form->{"${item}_base"}) {
-        $form->{"${item}_total"} =
-          $form->round_amount(
-                           ($form->{"${item}_base"} * $form->{"${item}_rate"} /
-                              (1 + $form->{"${item}_rate"})
-                           ),
-                           2);
-        $form->{"${item}_netto"} =
-          $form->round_amount(
-                          ($form->{"${item}_base"} - $form->{"${item}_total"}),
-                          2);
-        $form->{"${item}_total"} =
-          $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
-        $form->{"${item}_netto"} =
-          $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
+        $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"} / (1 + $form->{"${item}_rate"})), 2);
+        $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
+        $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
+        $form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
 
         $tax .= qq|
              <tr>
@@ -514,8 +470,7 @@ sub form_footer {
   }
 
   $form->{oldinvtotal} = $form->{invtotal};
-  $form->{invtotal}    =
-    $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
+  $form->{invtotal}    = $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
 
   my $follow_ups_block;
   if ($form->{id}) {
@@ -671,11 +626,9 @@ if ($form->{type} eq "credit_note") {
     # format amounts
     $totalpaid += $form->{"paid_$i"};
     if ($form->{"paid_$i"}) {
-      $form->{"paid_$i"} =
-        $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+      $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
     }
-    $form->{"exchangerate_$i"} =
-      $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+    $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
 
     if ($form->{"exchangerate_$i"} == 0) {
       $form->{"exchangerate_$i"} = "";
@@ -754,64 +707,37 @@ if ($form->{type} eq "credit_note") {
     my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar") && (($totalpaid == 0) || ($totalpaid eq ""));
 
     print qq|
-    <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
-      . $locale->text('Update') . qq|">
-    <input class="submit" type="submit" name="action" value="|
-      . $locale->text('Ship to') . qq|">
-    <input class="submit" type="submit" name="action" value="|
-      . $locale->text('Print') . qq|">
-    <input class="submit" type="submit" name="action" value="|
-      . $locale->text('E-mail') . qq|"> |;
-    print qq|<input class="submit" type="submit" name="action" value="|
-      . $locale->text('Storno') . qq|"> | if ($show_storno);
-    print qq|<input class="submit" type="submit" name="action" value="|
-      . $locale->text('Post Payment') . qq|">
-|;
-    print qq|<input class="submit" type="submit" name="action" value="|
-      . $locale->text('Use As Template') . qq|">
-|;
+    <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="| . $locale->text('Update') . qq|">
+    <input class="submit" type="submit" name="action" value="| . $locale->text('Ship to') . qq|">
+    <input class="submit" type="submit" name="action" value="| . $locale->text('Print') . qq|">
+    <input class="submit" type="submit" name="action" value="| . $locale->text('E-mail') . qq|"> |;
+    print qq|<input class="submit" type="submit" name="action" value="| . $locale->text('Storno') . qq|"> | if ($show_storno);
+    print qq|<input class="submit" type="submit" name="action" value="| . $locale->text('Post Payment') . qq|"> |;
+    print qq|<input class="submit" type="submit" name="action" value="| . $locale->text('Use As Template') . qq|"> |;
     if ($form->{id} && !($form->{type} eq "credit_note")) {
-      print qq|
-    <input class="submit" type="submit" name="action" value="|
-      . $locale->text('Credit Note') . qq|">
-|;
+      print qq| <input class="submit" type="submit" name="action" value="| . $locale->text('Credit Note') . qq|"> |;
     }
     if ($form->{radier}) {
-    print qq|
-    <input class="submit" type="submit" name="action" value="|
-      . $locale->text('Delete') . qq|">
-|;
+      print qq| <input class="submit" type="submit" name="action" value="| . $locale->text('Delete') . qq|"> |;
     }
 
 
     if ($invdate > $closedto) {
-      print qq|
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('Order') . qq|">
-|;
+      print qq| <input class="submit" type="submit" name="action" value="| . $locale->text('Order') . qq|"> |;
     }
 
-    print qq|
-      <input type="button" class="submit" onclick="follow_up_window()" value="|
-      . $locale->text('Follow-Up')
-      . qq|">|;
+    print qq| <input type="button" class="submit" onclick="follow_up_window()" value="| . $locale->text('Follow-Up') . qq|">|;
 
   } else {
     if ($invdate > $closedto) {
-      print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
-        . $locale->text('Update') . qq|">
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('Ship to') . qq|">
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('Preview') . qq|">
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('E-mail') . qq|">
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('Print and Post') . qq|">
-      <input class="submit" type="submit" name="action" value="|
-        . $locale->text('Post') . qq|"> | .
-        NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
-                         '-class' => 'submit'));
+      print qq|
+      <input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">
+      <input class="submit" type="submit" name="action" value="| . $locale->text('Ship to') . qq|">
+      <input class="submit" type="submit" name="action" value="| . $locale->text('Preview') . qq|">
+      <input class="submit" type="submit" name="action" value="| . $locale->text('E-mail') . qq|">
+      <input class="submit" type="submit" name="action" value="| . $locale->text('Print and Post') . qq|">
+      <input class="submit" type="submit" name="action" value="| . $locale->text('Post') . qq|"> | .
+        NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
     }
   }
 
@@ -828,8 +754,7 @@ if ($form->{type} eq "credit_note") {
 
   # mark_as_paid button
   if($form->{id} ne "") {
-    print qq|<input type="submit" class="submit" name="action" value="|
-          . $locale->text('mark as paid') . qq|">|;
+    print qq|<input type="submit" class="submit" name="action" value="| . $locale->text('mark as paid') . qq|">|;
   }
   # /mark_as_paid button
   print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .