summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-07-23 13:25:10 +0000
committerivan <ivan>2009-07-23 13:25:10 +0000
commitdbf7e7eb594830d3ac3db43039f470bb38489acf (patch)
tree6a596524af59fca41ce3c0138c8247aa41a3f294
parentcfaf9fea2cfb5cf14ad5f835e89fc2a34cc460de (diff)
add back remove ("collapse") links again. on each line this time. RT#2973
-rwxr-xr-xhttemplate/browse/cust_main_county.cgi47
-rwxr-xr-xhttemplate/edit/process/cust_main_county-collapse.cgi67
2 files changed, 65 insertions, 49 deletions
diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi
index 736d7fdbe..232e6883c 100755
--- a/httemplate/browse/cust_main_county.cgi
+++ b/httemplate/browse/cust_main_county.cgi
@@ -23,10 +23,6 @@
'link_onclicks' => \@link_onclicks,
)
%>
-%
-% # <FONT SIZE=-1><A HREF="<% $p %>edit/process/cust_main_county-collapse.cgi?<% $hashref->{taxnum} %>">collapse state</A></FONT>
-% # % }
-%
<%once>
my $conf = new FS::Conf;
@@ -102,6 +98,17 @@ sub expand_link {
'</FONT>';
}
+sub collapse_link {
+ my %param = @_;
+
+ my $taxnum = $param{'row'}->taxnum;
+ my $url = "${p}edit/process/cust_main_county-collapse.cgi?$taxnum";
+ $url = "javascript:collapse_areyousure('$url')";
+
+ qq(<FONT SIZE="-1"><A HREF="$url">$param{'label'}</A></FONT>);
+}
+
+
sub separate_taxclasses_link {
my( $row ) = @_;
my $taxnum = $row->taxnum;
@@ -110,6 +117,8 @@ sub separate_taxclasses_link {
qq!<FONT SIZE="-1"><A HREF="$url">!;
}
+#un-separate taxclasses too
+
</%once>
<%init>
@@ -122,9 +131,18 @@ my $enable_taxclasses = $conf->exists('enable_taxclasses');
my @menubar;
-my $html_init =
- "Click on <u>add states</u> to specify a country's tax rates by state or province.
- <BR>Click on <u>add counties</u> to specify a state's tax rates by county.";
+my $html_init = <<END;
+ <SCRIPT>
+ function collapse_areyousure(href) {
+ if (confirm("Are you sure you want to remove all county tax rates for this state?") == true)
+ window.location.href = href;
+ }
+ </SCRIPT>
+
+ Click on <u>add states</u> to specify a country's tax rates by state or province.
+ <BR>Click on <u>add counties</u> to specify a state's tax rates by county, or <u>remove counties</u> to remove per-county tax rates.
+END
+
$html_init .= "<BR>Click on <u>separate taxclasses</u> to specify taxes per taxclass."
if $enable_taxclasses;
$html_init .= '<BR><BR>';
@@ -360,11 +378,16 @@ my @fields = (
)
)
},
- sub { $_[0]->county || '(all)&nbsp'.
- expand_link( desc => 'Add Counties',
- row => $_[0],
- label => 'add&nbsp;counties',
- )
+ sub { $_[0]->county
+ ? $_[0]->county. '&nbsp'.
+ collapse_link( label=> 'remove&nbsp;counties',
+ row => $_[0],
+ )
+ : '(all)&nbsp'.
+ expand_link( desc => 'Add Counties',
+ row => $_[0],
+ label => 'add&nbsp;counties',
+ );
},
);
diff --git a/httemplate/edit/process/cust_main_county-collapse.cgi b/httemplate/edit/process/cust_main_county-collapse.cgi
index a917825ce..18bd1fde2 100755
--- a/httemplate/edit/process/cust_main_county-collapse.cgi
+++ b/httemplate/edit/process/cust_main_county-collapse.cgi
@@ -1,44 +1,37 @@
-%
-%
-%my($query) = $cgi->keywords;
-%$query =~ /^(\d+)$/ or die "Illegal taxnum!";
-%my $taxnum = $1;
-%my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
-% or die "Unknown taxnum $taxnum";
-%
-%#really should do this in a .pm & start transaction
-%
-%foreach my $delete ( qsearch('cust_main_county', {
-% 'country' => $cust_main_county->country,
-% 'state' => $cust_main_county->state
-% } ) ) {
-%# unless ( qsearch('cust_main',{
-%# 'state' => $cust_main_county->getfield('state'),
-%# 'county' => $cust_main_county->getfield('county'),
-%# 'country' => $cust_main_county->getfield('country'),
-%# } ) ) {
-% my $error = $delete->delete;
-% die $error if $error;
-%# } else {
-% #should really fix the $cust_main record
-%# }
-%
-%}
-%
-%$cust_main_county->taxnum('');
-%$cust_main_county->county('');
-%my $error = $cust_main_county->insert;
-%die $error if $error;
-%
-%print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi");
-%
-%
+<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi") %>
<%init>
-#this isn't actually linked from anywhere just now, but it will be again soon
-
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+my($query) = $cgi->keywords;
+$query =~ /^(\d+)$/ or die "Illegal taxnum!";
+my $taxnum = $1;
+my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
+ or die "Unknown taxnum $taxnum";
+
+#really should do this in a .pm & start transaction
+
+foreach my $delete ( qsearch('cust_main_county', {
+ 'country' => $cust_main_county->country,
+ 'state' => $cust_main_county->state
+ } ) ) {
+# unless ( qsearch('cust_main',{
+# 'state' => $cust_main_county->getfield('state'),
+# 'county' => $cust_main_county->getfield('county'),
+# 'country' => $cust_main_county->getfield('country'),
+# } ) ) {
+ my $error = $delete->delete;
+ die $error if $error;
+# } else {
+ #should really fix the $cust_main record
+# }
+
+}
+
+$cust_main_county->taxnum('');
+$cust_main_county->county('');
+my $error = $cust_main_county->insert;
+die $error if $error;
</%init>