[freeside-commits] freeside/httemplate/edit allocate.html, 1.2, 1.3 router.cgi, 1.7, 1.8 svc_acct_pop.cgi, 1.10, 1.11 svc_broadband.cgi, 1.16, 1.17
Jeff Finucane,420,,
jeff at wavetail.420.am
Sat Jun 28 12:25:26 PDT 2008
- Previous message: [freeside-commits] freeside/httemplate/browse addr_block.cgi, 1.8, 1.9 router.cgi, 1.12, 1.13 svc_acct_pop.cgi, 1.20, 1.21
- Next message: [freeside-commits] freeside/httemplate/edit/elements edit.html, 1.22, 1.23 svc_Common.html, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail.420.am:/tmp/cvs-serv20117/httemplate/edit
Modified Files:
allocate.html router.cgi svc_acct_pop.cgi svc_broadband.cgi
Log Message:
agent virtualize address blocks and routers
Index: router.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/router.cgi,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- router.cgi 13 Jan 2008 21:35:52 -0000 1.7
+++ router.cgi 28 Jun 2008 19:25:24 -0000 1.8
@@ -1,78 +1,44 @@
-<% include('/elements/header.html', "$action Router", menubar(
- 'View all routers' => "${p}browse/router.cgi",
- ))
+<% include('elements/edit.html',
+ 'post_url' => popurl(1).'process/router.cgi',
+ 'name' => 'router',
+ 'table' => 'router',
+ 'viewall_url' => "${p}browse/router.cgi",
+ 'labels' => { 'routernum' => 'Router',
+ 'routername' => 'Name',
+ 'svc_part' => 'Service',
+ },
+ 'fields' => [
+ { 'field'=>'routername', 'type'=>'text', 'size'=>32 },
+ { 'field'=>'agentnum', 'type'=>'select-agent' },
+ ],
+ 'error_callback' => $callback,
+ 'edit_callback' => $callback,
+ 'new_callback' => $callback,
+ )
%>
-
-<% include('/elements/error.html') %>
-
-<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%>">
- <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$router->svcnum%>">
- Router #<%$routernum or "(NEW)"%>
-
-<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%$router->routername%>">
-
-<BR><BR>
-Custom fields:
-<BR>
-<%table() %>
-%
-%foreach my $field ($router->virtual_fields) {
-% print $router->pvf($field)->widget('HTML', 'edit',
-% $router->getfield($field));
-%}
-%
-
-</TABLE>
-%
-%unless ($router->svcnum) {
-%
-
-<BR><BR>Select the service types available on this router<BR>
-%
-%
-% foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband',
-% disabled => '' }) ) {
-%
-
- <BR>
- <INPUT TYPE="checkbox" NAME="svcpart_<%$part_svc->svcpart%>"<%
- qsearchs('part_svc_router', { svcpart => $part_svc->svcpart,
- routernum => $routernum } ) ? ' CHECKED' : ''%> VALUE="ON">
- <A HREF="<%${p}%>edit/part_svc.cgi?<%$part_svc->svcpart%>">
- <%$part_svc->svcpart%>: <%$part_svc->svc%></A>
-% }
-% }
-
-
- <BR><BR><INPUT TYPE="submit" VALUE="Apply changes">
- </FORM>
-
-<% include('/elements/footer.html') %>
-
<%init>
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my $router;
-if ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $router = qsearchs('router', { routernum => $1 })
- or print $cgi->redirect(popurl(2)."browse/router.cgi") ;
-} else {
- $router = new FS::router ( {
- map { $_, scalar($cgi->param($_)) } fields('router')
- } );
-}
+my $curuser = $FS::CurrentUser::CurrentUser;
-my $routernum = $router->routernum;
-my $action = $routernum ? 'Edit' : 'Add';
+die "access denied"
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
-my $p3 = popurl(3);
+my $callback = sub {
+ my ($cgi, $object, $fields) = (shift, shift, shift);
+ unless ($object->svcnum) {
+ push @{$fields},
+ { 'type' => 'tablebreak-tr-title',
+ 'value' => 'Select the service types available on this router',
+ },
+ { 'field' => 'svc_part',
+ 'type' => 'checkboxes-table',
+ 'target_table' => 'part_svc',
+ 'link_table' => 'part_svc_router',
+ 'name_col' => 'svc',
+ 'hashref' => { 'svcdb' => 'svc_broadband', 'disabled' => '' },
+ };
+ }
+};
</%init>
Index: svc_acct_pop.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/svc_acct_pop.cgi,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- svc_acct_pop.cgi 13 Jan 2008 21:35:53 -0000 1.10
+++ svc_acct_pop.cgi 28 Jun 2008 19:25:24 -0000 1.11
@@ -27,8 +27,11 @@
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
my $svc_acct_pop;
if ( $cgi->param('error') ) {
Index: svc_broadband.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/svc_broadband.cgi,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- svc_broadband.cgi 13 Jan 2008 21:35:53 -0000 1.16
+++ svc_broadband.cgi 28 Jun 2008 19:25:24 -0000 1.17
@@ -1,167 +1,26 @@
-<% include('/elements/header.html', "Broadband Service $action") %>
-
-<% include('/elements/error.html') %>
-
-Service #<B><%$svcnum ? $svcnum : "(NEW)"%></B><BR><BR>
-
-<FORM ACTION="<%${p1}%>process/svc_broadband.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
- <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%$pkgnum%>">
- <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%$svcpart%>">
-
- <%&ntable("#cccccc",2)%>
- <TR>
- <TD ALIGN="right">Description</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('description')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="description" VALUE="<%$description%>"><%$description%>
-% } else {
-
- <INPUT TYPE="text" NAME="description" VALUE="<%$description%>">
-% }
-
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">IP Address</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('ip_addr')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="ip_addr" VALUE="<%$ip_addr%>"><%$ip_addr%>
-% } else {
-
- <INPUT TYPE="text" NAME="ip_addr" VALUE="<%$ip_addr%>">
-% }
-
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Download speed</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('speed_down')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="speed_down" VALUE="<%$speed_down%>"><%$speed_down%>Kbps
-% } else {
-
- <INPUT TYPE="text" NAME="speed_down" SIZE=5 VALUE="<%$speed_down%>">Kbps
-% }
-
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Upload speed</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('speed_up')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="speed_up" VALUE="<%$speed_up%>"><%$speed_up%>Kbps
-% } else {
-
- <INPUT TYPE="text" NAME="speed_up" SIZE=5 VALUE="<%$speed_up%>">Kbps
-% }
-
- </TD>
- </TR>
-% if ($action eq 'Add') {
-
- <TR>
- <TD ALIGN="right">Router/Block</TD>
- <TD BGCOLOR="#ffffff">
- <SELECT NAME="blocknum">
-%
-% warn $svc_broadband->svcpart;
-% foreach my $router ($svc_broadband->allowed_routers) {
-% warn $router->routername;
-% foreach my $addr_block ($router->addr_block) {
-%
-
- <OPTION VALUE="<%$addr_block->blocknum%>"<%($addr_block->blocknum eq $blocknum) ? ' SELECTED' : ''%>>
- <%$router->routername%>:<%$addr_block->ip_gateway%>/<%$addr_block->ip_netmask%></OPTION>
-%
-% }
-% }
-%
-
- </SELECT>
- </TD>
- </TR>
-% } else {
-
-
- <TR>
- <TD ALIGN="right">Router/Block</TD>
- <TD BGCOLOR="#ffffff">
- <%$svc_broadband->addr_block->router->routername%>:<%$svc_broadband->addr_block->NetAddr%>
- <INPUT TYPE="hidden" NAME="blocknum" VALUE="<%$svc_broadband->blocknum%>">
- </TD>
- </TR>
-% }
- <TR>
- <TD ALIGN="right">MAC Address</TD>
- <TD BGCOLOR="#ffffff">
- <INPUT TYPE="text" NAME="mac_addr" VALUE="<%$mac_addr%>">
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Latitude</TD>
- <TD BGCOLOR="#ffffff">
- <INPUT TYPE="text" NAME="latitude" VALUE="<%$latitude%>">
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Longitude</TD>
- <TD BGCOLOR="#ffffff">
- <INPUT TYPE="text" NAME="longitude" VALUE="<%$longitude%>">
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Altitude</TD>
- <TD BGCOLOR="#ffffff">
- <INPUT TYPE="text" NAME="altitude" VALUE="<%$altitude%>">
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">VLAN Profile</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('vlan_profile')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="vlan_profile" VALUE="<%$vlan_profile%>"><%$vlan_profile%>
-% } else {
-
- <INPUT TYPE="text" NAME="vlan_profile" VALUE="<%$vlan_profile%>">
-% }
-
- </TD>
- </TR>
- <TR>
- <TD ALIGN="right">Authentication Key</TD>
- <TD BGCOLOR="#ffffff">
-% if ( $part_svc->part_svc_column('auth_key')->columnflag eq 'F' ) {
-
- <INPUT TYPE="hidden" NAME="auth_key" VALUE="<%$auth_key%>"><%$auth_key%>
-% } else {
-
- <INPUT TYPE="text" NAME="auth_key" VALUE="<%$auth_key%>">
-% }
-
- </TD>
- </TR>
-%
-%foreach my $field ($svc_broadband->virtual_fields) {
-% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' &&
-% $part_svc->part_svc_column($field)->columnflag ne 'X') {
-% print $svc_broadband->pvf($field)->widget('HTML', 'edit',
-% $svc_broadband->getfield($field));
-% }
-%}
-
- </TABLE>
- <BR>
- <INPUT TYPE="submit" NAME="submit" VALUE="Submit">
-</FORM>
-
-<% include('/elements/footer.html') %>
-
+<% include('elements/svc_Common.html',
+ 'post_url' => popurl(1). 'process/svc_broadband.cgi',
+ 'name' => 'broadband service',
+ 'table' => 'svc_broadband',
+ 'labels' => { 'svcnum' => 'Service #',
+ 'description' => 'Description',
+ 'ip_addr' => 'IP address',
+ 'speed_down' => 'Download speed',
+ 'speed_up' => 'Upload speed',
+ 'blocknum' => 'Router/Block',
+ 'block_disp' => 'Router/Block',
+ 'mac_addr' => 'MAC address',
+ 'latitude' => 'Latitude',
+ 'longitude' => 'Longitude',
+ 'altitude' => 'Altitude',
+ 'vlan_profile' => 'VLAN profile',
+ 'authkey' => 'Authentication key',
+ },
+ 'fields' => \@fields,
+ 'field_callback' => $callback,
+ 'dummy' => $cgi->query_string,
+ )
+%>
<%init>
die "access denied"
@@ -170,85 +29,58 @@
# If it's stupid but it works, it's still stupid.
# -Kristian
-use HTML::Widgets::SelectLayers;
-use Tie::IxHash;
-
-my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_broadband );
-if ( $cgi->param('error') ) {
-
- $svc_broadband = new FS::svc_broadband ( {
- map { $_, scalar($cgi->param($_)) } fields('svc_broadband'), qw(svcpart)
- } );
- $svcnum = $svc_broadband->svcnum;
- $pkgnum = $cgi->param('pkgnum');
- $svcpart = $svc_broadband->svcpart;
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
-
-} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
-
- $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
- $pkgnum = $1;
- $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
- $svcpart = $1;
-
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
-
- $svc_broadband = new FS::svc_broadband({ svcpart => $svcpart });
-
- $svcnum='';
-
- $svc_broadband->set_default_and_fixed;
-
-} else { #editing
+my @fields = (
+ qw( description ip_addr speed_down speed_up blocknum ),
+ { field=>'block_label', type=>'fixed' },
+ qw( mac_addr latitude longitude altitude vlan_profile authkey )
+);
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/ or die "unparsable svcnum";
- $svcnum=$1;
- $svc_broadband=qsearchs('svc_broadband',{'svcnum'=>$svcnum})
- or die "Unknown (svc_broadband) svcnum!";
+my $callback = sub {
+ my ($cgi, $object, $fieldref) = @_;
- my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
- or die "Unknown (cust_svc) svcnum!";
+ my $svcpart = $object->svcnum ? $object->cust_svc->svcpart
+ : $cgi->param('svcpart');
- $pkgnum=$cust_svc->pkgnum;
- $svcpart=$cust_svc->svcpart;
-
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
+ my $part_svc = qsearchs( 'part_svc', { svcpart => $svcpart } );
die "No part_svc entry!" unless $part_svc;
-}
-my $action = $svc_broadband->svcnum ? 'Edit' : 'Add';
+ my $columndef = $part_svc->part_svc_column($fieldref->{'field'});
+ if ($columndef->columnflag eq 'F') {
+ $fieldref->{'type'} = 'fixed';
+ $fieldref->{'value'} = $columndef->columnvalue;
+ }
-if ($pkgnum) {
+ if ($object->svcnum) {
- #Nothing?
+ $fieldref->{type} = 'hidden'
+ if $fieldref->{field} eq 'blocknum';
+
+ $fieldref->{value} = $object->addr_block->label
+ if $fieldref->{field} eq 'block_label';
-} elsif ( $action eq 'Edit' ) {
+ } else {
- #Nothing?
+ $fieldref->{type} = 'hidden' if $fieldref->{field} eq 'block_label';
-} else {
- die "\$action eq Add, but \$pkgnum is null!\n";
-}
+ if ($fieldref->{field} eq 'blocknum') {
+ my $cust_pkg = qsearchs( 'cust_pkg', {pkgnum => $cgi->param('pkgnum')} );
+ die "No cust_pkg entry!" unless $cust_pkg;
-my $p1 = popurl(1);
+ $object->svcpart($part_svc->svcpart);
+ my @addr_block =
+ grep { ! $_->agentnum
+ || $cust_pkg->cust_main->agentnum == $_->agentnum
+ && $FS::CurrentUser::CurrentUser->agentnum($_->agentnum)
+ }
+ map { $_->addr_block } $object->allowed_routers;
+ my @options = map { $_->blocknum } @addr_block;
+ my %option_labels = map { ( $_->blocknum => $_->label ) } @addr_block;
+ $fieldref->{type} = 'select';
+ $fieldref->{options} = \@options;
+ $fieldref->{labels} = \%option_labels;
+ }
-my ($ip_addr, $speed_up, $speed_down, $blocknum, $mac_addr,
- $latitude, $longitude, $altitude, $vlan_profile, $auth_key,
- $description) =
- ($svc_broadband->ip_addr,
- $svc_broadband->speed_up,
- $svc_broadband->speed_down,
- $svc_broadband->blocknum,
- $svc_broadband->mac_addr,
- $svc_broadband->latitude,
- $svc_broadband->longitude,
- $svc_broadband->altitude,
- $svc_broadband->vlan_profile,
- $svc_broadband->auth_key,
- $svc_broadband->description,
- );
+ }
+};
</%init>
Index: allocate.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/allocate.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- allocate.html 18 Apr 2008 03:29:58 -0000 1.2
+++ allocate.html 28 Jun 2008 19:25:23 -0000 1.3
@@ -12,15 +12,22 @@
'table' => 'router',
'name_col' => 'routername',
'disable_empty' => 1,
+ 'agent_virt' => 1,
+ 'agent_null_right' =>
+ 'Engineering global configuration',
},
],
'post_url' => "process/addr_block/allocate.cgi",
'popup' => 1,
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Engineering global configuration',
)
%>
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
</%init>
- Previous message: [freeside-commits] freeside/httemplate/browse addr_block.cgi, 1.8, 1.9 router.cgi, 1.12, 1.13 svc_acct_pop.cgi, 1.20, 1.21
- Next message: [freeside-commits] freeside/httemplate/edit/elements edit.html, 1.22, 1.23 svc_Common.html, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list