default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / view / deploy_zone-geojson.cgi
1 <% $content %>\
2 <%init>
3
4 my $curuser = $FS::CurrentUser::CurrentUser;
5 my $acl_edit = $curuser->access_right('Edit FCC report configuration');
6 my $acl_edit_global = $curuser->access_right('Edit FCC report configuration for all agents');
7 die "access denied"
8   unless $acl_edit or $acl_edit_global;
9
10 my($name, $content);
11
12 my($query) = $cgi->keywords;
13 if ( $query =~ /^(\d+)$/ || $cgi->param('zonenum') =~ /^(\d+$)/ ) {
14   my $zonenum = $1;
15   $name = $zonenum;
16   my $deploy_zone = qsearchs('deploy_zone', { 'zonenum' => $zonenum })
17     or die 'unknown zonenum';
18
19   $content = $deploy_zone->geo_json_feature->to_json;
20
21 } elsif ( $cgi->param('zonetype') =~ /^(\w)$/ ) {
22   my $zonetype = $1;
23   $name = $zonetype;
24   my @deploy_zone = qsearch('deploy_zone', { 'zonetype' => $zonetype,
25                                              'disabled' => '',        });
26
27    my $fc = Geo::JSON::FeatureCollection->new({
28      features => [ map $_->geo_json_feature, @deploy_zone ],
29    });
30
31    $content = $fc->to_json;
32
33 } else {
34   die "no zonenum or zonetype\n";
35 }
36
37 http_header('Content-Type'        => 'application/geo+json' );
38 http_header('Content-Disposition' => "filename=$name.geojson" );
39 http_header('Content-Length'      => length($content) );
40 http_header('Cache-control'       => 'max-age=60' );
41
42 </%init>