summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/cust_main_county.cgi59
-rw-r--r--httemplate/edit/bulk-cust_main_county.html30
-rw-r--r--httemplate/edit/cust_main_county.html4
-rw-r--r--httemplate/edit/process/bulk-cust_main_county.html11
-rw-r--r--httemplate/elements/city.html4
-rw-r--r--httemplate/elements/dropdown-menu.html5
-rw-r--r--httemplate/elements/select-city.html176
-rw-r--r--httemplate/misc/process/tax_edit_excel.html9
-rw-r--r--httemplate/misc/tax_edit_excel.html70
9 files changed, 272 insertions, 96 deletions
diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi
index 552327836..9df8fed0b 100755
--- a/httemplate/browse/cust_main_county.cgi
+++ b/httemplate/browse/cust_main_county.cgi
@@ -260,6 +260,21 @@ if ( $country && $state &&
}
$cgi->delete('county');
+my $city = '';
+if ( $country && $state && $county &&
+ $cgi->param('city') =~
+ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/
+ )
+{
+ $city = $1;
+ if ( $city eq '__NONE__' ) {
+ $title = "No city, $title";
+ } else {
+ $title = "$city city, $title";
+ }
+}
+$cgi->delete('city');
+
$title = " for $title" if $title;
my $taxclass = '';
@@ -279,12 +294,18 @@ my $filter_change =
"window.location = '". $cgi->self_url.
";country=' + encodeURIComponent( document.getElementById('country').options[document.getElementById('country').selectedIndex].value ) + ".
"';state=' + encodeURIComponent( document.getElementById('state').options[document.getElementById('state').selectedIndex].value ) +".
- "';county=' + encodeURIComponent( document.getElementById('county').options[document.getElementById('county').selectedIndex].value );";
+ "';county=' + encodeURIComponent( document.getElementById('county').options[document.getElementById('county').selectedIndex].value )";
+
+$filter_change .= " +';city=' + encodeURIComponent( document.getElementById('city').options[document.getElementById('city').selectedIndex].value )"
+ if $conf->exists('enable_taxclasses');
+
+$filter_change .= ";";
#restore this so pagination works
$cgi->param('country', $country) if $country;
$cgi->param('state', $state ) if $state;
$cgi->param('county', $county ) if $county;
+$cgi->param('city', $city ) if $city;
$cgi->param('taxclass', $county ) if $taxclass;
my $html_posttotal =
@@ -338,6 +359,31 @@ if ( scalar(@counties) > 1 ) {
'</SELECT>';
}
+if ( $conf->exists('enable_taxclasses') ) {
+ my @cities = ( $country && $state && $county ) ? cities($county, $state, $country) : ();
+ if ( scalar(@cities) > 1 ) {
+ $html_posttotal .=
+ ' show city: '.
+ include('/elements/select-city.html',
+ 'country' => $country,
+ 'state' => $state,
+ 'county' => $county,
+ 'city' => $city,
+ 'onchange' => $filter_change,
+ 'empty_label' => '(all)',
+ 'empty_data_label' => '(none)',
+ 'empty_data_value' => '__NONE__',
+ 'disable_empty' => 0,
+ 'disable_cityupdate' => 1,
+ );
+ } else {
+ $html_posttotal .=
+ '<SELECT NAME="city" ID="city" STYLE="display:none">'.
+ ' <OPTION VALUE="" SELECTED>'.
+ '</SELECT>';
+ }
+}
+
$html_posttotal .= ' )';
my $bulk_popup_link =
@@ -412,7 +458,7 @@ my $html_foot = <<END;
|
<A HREF="javascript:void(0);" onClick="bulkPopup('edit');">Bulk edit selected</A>
|
-<A HREF="${p}misc/tax_edit_excel.html",">bulk edit with excel file</A>
+<A HREF="javascript:void(0);" onClick="bulkPopup('edit_rate_only');">Bulk edit rate only selected</A>
END
my $hashref = {};
@@ -434,6 +480,15 @@ if ( $county ) {
$count_query .= ' AND county = '. dbh->quote($county);
}
}
+if ( $city ) {
+ if ( $city eq '__NONE__' ) {
+ $hashref->{'city'} = '';
+ $count_query .= " AND ( city = '' OR city IS NULL ) ";
+ } else {
+ $hashref->{'city'} = $city;
+ $count_query .= ' AND city = '. dbh->quote($city);
+ }
+}
if ( $taxclass ) {
$hashref->{'taxclass'} = $taxclass;
$count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
diff --git a/httemplate/edit/bulk-cust_main_county.html b/httemplate/edit/bulk-cust_main_county.html
index 8b1234825..650fa7857 100644
--- a/httemplate/edit/bulk-cust_main_county.html
+++ b/httemplate/edit/bulk-cust_main_county.html
@@ -3,6 +3,7 @@
<FORM ACTION="<% popurl(1)."process/bulk-cust_main_county.html" %>" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="<% $action %>">
+<INPUT TYPE="hidden" NAME="rate_only" VALUE="<% $rate_only %>">
<INPUT TYPE="hidden" NAME="taxnum" VALUE="<% join(',', @taxnum) %>">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
@@ -45,11 +46,13 @@
</TR>
% }
-<% include('/elements/tr-input-text.html',
+% unless ($rate_only) {
+ <% include('/elements/tr-input-text.html',
'field' => 'taxname',
'label' => 'Tax name'
)
-%>
+ %>
+% }
<% include('/elements/tr-input-percentage.html',
'field' => 'tax',
@@ -57,27 +60,29 @@
)
%>
-<% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %>
+% unless ($rate_only) {
+ <% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %>
-<% include('/elements/tr-checkbox.html',
+ <% include('/elements/tr-checkbox.html',
'field' => 'setuptax',
'value' => 'Y',
'label' => 'This tax not applicable to setup fees',
)
-%>
+ %>
-<% include('/elements/tr-checkbox.html',
+ <% include('/elements/tr-checkbox.html',
'field' => 'recurtax',
'value' => 'Y',
'label' => 'This tax not applicable to recurring fees',
)
-%>
+ %>
-<% include('/elements/tr-input-money.html',
+ <% include('/elements/tr-input-money.html',
'field' => 'exempt_amount',
'label' => 'Monthly exemption per customer ($25 "Texas tax")',
)
-%>
+ %>
+% }
</TABLE>
@@ -97,8 +102,13 @@ $cgi->param('taxnum') =~ /^([\d,]+)$/
or $m->comp('/elements/errorpage-popup.html', $cgi->param('error') || 'Nothing selected');
my @taxnum = split(',', $1);
-$cgi->param('action') =~ /^(add|edit)$/ or die "unknown action";
+$cgi->param('action') =~ /^(add|edit|edit_rate_only)$/ or die "unknown action";
my $action = $1;
+my $rate_only;
+if ($action eq "edit_rate_only") {
+ $action = "edit";
+ $rate_only = 1;
+}
my $title = "Bulk $action tax rate";
my @cust_main_county =
diff --git a/httemplate/edit/cust_main_county.html b/httemplate/edit/cust_main_county.html
index 9cc5131a2..b0823098f 100644
--- a/httemplate/edit/cust_main_county.html
+++ b/httemplate/edit/cust_main_county.html
@@ -14,6 +14,7 @@
'setuptax' => 'This tax not applicable to setup fees',
'recurtax' => 'This tax not applicable to recurring fees',
'exempt_amount' => 'Monthly exemption per customer ($25 "Texas tax")',
+ 'charge_prediscount' => 'Charge this tax prior to any discounts',
},
'fields' => \@fields,
)
@@ -60,6 +61,9 @@ push @fields,
'taxname',
{ field=>'tax', type=>'percentage', },
+ { type=>'tablebreak-tr-title', value=>'Charging options' },
+ { field=>'charge_prediscount', type=>'checkbox', value=>'Y', },
+
{ type=>'tablebreak-tr-title', value=>'Exemptions' },
{ field=>'setuptax', type=>'checkbox', value=>'Y', },
{ field=>'recurtax', type=>'checkbox', value=>'Y', },
diff --git a/httemplate/edit/process/bulk-cust_main_county.html b/httemplate/edit/process/bulk-cust_main_county.html
index b5a0258b1..55832e9c5 100644
--- a/httemplate/edit/process/bulk-cust_main_county.html
+++ b/httemplate/edit/process/bulk-cust_main_county.html
@@ -27,6 +27,8 @@ my @taxnum = split(',', $1);
$cgi->param('action') =~ /^(add|edit)$/ or die "unknown action";
my $action = $1;
+my $rate_only = $cgi->param('rate_only') if $cgi->param('rate_only');
+
my $error = '';
foreach my $taxnum ( @taxnum ) {
@@ -35,8 +37,13 @@ foreach my $taxnum ( @taxnum ) {
if ( $action eq 'edit' || $cust_main_county->tax == 0 ) { #let's replace
- foreach (qw( taxname tax exempt_amount setuptax recurtax )) {
- $cust_main_county->set( $_ => scalar($cgi->param($_)) )
+ if ($rate_only) {
+ $cust_main_county->set( tax => scalar($cgi->param('tax')) );
+ }
+ else {
+ foreach (qw( taxname tax exempt_amount setuptax recurtax )) {
+ $cust_main_county->set( $_ => scalar($cgi->param($_)) )
+ }
}
$error = $cust_main_county->replace and last;
diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html
index 05250fef5..3c5e91782 100644
--- a/httemplate/elements/city.html
+++ b/httemplate/elements/city.html
@@ -153,9 +153,7 @@ my %opt = @_;
my $pre = $opt{'prefix'};
my $conf = new FS::Conf;
-# Using tax_district_method implies that there's not a preloaded city/county
-# tax district table.
-my $disable_select = 1 if $conf->config('tax_district_method');
+my $disable_select = 0;
$opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'});
diff --git a/httemplate/elements/dropdown-menu.html b/httemplate/elements/dropdown-menu.html
index 54447a23f..3c0f40f75 100644
--- a/httemplate/elements/dropdown-menu.html
+++ b/httemplate/elements/dropdown-menu.html
@@ -5,12 +5,17 @@
border: none;
}
+% if ( $opt{id} !~ /customer_/ ) {
+% # Fix for changes to how jQuery UI applies state classes
+
#<% $opt{id} %> .ui-state-active {
color: inherit;
background-color: transparent;
border-color: transparent;
}
+% }
+
#<% $opt{id} %> li {
float: left;
padding: .25em;
diff --git a/httemplate/elements/select-city.html b/httemplate/elements/select-city.html
new file mode 100644
index 000000000..09e28dd48
--- /dev/null
+++ b/httemplate/elements/select-city.html
@@ -0,0 +1,176 @@
+<%doc>
+
+Example:
+
+ <& /elements/select-city.html,
+ #recommended
+ country => $current_country,
+ state => $current_state,
+ county => $current_county,
+ city => $current_city,
+
+ #optional
+ prefix => $optional_unique_prefix,
+ onchange => $javascript,
+ disabled => 0, #bool
+ disable_empty => 1, #defaults to 1, set to 0 to disable the empty option
+ empty_label => 'all', #label for empty option
+ style => [ 'attribute:value', 'another:value' ],
+ &>
+
+</%doc>
+% if ( $cityflag ) {
+
+ <% include('/elements/xmlhttp.html',
+ 'url' => $p.'misc/cities.cgi',
+ 'subs' => [ $pre. 'get_cities' ],
+ )
+ %>
+
+ <SCRIPT TYPE="text/javascript">
+
+ function opt(what,value,text) {
+ var optionName = new Option(text, value, false, false);
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function <% $pre %>county_changed(what, callback) {
+
+ what.form.<% $pre %>city.disabled = 'disabled';
+
+ county = what.form.<% $pre %>county.options[what.form.<% $pre %>county.selectedIndex].value;
+ state = what.options[what.selectedIndex].value;
+ country = what.form.<% $pre %>country.options[what.form.<% $pre %>country.selectedIndex].value;
+
+ function <% $pre %>update_cities(cities) {
+
+ // blank the current city list
+ for ( var i = what.form.<% $pre %>city.length; i >= 0; i-- )
+ what.form.<% $pre %>city.options[i] = null;
+
+% unless ( $opt{disable_empty} ) {
+ opt( what.form.<% $pre %>city, '', <% $opt{empty_label} |js_string %> );
+% }
+
+ // add the new cities
+ var citiesArray = eval('(' + cities + ')' );
+ for ( var s = 0; s < citiesArray.length; s++ ) {
+ var cityLabel = citiesArray[s];
+ if ( cityLabel == "" )
+ cityLabel = '(n/a)';
+ opt(what.form.<% $pre %>city, citiesArray[s], cityLabel);
+ }
+
+ var cityFormLabel = document.getElementById('<% $pre %>citylabel');
+
+ if ( citiesArray.length > 1 ) {
+ what.form.<% $pre %>city.style.display = '';
+ if ( cityFormLabel ) {
+ //cityFormLabel.style.visibility = 'visible';
+ cityFormLabel.style.display = '';
+ }
+ } else {
+ what.form.<% $pre %>city.style.display = 'none';
+ if ( cityFormLabel ) {
+ //cityFormLabel.style.visibility = 'hidden';
+ cityFormLabel.style.display = 'none';
+ }
+ }
+
+ what.form.<% $pre %>city.disabled = '';
+
+ //run the callback
+ if ( callback != null ) {
+ callback();
+ } else {
+ <% $pre %>city_changed(what.form.<% $pre %>city);
+ }
+ }
+
+ // go get the new cities
+ <% $pre %>get_cities( state, country, <% $pre %>update_cities );
+
+ }
+
+ </SCRIPT>
+
+ <SELECT NAME = "<% $pre %>city"
+ ID = "<% $pre %>city"
+ onChange= "<% $onchange %>"
+ <% $opt{'disabled'} %>
+ <% $style %>
+ >
+
+% unless ( $opt{'disable_empty'} ) {
+ <OPTION VALUE="" <% $opt{county} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %>
+% }
+
+% foreach my $city ( @cities ) {
+
+ <OPTION VALUE="<% $city |h %>"
+ <% $city eq $opt{'city'} ? 'SELECTED' : '' %>
+ ><% $city eq $opt{'empty_data_value'} ? $opt{'empty_data_label'} : $city %>
+
+% }
+
+ </SELECT>
+
+% } else {
+
+ <SCRIPT TYPE="text/javascript">
+ function <% $pre %>city_changed(what) {
+ }
+ </SCRIPT>
+
+ <SELECT NAME = "<% $pre %>city"
+ ID = "<% $pre %>city"
+ STYLE = "display:none"
+ >
+ <OPTION SELECTED VALUE="<% $opt{'city'} |h %>">
+ </SELECT>
+
+% }
+
+<%init>
+
+my %opt = @_;
+foreach my $opt (qw( city county state country prefix onchange disabled
+ empty_value )) {
+ $opt{$opt} = '' unless exists($opt{$opt}) && defined($opt{$opt});
+}
+
+$opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'});
+
+my $pre = $opt{'prefix'};
+
+my $onchange = $opt{'onchange'};
+
+my $city_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : [];
+
+my @cities = ();
+if ( $cityflag ) {
+
+ @cities = map { length($_) ? $_ : $opt{'empty_data_value'} }
+ cities( $opt{'county'}, $opt{'state'}, $opt{'country'} );
+
+ push @$city_style, 'display:none'
+ unless scalar(@cities) > 1;
+
+}
+
+my $style =
+ scalar(@$city_style)
+ ? 'STYLE="'. join(';', @$city_style). '"'
+ : '';
+
+</%init>
+<%once>
+
+my $sql = "SELECT COUNT(*) FROM cust_main_county".
+ " WHERE city IS NOT NULL AND city != ''";
+my $sth = dbh->prepare($sql) or die dbh->errstr;
+$sth->execute or die $sth->errstr;
+my $cityflag = $sth->fetchrow_arrayref->[0];
+
+</%once> \ No newline at end of file
diff --git a/httemplate/misc/process/tax_edit_excel.html b/httemplate/misc/process/tax_edit_excel.html
deleted file mode 100644
index a9928f902..000000000
--- a/httemplate/misc/process/tax_edit_excel.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<% $server->process %>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my $server = new FS::UI::Web::JSRPC 'FS::cust_main_county::process_edit_import', $cgi;
-
-</%init> \ No newline at end of file
diff --git a/httemplate/misc/tax_edit_excel.html b/httemplate/misc/tax_edit_excel.html
deleted file mode 100644
index 1546393d9..000000000
--- a/httemplate/misc/tax_edit_excel.html
+++ /dev/null
@@ -1,70 +0,0 @@
-<% include('/elements/header.html', 'Edit tax rates with Excel' ) %>
-
-% # 'name' => 'RateImportForm',
-
-<& /elements/form-file_upload.html,
- 'name' => 'TaxEditForm',
- 'action' => 'process/tax_edit_excel.html',
- 'num_files' => 1,
- 'fields' => [ 'format' ],
- 'message' => 'Tax Rate edit successful',
- 'url' => $p."browse/cust_main_county.cgi",
- 'onsubmit' => "document.TaxEditForm.submitButton.disabled=true;"
-&>
-
-<% &ntable("#cccccc", 2) %>
-
- <TR>
- <TD ALIGN="left" COLSPAN=2>File format should be as follows:<BR>
- <TABLE>
- <TR><TD><B>Country</B> as standard two letter code</TD></TR>
- <TR><TD><B>State</B> as standard two letter code</TD></TR>
- <TR><TD><B>County name</B></TD></TR>
- <TR><TD><B>City name</B></TD></TR>
- <TR><TD><B>Tax name</B></TD></TR>
- <TR><TD><B>Tax rate</B></TD></TR>
- </TABLE><BR>
- * first row should be blank or contain headers<BR>
- * Tax rate should be formated as a number not percentage.
- <P>
- </TD>
- </TR>
- <TR>
- <TH ALIGN="left" COLSPAN=2>Upload tax rates with Excel (or other .XLS-compatible application)</TH>
- </TR>
-
-
- <% include( '/elements/file-upload.html',
- 'field' => 'file',
- 'label' => '',
- 'label_align' => 'left',
- )
- %>
-
- <INPUT TYPE="hidden" NAME="format" VALUE="default">
-
- <TR>
- <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
- <INPUT TYPE = "submit"
- ID = "submitButton"
- NAME = "submitButton"
- VALUE = "Upload"
- >
- </TD>
- </TR>
-
-
-</TABLE>
-
-<% include('/elements/footer.html') %>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my $sth = dbh->prepare('SELECT COUNT(*) FROM rate_detail WHERE conn_charge > 0 OR conn_sec > 0 LIMIT 1')
- or die dbh->errstr;
-$sth->execute or die $sth->errstr;
-my $have_conn = $sth->fetchrow_arrayref->[0];
-
-</%init> \ No newline at end of file