From: Sven Schöling Date: Fri, 23 Sep 2011 12:15:55 +0000 (+0200) Subject: bp::list_spool auf template umgestellt. X-Git-Tag: release-2.7.0beta1~266 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5bc7284448a240bfebdaba20a65f845708665bd6;p=kivitendo-erp.git bp::list_spool auf template umgestellt. --- diff --git a/bin/mozilla/bp.pl b/bin/mozilla/bp.pl index 87afc3293..8f34b19f6 100644 --- a/bin/mozilla/bp.pl +++ b/bin/mozilla/bp.pl @@ -210,261 +210,56 @@ sub print { } sub list_spool { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - + $::lxdebug->enter_sub; assert_bp_access(); - $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} }); - ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = - split(/--/, $form->{ $form->{vc} }); - - BP->get_spoolfiles(\%myconfig, \%$form); - - my $title = $form->escape($form->{title}); - my $href = "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title"; + # parse old vc picker + $::form->{ $::form->{vc} } = $::form->unescape($::form->{ $::form->{vc} }); + ($::form->{ $::form->{vc} }, $::form->{"$::form->{vc}_id"}) = split(/--/, $::form->{ $::form->{vc} }); - $title = $form->escape($form->{title}, 1); - my $callback = - "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title"; - my $option; + BP->get_spoolfiles(\%::myconfig, $::form); - if ($form->{ $form->{vc} }) { - $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1); - $href .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }); - $option = - ($form->{vc} eq 'customer') - ? $locale->text('Customer') - : $locale->text('Vendor'); - $option .= " : $form->{$form->{vc}}"; - } - if ($form->{account}) { - $callback .= "&account=" . $form->escape($form->{account}, 1); - $href .= "&account=" . $form->escape($form->{account}); - $option .= "\n
" if ($option); - $option .= $locale->text('Account') . " : $form->{account}"; - } - if ($form->{invnumber}) { - $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1); - $href .= "&invnumber=" . $form->escape($form->{invnumber}); - $option .= "\n
" if ($option); - $option .= $locale->text('Invoice Number') . " : $form->{invnumber}"; - } - if ($form->{ordnumber}) { - $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1); - $href .= "&ordnumber=" . $form->escape($form->{ordnumber}); - $option .= "\n
" if ($option); - $option .= $locale->text('Order Number') . " : $form->{ordnumber}"; - } - if ($form->{quonumber}) { - $callback .= "&quonumber=" . $form->escape($form->{quonumber}, 1); - $href .= "&quonumber=" . $form->escape($form->{quonumber}); - $option .= "\n
" if ($option); - $option .= $locale->text('Quotation Number') . " : $form->{quonumber}"; - } + my @href_options = ('vc', 'type', 'title', $::form->{vc}); - if ($form->{transdatefrom}) { - $callback .= "&transdatefrom=$form->{transdatefrom}"; - $href .= "&transdatefrom=$form->{transdatefrom}"; - $option .= "\n
" if ($option); - $option .= - $locale->text('From') . " " - . $locale->date(\%myconfig, $form->{transdatefrom}, 1); - } - if ($form->{transdateto}) { - $callback .= "&transdateto=$form->{transdateto}"; - $href .= "&transdateto=$form->{transdateto}"; - $option .= "\n
" if ($option); - $option .= - $locale->text('To') . " " - . $locale->date(\%myconfig, $form->{transdateto}, 1); - } - - my $name = ucfirst $form->{vc}; + my %option_texts = ( + customer => sub { $::locale->text('Customer') . " : $::form->{customer}" }, + vendor => sub { $::locale->text('Customer') . " : $::form->{vendor}" }, + account => sub { $::locale->text('Account') . " : $::form->{account}" }, + invnumber => sub { $::locale->text('Invoice Number') . " : $::form->{invnumber}" }, + ordnumber => sub { $::locale->text('Order Number') . " : $::form->{ordnumber}" }, + quonumber => sub { $::locale->text('Quotation Number') . " : $::form->{quonumber}" }, + transdatefrom => sub { $::locale->text('From') . " " . $::locale->date(\%::myconfig, $::form->{transdatefrom}, 1) }, + transdateto => sub { $::locale->text('To') . " " . $::locale->date(\%::myconfig, $::form->{transdateto}, 1) }, + ); - my @columns = qw(transdate); - if ($form->{type} =~ /_order$/) { - push @columns, "ordnumber"; + my @options; + for my $key ($::form->{vc}, qw(account invnumber ordnumber quonumber transdatefrom transdateto)) { + next unless $::form->{$key}; + push @href_options, $key; + push @options, $option_texts{$key} ? $option_texts{$key}->() : ''; } - if ($form->{type} =~ /_quotation$/) { - push @columns, "quonumber"; - } - - push @columns, qw(name spoolfile); - my @column_index = $form->sort_columns(@columns); - unshift @column_index, "checked"; - - my %column_header; - my %column_data; - - $column_header{checked} = " "; - $column_header{transdate} = - "" - . $locale->text('Date') - . ""; - $column_header{invnumber} = - "" - . $locale->text('Invoice') - . ""; - $column_header{ordnumber} = - "" - . $locale->text('Order') - . ""; - $column_header{quonumber} = - "" - . $locale->text('Quotation') - . ""; - $column_header{name} = - "" - . $locale->text($name) - . ""; - $column_header{spoolfile} = - "" . $locale->text('Spoolfile') . ""; - - $form->header; - - print qq| - - -
- - - - - - - - - - - - - - - -
$form->{title}
$option
- - -|; - - map { print "\n$column_header{$_}" } @column_index; - - print qq| - -|; - - # add sort and escape callback, this one we use for the add sub - $form->{callback} = $callback .= "&sort=$form->{sort}"; - - # escape callback for href - $callback = $form->escape($callback); - - my $i = 0; - my $j = 0; - my $spoolfile; - my $spool = $::lx_office_conf{paths}->{spool}; - - foreach my $ref (@{ $form->{SPOOL} }) { - - $i++; - - $form->{"checked_$i"} = "checked" if $form->{"checked_$i"}; - - if ($ref->{invoice}) { - $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir"; - } - my $module = "$ref->{module}.pl"; - - $column_data{transdate} = ""; - - if ($spoolfile eq $ref->{spoolfile}) { - $column_data{checked} = qq||; - } else { - $column_data{checked} = - qq||; - } - - $column_data{invnumber} = - ""; - $column_data{ordnumber} = - ""; - $column_data{quonumber} = - ""; - $column_data{name} = ""; - $column_data{spoolfile} = - qq| -{spoolfile}> -|; - - $spoolfile = $ref->{spoolfile}; - - $j++; - $j %= 2; - print " - -"; - - map { print "\n$column_data{$_}" } @column_index; - - print qq| - -|; + my $last_spoolfile; + for my $ref (@{ $::form->{SPOOL} }) { + $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir" if $ref->{invoice}; + $ref->{new_file} = $last_spoolfile ne $ref->{spoolfile}; + } continue { + $last_spoolfile = $ref->{spoolfile}; } - print qq| - - -
$ref->{transdate} {"checked_$i"} $form->{"checked_$i"}>{id}&type=$form->{type}&callback=$callback>$ref->{invnumber}{id}&type=$form->{type}&callback=$callback>$ref->{ordnumber}{id}&type=$form->{type}&callback=$callback>$ref->{quonumber}$ref->{name}{spoolfile}>$ref->{spoolfile}
-

- -
+ $::form->get_lists(printers => "ALL_PRINTERS"); - - - - - - - - -|; - -# if ($myconfig{printer}) { - print qq| -{transdateto}> -{transdatefrom}> -{invnumber}> -{ordnumber}> -{quonumber}> -{customer}> -{vendor}> - - - -|; - -$form->get_lists(printers=>"ALL_PRINTERS"); -print qq||; - -# } - - print qq| -
- - - -|; + $::form->header; + print $::form->parse_html_template('bp/list_spool', { + spool => $::lx_office_conf{paths}->{spool}, + href => build_std_url('bp.pl', @href_options), + is_invoice => scalar ($::form->{type} =~ /^invoice$/), + is_order => scalar ($::form->{type} =~ /_order$/), + is_quotation => scalar ($::form->{type} =~ /_quotation$/), + options => \@options, + }); - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub select_all { diff --git a/templates/webpages/bp/list_spool.html b/templates/webpages/bp/list_spool.html new file mode 100644 index 000000000..02e4b2682 --- /dev/null +++ b/templates/webpages/bp/list_spool.html @@ -0,0 +1,86 @@ +[%- USE L %] +[%- USE HTML %] +[%- USE LxERP %] +[%- USE T8 %] +[%- USE url %] +[% SET list_spool__callback = href _ '&sort=' _ sort %] + + +

[% title | html %]

+ +
+ +

+[% FOREACH option IN options %] + [% option %] + [% ', ' UNLESS loop.last %] +[% END %] +

+ + + + + +[%- IF is_invoice %] + +[%- END %] +[%- IF is_order %] + +[%- END %] +[%- IF is_quotation %] + +[%- END %] + + + +[%- FOREACH row = SPOOL %] + + + +[%- IF is_invoice %] + +[%- END %] +[%- IF is_order %] + +[%- END %] +[%- IF is_quotation %] + +[%- END %] + + + +[%- END %] + +[% L.hidden_tag('rowcount', SPOOL.size) %] + +
 [% L.link(href _ '&sort=transdate', LxERP.t8('Date')) %][% L.link(href _ '&sort=invoice', LxERP.t8('Invoice')) %][% L.link(href _ '&sort=ordnumber', LxERP.t8('Order')) %][% L.link(href _ '&sort=quonumber', LxERP.t8('Quotation')) %][% L.link(href _ '&sort=name', vc == 'customer' ? LxERP.t8('Customer') : LxERP.t8('Vendor')) %][% 'Spoolfile' | $T8 %]
[% SET list_spool__checked='checked_' _ loop.count; L.checkbox_tag(list_spool__checked, checked=$list_spool__checked) IF row.new_file %][% row.transdate %][% L.link(url(row.module _ '.pl', action='edit' ,type=type, callback=list_spool__callback, id=row.id), row.invnumber) %][% L.link(url(row.module _ '.pl', action='edit' ,type=type, callback=list_spool__callback, id=row.id), row.ordnumber) %][% L.link(url(row.module _ '.pl', action='edit' ,type=type, callback=list_spool__callback, id=row.id), row.quonumber) %][% row.name | html %][% L.link(spool _ '/' _ row.spoolfile, row.spoolfile) %][% L.hidden_tag('spoolfile_' _ loop.count, row.spoolfile) %]
+ +
+
+ +[% L.hidden_tag('callback', callback) %] +[% L.hidden_tag('title', title) %] +[% L.hidden_tag('vc', vc) %] +[% L.hidden_tag('type', type) %] +[% L.hidden_tag('sort', sort) %] +[% L.hidden_tag('account', account) %] + +[% L.hidden_tag('transdateto', transdateto) %] +[% L.hidden_tag('transdatefrom', transdatefrom) %] +[% L.hidden_tag('invnumber', invnumber) %] +[% L.hidden_tag('ordnumber', ordnumber) %] +[% L.hidden_tag('quonumber', quonumber) %] +[% L.hidden_tag('customer', customer) %] +[% L.hidden_tag('vendor', vendor) %] + +[% L.submit_tag('action', LxERP.t8('Remove')) %] +[% L.submit_tag('action', LxERP.t8('Print')) %] + +[% L.select_tag('printer', L.options_for_select(ALL_PRINTERS, title='printer_description')) %] + +
+ + + + +