"Vertreter" sind Kunden mit Kundentyp mit Vertreter-Flag, nicht die Kundentypen selber
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 4 Mar 2010 11:08:15 +0000 (12:08 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 4 Mar 2010 11:08:15 +0000 (12:08 +0100)
SL/Form.pm
bin/mozilla/ct.pl
templates/webpages/ct/form_header_de.html
templates/webpages/ct/form_header_master.html

index 82f073e..9561205 100644 (file)
@@ -2299,14 +2299,15 @@ $main::lxdebug->enter_sub();
 sub _get_customers {
   $main::lxdebug->enter_sub();
 
-  my ($self, $dbh, $key, $limit) = @_;
-
-  $key = "all_customers" unless ($key);
-  my $limit_clause = "LIMIT $limit" if $limit;
+  my ($self, $dbh, $key) = @_;
 
-  my $query = qq|SELECT * FROM customer WHERE NOT obsolete ORDER BY name $limit_clause|;
+  my $options        = ref $key eq 'HASH' ? $key : { key => $key };
+  $options->{key}  ||= "all_customers";
+  my $limit_clause   = "LIMIT $options->{limit}" if $options->{limit};
+  my $where          = $options->{business_is_salesman} ? qq| AND business_id IN (SELECT id FROM business WHERE salesman)| : '';
 
-  $self->{$key} = selectall_hashref_query($self, $dbh, $query);
+  my $query = qq|SELECT * FROM customer WHERE NOT obsolete $where ORDER BY name $limit_clause|;
+  $self->{ $options->{key} } = selectall_hashref_query($self, $dbh, $query);
 
   $main::lxdebug->leave_sub();
 }
@@ -2473,11 +2474,7 @@ sub get_lists {
   }
 
   if($params{"customers"}) {
-    if (ref $params{"customers"} eq 'HASH') {
-      $self->_get_customers($dbh, $params{"customers"}{key}, $params{"customers"}{limit});
-    } else {
-      $self->_get_customers($dbh, $params{"customers"});
-    }
+    $self->_get_customers($dbh, $params{"customers"});
   }
 
   if($params{"vendors"}) {
index c2d3b90..7fe6afa 100644 (file)
@@ -285,11 +285,12 @@ sub form_header {
   my %myconfig = %main::myconfig;
   my $locale   = $main::locale;
 
-  $form->get_lists(employees      => "ALL_EMPLOYEES",
-                   taxzones       => "ALL_TAXZONES",
-                   business_types => { key => 'ALL_SALESMAN_BUSINESSES', salesman => 1 });
+  $form->get_lists(employees => "ALL_EMPLOYEES",
+                   taxzones  => "ALL_TAXZONES");
   $form->get_pricegroup(\%myconfig, { all => 1 });
 
+  $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::vertreter;
+
   $form->{ALL_SALESMEN}   = $form->{ALL_EMPLOYEES};
   $form->{taxincluded}    = ($form->{taxincluded}) ? "checked" : "";
   $form->{is_admin}       = $myconfig{role} eq 'admin';
index 4113f0d..2cf95ad 100644 (file)
        <th align="right">Vertreter</th>
        <td>
         [%- INCLUDE generic/multibox.html
-              name       = 'salesman_id',
-              DATA       = ALL_SALESMAN_BUSINESSES,
-              show_empty = 1,
-              id_key     = 'id',
-              label_key  = 'description',
+              name      = 'salesman_id',
+              DATA      = ALL_SALESMAN_CUSTOMERS,
+              id_key    = 'id',
+              label_key = 'name',
         -%]
        </td>
       </tr>
              label_key  = 'description',
        -%]
       </td>
-      [%- IF is_customer && !use_vertreter %]
+      [%- IF is_customer && !conf_vertreter %]
       <th align="right">Verkäufer/in</th>
       <td>
        [%- INCLUDE generic/multibox.html
index 33ecfef..4c2db99 100644 (file)
        <th align="right"><translate>Representative</translate></th>
        <td>
         [%- INCLUDE generic/multibox.html
-              name       = 'salesman_id',
-              DATA       = ALL_SALESMAN_BUSINESSES,
-              show_empty = 1,
-              id_key     = 'id',
-              label_key  = 'description',
+              name      = 'salesman_id',
+              DATA      = ALL_SALESMAN_CUSTOMERS,
+              id_key    = 'id',
+              label_key = 'name',
         -%]
        </td>
       </tr>
              label_key  = 'description',
        -%]
       </td>
-      [%- IF is_customer && !use_vertreter %]
+      [%- IF is_customer && !conf_vertreter %]
       <th align="right"><translate>Salesman</translate></th>
       <td>
        [%- INCLUDE generic/multibox.html