diff options
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/part_svc.cgi | 10 | ||||
-rw-r--r-- | httemplate/browse/part_virtual_field.cgi | 39 | ||||
-rw-r--r-- | httemplate/browse/router.cgi | 25 | ||||
-rw-r--r-- | httemplate/docs/upgrade10.html | 54 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 72 | ||||
-rw-r--r-- | httemplate/edit/part_virtual_field.cgi | 92 | ||||
-rw-r--r-- | httemplate/edit/process/router.cgi | 41 | ||||
-rw-r--r-- | httemplate/edit/process/svc_broadband.cgi | 36 | ||||
-rwxr-xr-x | httemplate/edit/router.cgi | 42 | ||||
-rwxr-xr-x | httemplate/edit/svc_acct.cgi | 12 | ||||
-rw-r--r-- | httemplate/edit/svc_broadband.cgi | 34 | ||||
-rw-r--r-- | httemplate/edit/svc_www.cgi | 12 | ||||
-rw-r--r-- | httemplate/index.html | 8 | ||||
-rwxr-xr-x | httemplate/view/svc_acct.cgi | 18 | ||||
-rw-r--r-- | httemplate/view/svc_broadband.cgi | 24 | ||||
-rwxr-xr-x | httemplate/view/svc_forward.cgi | 9 | ||||
-rw-r--r-- | httemplate/view/svc_www.cgi | 11 |
17 files changed, 303 insertions, 236 deletions
diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 7c83924a2..3fece2925 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -53,12 +53,13 @@ function part_export_areyousure(href) { <% foreach my $part_svc ( @part_svc ) { my $hashref = $part_svc->hashref; my $svcdb = $hashref->{svcdb}; - my @dfields = fields($svcdb); + my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } ); + my @dfields = $svc_x->fields; push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge my @fields = - grep { $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag } - @dfields; - + grep { $svc_x->pvf($_) + or $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag } + @dfields ; my $rowspan = scalar(@fields) || 1; my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}"; %> @@ -96,6 +97,7 @@ map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export <% if ( $flag eq "D" ) { print "Default"; } elsif ( $flag eq "F" ) { print "Fixed"; } + elsif ( not $flag ) { } else { print "(Unknown!)"; } %> </TD><TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD> diff --git a/httemplate/browse/part_virtual_field.cgi b/httemplate/browse/part_virtual_field.cgi new file mode 100644 index 000000000..9bb5c1373 --- /dev/null +++ b/httemplate/browse/part_virtual_field.cgi @@ -0,0 +1,39 @@ +<%= header('Virtual field definitions', menubar('Main Menu' => $p)) %> +<% + +my %pvfs; +my $block; +my $p2 = popurl(2); +my $dbtable; + +foreach (qsearch('part_virtual_field', {})) { + push @{ $pvfs{$_->dbtable} }, $_; +} +%> + +<% if ($cgi->param('error')) { %> + <FONT SIZE="+1" COLOR="#ff0000">Error: <%=$cgi->param('error')%></FONT> + <BR><BR> +<% } %> + +<A HREF="<%=$p2%>edit/part_virtual_field.cgi"><I>Add a new field</I></A><BR><BR> + +<% foreach $dbtable (sort { $a cmp $b } keys (%pvfs)) { %> +<H3><%=$dbtable%></H3> + +<%=table()%> +<TH><TD>Field name</TD><TD>Description</TD></TH> +<% foreach $pvf (sort {$a->name cmp $b->name} @{ $pvfs{$dbtable} }) { %> + <TR> + <TD></TD> + <TD> + <A HREF="<%=$p2%>edit/part_virtual_field.cgi?<%=$pvf->vfieldpart%>"> + <%=$pvf->name%></A></TD> + <TD><%=$pvf->label%></TD> + </TR> +<% } %> +</TABLE> +<% } %> +</BODY> +</HTML> + diff --git a/httemplate/browse/router.cgi b/httemplate/browse/router.cgi index 8864936d9..a9ec6fd61 100644 --- a/httemplate/browse/router.cgi +++ b/httemplate/browse/router.cgi @@ -14,21 +14,22 @@ my $p2 = popurl(2); <A HREF="<%=$p2%>edit/router.cgi"><I>Add a new router</I></A><BR><BR> <%=table()%> -<!-- <TH><TD>Field name</TD><TD>Field value</TD></TH> --> -<% foreach $router (sort {$a->routernum <=> $b->routernum} @router) { %> <TR> -<!-- <TD ROWSPAN="<%=scalar($router->router_field) + 2%>"> --> - <TD> + <TD><B>Router name</B></TD> + <TD><B>Address block(s)</B></TD> + </TR> +<% foreach $router (sort {$a->routernum <=> $b->routernum} @router) { + my @addr_block = $router->addr_block; +%> + <TR> + <TD ROWSPAN="<%=scalar(@addr_block)%>"> <A HREF="<%=$p2%>edit/router.cgi?<%=$router->routernum%>"><%=$router->routername%></A> </TD> - <!-- - <% foreach (sort { $a->part_router_field->name cmp $b->part_router_field->name } $router->router_field ) { %> - <TR> - <TD BGCOLOR="#cccccc" ALIGN="right"><%=$_->part_router_field->name%></TD> - <TD BGCOLOR="#ffffff"><%=$_->value%></TD> - </TR> - <% } %> - --> + <TD> + <% foreach my $block ( @addr_block ) { %> + <%=$block->NetAddr%></BR> + <% } %> + </TD> </TR> <% } %> </TABLE> diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 1035510db..4c2c17b85 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -14,6 +14,24 @@ CREATE TABLE cust_bill_pkg_detail ( ); CREATE INDEX cust_bill_pkg_detail1 ON cust_bill_pkg_detail ( pkgnum, invnum ); +CREATE TABLE part_virtual_field ( + vfieldpart int NOT NULL, + dbtable varchar(32) NOT NULL, + name varchar(32) NOT NULL, + check_block text, + list_source text, + length integer, + label varchar(80), + PRIMARY KEY (vfieldpart) +); + +CREATE TABLE virtual_field ( + recnum integer NOT NULL, + vfieldpart integer NOT NULL, + value varchar(128) NOT NULL, + PRIMARY KEY (vfieldpart, recnum) +); + CREATE TABLE router ( routernum serial, routername varchar(80), @@ -26,22 +44,6 @@ CREATE TABLE part_svc_router ( routernum int NOT NULL ); -CREATE TABLE part_router_field ( - routerfieldpart serial, - name varchar(80), - length int NOT NULL, - check_block text, - list_source text, - PRIMARY KEY (routerfieldpart) -); - -CREATE TABLE router_field ( - routerfieldpart int NOT NULL, - routernum int NOT NULL, - value varchar(128) -); -CREATE UNIQUE INDEX router_field1 ON router_field ( routerfieldpart, routernum ); - CREATE TABLE addr_block ( blocknum serial, routernum int NOT NULL, @@ -51,24 +53,6 @@ CREATE TABLE addr_block ( ); CREATE UNIQUE INDEX addr_block1 ON addr_block ( blocknum, routernum ); -CREATE TABLE part_sb_field ( - sbfieldpart serial, - svcpart int NOT NULL, - name varchar(80) NOT NULL, - length int NOT NULL, - check_block text NULL, - list_source text NULL, - PRIMARY key (sbfieldpart) -); -CREATE UNIQUE INDEX part_sb_field1 ON part_sb_field ( sbfieldpart, svcpart ); - -CREATE TABLE sb_field ( - sbfieldpart int NOT NULL, - svcnum int NOT NULL, - value varchar(128) -); -CREATE UNIQUE INDEX sb_field1 ON sb_field ( sbfieldpart, svcnum ); - CREATE TABLE svc_broadband ( svcnum int NOT NULL, blocknum int NOT NULL, @@ -112,7 +96,7 @@ optionally: mandatory again: dbdef-create username -create-history-tables username cust_bill_pkg_detail router part_svc_router part_router_field router_field addr_block part_sb_field sb_field svc_broadband +create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband dbdef-create username diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index d4bb4704c..45e0b6ffe 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -65,6 +65,9 @@ blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or <BR><BR> <% + +my %vfields; + #these might belong somewhere else for other user interfaces #pry need to eventually create stuff that's shared amount UIs my %defs = ( @@ -109,29 +112,43 @@ my %defs = ( 'dstsvc' => 'service to which mail is to be forwarded', 'dst' => 'someone@another.domain.com to use when dstsvc is 0', }, - 'svc_charge' => { - 'amount' => 'amount', - }, - 'svc_wo' => { - 'worker' => 'Worker', - '_date' => 'Date', - }, +# 'svc_charge' => { +# 'amount' => 'amount', +# }, +# 'svc_wo' => { +# 'worker' => 'Worker', +# '_date' => 'Date', +# }, 'svc_www' => { #'recnum' => '', #'usersvc' => '', }, 'svc_broadband' => { - 'actypenum' => 'This is the actypenum that refers to the type of AC that can be provisioned for this service. This field must be set fixed.', 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', - 'acnum' => 'acnum of a specific AC that this service is restricted to. Not required', 'ip_addr' => 'IP address. Leave blank for automatic assignment.', - 'ip_netmask' => 'Mask length, aka. netmask bits. (Eg. 255.255.255.0 == 24)', - 'mac_addr' => 'MAC address which is used by some ACs for access control. Specified by 6 colon seperated hex octets. (Eg. 00:00:0a:bc:1a:2b)', - 'location' => 'Defines the physically location at which this service was installed. This is not necessarily the billing address', + 'blocknum' => 'Address block.', }, ); + foreach $svcdb (keys(%defs)) { + my $self = "FS::$svcdb"->new; + $vfields{$svcdb} = {}; + foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them + my $pvf = $self->pvf($field); + my @list = $pvf->list; + if (scalar @list) { + $defs{$svcdb}->{$field} = { desc => $pvf->label, + type => 'select', + select_list => \@list }; + } else { + $defs{$svcdb}->{$field} = $pvf->label; + } #endif + $vfields{$svcdb}->{$field} = $pvf; + warn "\$vfields{$svcdb}->{$field} = $pvf"; + } #next $field + } #next $svcdb + my @dbs = $hashref->{svcdb} ? ( $hashref->{svcdb} ) : qw( svc_acct svc_domain svc_forward svc_www svc_broadband ); @@ -157,7 +174,7 @@ my %defs = ( $html .= '<BR><BR>'. table(). table(). "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>"; foreach my $part_export ( @part_export ) { - $html .= '<TD><INPUT TYPE="checkbox"'. + $html .= '<TD><INPUT TYPE="checbox"'. ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" '; $html .= 'CHECKED' if ( $clone || $part_svc->svcpart ) #null svcpart search causing error @@ -202,19 +219,27 @@ my %defs = ( qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="D"!. ' CHECKED'x($flag eq 'D'). ">Default ". qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="F"!. - ' CHECKED'x($flag eq 'F'). ">Fixed ". - '<BR>'; + ' CHECKED'x($flag eq 'F'). ">Fixed "; + $html .= '<BR>'; } if ( ref($def) ) { if ( $def->{type} eq 'select' ) { $html .= qq!<SELECT NAME="${layer}__${field}">!; $html .= '<OPTION> </OPTION>' unless $value; - foreach my $record ( qsearch( $def->{select_table}, {} ) ) { - my $rvalue = $record->getfield($def->{select_key}); - $html .= qq!<OPTION VALUE="$rvalue"!. - ( $rvalue==$value ? ' SELECTED>' : '>' ). - $record->getfield($def->{select_label}). '</OPTION>'; - } + if ( $def->{select_table} ) { + foreach my $record ( qsearch( $def->{select_table}, {} ) ) { + my $rvalue = $record->getfield($def->{select_key}); + $html .= qq!<OPTION VALUE="$rvalue"!. + ( $rvalue==$value ? ' SELECTED>' : '>' ). + $record->getfield($def->{select_label}). '</OPTION>'; + } #next $record + } else { # select_list + foreach my $item ( @{$def->{select_list}} ) { + $html .= qq!<OPTION VALUE="$item"!. + ( $item eq $value ? ' SELECTED>' : '>' ). + $item. '</OPTION>'; + } #next $item + } #endif $html .= '</SELECT>'; } elsif ( $def->{type} eq 'radius_usergroup_selector' ) { $html .= FS::svc_acct::radius_usergroup_selector( @@ -229,6 +254,11 @@ my %defs = ( $html .= qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value">!; } + + if($vfields{$layer}->{$field}) { + $html .= qq!<BR><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="X"!. + ' CHECKED'x($flag eq 'X'). ">Excluded "; + } $html .= "</TD></TR>\n"; } $part_svc->svcpart('') if $clone; #undone diff --git a/httemplate/edit/part_virtual_field.cgi b/httemplate/edit/part_virtual_field.cgi new file mode 100644 index 000000000..8bc84387f --- /dev/null +++ b/httemplate/edit/part_virtual_field.cgi @@ -0,0 +1,92 @@ +<!-- mason kludge --> +<% +my ($vfieldpart, $part_virtual_field); + +if ( $cgi->param('error') ) { + $part_virtual_field = new FS::part_virtual_field ( { + map { $_, scalar($cgi->param($_)) } fields('part_virtual_field')}); + $vfieldpart = $part_virtual_field->vfieldpart; +} else { + my($query) = $cgi->keywords; + if ( $query =~ /^(\d+)$/ ) { #editing + $vfieldpart=$1; + $part_virtual_field=qsearchs('part_virtual_field', + {'vfieldpart' => $vfieldpart}) + or die "Unknown vfieldpart!"; + + } else { #adding + $part_virtual_field = new FS::part_virtual_field({}); + } +} +my $action = $part_virtual_field->vfieldpart ? 'Edit' : 'Add'; + +my $p1 = popurl(1); +print header("$action Virtual Field Definition", ''); + +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), + "</FONT>" + if $cgi->param('error'); +%> +<FORM ACTION="<%=$p1%>process/generic.cgi" METHOD="POST"> + +<INPUT TYPE="hidden" NAME="table" VALUE="part_virtual_field"> +<INPUT TYPE="hidden" NAME="redirect_ok" + VALUE="<%=popurl(2)%>browse/part_virtual_field.cgi"> +<INPUT TYPE="hidden" NAME="vfieldpart" VALUE="<%= + $vfieldpart%>"> +Field #<B><%=$vfieldpart or "(NEW)"%></B><BR><BR> + +<%=ntable("#cccccc",2)%> + <TR> + <TD ALIGN="right">Name</TD> + <TD><INPUT TYPE="text" NAME="name" MAXLENGTH=15 VALUE="<%= + $part_virtual_field->name%>"></TD> + </TR> + <TR> + <TD ALIGN="right">Table</TD> + <TD><% if ($action eq 'Add') { %> + <SELECT SIZE=1 NAME="dbtable"><% + my $dbdef = dbdef; # ick + foreach my $dbtable ($dbdef->tables) { + if ($dbtable !~ /^h_/ + and $dbdef->table($dbtable)->primary_key) { %> + <OPTION VALUE="<%=$dbtable%>"><%=$dbtable%></OPTION><% + } + } + %></SELECT><% + } else { # Edit + %><%=$part_virtual_field->dbtable%> + <INPUT TYPE="hidden" NAME="dbtable" VALUE="<%=$part_virtual_field->dbtable%>"> + <% } %> + </TD> + <TR> + <TD ALIGN="right">Label</TD> + <TD><INPUT TYPE="text" NAME="label" MAXLENGTH="20" VALUE="<%= + $part_virtual_field->label%>"></TD> + </TR> + <TR> + <TD ALIGN="right">Length</TD> + <TD><INPUT TYPE="text" NAME="length" MAXLENGTH=4 VALUE="<%= + $part_virtual_field->length%>"></TD> + </TR> + <TR> + <TD ALIGN="right">Check</TD> + <TD><TEXTAREA COLS="20" ROWS="4" NAME="check_block"><%= + $part_virtual_field->check_block%></TEXTAREA></TD> + </TR> + <TR> + <TD ALIGN="right">List source</TD> + <TD><TEXTAREA COLS="20" ROWS="4" NAME="list_source"><%= + $part_virtual_field->list_source%></TEXTAREA></TD> + </TR> +</TABLE><BR><INPUT TYPE="submit" VALUE="Submit"> + +</FORM> + +<BR><BR> +<FONT SIZE=-2>If you don't understand what <I>check_block</I> and +<I>list_source</I> mean, <B>LEAVE THEM BLANK</B>. We mean it.</FONT> + + +</BODY> +</HTML> diff --git a/httemplate/edit/process/router.cgi b/httemplate/edit/process/router.cgi index 1b7fc3805..7e40c48a7 100644 --- a/httemplate/edit/process/router.cgi +++ b/httemplate/edit/process/router.cgi @@ -19,19 +19,16 @@ my $error = ''; my $routernum = $cgi->param('routernum'); my $routername = $cgi->param('routername'); my $old = qsearchs('router', { routernum => $routernum }); -my @old_rf; my @old_psr; my $new = new FS::router { - routernum => $routernum, - routername => $routername, - svcnum => 0 - }; + map { + ($_, scalar($cgi->param($_))); + } fields('router') +}; if($old) { - if($old->routername ne $new->routername) { - $error = $new->replace($old); - } #else do nothing + $error = $new->replace($old); } else { $error = $new->insert; $routernum = $new->routernum; @@ -49,21 +46,6 @@ if ($old) { } } check($error); - @old_rf = $old->router_field; - foreach $rf (@old_rf) { - if(my $new_val = $cgi->param('rf_'.$rf->routerfieldpart)) { - if($new_val ne $rf->value) { - my $new_rf = new FS::router_field - { routernum => $routernum, - value => $new_val, - routerfieldpart => $rf->routerfieldpart }; - $error = $new_rf->replace($rf); - } #else do nothing - } else { - $error = $rf->delete; - } - check($error); - } } foreach($cgi->param) { @@ -77,23 +59,10 @@ foreach($cgi->param) { $error = $new_psr->insert; } check($error); - } elsif($cgi->param($_) ne '' and /^rf_(\d+)$/) { - my $part = $1; - if(my @x = grep {$_->routerfieldpart == $part} @old_rf) { - # already handled all of these - } else { - my $new_rf = new FS::router_field - { routernum => $routernum, - value => $cgi->param('rf_'.$part), - routerfieldpart => $part }; - $error = $new_rf->insert; - check($error); - } } } - # Yay, everything worked! $dbh->commit or die $dbh->errstr; print $cgi->redirect(popurl(3). "browse/router.cgi"); diff --git a/httemplate/edit/process/svc_broadband.cgi b/httemplate/edit/process/svc_broadband.cgi index ab8b9f9d8..4912a3a9f 100644 --- a/httemplate/edit/process/svc_broadband.cgi +++ b/httemplate/edit/process/svc_broadband.cgi @@ -9,11 +9,10 @@ my $dbh = FS::UID::dbh; $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; my $svcnum = $1; -my $old; my @old_sbf; +my $old; if ( $svcnum ) { $old = qsearchs('svc_broadband', { 'svcnum' => $svcnum } ) or die "fatal: can't find broadband service (svcnum $svcnum)!"; - @old_sbf = $old->sb_field; } else { $old = ''; } @@ -32,39 +31,6 @@ if ( $svcnum ) { $svcnum = $new->svcnum; } -unless ($error) { - my $sb_field; - - foreach ($cgi->param) { - #warn "\$cgi->param $_: " . $cgi->param($_); - if(/^sbf_(\d+)/) { - my $part = $1; - #warn "\$part $part"; - $sb_field = new FS::sb_field - { svcnum => $svcnum, - value => $cgi->param($_), - sbfieldpart => $part }; - if (my @x = grep { $_->sbfieldpart eq $part } @old_sbf) { - #if (my $old_sb_field = (grep { $_->sbfieldpart eq $part} @old_Sbf)[0]) { - #warn "array: " . scalar(@x); - if (length($sb_field->value) && ($sb_field->value ne $x[0]->value)) { - #warn "replacing " . $x[0]->value . " with " . $sb_field->value; - $error = $sb_field->replace($x[0]); - #$error = $sb_field->replace($old_sb_field); - } elsif (length($sb_field->value) == 0) { - #warn "delete"; - $error = $x[0]->delete; - } - } else { - if (length($sb_field->value) > 0) { - #warn "insert"; - $error = $sb_field->insert; - } - # else do nothing - } - } - } -} if ( $error ) { $cgi->param('error', $error); diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi index b524c6494..5c365a21e 100755 --- a/httemplate/edit/router.cgi +++ b/httemplate/edit/router.cgi @@ -16,7 +16,6 @@ if ( $cgi->keywords ) { my $routernum = $router->routernum; my $action = $routernum ? 'Edit' : 'Add'; -my $hashref = $router->hashref; print header("$action Router", menubar( 'Main Menu' => "$p", @@ -28,10 +27,13 @@ if($cgi->param('error')) { <% } %> <FORM ACTION="<%=popurl(1)%>process/router.cgi" METHOD=POST> + <INPUT TYPE="hidden" NAME="table" VALUE="router"> + <INPUT TYPE="hidden" NAME="redirect_ok" VALUE="<%=$p3%>/browse/router.cgi"> + <INPUT TYPE="hidden" NAME="redirect_error" VALUE="<%=$p3%>/edit/router.cgi"> <INPUT TYPE="hidden" NAME="routernum" VALUE="<%=$routernum%>"> Router #<%=$routernum or "(NEW)"%> -<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%=$hashref->{routername}%>"> +<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%=$router->routername%>"> <BR><BR> Custom fields: @@ -39,35 +41,11 @@ Custom fields: <%=table() %> <% -# I know, I know. Massive false laziness with edit/svc_broadband.cgi. But -# Kristian won't let me generalize the custom field mechanism to every table in -# the database, so this is what we get. <snarl> -# -- MW - -my @part_router_field = qsearch('part_router_field', { }); -my %rf = map { $_->part_router_field->name, $_->value } $router->router_field; -foreach (sort { $a->name cmp $b->name } @part_router_field) { - %> - <TR> - <TD ALIGN="right"><%=$_->name%></TD> - <TD><% - if(my @opts = $_->list_values) { - %> <SELECT NAME="rf_<%=$_->routerfieldpart%>" SIZE="1"> - <% - foreach $opt (@opts) { - %> <OPTION VALUE="<%=$opt%>"<%=($opt eq $rf{$_->name}) - ? ' SELECTED' : ''%>> - <%=$opt%> - </OPTION> - <% } %> - </SELECT> - <% } else { %> - <INPUT NAME="rf_<%=$_->routerfieldpart%>" - VALUE="<%=$rf{$_->name}%>" - <%=$_->length ? 'SIZE="'.$_->length.'"' : ''%>> - <% } %></TD> - </TR> -<% } %> +foreach my $field ($router->virtual_fields) { + print $router->pvf($field)->widget('HTML', 'edit', + $router->getfield($field)); +} +%> </TABLE> @@ -81,7 +59,7 @@ foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband', <BR> <INPUT TYPE="checkbox" NAME="svcpart_<%=$part_svc->svcpart%>"<%= qsearchs('part_svc_router', { svcpart => $part_svc->svcpart, - routernum => $routernum } ) ? 'CHECKED' : ''%> VALUE="ON"> + routernum => $routernum } ) ? ' CHECKED' : ''%> VALUE="ON"> <A HREF="<%=${p}%>edit/part_svc.cgi?<%=$part_svc->svcpart%>"> <%=$part_svc->svcpart%>: <%=$part_svc->svc%></A> <% } %> diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 4420bb609..44606d9a0 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -35,8 +35,6 @@ if ( $cgi->param('error') ) { } else { #adding - $svc_acct = new FS::svc_acct({}); - foreach $_ (split(/-/,$query)) { $pkgnum=$1 if /^pkgnum(\d+)$/; $svcpart=$1 if /^svcpart(\d+)$/; @@ -44,6 +42,8 @@ if ( $cgi->param('error') ) { $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); die "No part_svc entry for svcpart $svcpart!" unless $part_svc; + $svc_acct = new FS::svc_acct({svcpart => $svcpart}); + $svcnum=''; #set gecos @@ -281,6 +281,14 @@ if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) { } print '</TD></TR>'; +foreach $field ($svc_acct->virtual_fields) { + if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { + # If the flag is X, it won't even show up in $svc_acct->virtual_fields. + print $svc_acct->pvf($field)->widget('HTML', 'edit', + $svc_acct->getfield($field)); + } +} + #submit print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!; diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index ee7f8becf..6828791c0 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -36,8 +36,6 @@ if ( $cgi->param('error') ) { } else { #adding - $svc_broadband = new FS::svc_broadband({}); - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart $pkgnum=$1 if /^pkgnum(\d+)$/; $svcpart=$1 if /^svcpart(\d+)$/; @@ -45,7 +43,7 @@ if ( $cgi->param('error') ) { $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; - $svc_broadband->setfield('svcpart', $svcpart); + $svc_broadband = new FS::svc_broadband({ svcpart => $svcpart }); $svcnum=''; @@ -159,30 +157,12 @@ Service #<B><%=$svcnum ? $svcnum : "(NEW)"%></B><BR><BR> <% } %> <% - - my @part_sb_field = qsearch('part_sb_field', { svcpart => $svcpart }); - my $sbf_hashref = $svc_broadband->sb_field_hashref($svcpart); - foreach (sort { $a->name cmp $b->name } @part_sb_field) { - %> - <TR> - <TD ALIGN="right"><%=$_->name%></TD> - <TD><% - if(my @opts = $_->list_values) { - %> - <SELECT NAME="sbf_<%=$_->sbfieldpart%>" SIZE=1> <% - foreach $opt (@opts) { %> - <OPTION VALUE="<%=$opt%>"<%= - ($opt eq $sbf_hashref->{$_->name}) ? ' SELECTED' : ''%>> - <%=$opt%></OPTION><% - } %></SELECT> - <% } else { %> - <INPUT NAME="sbf_<%=$_->sbfieldpart%>" - VALUE="<%=$sbf_hashref->{$_->name}%>" - <%=$_->length ? 'SIZE="'.$_->length.'"' : ''%>> - <% } %> - </TD> - </TR> -<% } %> +foreach $field ($svc_broadband->virtual_fields) { + if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { + print $svc_broadband->pvf($field)->widget('HTML', 'edit', + $svc_broadband->getfield($field)); + } +} %> </TABLE> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> diff --git a/httemplate/edit/svc_www.cgi b/httemplate/edit/svc_www.cgi index d2c9ade5c..043af610b 100644 --- a/httemplate/edit/svc_www.cgi +++ b/httemplate/edit/svc_www.cgi @@ -29,12 +29,12 @@ if ( $cgi->param('error') ) { } else { #adding - $svc_www = new FS::svc_www({}); - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart $pkgnum=$1 if /^pkgnum(\d+)$/; $svcpart=$1 if /^svcpart(\d+)$/; } + $svc_www = new FS::svc_www { svcpart => $svcpart }; + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; @@ -167,6 +167,14 @@ foreach $_ (keys %username) { } print "</SELECT></TD></TR>"; +foreach $field ($svc_www->virtual_fields) { + if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { + # If the flag is X, it won't even show up in $svc_acct->virtual_fields. + print $svc_www->pvf($field)->widget('HTML', 'edit', + $svc_www->getfield($field)); + } +} + print '</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">'; print <<END; diff --git a/httemplate/index.html b/httemplate/index.html index 017ffcd88..1895f2912 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -11,7 +11,7 @@ </td><td> <font color="#ff0000" size=7>freeside main menu</font> </td><td align=right valign=bottom> - version %%%VERSION%%% + version 1.5.0pre2 <BR><A HREF="http://www.sisd.com/freeside">Freeside home page</A> <BR><A HREF="docs/">Documentation</A> </td></tr> @@ -199,10 +199,8 @@ - Points of Presence <LI><A HREF="browse/part_bill_event.cgi">View/Edit invoice events</A> - Actions for overdue invoices <LI><A HREF="browse/msgcat.cgi">View/Edit message catalog</A> - Change error messages and other customizable labels. - <LI><A HREF="browse/part_sb_field.cgi">View/Edit custom svc_broadband fields</A> - - Custom broadband service fields for site-specific export/informational data. - <LI><A HREF="browse/generic.cgi?part_router_field">View/Edit custom router fields</A> - - Custom router fields for site-specific export data. + <LI><A HREF="browse/part_virtual_field.cgi">View/Edit virtual fields</A> + - Locally defined fields <LI><A HREF="browse/router.cgi">View/Edit routers</A> - Broadband access routers <LI><A HREF="browse/addr_block.cgi">View/Edit address blocks</A> diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 599c1d8b9..4e01db341 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -172,7 +172,7 @@ if ($svc_acct->slipip) { : $svc_acct->slipip ). "</TD>"; my($attribute); - foreach $attribute ( grep /^radius_/, fields('svc_acct') ) { + foreach $attribute ( grep /^radius_/, $svc_acct->fields ) { #warn $attribute; $attribute =~ /^radius_(.*)$/; my $pattribute = $FS::raddb::attrib{$1}; @@ -180,7 +180,7 @@ if ($svc_acct->slipip) { "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute). "</TD></TR>"; } - foreach $attribute ( grep /^rc_/, fields('svc_acct') ) { + foreach $attribute ( grep /^rc_/, $svc_acct->fields ) { #warn $attribute; $attribute =~ /^rc_(.*)$/; my $pattribute = $FS::raddb::attrib{$1}; @@ -195,7 +195,19 @@ if ($svc_acct->slipip) { print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'. join('<BR>', $svc_acct->radius_groups). '</TD></TR>'; -print '</TABLE></TD></TR></TABLE><BR><BR>'; +# Can this be abstracted further? Maybe a library function like +# widget('HTML', 'view', $svc_acct) ? It would definitely make UI +# style management easier. + +foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { + print $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)), + "\n"; +} +%> +</TABLE></TD></TR></TABLE> +<% + +print '<BR><BR>'; print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'. joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>'; diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi index 164b5b22c..677a4b058 100644 --- a/httemplate/view/svc_broadband.cgi +++ b/httemplate/view/svc_broadband.cgi @@ -64,26 +64,12 @@ print header('Broadband Service View', menubar( qq!<TD BGCOLOR="#ffffff">$ip_addr</TD></TR>!. '</TD></TR><TR ROWSPAN="1"><TD></TD></TR>'; +foreach (sort { $a cmp $b } $svc_broadband->virtual_fields) { + print $svc_broadband->pvf($_)->widget('HTML', 'view', + $svc_broadband->getfield($_)), "\n"; +} -# foreach my $sb_field -# ( qsearch('sb_field', { svcnum => $svcnum }) ) { -# my $part_sb_field = qsearchs('part_sb_field', -# { sbfieldpart => $sb_field->sbfieldpart }); -# print q!<TR><TD ALIGN="right">! . $part_sb_field->name . -# q!</TD><TD BGCOLOR="#ffffff">! . $sb_field->value . -# q!</TD></TR>!; -# } -# print '</TABLE>'; - - - my $sb_field = $svc_broadband->sb_field_hashref; - foreach (sort { $a cmp $b } keys(%{$sb_field})) { - print q!<TR><TD ALIGN="right">! . $_ . - q!</TD><TD BGCOLOR="#ffffff">! . $sb_field->{$_} . - q!</TD></TR>!; - } - print '</TABLE>'; - +print '</TABLE>'; print '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>' diff --git a/httemplate/view/svc_forward.cgi b/httemplate/view/svc_forward.cgi index c8d1d6213..5d619de54 100755 --- a/httemplate/view/svc_forward.cgi +++ b/httemplate/view/svc_forward.cgi @@ -61,7 +61,14 @@ print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!. qq!<TR><TD ALIGN="right">Email to</TD>!. qq!<TD BGCOLOR="#ffffff">$source</TD></TR>!. qq!<TR><TD ALIGN="right">Forwards to </TD>!. - qq!<TD BGCOLOR="#ffffff">$destination</TD></TR></TABLE>!. + qq!<TD BGCOLOR="#ffffff">$destination</TD></TR>!; + +foreach (sort { $a cmp $b } $svc_forward->virtual_fields) { + print $svc_forward->pvf($_)->widget('HTML', 'view', $svc_forward->getfield($_)), + "\n"; +} + +print qq! </TABLE>!. '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>' ; diff --git a/httemplate/view/svc_www.cgi b/httemplate/view/svc_www.cgi index 442614491..7a716b4b8 100644 --- a/httemplate/view/svc_www.cgi +++ b/httemplate/view/svc_www.cgi @@ -47,8 +47,15 @@ print header('Website View', menubar( qq!<TR><TD ALIGN="right">Website name</TD>!. qq!<TD BGCOLOR="#ffffff"><A HREF="http://$www">$www<A></TD></TR>!. qq!<TR><TD ALIGN="right">Account</TD>!. - qq!<TD BGCOLOR="#ffffff"><A HREF="${p}view/svc_acct.cgi?$usersvc">$email</A></TD></TR>!. - '</TABLE></TD></TR></TABLE>'. + qq!<TD BGCOLOR="#ffffff"><A HREF="${p}view/svc_acct.cgi?$usersvc">$email</A></TD></TR>!; + +foreach (sort { $a cmp $b } $svc_www->virtual_fields) { + print $svc_www->pvf($_)->widget('HTML', 'view', $svc_www->getfield($_)), + "\n"; +} + + +print '</TABLE></TD></TR></TABLE>'. '<BR>'. joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>' ; |