Filtern/Anzeigen von Kunden-/Lieferanten-CVars in Angebots/Auftrags-Berichten
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 3 Dec 2012 11:37:24 +0000 (12:37 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 28 Apr 2015 13:08:07 +0000 (15:08 +0200)
Conflicts:

SL/OE.pm
bin/mozilla/oe.pl
templates/webpages/oe/search.html

SL/OE.pm
bin/mozilla/oe.pl
templates/webpages/oe/search.html

index 8702154..b8dd560 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -281,6 +281,15 @@ SQL
     push @values, conv_date($form->{expected_billing_date_to});
   }
 
+  my ($cvar_where, @cvar_values) = CVar->build_filter_query('module'         => 'CT',
+                                                            'trans_id_field' => 'ct.id',
+                                                            'filter'         => $form,
+                                                           );
+  if ($cvar_where) {
+    $query .= qq| AND ($cvar_where)|;
+    push @values, @cvar_values;
+  }
+
   my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
   my $sortorder = join(', ', map { "${_} ${sortdir} " } ("o.id", $form->sort_columns("transdate", $ordnumber, "name"), "o.itime"));
   my %allowed_sort_columns = (
index dd8db43..93e9f2a 100644 (file)
@@ -774,6 +774,12 @@ sub search {
                    "business_types" => "ALL_BUSINESS_TYPES",);
   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
 
+  $form->{CT_CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'CT');
+  ($form->{CT_CUSTOM_VARIABLES_FILTER_CODE},
+   $form->{CT_CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables'      => $form->{CT_CUSTOM_VARIABLES},
+                                                                              'include_prefix' => 'l_',
+                                                                              'include_value'  => 'Y');
+
   # constants and subs for template
   $form->{vc_keys}         = sub { "$_[0]->{name}--$_[0]->{id}" };
 
@@ -883,12 +889,20 @@ sub orders {
 
   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
+  my $ct_cvar_configs = CVar->get_configs('module' => 'CT');
+  my @ct_includeable_custom_variables = grep { $_->{includeable} } @{ $ct_cvar_configs };
+  my @ct_searchable_custom_variables  = grep { $_->{searchable} }  @{ $ct_cvar_configs };
+
+  my %column_defs_cvars            = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @ct_includeable_custom_variables;
+  push @columns, map { "cvar_$_->{name}" } @ct_includeable_custom_variables;
+
   my @hidden_variables = map { "l_${_}" } @columns;
   push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber cusordnumber
                                                         transaction_description transdatefrom transdateto type vc employee_id salesman_id
                                                         reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive
                                                         business_id shippingpoint taxzone_id reqdate_unset_or_old insertdatefrom insertdateto
                                                         order_probability_op order_probability_value expected_billing_date_from expected_billing_date_to);
+  push @hidden_variables, map { "cvar_$_->{name}" } @ct_searchable_custom_variables;
 
   my   @keys_for_url = grep { $form->{$_} } @hidden_variables;
   push @keys_for_url, 'taxzone_id' if $form->{taxzone_id} ne ''; # taxzone_id could be 0
@@ -930,6 +944,7 @@ sub orders {
     'order_probability'       => { 'text' => $locale->text('Order probability'), },
     'expected_billing_date'   => { 'text' => $locale->text('Exp. bill. date'), },
     'expected_netamount'      => { 'text' => $locale->text('Exp. netamount'), },
+    %column_defs_cvars,
   );
 
   foreach my $name (qw(id transdate reqdate quonumber ordnumber cusordnumber name employee salesman shipvia transaction_description shippingpoint taxzone insertdate)) {
@@ -948,6 +963,12 @@ sub orders {
   $report->set_export_options('orders', @hidden_variables, qw(sort sortdir));
   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
 
+  CVar->add_custom_variables_to_report('module'         => 'CT',
+                                       'trans_id_field' => "$form->{vc}_id",
+                                       'configs'        => $ct_cvar_configs,
+                                       'column_defs'    => \%column_defs,
+                                       'data'           => $form->{OE});
+
   my @options;
   my ($department) = split m/--/, $form->{department};
 
index c881211..323fd23 100644 (file)
      </td>
     </tr>
 [%- END %]
+
+[%- IF CT_CUSTOM_VARIABLES.size %]
+    <tr>
+      <td></td>
+      <td colspan=4 align=left><b>[% 'Custom variables for module' | $T8 %]: [%'Customers and vendors' | $T8 %]</td>
+    </tr>
+    [% CT_CUSTOM_VARIABLES_FILTER_CODE %]
+[%- END %]
+
     <tr>
      <th align="right">[% 'Include in Report' | $T8 %]</th>
      <td colspan="5">
          <label for="l_ustid">[% 'USt-IdNr.' | $T8 %]</label>
         </td>
        </tr>
+
+      [% CT_CUSTOM_VARIABLES_INCLUSION_CODE %]
+
 [%- IF type == 'sales_order' %]
        <tr><td colspan="3"><hr></td></tr>
 [%- END %]