Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / misc / tower-export.html
1 <%init>
2 # currently, browse/tower just shows all towers, so do the same here
3 my @towers = qsearch({ table => 'tower' });
4 http_header('Content-Type' => 'text/csv');
5 http_header('Content-Disposition' => 'attachment;filename=towers.csv');
6 if ( $cgi->param('format') eq 'tc' ) {
7   # towercoverage.com format: not a true CSV, no quoting (so no way to include
8   # commas in any field, so we strip them)
9
10   # lat/long are signed decimals, northeast positive
11   # height is in meters
12   # Description/Group are not necessary
13   # sector/antenna information (orientation, beamwidth, gain, frequency,
14   # etc.) is in what TC calls a "Coverage", which can't be edited this way.
15   my $text = "SiteName,Latitude,Longitude,Description,Group,Height\n";
16
17   foreach my $tower (@towers) {
18     next if ( !$tower->latitude or !$tower->longitude );
19
20     my $name = $tower->towername;
21     my $height = ($tower->height || 0) / 3.28;
22     $name =~ s(,)( )g;
23     $text .= join(',',
24       $name,
25       $tower->latitude,
26       $tower->longitude,
27       '',
28       '',
29       $height,
30     ) . "\n";
31   }
32   $m->print($text);
33 } else {
34   die('unknown format '.$cgi->param('format'));
35 }
36 </%init>