[freeside-commits] freeside/httemplate/edit/process cust_main_county-add.cgi, NONE, 1.1 cust_main_county-collapse.cgi, 1.8, 1.9 cust_main_county-remove.cgi, NONE, 1.1

Ivan,,, ivan at wavetail.420.am
Sat Jan 29 22:33:43 PST 2011


Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail.420.am:/tmp/cvs-serv30546/edit/process

Modified Files:
	cust_main_county-collapse.cgi 
Added Files:
	cust_main_county-add.cgi cust_main_county-remove.cgi 
Log Message:
improve tax edit UI: add more counties & remove individual counties, RT#11144

--- NEW FILE: cust_main_county-remove.cgi ---
<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?".
                             "country=". uri_escape($cgi->param('country')).";".
                             'state='.   uri_escape($cgi->param('state')).  ';'.
                             'county='.  uri_escape($cgi->param('county'))
                 )
%>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

$cgi->param('taxnum') =~ /^(\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

my %search = (
               'country' => $cust_main_county->country,
               'state'   => $cust_main_county->state,
             );

$search{'county'} = $cust_main_county->county
  if $cust_main_county->city;

my $error = $cust_main_county->delete;
die $error if $error;

unless ( qsearch('cust_main_county', \%search) ) {

  #if we're the last, clear our (state?)/county/city and reinsert

  $cust_main_county->taxnum('');
  if ( $cust_main_county->city ) {
    $cust_main_county->city('');
  } elsif ( $cust_main_county->county ) {
    $cust_main_county->county('');
  } else {
    die "can't remove that";
  }

  my $error = $cust_main_county->insert;
  die $error if $error;

}

</%init>

Index: cust_main_county-collapse.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/cust_main_county-collapse.cgi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- cust_main_county-collapse.cgi	12 Oct 2009 01:45:12 -0000	1.8
+++ cust_main_county-collapse.cgi	30 Jan 2011 06:33:41 -0000	1.9
@@ -1,11 +1,15 @@
-<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi") %>
+<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?".
+                             "country=". uri_escape($cgi->param('country')).";".
+                             'state='.   uri_escape($cgi->param('state')).  ';'.
+                             'county='.  uri_escape($cgi->param('county'))
+                 )
+%>
 <%init>
 
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
-my($query) = $cgi->keywords;
-$query =~ /^(\d+)$/ or die "Illegal taxnum!";
+$cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
 my $taxnum = $1;
 my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } )
   or die "Unknown taxnum $taxnum";
@@ -37,9 +41,12 @@
 $cust_main_county->taxnum('');
 if ( $cust_main_county->city ) {
   $cust_main_county->city('');
-} else {
+} elsif ( $cust_main_county->county ) {
   $cust_main_county->county('');
+} else {
+  die "can't collapse that";
 }
+
 my $error = $cust_main_county->insert;
 die $error if $error;
 

--- NEW FILE: cust_main_county-add.cgi ---
<% include('/elements/header-popup.html', 'Addition successful' ) %>

<SCRIPT TYPE="text/javascript">
  window.top.location.reload();
</SCRIPT>

</BODY>
</HTML>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

$cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
my $taxnum = $1;
my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
  or die ("Unknown taxnum!");

my @expansion = split /[\n\r]{1,2}/, $cgi->param('expansion');

@expansion=map {
  unless ( /^\s*([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)\s*$/ ) {
    $cgi->param('error', "Illegal item in expansion: $_");
    print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string );
    myexit();
  }
  $1;
} @expansion;

foreach ( @expansion ) {
  my(%hash)=$cust_main_county->hash;
  my($new)=new FS::cust_main_county \%hash;
  $new->setfield('taxnum','');
  if ( $cgi->param('what') eq 'state' ) { #??
    $new->setfield('state',$_);
  } elsif ( $cgi->param('what') eq 'county' ) {
    $new->setfield('county',$_);
  } elsif ( $cgi->param('what') eq 'city' ) {
    #uppercase cities in the US to try and agree with USPS validation
    $new->setfield('city', $new->country eq 'US' ? uc($_) : $_ );
  } else { #???
    die 'unknown what '. $cgi->param('what');
  }
  my $error = $new->insert;
  die $error if $error;
}

</%init>



More information about the freeside-commits mailing list