Filtern/Anzeigen von Kunden-/Lieferanten-CVars in VK-Rechnungs-Berichten
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 24 Jun 2014 14:21:30 +0000 (16:21 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 28 Apr 2015 13:20:55 +0000 (15:20 +0200)
Conflicts:

bin/mozilla/ar.pl

SL/AR.pm
bin/mozilla/ar.pl
templates/webpages/ar/search.html

index 65ab4ce..74bfeee 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -573,6 +573,15 @@ sub ar_transactions {
     }
   };
 
+  my ($cvar_where, @cvar_values) = CVar->build_filter_query('module'         => 'CT',
+                                                            'trans_id_field' => 'c.id',
+                                                            'filter'         => $form,
+                                                           );
+  if ($cvar_where) {
+    $where .= qq| AND ($cvar_where)|;
+    push @values, @cvar_values;
+  }
+
   my @a = qw(transdate invnumber name);
   push @a, "employee" if $form->{l_employee};
   my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
index 2960001..6a024a3 100644 (file)
@@ -842,6 +842,12 @@ sub search {
   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 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}" };
 
@@ -898,8 +904,16 @@ sub ar_transactions {
        datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia
        marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype);
 
+  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", qw(open closed customer invnumber ordnumber cusordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id);
+  push @hidden_variables, map { "cvar_$_->{name}" } @ct_searchable_custom_variables;
 
   $href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables);
 
@@ -934,6 +948,7 @@ sub ar_transactions {
     'payment_terms'           => { 'text' => $locale->text('Payment Terms'), },
     'charts'                  => { 'text' => $locale->text('Buchungskonto'), },
     'customertype'            => { 'text' => $locale->text('Customer type'), },
+    %column_defs_cvars,
   );
 
   foreach my $name (qw(id transdate duedate invnumber ordnumber cusordnumber name datepaid employee shippingpoint shipvia transaction_description)) {
@@ -953,6 +968,12 @@ sub ar_transactions {
 
   $report->set_sort_indicator($form->{sort}, $form->{sortdir});
 
+  CVar->add_custom_variables_to_report('module'         => 'CT',
+                                       'trans_id_field' => 'customer_id',
+                                       'configs'        => $ct_cvar_configs,
+                                       'column_defs'    => \%column_defs,
+                                       'data'           => $form->{AR});
+
   my @options;
   if ($form->{customer}) {
     push @options, $locale->text('Customer') . " : $form->{customer}";
index 0790e2c..b43630f 100644 (file)
       [% L.date_tag('transdateto') %]
      </td>
     </tr>
+
+[%- 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 %]
+
    <input type=hidden name=sort value=transdate>
    </table>
     </td>
            <td align=right><input name="l_ustid" id="l_ustid" class=checkbox type=checkbox value=Y></td>
            <td nowrap>[% 'USt-IdNr.' | $T8 %]</td>
           </tr>
+
+          <table>
+            <tr><td align="right">
+            [% CT_CUSTOM_VARIABLES_INCLUSION_CODE %]
+            </td></tr>
+          </table>
+
          </table>
         </td>
        </tr>