Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2b9fab81

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID 2b9fab819f0cf1edc963fe7a0a618efb20b74648
  • Vorgänger 183d93d5
  • Nachfolger a40cecf8

Reclamation: Presenter ReclamationFilter added

Generate the filter html in a Presenter instead in _filter.html

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
5 5

  
6 6
use SL::Helper::Flash qw(flash_later);
7 7
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
8
use SL::Presenter::ReclamationFilter qw(filter);
8 9
use SL::Locale::String qw(t8);
9 10
use SL::SessionFile::Random;
10 11
use SL::PriceSource;
......
2100 2101
  }
2101 2102
  $column_defs{$_}->{text} ||= t8( $self->models->get_sort_spec->{$_}->{title} || $_ ) for keys %column_defs;
2102 2103

  
2103
  my @columns_to_show = grep { $::form->{"include_in_report_$_"}} keys %column_defs;
2104
  my @columns_to_show = grep { $::form->{active_in_report}->{"$_"} } keys %column_defs;
2104 2105
  unless (scalar(@columns_to_show)){ @columns_to_show = @default_columns; }
2105 2106

  
2106 2107
  my %active_in_report = map { $_ => 1 } @columns_to_show;
2107
  $self->models->add_additional_url_params(map { "include_in_report_" . $_ => 1 } @columns_to_show); #for reorder
2108
  $self->models->add_additional_url_params(map { "active_in_report." . $_ => 1 } @columns_to_show); #for reorder
2108 2109
  my %columns_in_report = map {$_ => $column_defs{$_}} @columns_to_show;
2109 2110

  
2110 2111
  ## add cvars TODO(Tamino): Add own cvars
......
2123 2124
  #my @cvar_column_form_names = ('_include_cvars_from_form', map { "include_cvars_" . $_->name } @{ $self->includeable_cvar_configs });
2124 2125

  
2125 2126
  # make all sortable
2126
  my @sortable    = keys %columns_in_report;
2127
  my @sortable = keys %columns_in_report;
2128

  
2129
  my $filter_html = SL::Presenter::ReclamationFilter::filter(
2130
    $::form->{filter}, $self->type, active_in_report => \%active_in_report
2131
  );
2127 2132

  
2128 2133
  $report->set_options(
2129 2134
    std_column_visibility => 1,
......
2132 2137
    raw_top_info_text     => $self->render(
2133 2138
     'reclamation/_report_top',
2134 2139
     { output => 0 },
2135
     type => $self->type,
2136
     active_in_report => \%active_in_report,
2140
     FILTER_HTML => $filter_html,
2137 2141
    ),
2138 2142
    raw_bottom_info_text  => $self->render(
2139 2143
     'reclamation/_report_bottom',
SL/Presenter/ReclamationFilter.pm
1
package SL::Presenter::ReclamationFilter;
2

  
3
use strict;
4

  
5
use SL::Presenter::EscapedText qw(escape is_escaped);
6
use SL::Presenter::Tag qw(html_tag input_tag select_tag date_tag checkbox_tag);
7
use SL::Locale::String qw(t8);
8

  
9
use Exporter qw(import);
10
our @EXPORT_OK = qw(
11
filter
12
);
13

  
14
use Carp;
15

  
16
sub filter {
17
  my ($filter, $reclamation_type, %params) = @_;
18

  
19
  $filter ||= undef; #filter should not be '' (empty string);
20
  my %default_filter_elements = ( # {{{
21
    'reason_names' => {
22
      'position' => 1,
23
      'text' => t8("Reclamation Reason"),
24
      'input_type' => 'input_tag',
25
      'input_name' => 'filter.reclamation_items.reason.name:substr::ilike',
26
      'input_default' => $filter->{reclamation_items}->{reason}->{'name:substr::ilike'},
27
      'active' => 1,
28
    },
29
    'id' => {
30
      'position' => 2,
31
      'text' => t8("Reclamation ID"),
32
      'input_type' => 'input_tag',
33
      'input_name' => 'filter.id:number',
34
      'input_default' =>$filter->{'id:number'},
35
      'report_id' => 'id',
36
      'active' => 1,
37
    },
38
    'record_number' => {
39
      'position' => 3,
40
      'text' => t8("Reclamation Number"),
41
      'input_type' => 'input_tag',
42
      'input_name' => 'filter.record_number:substr::ilike',
43
      'input_default' =>$filter->{'record_number:substr::ilike'},
44
      'report_id' => 'record_number',
45
      'active' => 1,
46
    },
47
    'employee_name' => {
48
      'position' => 4,
49
      'text' => t8("Employee Name"),
50
      'input_type' => 'input_tag',
51
      'input_name' => 'filter.employee.name:substr::ilike',
52
      'input_default' =>$filter->{employee}->{'name:substr::ilike'},
53
      'report_id' => 'employee_id',
54
      'active' => 1,
55
    },
56
    'salesman_name' => {
57
      'position' => 5,
58
      'text' => t8("Salesman Name"),
59
      'input_type' => 'input_tag',
60
      'input_name' => 'filter.salesman.name:substr::ilike',
61
      'input_default' =>$filter->{salesman}->{'name:substr::ilike'},
62
      'report_id' => 'salesman_id',
63
      'active' => 1,
64
    },
65
    # 6,7 for Customer/Vendor
66
    'customer_name' => {
67
      'position' => 6,
68
      'text' => t8("Customer Name"),
69
      'input_type' => 'input_tag',
70
      'input_name' => 'filter.customer.name:substr::ilike',
71
      'input_default' => $filter->{customer}->{'name:substr::ilike'},
72
      'report_id' => 'customer_id',
73
      'active' => ($reclamation_type eq 'sales_reclamation' ? 1 : 0),
74
    },
75
    'vendor_name' => {
76
      'position' => 6,
77
      'text' => t8("Vendor"),
78
      'input_type' => 'input_tag',
79
      'input_name' => 'filter.vendor.name:substr::ilike',
80
      'input_default' => $filter->{vendor}->{'name:substr::ilike'},
81
      'report_id' => 'vendor_id',
82
      'active' => ($reclamation_type eq 'purchase_reclamation' ? 1 : 0),
83
    },
84
    'customer_number' => {
85
      'position' => 7,
86
      'text' => t8("Customer Number"),
87
      'input_type' => 'input_tag',
88
      'input_name' => 'filter.customer.customernumber:substr::ilike',
89
      'input_default' => $filter->{customer}->{'customernumber:substr::ilike'},
90
      'active' => ($reclamation_type eq 'sales_reclamation' ? 1 : 0),
91
    },
92
    'vendor_number' => {
93
      'position' => 7,
94
      'text' => t8("Vendor Number"),
95
      'input_type' => 'input_tag',
96
      'input_name' => 'filter.vendor.vendornumber:substr::ilike',
97
      'input_default' => $filter->{vendor}->{'vendornumber:substr::ilike'},
98
      'active' => ($reclamation_type eq 'purchase_reclamation' ? 1 : 0),
99
    },
100
    'contact_name' => {
101
      'position' => 8,
102
      'text' => t8("Contact Name"),
103
      'input_type' => 'input_tag',
104
      'input_name' => 'filter.contact.cp_name:substr::ilike',
105
      'input_default' =>$filter->{contact}->{'cp_name:substr::ilike'},
106
      'report_id' => 'contact_id',
107
      'active' => 1,
108
    },
109
    'language_code' => {
110
      'position' => 9,
111
      'text' => t8("Language Code"),
112
      'input_type' => 'input_tag',
113
      'input_name' => 'filter.language.article_code:substr::ilike',
114
      'input_default' =>$filter->{language}->{'article_code:substr::ilike'},
115
      'report_id' => 'language_id',
116
      'active' => 1,
117
    },
118
    'department_description' => {
119
      'position' => 10,
120
      'text' => t8("Department Description"),
121
      'input_type' => 'input_tag',
122
      'input_name' => 'filter.department.description:substr::ilike',
123
      'input_default' =>$filter->{department}->{'description:substr::ilike'},
124
      'report_id' => 'department_id',
125
      'active' => 1,
126
    },
127
    'globalproject_projectnumber' => {
128
      'position' => 11,
129
      'text' => t8("Project Number"),
130
      'input_type' => 'input_tag',
131
      'input_name' => 'filter.globalproject.projectnumber:substr::ilike',
132
      'input_default' =>$filter->{globalproject}->{'projectnumber:substr::ilike'},
133
      'report_id' => 'globalproject_id',
134
      'active' => 1,
135
    },
136
    'globalproject_description' => {
137
      'position' => 12,
138
      'text' => t8("Project Description"),
139
      'input_type' => 'input_tag',
140
      'input_name' => 'filter.globalproject.description:substr::ilike',
141
      'input_default' =>$filter->{globalproject}->{'description:substr::ilike'},
142
      'active' => 1,
143
    },
144
    'cv_record_number' => {
145
      'position' => 13,
146
      'text' => ($reclamation_type eq 'sales_reclamation'
147
                  ? t8("Customer Record Number")
148
                  : t8("Vendor Record Number")
149
                ),
150
      'input_type' => 'input_tag',
151
      'input_name' => 'filter.cv_record_number:substr::ilike',
152
      'input_default' => $filter->{'cv_record_number:substr::ilike'},
153
      'report_id' => 'cv_record_number',
154
      'active' => 1,
155
    },
156
    'transaction_description' => {
157
      'position' => 14,
158
      'text' => t8("Description"),
159
      'input_type' => 'input_tag',
160
      'input_name' => 'filter.transaction_description:substr::ilike',
161
      'input_default' =>$filter->{'transaction_description:substr::ilike'},
162
      'report_id' => 'transaction_description',
163
      'active' => 1,
164
    },
165
    'notes' => {
166
      'position' => 15,
167
      'text' => t8("Notes"),
168
      'input_type' => 'input_tag',
169
      'input_name' => 'filter.notes:substr::ilike',
170
      'input_default' =>$filter->{'notes:substr::ilike'},
171
      'report_id' => 'notes',
172
      'active' => 1,
173
    },
174
    'intnotes' => {
175
      'position' => 16,
176
      'text' => t8("Internal Notes"),
177
      'input_type' => 'input_tag',
178
      'input_name' => 'filter.intnotes:substr::ilike',
179
      'input_default' =>$filter->{'intnotes:substr::ilike'},
180
      'report_id' => 'intnotes',
181
      'active' => 1,
182
    },
183
    'shippingpoint' => {
184
      'position' => 17,
185
      'text' => t8("Shipping Point"),
186
      'input_type' => 'input_tag',
187
      'input_name' => 'filter.shippingpoint:substr::ilike',
188
      'input_default' =>$filter->{'shippingpoint:substr::ilike'},
189
      'report_id' => 'shippingpoint',
190
      'active' => 1,
191
    },
192
    'shipvia' => {
193
      'position' => 18,
194
      'text' => t8("Ship via"),
195
      'input_type' => 'input_tag',
196
      'input_name' => 'filter.shipvia:substr::ilike',
197
      'input_default' =>$filter->{'shipvia:substr::ilike'},
198
      'report_id' => 'shipvia',
199
      'active' => 1,
200
    },
201
    'amount' => {
202
      'position' => 19,
203
      'text' => t8("Total"),
204
      'input_type' => 'input_tag',
205
      'input_name' => 'filter.amount:number',
206
      'input_default' =>$filter->{'amount:number'},
207
      'report_id' => 'amount',
208
      'active' => 1,
209
    },
210
    'netamount' => {
211
      'position' => 20,
212
      'text' => t8("Subtotal"),
213
      'input_type' => 'input_tag',
214
      'input_name' => 'filter.netamount:number',
215
      'input_default' =>$filter->{'netamount:number'},
216
      'report_id' => 'netamount',
217
      'active' => 1,
218
    },
219
    'delivery_term_description' => {
220
      'position' => 21,
221
      'text' => t8("Delivery Terms"),
222
      'input_type' => 'input_tag',
223
      'input_name' => 'filter.delivery_term.description:substr::ilike',
224
      'input_default' =>$filter->{delivery_term}->{'description:substr::ilike'},
225
      'report_id' => 'delivery_term_id',
226
      'active' => 1,
227
    },
228
    'payment_description' => {
229
      'position' => 22,
230
      'text' => t8("Payment Terms"),
231
      'input_type' => 'input_tag',
232
      'input_name' => 'filter.payment.description:substr::ilike',
233
      'input_default' =>$filter->{payment}->{'description:substr::ilike'},
234
      'report_id' => 'payment_id',
235
      'active' => 1,
236
    },
237
    'currency_name' => {
238
      'position' => 23,
239
      'text' => t8("Currency"),
240
      'input_type' => 'input_tag',
241
      'input_name' => 'filter.currency.name:substr::ilike',
242
      'input_default' =>$filter->{currency}->{'name:substr::ilike'},
243
      'report_id' => 'currency_id',
244
      'active' => 1,
245
    },
246
    'exchangerate' => {
247
      'position' => 24,
248
      'text' => t8("Exchangerate"),
249
      'input_type' => 'input_tag',
250
      'input_name' => 'filter.exchangerate:number',
251
      'input_default' =>$filter->{'exchangerate:number'},
252
      'report_id' => 'exchangerate',
253
      'active' => 1,
254
    },
255
    'taxincluded' => {
256
      'position' => 25,
257
      'text' => t8("Tax Included"),
258
      'input_type' => 'yes_no_tag',
259
      'input_name' => 'filter.taxincluded',
260
      'input_default' =>$filter->{taxincluded},
261
      'report_id' => 'taxincluded',
262
      'active' => 1,
263
    },
264
    'taxzone_description' => {
265
      'position' => 26,
266
      'text' => t8("Tax zone"),
267
      'input_type' => 'input_tag',
268
      'input_name' => 'filter.taxzone.description:substr::ilike',
269
      'input_default' =>$filter->{taxzone}->{'description:substr::ilike'},
270
      'report_id' => 'taxzone_id',
271
      'active' => 1,
272
    },
273
    'tax_point' => {
274
      'position' => 27,
275
      'text' => t8("Tax point"),
276
      'input_type' => 'date_tag',
277
      'input_name' => 'tax_point',
278
      'input_default_ge' => $filter->{'tax_pont' . ':date::ge'},
279
      'input_default_le' => $filter->{'tax_pont' . ':date::le'},
280
      'report_id' => 'tax_point',
281
      'active' => 1,
282
    },
283
    'reqdate' => {
284
      'position' => 28,
285
      'text' => t8("Due Date"),
286
      'input_type' => 'date_tag',
287
      'input_name' => 'reqdate',
288
      'input_default_ge' => $filter->{'reqdate' . ':date::ge'},
289
      'input_default_le' => $filter->{'reqdate' . ':date::le'},
290
      'report_id' => 'reqdate',
291
      'active' => 1,
292
    },
293
    'transdate' => {
294
      'position' => 29,
295
      'text' => t8("Booking Date"),
296
      'input_type' => 'date_tag',
297
      'input_name' => 'transdate',
298
      'input_default_ge' => $filter->{'transdate' . ':date::ge'},
299
      'input_default_le' => $filter->{'transdate' . ':date::le'},
300
      'report_id' => 'transdate',
301
      'active' => 1,
302
    },
303
    'itime' => {
304
      'position' => 30,
305
      'text' => t8("Creation Time"),
306
      'input_type' => 'date_tag',
307
      'input_name' => 'itime',
308
      'input_default_ge' => $filter->{'itime' . ':date::ge'},
309
      'input_default_le' => $filter->{'itime' . ':date::le'},
310
      'report_id' => 'itime',
311
      'active' => 1,
312
    },
313
    'mtime' => {
314
      'position' => 31,
315
      'text' => t8("Last modification Time"),
316
      'input_type' => 'date_tag',
317
      'input_name' => 'mtime',
318
      'input_default_ge' => $filter->{'mtime' . ':date::ge'},
319
      'input_default_le' => $filter->{'mtime' . ':date::le'},
320
      'report_id' => 'mtime',
321
      'active' => 1,
322
    },
323
    'delivered' => {
324
      'position' => 32,
325
      'text' => t8("Delivered"),
326
      'input_type' => 'yes_no_tag',
327
      'input_name' => 'filter.delivered',
328
      'input_default' =>$filter->{delivered},
329
      'report_id' => 'delivered',
330
      'active' => 1,
331
    },
332
    'closed' => {
333
      'position' => 33,
334
      'text' => t8("Closed"),
335
      'input_type' => 'yes_no_tag',
336
      'input_name' => 'filter.closed',
337
      'input_default' =>$filter->{closed},
338
      'report_id' => 'closed',
339
      'active' => 1,
340
    },
341
  ); # }}}
342

  
343
  # combine default and param values for filter_element,
344
  # only replace the lowest occurrence
345
  my %filter_elements = %default_filter_elements;
346
  while(my ($key, $value) = each (%{$params{filter_elements}})) {
347
    if(exists $filter_elements{$key}) {
348
      $filter_elements{$key} = ({
349
        %{$filter_elements{$key}},
350
        %{$value},
351
      });
352
    } else {
353
      $filter_elements{$key} = $value;
354
    }
355
  }
356

  
357
  my @filter_element_params =
358
    sort { $a->{position} <=> $b->{position} }
359
    grep { $_->{active} }
360
    values %filter_elements;
361

  
362
  my @filter_elements;
363
  for my $filter_element_param (@filter_element_params) {
364
    unless($filter_element_param->{active}) {
365
      next;
366
    }
367

  
368
    my $filter_element = _create_input_element($filter_element_param, %params);
369

  
370
    push @filter_elements, $filter_element;
371
  }
372

  
373
  my $filter_form_div = _create_filter_form_div(\@filter_elements, %params);
374

  
375
  is_escaped($filter_form_div);
376
}
377

  
378
sub _create_input_element {
379
  my ($element_param, %params) = @_;
380

  
381
  my $element_th =  html_tag('th', $element_param->{text}, align => 'right');
382

  
383
  my $element_input = '';
384

  
385
  if($element_param->{input_type} eq 'input_tag') {
386

  
387
    $element_input = input_tag($element_param->{input_name}, $element_param->{input_default});
388

  
389
  } elsif ($element_param->{input_type} eq 'yes_no_tag') {
390

  
391
    $element_input = select_tag($element_param->{input_name}, [ [ 1 => t8('Yes') ], [ 0 => t8('No') ] ], default => $element_param->{input_default}, with_empty => 1)
392

  
393
  } elsif($element_param->{input_type} eq 'date_tag') {
394

  
395
    my $after_input =
396
      html_tag('th', t8("After"), align => 'right') .
397
      html_tag('td',
398
        date_tag("filter." . $element_param->{input_name} . ":date::ge", $element_param->{input_default_ge})
399
      )
400
    ;
401
    my $before_input =
402
      html_tag('th', t8("Before"), align => 'right') .
403
      html_tag('td',
404
        date_tag("filter." . $element_param->{input_name} . ":date::le", $element_param->{input_default_le})
405
      )
406
    ;
407

  
408
    $element_input =
409
      html_tag('table',
410
        html_tag('tr', $after_input)
411
        .
412
        html_tag('tr', $before_input)
413
      )
414
    ;
415
  }
416

  
417
  my $element_input_td =  html_tag('td',
418
    $element_input,
419
    nowrap => 1,
420
  );
421

  
422
  my $element_checkbox_td =  '';
423
  unless($params{no_show} || $element_param->{report_id} eq '') {
424
    my $checkbox =  checkbox_tag('active_in_report.' . $element_param->{report_id}, checked => $params{active_in_report}->{$element_param->{report_id}}, for_submit => 1);
425
    $element_checkbox_td = html_tag('td', $checkbox);
426
  }
427

  
428
  return $element_th . $element_input_td . $element_checkbox_td;
429
}
430

  
431
sub _create_filter_form_div {
432
  my ($ref_elements, %params) = @_;
433

  
434
  my $toggle_button_show =  html_tag('a', t8('Show Filter'), href => '#', onclick => '$(".filter_toggle").toggle()' );
435
  my $toggle_button_show_div = html_tag('div', $toggle_button_show, class => 'filter_toggle', style => 'display:none');
436

  
437

  
438
  my $toggle_button_hide =  html_tag('a', t8('Hide Filter'), href => '#', onclick => '$(".filter_toggle").toggle()' );
439

  
440
  my $filter_table = _create_input_div($ref_elements, %params);
441

  
442
  my $filter_form = html_tag('form', $filter_table, method => 'post', action => 'controller.pl', id => 'search_form');
443
  my $filter_form_div = $toggle_button_show_div . html_tag('div', $toggle_button_hide . $filter_form . $toggle_button_hide, class => 'filter_toggle');
444

  
445
  return $filter_form_div;
446
}
447

  
448
sub _create_input_div {
449
  my ($ref_elements, %params) = @_;
450
  my @elements = @{$ref_elements};
451

  
452
  my $div_columns = "";
453

  
454
  $params{count_columns} ||= 4;
455
  my $elements_per_column = (int((scalar(@{$ref_elements}) - 1) / $params{count_columns}) + 1);
456
  for my $i (0 .. ($params{count_columns} - 1)) {
457

  
458
    my $rows = "";
459
    for my $j (0 .. ($elements_per_column - 1) ) {
460
      my $idx = $elements_per_column * $i + $j;
461
      my $element = $elements[$idx];
462
      $rows .= html_tag('tr', $element);
463

  
464
    }
465
    $div_columns .= html_tag('div',
466
      html_tag('table',
467
        html_tag('tr',
468
          html_tag('td')
469
          . html_tag('th', t8('Filter'))
470
          . ( $params{no_show} ? '' : html_tag('th', t8('Show')) )
471
        )
472
        . $rows
473
      ),
474
      style => "flex:1");
475
  }
476
  
477
  my $input_div = html_tag('div', $div_columns, style => "display:flex;flex-wrap:wrap");
478

  
479
  return $input_div;
480
}
481

  
482
1;
483

  
484
__END__
485

  
486
=pod
487

  
488
=encoding utf8
489

  
490
=head1 NAME
491

  
492
SL::Presenter::ReclamationFilter - Presenter module for a generic Filter on
493
Reclamation.
494

  
495
=head1 SYNOPSIS
496

  
497
  # in Reclamation Controller
498
  my $filter_html = SL::Presenter::ReclamationFilter::filter(
499
    $::form->{filter}, $self->type, active_in_report => $::form->{active_in_report}
500
  );
501

  
502

  
503
=head1 FUNCTIONS
504

  
505
=over 4
506

  
507
=item C<filter $filter, $reclamation_type, %params>
508

  
509
Returns a rendered version (actually an instance of
510
L<SL::Presenter::EscapedText>) of a filter form for reclamations of type
511
C<$reclamation_type>.
512

  
513
C<$filter> should be the C<filter> value of the last C<$::form>. This is used to
514
get the previous values of the input fields.
515

  
516
C<%params> can include:
517

  
518
=over 2
519

  
520
=item * no_show
521

  
522
If falsish (the default) then a check box is added after the input field. Which
523
specifies whether the corresponding column appears in the report. The value of
524
the check box can be changed by the user.
525

  
526
=item * active_in_report
527

  
528
If C<$params{no_show}> is falsish, this is used to set the values of the check
529
boxes, after the input fields. This can be set to the C<active_in_report> value
530
of the last C<$::form>.
531

  
532
=item * filter_elements
533

  
534
Is combined with the default filter elements. This can be used to override
535
default values of the filter elements or to add a new ones.
536

  
537
  #deactivate the id and record_number fields
538
  $params{filter_elements} = ({
539
    id => {active => 0},
540
    record_number => {active => 0}
541
  });
542

  
543
=back
544

  
545
=back
546

  
547
=head1 FILTER ELEMENTS
548

  
549
A filter element is stored in and as a hash map. Each filter has a unique key
550
and should have entries for:
551

  
552
=over 4
553

  
554
=item * position
555

  
556
Is a number after which the elements are ordered. This can be a float.
557

  
558
=item * text
559

  
560
Is shown before the input field.
561

  
562
=item * input_type
563

  
564
This must be C<input_tag>, C<yes_no_tag> or C<date_tag>. It sets the input type
565
for the filter.
566

  
567
=over 2
568

  
569
=item * input_tag
570

  
571
Creates a text input field. The default value of this field is set to the
572
C<input_default> entry of the filter element. C<input_name> is used to set the
573
name of the field, which should match the filter syntax.
574

  
575
=item * yes_no_tag
576

  
577
Creates a yes/no input field. The default value of this field is set to the
578
C<input_default> entry of the filter element. C<input_name> is used to set the
579
name of the field, which should match the filter syntax.
580

  
581
=item * date_tag
582

  
583
Creates two date input fields. One filters for after the date and the other
584
filters for before the date. The default values of these fields are set to the
585
C<input_default_ge> and C<input_default_le> entries of the filter element.
586
C<input_name> is used to set the names of these fields, which should match the
587
filter syntax. For the first field ":date::ge" and for the second ":date::le" is
588
added to the end of C<input_name>.
589

  
590
=back
591

  
592
=item * report_id
593

  
594
Is used to generate the id of the check box after the input field. The value of
595
the check box can be found in the form under
596
C<$::form-E<gt>{'active_in_report'}-E<gt>{report_id}>.
597

  
598
=item * active
599

  
600
If falsish the element is ignored.
601

  
602
=item * input_name, input_default, input_default_ge, input_default_le
603

  
604
Look at I<input_tag> to see how they are used.
605

  
606
=back
607

  
608
=head1 BUGS
609

  
610
Nothing here yet.
611

  
612
=head1 AUTHOR
613

  
614
Tamino Steinert E<lt>tamino.steinert@tamino.stE<gt>
615

  
616
=cut
templates/webpages/reclamation/_filter.html
1
[%- USE HTML %][%- USE L %][%- USE LxERP %]
2

  
3
[%- SET filter_element_hash = {
4
'1' = {
5
  'text' = LxERP.t8("Reclamation Reason"),
6
  'input_type' = 'input_tag'
7
  'input_name' = 'filter.reclamation_items.reason.name:substr::ilike',
8
  'input_default' = filter.reclamation_items.reason.name_substr__ilike,
9
},
10
'2' = {
11
  'text' = LxERP.t8("Reclamation ID"),
12
  'input_type' = 'input_tag'
13
  'input_name' = 'filter.id:number',
14
  'input_default' = filter.id_number,
15
  'report_id' = 'id',
16
},
17
'3' = {
18
  'text' = LxERP.t8("Reclamation Number"),
19
  'input_type' = 'input_tag'
20
  'input_name' = 'filter.record_number:substr::ilike',
21
  'input_default' = filter.record_number_substr__ilike,
22
  'report_id' = 'record_number',
23
},
24
'4' = {
25
  'text' = LxERP.t8("Employee Name"),
26
  'input_type' = 'input_tag'
27
  'input_name' = 'filter.employee.name:substr::ilike',
28
  'input_default' = filter.employee.name_substr__ilike,
29
  'report_id' = 'employee_id',
30
},
31
'5' = {
32
  'text' = LxERP.t8("Salesman Name"),
33
  'input_type' = 'input_tag'
34
  'input_name' = 'filter.salesman.name:substr::ilike',
35
  'input_default' = filter.salesman.name_substr__ilike,
36
  'report_id' = 'salesman_id',
37
},
38
# 6,7 for Customer/Vendor
39
'8' = {
40
  'text' = LxERP.t8("Contact Name"),
41
  'input_type' = 'input_tag'
42
  'input_name' = 'filter.contact.cp_name:substr::ilike',
43
  'input_default' = filter.contact.cp_name_substr__ilike,
44
  'report_id' = 'contact_id',
45
},
46
'9' = {
47
  'text' = LxERP.t8("Language Code"),
48
  'input_type' = 'input_tag'
49
  'input_name' = 'filter.language.article_code:substr::ilike',
50
  'input_default' = filter.language.article_code_substr__ilike,
51
    'report_id' = 'language_id',
52
},
53
'10' = {
54
  'text' = LxERP.t8("Department Description"),
55
  'input_type' = 'input_tag'
56
  'input_name' = 'filter.department.description:substr::ilike',
57
  'input_default' = filter.department.description_substr__ilike,
58
    'report_id' = 'department_id',
59
},
60
'11' = {
61
  'text' = LxERP.t8("Project Number"),
62
  'input_type' = 'input_tag'
63
  'input_name' = 'filter.globalproject.projectnumber:substr::ilike',
64
  'input_default' = filter.globalproject.projectnumber_substr__ilike,
65
  'report_id' = 'globalproject_id',
66
},
67
'12' = {
68
  'text' = LxERP.t8("Project Description"),
69
  'input_type' = 'input_tag'
70
  'input_name' = 'filter.globalproject.description:substr::ilike',
71
  'input_default' = filter.globalproject.description_substr__ilike,
72
},
73
# 13 cv_record_number
74
'14' = {
75
  'text' = LxERP.t8("Description"),
76
  'input_type' = 'input_tag'
77
  'input_name' = 'filter.transaction_description:substr::ilike',
78
  'input_default' = filter.transaction_description_substr__ilike,
79
  'report_id' = 'transaction_description',
80
},
81
'15' = {
82
  'text' = LxERP.t8("Notes"),
83
  'input_type' = 'input_tag'
84
  'input_name' = 'filter.notes:substr::ilike',
85
  'input_default' = filter.notes_substr__ilike,
86
  'report_id' = 'notes',
87
},
88
'16' = {
89
  'text' = LxERP.t8("Internal Notes"),
90
  'input_type' = 'input_tag'
91
  'input_name' = 'filter.intnotes:substr::ilike',
92
  'input_default' = filter.intnotes_substr__ilike,
93
  'report_id' = 'intnotes',
94
},
95
'17' = {
96
  'text' = LxERP.t8("Shipping Point"),
97
  'input_type' = 'input_tag'
98
  'input_name' = 'filter.shippingpoint:substr::ilike',
99
  'input_default' = filter.shippingpoint_substr__ilike,
100
  'report_id' = 'shippingpoint',
101
},
102
'18' = {
103
  'text' = LxERP.t8("Ship via"),
104
  'input_type' = 'input_tag'
105
  'input_name' = 'filter.shipvia:substr::ilike',
106
  'input_default' = filter.shipvia_substr__ilike,
107
  'report_id' = 'shipvia',
108
},
109
'19' = {
110
  'text' = LxERP.t8("Total"),
111
  'input_type' = 'input_tag'
112
  'input_name' = 'filter.amount:number',
113
  'input_default' = filter.amount_number,
114
  'report_id' = 'amount',
115
},
116
'20' = {
117
  'text' = LxERP.t8("Subtotal"),
118
  'input_type' = 'input_tag'
119
  'input_name' = 'filter.netamount:number',
120
  'input_default' = filter.netamount_number,
121
  'report_id' = 'netamount',
122
},
123
'21' = {
124
  'text' = LxERP.t8("Delivery Term"),
125
  'input_type' = 'input_tag'
126
  'input_name' = 'filter.delivery_term.description:substr::ilike',
127
  'input_default' = filter.delivery_term.description_substr__ilike,
128
  'report_id' = 'delivery_term_id',
129
},
130
'22' = {
131
  'text' = LxERP.t8("Payment Term"),
132
  'input_type' = 'input_tag'
133
  'input_name' = 'filter.payment.description:substr::ilike',
134
  'input_default' = filter.payment.description_substr__ilike,
135
  'report_id' = 'payment_id',
136
},
137
'23' = {
138
  'text' = LxERP.t8("Currency"),
139
  'input_type' = 'input_tag'
140
  'input_name' = 'filter.currency.name:substr::ilike',
141
  'input_default' = filter.currency.name_substr__ilike,
142
  'report_id' = 'currency_id',
143
},
144
'24' = {
145
  'text' = LxERP.t8("Exchangerate"),
146
  'input_type' = 'input_tag'
147
  'input_name' = 'filter.exchangerate:number',
148
  'input_default' = filter.exchangerate_number,
149
  'report_id' = 'exchangerate',
150
},
151
'25' = {
152
  'text' = LxERP.t8("Tax included"),
153
  'input_type' = 'yes_no_tag'
154
  'input_name' = 'filter.taxincluded',
155
  'input_default' = filter.taxincluded,
156
  'report_id' = 'taxincluded',
157
},
158
'26' = {
159
  'text' = LxERP.t8("Tax Zone"),
160
  'input_type' = 'input_tag'
161
  'input_name' = 'filter.taxzone.description:substr::ilike',
162
  'input_default' = filter.taxzone.description_substr__ilike,
163
  'report_id' = 'taxzone_id',
164
},
165
'27' = {
166
  'text' = LxERP.t8("Tax Point"),
167
  'input_type' = 'date_tag'
168
  'input_name' = 'tax_point',
169
  'report_id' = 'tax_point',
170
},
171
'28' = {
172
  'text' = LxERP.t8("Due Date"),
173
  'input_type' = 'date_tag'
174
  'input_name' = 'reqdate',
175
  'report_id' = 'reqdate',
176
},
177
'29' = {
178
  'text' = LxERP.t8("Booking Date"),
179
  'input_type' = 'date_tag'
180
  'input_name' = 'transdate',
181
  'report_id' = 'transdate',
182
},
183
'30' = {
184
  'text' = LxERP.t8("Creation Time"),
185
  'input_type' = 'date_tag'
186
  'input_name' = 'itime',
187
  'report_id' = 'itime',
188
},
189
'31' = {
190
  'text' = LxERP.t8("Last modified Time"),
191
  'input_type' = 'date_tag'
192
  'input_name' = 'mtime',
193
  'report_id' = 'mtime',
194
},
195
'32' = {
196
  'text' = LxERP.t8("Delivered"),
197
  'input_type' = 'yes_no_tag'
198
  'input_name' = 'filter.delivered',
199
  'input_default' = filter.delivered,
200
  'report_id' = 'delivered',
201
},
202
'33' = {
203
  'text' = LxERP.t8("Closed"),
204
  'input_type' = 'yes_no_tag'
205
  'input_name' = 'filter.closed',
206
  'input_default' = filter.closed,
207
  'report_id' = 'closed',
208
},
209

  
210
} %]
211

  
212
[%- IF SELF.type == 'sales_reclamation' %]
213
[%- filter_element_hash.import( {
214
  '6' = {
215
    'text' = LxERP.t8("Customer Name"),
216
    'input_type' = 'input_tag'
217
    'input_name' = 'filter.customer.name:substr::ilike',
218
    'input_default' = filter.customer.name_substr__ilike,
219
    'report_id' = 'customer_id',
220
  },
221
  '7' = {
222
    'text' = LxERP.t8("Customer Number"),
223
    'input_type' = 'input_tag'
224
    'input_name' = 'filter.customer.customernumber:substr::ilike',
225
    'input_default' = filter.customer.customernumber_substr__ilike,
226
  }
227
  '13' = {
228
    'text' = LxERP.t8("Customer Record Numeber"),
229
    'input_type' = 'input_tag'
230
    'input_name' = 'filter.cv_record_number:substr::ilike',
231
    'input_default' = filter.cv_record_number_substr__ilike,
232
    'report_id' = 'cv_record_number',
233
  },
234
} ) %]
235
[%- ELSE %]
236
[%- filter_element_hash.import( {
237
  '6' = {
238
    'text' = LxERP.t8("Vendor"),
239
    'input_type' = 'input_tag'
240
    'input_name' = 'filter.vendor.name:substr::ilike',
241
    'input_default' = filter.vendor.name_substr__ilike,
242
    'report_id' = 'vendor_id',
243
  },
244
  '7' = {
245
    'text' = LxERP.t8("Vendor Number"),
246
    'input_type' = 'input_tag'
247
    'input_name' = 'filter.vendor.vendornumber:substr::ilike',
248
    'input_default' = filter.vendor.vendornumber_substr__ilike,
249
  }
250
  '13' = {
251
    'text' = LxERP.t8("Vendor Record Numeber"),
252
    'input_type' = 'input_tag'
253
    'input_name' = 'filter.cv_record_number:substr::ilike',
254
    'input_default' = filter.cv_record_number_substr__ilike,
255
    'report_id' = 'cv_record_number',
256
  },
257
} ) %]
258
[%- END %]
259
[% # L.dump(filter_element_list) %]
260
[% # L.dump(active_in_report) %]
261

  
262
<div class="filter_toggle" style="display:none">
263
 <a href="#" onClick="$('.filter_toggle').toggle(); $('#filter_customer_name_substr_ilike').focus();">[% LxERP.t8("Show Filter") %]</a>
264
</div>
265

  
266
<div class="filter_toggle">
267
 <a href="#" onClick="javascript:$('.filter_toggle').toggle()">[% LxERP.t8("Hide Filter") %]</a>
268

  
269
 <form method="post" action="controller.pl" id="search_form">
270
  [%- L.hidden_tag("_include_cvars_from_form", 1) %]
271

  
272
  <p>
273
   <table>
274
    [%- SET count=0 %]
275
    [%- SET table_size_count=0 %]
276
    [%- SET size = filter_element_hash.size %]
277
    <tr> <td>
278
     <table>
279
      [%- WHILE count < size %]
280
      [%- SET count=count + 1 %]
281
      [%- SET filter_element = filter_element_hash.${count} %]
282
      <tr>
283
       <th align="right">[% filter_element.text %]</th>
284
       [%- IF filter_element.input_type == 'input_tag' %]
285
         <td>[% L.input_tag(filter_element.input_name, filter_element.input_default)%]</td>
286
       [%- ELSIF filter_element.input_type == 'yes_no_tag' %]
287
         <td align="middle">[% L.yes_no_tag(filter_element.input_name, NONE , default=filter_element.input_default, with_empty=1) %]</td>
288
       [%- ELSIF filter_element.input_type == 'date_tag' %]
289
         <td>
290
          <table>
291
           <tr>
292
            <th> [% LxERP.t8("After") %] </th>
293
            <td>[% L.date_tag("filter.${filter_element.input_name}:date::ge", filter.${"${filter_element.input_name}_date__ge"})%]</td>
294
           </tr><tr>
295
            <th> [% LxERP.t8("Before") %] </th>
296
            <td>[% L.date_tag("filter.${filter_element.input_name}:date::le", filter.${"${filter_element.input_name}_date__le"})%]</td>
297
           </tr>
298
          </table>
299
         [%- SET table_size_count=table_size_count + 1 %]
300
         </td>
301
       [%- END %]
302
       [%- IF filter_element.report_id %]
303
       <td align="left">[% L.checkbox_tag("include_in_report_${filter_element.report_id}", checked=active_in_report.${filter_element.report_id}, for_submit=1) %]</td>
304
       [%- END %]
305
      </tr>
306
      [%- SET table_size_count=table_size_count + 1 %]
307
    [%- IF (table_size_count > 7) %]
308
    [%- SET table_size_count=0 %]
309
     </table>
310
    </td>
311
    <td>
312
     <table>
313
    [%- END %]
314
      [%- END %]
315
     </table>
316
    </td> </tr>
317

  
318
    [%- FOREACH cvar_cfg = SELF.cvar_configs %]
319
    [%- IF cvar_cfg.searchable %]
320
    <tr>
321
      <th align="right">[% HTML.escape(cvar_cfg.description) %]</th>
322
      <td>[% INCLUDE 'common/render_cvar_filter_input.html' cvar_cfg=cvar_cfg cvar_ %]</td>
323
    </tr>
324
    [%- END %]
325
    [%-END %]
326

  
327
    [%- IF SELF.includeable_cvar_configs.size %]
328
     <tr>
329
      <th align="right">[% LxERP.t8("Include in Report") %]</th>
330
      <td>
331
       <table>
332
        <tr>
333
         [%- FOREACH cvar_cfg = SELF.includeable_cvar_configs %]
334
          <td>
335
           [%- name__ = cvar_cfg.name;
336
              L.checkbox_tag("include_cvars_" _ name__, value="1", checked=(SELF.include_cvars.$name__ ? 1 : ''), label=cvar_cfg.description) %]
337
          </td>
338
          [%- IF !loop.last && ((loop.count % 3) == 0) %]
339
           </tr><tr>
340
          [%- END %]
341
         [%- END %]
342
        </tr>
343
       </table>
344
      </td>
345
     </tr>
346
    [%- END %]
347

  
348
   </table>
349
  </p>
350
 </form>
351
 <p>
352
 <a href="#" onClick="javascript:$('.filter_toggle').toggle()">[% LxERP.t8("Hide Filter") %]</a>
353
</div>
354

  
templates/webpages/reclamation/_report_top.html
1 1
[%- USE L %]
2
[%- PROCESS "reclamation/_filter.html" filter=SELF.models.filtered.laundered active_in_report=active_in_report %]
2
[%- FILTER_HTML %]
3 3
 <hr>

Auch abrufbar als: Unified diff