1 <& elements/svc_Common.html,
2 'post_url' => popurl(1). 'process/svc_broadband.cgi',
3 'name' => 'broadband service',
4 'table' => 'svc_broadband',
6 'svc_field_callback' => $svc_field_callback,
7 'svc_new_callback' => $svc_edit_callback,
8 'svc_edit_callback' => $svc_edit_callback,
9 'svc_error_callback' => $svc_edit_callback,
10 'dummy' => $cgi->query_string,
11 'onsubmit' => 'validate_coords',
17 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
19 # If it's stupid but it works, it's still stupid.
22 my $conf = new FS::Conf;
25 <script type="text/javascript">
26 function validate_coords(f){
29 if ( $conf->exists('svc_broadband-require-nw-coordinates') ) {
31 var lon = f.longitude;
33 if ( lon == null || lat == null ||
34 lon.value.length == 0 || lat.value.length == 0 ) return true;
36 return (ut_coord(lat.value,1,90) && ut_coord(lon.value,-180,-1));
39 /* this is a JS re-implementation of FS::Record::ut_coord */
40 function ut_coord(coord,lower,upper) {
41 var neg = /^-/.test(coord);
42 coord = coord.replace(/^-/,'');
48 var t1 = /^(\\s*\\d{1,3}(?:\\.\\d+)?)\\s*\$/.exec(coord);
49 var t2 = /^(\\s*\\d{1,3})\\s+(\\d{1,2}(?:\\.\\d+))\\s*\$/.exec(coord);
50 var t3 = /^(\\s*\\d{1,3})\\s+(\\d{1,2})\\s+(\\d{1,3})\\s*\$/.exec(coord);
53 } else if ( t2 != null ) {
56 } else if ( t3 != null ) {
61 alert('Invalid co-ordinates! Latitude must be positive and longitude must be negative.');
65 var ts = /^\\d{3}\$/.exec(s);
66 if ( ts != null || s > 59 ) {
75 alert('Invalid coordinate with minutes > 59');
79 var tmp = parseInt(d)+parseInt(m)+parseInt(s);
81 coord = (neg ? -1 : 1) * tmp;
84 alert('Error: invalid coordinate < '+lower);
88 alert('Error: invalid coordinate > '+upper);
103 qw( description speed_down speed_up ),
104 { field=>'sectornum', type=>'select-tower_sector', },
105 { field=>'routernum', type=>'select-router_block_ip',
106 include_opt_callback => sub {
107 my $svc_broadband = shift;
108 my $part_svc = $svc_broadband->part_svc;
109 return () unless $part_svc; #sanity check
110 my $col = $part_svc->part_svc_column('ip_addr');
111 return () unless $col; #sanity check
112 return ('ip_addr_required' => $col->required);
115 { field=>'mac_addr' , type=>'input-mac_addr' },
117 latitude longitude altitude
118 radio_serialnum radio_location poe_location rssi suid
120 { field=>'shared_svcnum', type=>'search-svc_broadband', },
121 qw( vlan_profile performance_profile authkey plan_id ),
124 if ( $conf->exists('svc_broadband-radius') ) {
126 { field => 'usergroup',
127 type => 'select-radius_group',
134 my $svc_edit_callback = sub {
135 my ($cgi, $svc_x, $part_svc_x, $cust_pkg, $fields, $opt) = @_;
137 $part_svc = $part_svc_x; #for field_callback to use
139 my ($nas_export) = $part_svc->part_export('broadband_nas');
140 #can we assume there's only one of these per part_svc?
143 if ( $svc_x->svcnum ) {
144 $nas = qsearchs('nas', { 'svcnum' => $svc_x->svcnum });
146 $nas ||= $nas_export->default_nas;
147 $svc_x->set($_, $nas->$_) foreach fields('nas');
149 # duplicates the fields in httemplate/edit/nas.html (mostly)
151 { type => 'tablebreak-tr-title',
152 #value => 'Attached NAS',
153 value => $nas_export->exportname,
156 { field=>'nasnum', type=>'hidden', },
157 { field=>'shortname', size=>16, maxlength=>32 },
158 { field=>'secret', size=>40, maxlength=>60, required=>1 },
159 { field=>'type', type=>'select',
160 options=>[qw( cisco computone livingston max40xx multitech netserver
161 pathras patton portslave tc usrhiper other )],
163 { field=>'ports', size=>5 },
164 { field=>'server', size=>40, maxlength=>64 },
165 { field=>'community', size=>40, maxlength=>50 },
168 $opt->{'labels'}{'shortname'} = 'Short name';
169 $opt->{'labels'}{'secret'} = 'Shared secret';
170 $opt->{'labels'}{'type'} = 'Type';
171 $opt->{'labels'}{'ports'} = 'Ports';
172 $opt->{'labels'}{'server'} = 'Server';
173 $opt->{'labels'}{'community'} = 'Community';
177 my $svc_field_callback = sub {
178 my ($cgi, $object, $fieldref) = @_;
180 my $columndef = $part_svc->part_svc_column($fieldref->{'field'});
181 if ($fieldref->{field} eq 'usergroup' && $columndef->columnflag eq 'F') {
183 $fieldref->{'formatted_value'} =
184 [ $object->radius_groups('long_description') ];