From 37f181cc0b65e4509dd68593cb7555db42d8e088 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 2 Apr 2008 20:42:44 +0000 Subject: [PATCH] checkpoint tax editors and correct a blunder --- FS/FS/Schema.pm | 4 +- FS/FS/part_pkg_taxoverride.pm | 6 +- httemplate/browse/tax_class.html | 92 +++++++++++++++++ httemplate/edit/part_pkg.cgi | 7 +- httemplate/edit/part_pkg_taxoverride.html | 157 +++++++++++++++++++++--------- httemplate/edit/process/part_pkg.cgi | 2 +- httemplate/search/elements/search.html | 25 ++++- 7 files changed, 233 insertions(+), 60 deletions(-) create mode 100755 httemplate/browse/tax_class.html diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index e431b0764..d4a51a60d 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1055,11 +1055,11 @@ sub tables_hashref { 'columns' => [ 'taxoverridenum', 'serial', '', '', '', '', 'pkgpart', 'serial', '', '', '', '', - 'taxnum', 'serial', '', '', '', '', + 'taxclassnum', 'serial', '', '', '', '', ], 'primary_key' => 'taxoverridenum', 'unique' => [], - 'index' => [ [ 'pkgpart' ], [ 'taxnum' ] ], + 'index' => [ [ 'pkgpart' ], [ 'taxclassnum' ] ], }, # 'part_title' => { diff --git a/FS/FS/part_pkg_taxoverride.pm b/FS/FS/part_pkg_taxoverride.pm index 656fe53e2..0fdfa5002 100644 --- a/FS/FS/part_pkg_taxoverride.pm +++ b/FS/FS/part_pkg_taxoverride.pm @@ -41,9 +41,9 @@ Primary key The package definition id -=item taxnum +=item taxclassnum -The tax rate definition id +The tax class id =back @@ -96,7 +96,7 @@ sub check { my $error = $self->ut_numbern('taxoverridenum') || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart') - || $self->ut_foreign_key('taxnum', 'tax_rate', 'taxnum') + || $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum') ; return $error if $error; diff --git a/httemplate/browse/tax_class.html b/httemplate/browse/tax_class.html new file mode 100755 index 000000000..76d266bf9 --- /dev/null +++ b/httemplate/browse/tax_class.html @@ -0,0 +1,92 @@ +<% include( 'elements/browse.html', + 'title' => "Tax classes $title", + 'name_singular' => 'tax class', + 'menubar' => \@menubar, + 'html_init' => $html_init, + 'query' => { + 'table' => 'tax_class', + 'hashref' => $hashref, + 'extra_sql' => $where, + 'order_by' => 'ORDER BY taxclass', + }, + 'count_query' => $count_query, + 'header' => \@header, + 'fields' => \@fields, + 'align' => $align, + 'links' => \@links, + 'link_onclicks' => \@link_onclicks, + 'disable_maxselect' => 1, + 'disable_total' => 1, + ) +%> +<%once> + +my $conf = new FS::Conf; + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $title = ''; +my @menubar = (); +my $html_init = ''; +my $hashref = {}; +my @where = (); +my $onclick = 'return true;'; + +my $omit = ''; +if ( $cgi->param('magic') eq 'omit' ) { + $cgi->param('omit') =~ /^([,\d]+)$/; + $omit = $1; + $title .= " unselected"; + push @where, map { "taxclassnum != $_" } grep {$_} split( /,/, $omit ); + $onclick = sub{ 'parent.doSelect('. shift->taxclassnum. '); return false;' } +} +$cgi->delete('omit'); + +my $data_vendor = ''; +if ( $cgi->param('datavendor') =~ /^([\w]+)$/ ) { + $data_vendor = $1; + $title .= " for data vendor $1"; + push @where, 'data_vendor = '. dbh->quote($data_vendor); +} +$cgi->delete('data_vendor'); + +my $selected = ''; +if ( $cgi->param('magic') eq 'select') +{ + $cgi->param('selected') =~ /^([,\d]*)$/; + $selected = $1; + $title = " selected"; + my @clauses = map { "taxclassnum = $_" } grep {$_} split( /,/, $selected ); + @where = scalar(@clauses) ? '( '. join(' OR ', @clauses) .')' : '1=0'; + $onclick = sub{ 'parent.doUnselect('. shift->taxclassnum. '); return false;' } ; +} +$cgi->delete('selected'); + + +if ( $data_vendor ) { + push @menubar, 'View all tax classes' => $p.'browse/tax_class.html'; +} + +$cgi->param('dummy', 1); + +#restore this so pagination works +$cgi->param('omit', $omit ) if $omit; +$cgi->param('selected', $selected ) if $selected; +$cgi->param('data_vendor', $data_vendor ) if $data_vendor; + +my $where = scalar(@where) ? 'WHERE '. join( ' AND ', @where ) : ''; +my $count_query = 'SELECT COUNT(*) FROM tax_class '. $where; + +my $link = [ 'javascript:void(0);', sub{ ''; } ]; + +my @header = ( '', '', '' ); +my @links = ( $link, $link, $link ); +my @link_onclicks = ( $onclick, $onclick, $onclick ); +my $align = 'lll'; +my @fields = ( 'data_vendor', 'taxclass', 'description' ); + + diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 84f7498e1..2e7c732e6 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -94,13 +94,13 @@ Tax information Tax product - + - + <% $tax_override ? 'Edit tax overrides' : 'Override taxes' %> @@ -467,7 +467,8 @@ if ( $cgi->param('clone') ) { (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1}) unless $part_pkg; $tax_override = - join (",", map {$_->taxnum} qsearch('part_pkg_taxoverride',{'pkgpart'=>$1})) + join (",", map {$_->taxclassnum} + qsearch('part_pkg_taxoverride',{'pkgpart'=>$1})) unless $part_pkg; $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); $pkgpart = $part_pkg->pkgpart; diff --git a/httemplate/edit/part_pkg_taxoverride.html b/httemplate/edit/part_pkg_taxoverride.html index 61cca1fbc..ba709ce64 100644 --- a/httemplate/edit/part_pkg_taxoverride.html +++ b/httemplate/edit/part_pkg_taxoverride.html @@ -1,61 +1,124 @@ -<%doc> +<% include('/elements/header-popup.html', 'Override taxes', '', 'onload="resizeFrames()"') %> - The crappy version - - -<% include('/elements/header-popup.html', 'Select tax product') %> + + + + + + + +
+ +
+
+ +
+ + +
+ +
+ +
+
- - -<% ntable("#cccccc", 2) %> - - Tax override - - <% include( '/elements/select-table.html', - 'table' => 'tax_rate', - 'name_col' => 'taxname', - 'curr_value' => \@curr_value, - 'element_etc' => "id='taxoverride_popup_select'", - 'multiple' => '1', - ) - %> - - - -

-
- + <% include('/elements/footer.html') %> +<%once> + +my $conf = new FS::Conf; + <%init> -my $conf = new FS::Conf; +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + + +my $selected_offset = $1 + if $cgi->param('selected_offset') =~/^(\d+)$/; -my @curr_value; -my ( $query ) = $cgi->keywords; -$query =~ /^([\d,]+)$/; -push @curr_value, split ',', $1 - if $1; +my $unselected_offset = $1 + if $cgi->param('unselected_offset') =~/^(\d+)$/; -unless (scalar(@curr_value)) { - #push @curr_value, map {$_=>taxnum} $part_pkg->tax_rate; -} +my $selected = $1 + if $cgi->param('selected') =~/^([,\d]+)$/; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index eac20af57..94bff0fbb 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -116,7 +116,7 @@ unless ( $error || $conf->exists('agent_defaultpkg') ) { unless ( $error ) { $error = $new->process_m2m( 'link_table' => 'part_pkg_taxoverride', - 'target_table' => 'tax_rate', + 'target_table' => 'tax_class', 'params' => \@tax_overrides, ); } diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index e1bc02450..40c71d812 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -93,6 +93,8 @@ Example: #disabling things 'disable_download' => '', # set true to hide the CSV/Excel download links + 'disable_total' => '', # set true to hide the total" + 'disable_maxselect' => '', # set true to disable record/page selection 'disable_nonefound' => '', # set true to disable the "No matching Xs found" # message @@ -291,6 +293,17 @@ Example: <% include( '/elements/header-popup.html', $opt{'title'} ) %> +% } elsif ( $type eq 'select' ) { + + <% include( '/elements/header-popup.html', $opt{'title'} ) %> + <% defined($opt{'html_init'}) + ? ( ref($opt{'html_init'}) + ? &{$opt{'html_init'}}() + : $opt{'html_init'} + ) + : '' + %> + % } else { % % my @menubar = (); @@ -330,14 +343,18 @@ Example:
- <% $total %> total <% $opt{'name'} %> +% if (! $opt{'disable_total'}) { + <% $total %> total <% $opt{'name'} %> +% } -% if ( $confmax && $total > $confmax && $type ne 'html-print' ) { +% if ( $confmax && $total > $confmax +% && ! $opt{'disable_maxselect'} +% && $type ne 'html-print' ) +% { % $cgi->delete('maxrecords'); % $cgi->param('_dummy', 1); %# ( show % foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) { @@ -770,7 +787,7 @@ if ( $opt{'disableable'} ) { } -my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|html(-print)?)$/ +my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|select|html(-print)?)$/ ? $1 : 'html'; my $limit = ''; -- 2.11.0