]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/oe.pl
Bugfix 624 und 93.
[mfinanz.git] / bin / mozilla / oe.pl
index 640fb37e5d7e3905cedcf29954cab01a68848baa..b5cd79d636621c7baad5e47d73daca7b742a4c9a 100644 (file)
@@ -403,6 +403,7 @@ sub form_header {
   map({ push(@old_project_ids, $form->{"project_id_$_"})
           if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
 
+  my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
   $form->get_lists("contacts" => "ALL_CONTACTS",
                    "shipto" => "ALL_SHIPTO",
                    "projects" => { "key" => "ALL_PROJECTS",
@@ -411,11 +412,9 @@ sub form_header {
                    "employees" => "ALL_SALESMEN",
                    "taxzones" => "ALL_TAXZONES",
                    "payments" => "ALL_PAYMENTS",
-                   "currencies" => "ALL_CURRENCIES");
-                  ($form->{vc} eq "customer" 
-                      ? $form->get_lists("customers" => "ALL_CUSTOMERS") 
-                      : $form->get_lists("vendors" => "ALL_VENDORS"));
-  
+                   "currencies" => "ALL_CURRENCIES",
+                   $vc => "ALL_" . uc($vc));
+
   my %labels;
   my @values = (undef);
   foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
@@ -435,11 +434,13 @@ sub form_header {
     $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
   }
 
-  my $vc = qq|
+  $vc = qq|
+      <input type="hidden" name="$form->{vc}_id" value="| . H($form->{"$form->{vc}_id"}) . qq|">
+      <input type="hidden" name="old$form->{vc}" value="| . H($form->{"old$form->{vc}"}) . qq|">
       <th align="right">| . $locale->text(ucfirst($form->{vc})) . qq|</th>
       <td>| . 
-        (($myconfig{vclimit} == 1 
-              ? qq|<input type="text" value="$form->{old$form->{vc}}" name="$form->{vc}">| 
+        (($myconfig{vclimit} <=  scalar(@values)
+              ? qq|<input type="text" value="| . H($form->{"old$form->{vc}"}) . qq|" name="$form->{vc}">| 
               : (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"}, 
                              '-onChange' => 'document.getElementById(\'update_button\').click();',
                              '-values' => \@values, '-labels' => \%labels)))) . qq|
@@ -1428,8 +1429,11 @@ sub search {
                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\></td>|;
   }
 
+  my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
+
   $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
-                                   "all" => 1 });
+                                   "all" => 1 },
+                   $vc => "ALL_" . uc($vc));
 
   my %labels = ();
   my @values = ("");
@@ -1441,6 +1445,24 @@ sub search {
     NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
                          '-labels' => \%labels));
 
+  %labels = ();
+  @values = ("");
+
+  foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
+    push(@values, $item->{name}.qq|--|.$item->{"id"});
+    $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+  }
+
+  my $vc_label = $form->{vc} eq "customer" ? $locale->text('Customer') : $locale->text('Vendor');
+  $vc =
+    $myconfig{vclimit} <=  scalar(@values)
+    ? qq|<input type="text" value="| . H($form->{"old$form->{vc}"}) . qq|" name="$form->{vc}">|
+    : NTI($cgi->popup_menu('-name' => "$form->{vc}",
+                           '-default' => $form->{"old$form->{vc}"},
+                           '-onChange' => 'document.getElementById(\'update_button\').click();',
+                           '-values' => \@values,
+                           '-labels' => \%labels));
+
   $form->header;
 
   print qq|
@@ -1457,7 +1479,8 @@ sub search {
     <td>
       <table>
         <tr>
-          $vc
+          <th align=right>$vc_label</th>
+          <td colspan=3>$vc</td>
         </tr>
        $department
         <tr>
@@ -1556,12 +1579,6 @@ $jsscript
 sub orders {
   $lxdebug->enter_sub();
 
-  # split vendor / customer
-  ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
-    split(/--/, $form->{ $form->{vc} });
-
-  OE->transactions(\%myconfig, \%$form);
-
   $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
 
   # construct href
@@ -1569,11 +1586,18 @@ sub orders {
     qw(type vc login password transdatefrom transdateto
        open closed notdelivered delivered department
        transaction_description);
+  push @fields, $form->{vc};
   $href = "$form->{script}?action=orders&"
     . join("&", map { "${_}=" . E($form->{$_}) } @fields)
     . "&${ordnumber}=" . E($form->{$ordnumber});
   $callback = $href;
 
+  # split vendor / customer
+  ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
+    split(/--/, $form->{ $form->{vc} });
+
+  OE->transactions(\%myconfig, \%$form);
+
   @columns = (
     "transdate",               "reqdate",
     "id",                      "$ordnumber",
@@ -1927,6 +1951,10 @@ sub save_and_close {
     $form->isblank("transdate", $locale->text('Quotation Date missing!'));
   }
 
+  my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+  $form->{$idx} =~ s/^\s*//g;
+  $form->{$idx} =~ s/\s*$//g;
+
   $msg = ucfirst $form->{vc};
   $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
 
@@ -2018,6 +2046,10 @@ sub save {
     $form->isblank("transdate", $locale->text('Quotation Date missing!'));
   }
 
+  my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+  $form->{$idx} =~ s/^\s*//g;
+  $form->{$idx} =~ s/\s*$//g;
+
   $msg = ucfirst $form->{vc};
   $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
 
@@ -2495,6 +2527,8 @@ sub save_as_new {
   # Let Lx-Office assign a new order number if the user hasn't changed the
   # previous one. If it has been changed manually then use it as-is.
   my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+  $form->{$idx} =~ s/^\s*//g;
+  $form->{$idx} =~ s/\s*$//g;
   if ($form->{saved_xyznumber} &&
       ($form->{saved_xyznumber} eq $form->{$idx})) {
     delete($form->{$idx});