1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<& elements/edit.html,
name_singular => 'tower',
table => 'tower',
viewall_dir => 'browse',
html_init => include('/elements/mapselect.html'),
fields => [ 'towername',
{ field=>'disabled', type=>'checkbox', value=>'Y', },
{ field=>'color', type=>'pickcolor' },
{ field => 'default_ip_addr',
curr_value_callback => $default_ip_addr_callback },
'latitude',
'longitude',
'altitude',
'height',
'veg_height',
'up_rate_limit',
'down_rate_limit',
# { field => 'sectornum',
# type => 'tower_sector',
# o2m_table => 'tower_sector',
# m2_label => 'Sector',
# m2_label_callback => sub { 'Sector #'.shift->sectornum; },
# m2_error_callback => $m2_error_callback,
# },
{ type => 'tower_sectors',
field => 'sectornum',
# does its own o2m-thing
},
],
labels => { 'towernum' => 'Tower',
'towername' => 'Name',
'sectornum' => 'Sector',
'disabled' => 'Disabled',
'default_ip_addr' => 'Tower IP address',
'latitude' => 'Latitude',
'longitude' => 'Longitude',
'altitude' => 'Altitude (feet)',
'height' => 'Tower height (feet)',
'veg_height' => 'Vegetation height (feet)',
'color' => 'Color',
'up_rate_limit' => 'Up Rate Limit(Kbps)',
'down_rate_limit' => 'Down Rate Limit(Kbps)',
},
&>
<%init>
my $m2_error_callback = sub { # reconstruct the list
my ($cgi, $object) = @_;
my @fields = qw(
sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range up_rate_limit down_rate_limit
);
my @sectors;
foreach my $k ($cgi->param) {
if ($k =~ /^sectornum\d+$/) {
my $sectornum = $cgi->param($k);
my $sector = FS::tower_sector->new({
'sectornum' => $sectornum,
'towernum' => $object->towernum,
map { $_ => scalar($cgi->param($k.'_'.$_)) } @fields,
});
push @sectors, $sector if length($sector->sectorname) && $sector->sectorname ne '_default';
}
}
return @sectors;
};
my $default_ip_addr_callback = sub {
my ($cgi, $object) = @_;
my $sector = $object ? $object->default_sector : '';
$sector ? $sector->ip_addr : '';
};
</%init>
|