From: Thomas Heck Date: Mon, 15 Jul 2013 15:57:12 +0000 (+0200) Subject: CustomerVendor: Vertreter gefixt/implementiert X-Git-Tag: release-3.1.0beta1~161^2^2~10 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d76392bcf7a0d76951d943b139cce11af892698e;p=kivitendo-erp.git CustomerVendor: Vertreter gefixt/implementiert --- diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index cdff74c44..79379494a 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -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'); } diff --git a/templates/webpages/customer_vendor/tabs/billing.html b/templates/webpages/customer_vendor/tabs/billing.html index d2b422573..b82849127 100644 --- a/templates/webpages/customer_vendor/tabs/billing.html +++ b/templates/webpages/customer_vendor/tabs/billing.html @@ -8,7 +8,7 @@ - [% IF ( conf_vertreter ) %] + [% IF ( conf_vertreter ) %] [% IF SELF.is_vendor() %] @@ -29,8 +29,7 @@ - - [% 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) %] @@ -343,16 +342,16 @@ [% 'Salesman' | $T8 %] - - [% 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) %] + [%- END %] - [% 'taxincluded checked' | $T8 %] + [% 'taxincluded checked' | $T8 %] + + + [% 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) %] + - - [% 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) %] - - [%- END %]