X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_broadband.cgi;h=5a3692e1449febd0480a066edfb1fc9ae7bb1ea0;hp=d8a1f7a2a7362743b59a88c270739f3ff6b70b2b;hb=c49cfd25a8f92c7a2f44b51d72506a21f6b8d09f;hpb=44398c83f25bf4e43838df9f39331c29fdeff19d diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index d8a1f7a2a..5a3692e14 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -1,219 +1,203 @@ - -<% - -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') - } ); - $svcnum = $svc_broadband->svcnum; - $pkgnum = $cgi->param('pkgnum'); - $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; -} else { - my($query) = $cgi->keywords; - if ( $query =~ /^(\d+)$/ ) { #editing - $svcnum=$1; - $svc_broadband=qsearchs('svc_broadband',{'svcnum'=>$svcnum}) - or die "Unknown (svc_broadband) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - } 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+)$/; - } - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; - - $svcnum=''; - - #set fixed and default fields from part_svc - foreach my $part_svc_column ( - grep { $_->columnflag } $part_svc->all_part_svc_column - ) { - $svc_broadband->setfield( $part_svc_column->columnname, - $part_svc_column->columnvalue, - ); - } - - } -} -my $action = $svc_broadband->svcnum ? 'Edit' : 'Add'; - -my @ac_list; - -if ($pkgnum) { - - unless ($svc_broadband->actypenum) {die "actypenum must be set fixed";}; - @ac_list = qsearch('ac', { actypenum => $svc_broadband->getfield('actypenum') }); - -} elsif ( $action eq 'Edit' ) { - - #Nothing? - -} else { - die "\$action eq Add, but \$pkgnum is null!\n"; +<& elements/svc_Common.html, + 'post_url' => popurl(1). 'process/svc_broadband.cgi', + 'name' => 'broadband service', + 'table' => 'svc_broadband', + 'fields' => \@fields, + 'svc_field_callback' => $svc_field_callback, + 'svc_new_callback' => $svc_edit_callback, + 'svc_edit_callback' => $svc_edit_callback, + 'svc_error_callback' => $svc_edit_callback, + 'dummy' => $cgi->query_string, + 'onsubmit' => 'validate_coords', + 'html_foot' => $js, +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +# If it's stupid but it works, it's still stupid. +# -Kristian + +my $conf = new FS::Conf; + +my $js = < + function validate_coords(f){ +END +; +if ( $conf->exists('svc_broadband-require-nw-coordinates') ) { +$js .= < 59 ) { + s /= 1000; + } else { + s /= 60; + } + s /= 60; + + m /= 60; + if ( m > 59 ) { + alert('Invalid coordinate with minutes > 59'); + return false; + } + + var tmp = parseInt(d)+parseInt(m)+parseInt(s); + tmp = tmp.toFixed(8); + coord = (neg ? -1 : 1) * tmp; + + if(coord < lower) { + alert('Error: invalid coordinate < '+lower); + return false; + } + if(coord > upper) { + alert('Error: invalid coordinate > '+upper); + return false; + } + + return true; +END +; } - - -my $p1 = popurl(1); -print header("Broadband Service $action", ''); - -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); - -print qq!
!; - -#display - - - -#svcnum -print qq!!; -print qq!Service #!, $svcnum ? $svcnum : "(NEW)", "

"; - -#pkgnum -print qq!!; - -#svcpart -print qq!!; - -#actypenum -print ''; - - -print &ntable("#cccccc",2) . qq!AC!; - -#acnum -if (( $part_svc->part_svc_column('acnum')->columnflag eq 'F' ) or - ( !$pkgnum )) { - - my $ac = qsearchs('ac', { acnum => $svc_broadband->acnum }); - my ($acnum, $acname) = ($ac->acnum, $ac->acname); - - print qq!! . - qq!${acnum}: ${acname}!; - -} else { - - my @ac_list = qsearch('ac', { actypenum => $svc_broadband->actypenum }); - print qq!! . - qq!${speed_down}Kbps!; -} else { - print qq!! . - qq!Kbps!; } -print 'Upload speed'; -if ( $part_svc->part_svc_column('speed_up')->columnflag eq 'F' ) { - print qq!! . - qq!${speed_up}Kbps!; -} else { - print qq!! . - qq!Kbps!; -} +my $part_svc; -#ip_addr & ip_netmask -#We're assuming that ip_netmask is fixed if ip_addr is fixed. -#If it isn't, well, what the heck are you doing!?!? - -my ($ip_addr, $ip_netmask) = ($svc_broadband->ip_addr, - $svc_broadband->ip_netmask); - -print 'IP address/Mask'; -if ( $part_svc->part_svc_column('ip_addr')->columnflag eq 'F' ) { - print qq!! . - qq!! . - qq!${ip_addr}/${ip_netmask}!; -} else { - $ip_addr =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; - print <. - . - . - / - - - -

Leave the IP address and netmask blank for automatic assignment of a /32 address. Specifing the netmask and not the address will force assignment of a larger block.

- -END -} +my $svc_edit_callback = sub { + my ($cgi, $svc_x, $part_svc_x, $cust_pkg, $fields, $opt) = @_; -#mac_addr -my $mac_addr = $svc_broadband->mac_addr; - -unless (( $part_svc->part_svc_column('mac_addr')->columnflag eq 'F' ) and - ( $mac_addr eq '' )) { - print 'MAC Address'; - if ( $part_svc->part_svc_column('mac_addr')->columnflag eq 'F' ) { #Why? - print qq!! . - qq!${mac_addr}!; - } else { - #Ewwww - $mac_addr =~ /^([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2}):([a-f0-9]{2})$/i; - print <: - : - : - : - : - - -END + $part_svc = $part_svc_x; #for field_callback to use + my ($nas_export) = $part_svc->part_export('broadband_nas'); + #can we assume there's only one of these per part_svc? + if ( $nas_export ) { + my $nas; + if ( $svc_x->svcnum ) { + $nas = qsearchs('nas', { 'svcnum' => $svc_x->svcnum }); + } + $nas ||= $nas_export->default_nas; + $svc_x->set($_, $nas->$_) foreach fields('nas'); + + # duplicates the fields in httemplate/edit/nas.html (mostly) + push @$fields, + { type => 'tablebreak-tr-title', + #value => 'Attached NAS', + value => $nas_export->exportname, + colspan => 2, + }, + { field=>'nasnum', type=>'hidden', }, + { field=>'shortname', size=>16, maxlength=>32 }, + { field=>'secret', size=>40, maxlength=>60, required=>1 }, + { field=>'type', type=>'select', + options=>[qw( cisco computone livingston max40xx multitech netserver + pathras patton portslave tc usrhiper other )], + }, + { field=>'ports', size=>5 }, + { field=>'server', size=>40, maxlength=>64 }, + { field=>'community', size=>40, maxlength=>50 }, + ; + + $opt->{'labels'}{'shortname'} = 'Short name'; + $opt->{'labels'}{'secret'} = 'Shared secret'; + $opt->{'labels'}{'type'} = 'Type'; + $opt->{'labels'}{'ports'} = 'Ports'; + $opt->{'labels'}{'server'} = 'Server'; + $opt->{'labels'}{'community'} = 'Community'; } -} - -#location -my $location = $svc_broadband->location; +}; -print 'Location'; -if ( $part_svc->part_svc_column('location')->columnflag eq 'F' ) { - print qq!
${location}
!; -} else { - print qq!!; -} +my $svc_field_callback = sub { + my ($cgi, $object, $fieldref) = @_; -print '
'; + my $columndef = $part_svc->part_svc_column($fieldref->{'field'}); + if ($fieldref->{field} eq 'usergroup' && $columndef->columnflag eq 'F') { + $fieldref->{'formatted_value'} = + [ $object->radius_groups('long_description') ]; + } -print < - - -END -%> +