ACLs
[freeside.git] / httemplate / edit / cust_main_county-expand.cgi
1 <% include('/elements/header-popup.html', "Enter $title") %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% $p1 %>process/cust_main_county-expand.cgi" METHOD=POST>
6
7 <INPUT TYPE="hidden" NAME="taxnum" VALUE="<% $taxnum %>">
8 <INPUT TYPE="hidden" NAME="taxclass" VALUE="<% $taxclass |h %>">
9
10 <TEXTAREA NAME="expansion" COLS="50" ROWS="16"><% $expansion |h %></TEXTAREA>
11
12 <BR>
13 <INPUT TYPE="submit" VALUE="Add <% $title %>">
14
15 </FORM>
16 </BODY>
17 </HTML>
18
19 <%init>
20
21 die "access denied"
22   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
23
24 my($taxnum, $expansion, $taxclass);
25 my($query) = $cgi->keywords;
26 if ( $cgi->param('error') ) {
27   $taxnum = $cgi->param('taxnum');
28   $expansion = $cgi->param('expansion');
29   $taxclass = $cgi->param('taxclass');
30 } else {
31   $query =~ /^(taxclass)?(\d+)$/
32     or die "Illegal taxnum (query $query)";
33   $taxclass = $1 ? 'taxclass' : '';
34   $taxnum = $2;
35   $expansion = '';
36 }
37
38 my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
39   or die "cust_main_county.taxnum $taxnum not found";
40
41 my $title;
42 if ( $taxclass ) {
43   die "Can't expand entry!" if $cust_main_county->taxclass;
44
45   $title = 'Tax Classes';
46
47   # prepopuplate with other tax classes... which should really have a primary
48   #  key of their own... also this could be more efficient in the error case...
49   my $sth = dbh->prepare("SELECT DISTINCT taxclass FROM cust_main_county")
50     or die dbh->errstr;
51   $sth->execute or die $sth->errstr;
52   my %taxclasses = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
53   $expansion ||= join("\n", grep $_, keys %taxclasses );
54   
55 } else {
56   die "Can't expand entry!" if $cust_main_county->county;
57
58   if ( $cust_main_county->state ) {
59     $title = 'Counties';
60   } else {
61     $title = 'States/Provinces';
62   }
63
64 }
65
66 my $p1 = popurl(1);
67
68 </%init>