CustomerVendor: Vertreter gefixt/implementiert
authorThomas Heck <theck@linet-services.de>
Mon, 15 Jul 2013 15:57:12 +0000 (17:57 +0200)
committerThomas Heck <theck@linet-services.de>
Tue, 16 Jul 2013 12:23:58 +0000 (14:23 +0200)
SL/Controller/CustomerVendor.pm
templates/webpages/customer_vendor/tabs/billing.html

index cdff74c..7937949 100644 (file)
@@ -681,6 +681,8 @@ sub _create_customer_vendor {
 sub _pre_render {
   my ($self) = @_;
 
+  $self->{template_args}->{conf_vertreter} = $::instance_conf->get_vertreter();
+
   my $dbh = $::form->get_standard_dbh();
 
   my $query;
@@ -723,9 +725,26 @@ sub _pre_render {
 
   $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all();
 
-  #Employee:
-  #TODO: ALL_SALESMAN
-  #TODO: ALL_SALESMAN_CUSTOMERS
+  if ( $::instance_conf->get_vertreter() ) {
+    $query =
+      'SELECT id
+       FROM business
+       WHERE salesman';
+    my $business_ids = [
+      map(
+        { $_->{id} }
+        selectall_hashref_query($::form, $dbh, $query)
+      )
+    ];
+
+    if ( $business_ids->[0] ) {
+      $self->{all_salesman_customers} = SL::DB::Manager::Customer->get_all(query => [business_id => $business_ids]);
+    } else {
+      $self->{all_salesman_customers} = [];
+    }
+  } else {
+    $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id,  deleted => 0 ] ]);
+  }
 
   $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
 
@@ -749,7 +768,7 @@ sub _pre_render {
   $self->{shiptos} = $self->{cv}->shipto;
   $self->{shiptos} ||= [];
 
-  $self->{template_args} = {};
+  $self->{template_args} ||= {};
 
   $::request->{layout}->add_javascripts('autocomplete_customer.js');
 }
index d2b4225..b828491 100644 (file)
@@ -8,7 +8,7 @@
 
     <tr height="5"></tr>
 
-    [% IF ( conf_vertreter ) %]<!-- == $::lx_office_conf{features}->{vertreter}; -->
+    [% IF ( conf_vertreter ) %]
       <tr>
         <th align="right">
           [% IF SELF.is_vendor() %]
@@ -29,8 +29,7 @@
         </th>
 
         <td>
-          <!-- TODO: ALL_SALESMAN_CUSTOMERS -->
-          [% L.select_tag('cv.salesman_id', SELF.all_employees, value_key = 'id', title_key = 'safe_name', with_empty = 1) %]
+          [% L.select_tag('cv.salesman_id', SELF.all_salesman_customers, default = SELF.cv.salesman_id, value_key = 'id', title_key = 'name', with_empty = 1) %]
         </td>
       </tr>
 
         <th align="right">[% 'Salesman' | $T8 %]</th>
 
         <td>
-          <!-- TODO: ALL_SALESMAN -->
-          [% L.select_tag('cv.salesman_id', SELF.all_employees, default = salesman_id, value_key = 'id', title_key = 'safe_name', with_empty = 1) %]
+          [% L.select_tag('cv.salesman_id', SELF.all_salesmen, default = SELF.cv.salesman_id, value_key = 'id', title_key = 'safe_name', with_empty = 1) %]
         </td>
+      [%- END %]
 
-        <td>[% 'taxincluded checked' | $T8 %]</td>
+      <td>[% 'taxincluded checked' | $T8 %]</td>
+
+      <td>
+        [% L.select_tag('cv.taxincluded_checked', [[undef, LxERP.t8('use user config')], ['1', LxERP.t8('Yes')], ['0', LxERP.t8('No')]], default = SELF.cv.taxincluded_checked) %]
+      </td>
 
-        <td>
-          [% L.select_tag('cv.taxincluded_checked', [[undef, LxERP.t8('use user config')], ['1', LxERP.t8('Yes')], ['0', LxERP.t8('No')]], default = SELF.cv.taxincluded_checked) %]
-        </td>
-      [%- END %]
     </tr>
   </table>