Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / deploy_zone-fixed.html
1 <& elements/edit.html,
2     'name_singular' => 'deployment zone',
3     'table'         => 'deploy_zone',
4     'post_url'      => popurl(1).'process/deploy_zone-fixed.html',
5     'viewall_dir'   => 'browse',
6     'labels'        => {
7         'description'     => 'Description',
8         'agentnum'        => 'Agent',
9         'dbaname'         => 'Business name (if different from agent)',
10         'technology'      => 'Technology',
11         'adv_speed_up'    => 'Upstream',
12         'adv_speed_down'  => 'Downstream',
13         'cir_speed_up'    => 'Upstream',
14         'cir_speed_down'  => 'Downstream',
15         'is_consumer'     => 'Consumer/mass market',
16         'is_business'     => 'Business/government',
17         'blocknum'        => '',
18         'active_date'     => 'Active since',
19         'file'            => 'Import blocks from text file',
20         'censusyear'      => 'as census year',
21     },
22     'fields'        => [
23         { field         => 'zonetype',
24           type          => 'hidden',
25           value         => 'B'
26         },
27         { field         => 'is_broadband',
28           type          => 'hidden',
29           value         => 'Y',
30         },
31         'description',
32         { field         => 'active_date',
33           type          => 'fixed-date',
34           value         => time,
35         },
36         { field         => 'agentnum',
37           type          => 'select-agent',
38           disable_empty => 1,
39           viewall_right => 'Edit FCC report configuration for all agents',
40         },
41         'dbaname',
42         { field         => 'technology',
43           type          => 'select',
44           options       => [ map { @$_ } values(%$media_types) ],
45           labels        => $technology_labels,
46         },
47         { field         => 'is_consumer', type => 'checkbox', value=>'Y' },
48         { field         => 'is_business', type => 'checkbox', value=>'Y' },
49         { type => 'tablebreak-tr-title',
50           value => 'Advertised maximum speed (Mbps)' },
51         'adv_speed_down',
52         'adv_speed_up',
53         { type => 'tablebreak-tr-title',
54           value => 'Contractually guaranteed speed (Mbps)' },
55         'cir_speed_down',
56         'cir_speed_up',
57
58         { type => 'tablebreak-tr-title', value => 'Census blocks'},
59         { field => 'file',
60           type  => 'file-upload',
61         },
62         { field => 'format',
63           type  => 'hidden',
64           value => 'plain',
65         },
66         { field => 'censusyear',
67           type  => 'select',
68           options => [ '', qw( 2013 2012 2011 ) ],
69         },
70
71         { type => 'tablebreak-tr-title', value => '', },
72         { field => 'blocknum',
73           type              => 'deploy_zone_block',
74           o2m_table         => 'deploy_zone_block',
75           m2_label          => ' ',
76           m2_error_callback => $m2_error_callback,
77         },
78     ],
79
80 &>
81 <%init>
82 my $curuser = $FS::CurrentUser::CurrentUser;
83 die "access denied"
84   unless $curuser->access_right([
85     'Edit FCC report configuration',
86     'Edit FCC report configuration for all agents',
87   ]);
88
89 my $technology_labels = FS::part_pkg_fcc_option->technology_labels;
90 my $media_types = FS::part_pkg_fcc_option->media_types;
91 delete $media_types->{'Mobile Wireless'}; # cause this is the fixed zone page
92
93 my $m2_error_callback = sub {
94   my ($cgi, $deploy_zone) = @_;
95   my @blocknums = grep {
96     /^blocknum\d+/ and length($cgi->param($_.'_censusblock'))
97   } $cgi->param;
98
99   sort { $a->censusblock <=> $b->censusblock }
100   map {
101     my $k = $_;
102     FS::deploy_zone_block->new({
103       blocknum    => scalar($cgi->param($k)),
104       zonenum     => $deploy_zone->zonenum,
105       censusblock => scalar($cgi->param($k.'_censusblock')),
106       censusyear  => scalar($cgi->param($k.'_censusyear')),
107     })
108   } @blocknums;
109 };
110
111 </%init>