sub _pre_render {
my ($self) = @_;
+ $self->{template_args}->{conf_vertreter} = $::instance_conf->get_vertreter();
+
my $dbh = $::form->get_standard_dbh();
my $query;
$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();
$self->{shiptos} = $self->{cv}->shipto;
$self->{shiptos} ||= [];
- $self->{template_args} = {};
+ $self->{template_args} ||= {};
$::request->{layout}->add_javascripts('autocomplete_customer.js');
}
<tr height="5"></tr>
- [% IF ( conf_vertreter ) %]<!-- == $::lx_office_conf{features}->{vertreter}; -->
+ [% IF ( conf_vertreter ) %]
<tr>
<th align="right">
[% IF SELF.is_vendor() %]
</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>