default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / view / deploy_zone-kmz.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 $kml = Geo::GoogleEarth::Pluggable->new;
11
12 my $name;
13
14 my($query) = $cgi->keywords;
15 if ( $query =~ /^(\d+)$/ || $cgi->param('zonenum') =~ /^(\d+$)/ ) {
16   my $zonenum = $1;
17   $name = $zonenum;
18   my $deploy_zone = qsearchs('deploy_zone', { 'zonenum' => $zonenum })
19     or die 'unknown zonenum';
20
21   $deploy_zone->kml_polygon($kml);
22
23 } elsif ( $cgi->param('zonetype') =~ /^(\w)$/ ) {
24   my $zonetype = $1;
25   $name = $zonetype;
26   my @deploy_zone = qsearch('deploy_zone', { 'zonetype' => $zonetype,
27                                              'disabled' => '',        });
28
29   $_->kml_polygon($kml) foreach @deploy_zone;
30
31 } else {
32   die "no zonenum or zonetype\n";
33 }
34
35 my $content = $kml->archive;
36
37 http_header('Content-Type' => 'application/vnd.google-earth.kmz' ); #kmz
38 http_header('Content-Disposition' => "filename=$name.kmz" );
39 http_header('Content-Length'      => length($content) );
40 http_header('Cache-control'       => 'max-age=60' );
41
42 </%init>