RT# 75817 - updated UI to be more intuitive
[freeside.git] / httemplate / misc / phone_device_config.html
1 %if ($config) {
2 <% $config %>
3 %}else{
4 <% include("/elements/errorpage.html", "No configuration data produced.") %>
5 %}
6 <%init>
7
8 die "access denied"
9   unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
10
11 my $exportnum;
12 if ( $cgi->param('exportnum') ) {
13   $cgi->param('exportnum') =~ /^(\d+)$/ or die "unparsable exportnum";
14   $exportnum = $1;
15
16
17 die "no export provided"
18   unless $exportnum;
19
20 my $svcnum;
21 if ( $cgi->param('svcnum') ) {
22   $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
23   $svcnum = $1;
24
25
26 my $devicenum;
27 if ( $cgi->param('devicenum') ) {
28   $cgi->param('devicenum') =~ /^(\d+)$/ or die "unparsable devicenum";
29   $devicenum = $1;
30
31
32 die "no device or service provided"
33   unless $svcnum || $devicenum;
34
35 my $part_export = qsearchs('part_export', { 'exportnum' => $exportnum })
36   or die "Unknown exportnum $exportnum\n";
37
38 my $phone_device;
39 my $svc_phone;
40 if ($devicenum) {
41   $phone_device = qsearchs('phone_device', { 'devicenum' => $devicenum })
42     or die "Unknown device $devicenum\n";
43   $svc_phone = $phone_device->svc_phone;
44 } else {
45   $svc_phone = qsearchs('svc_phone', { 'svcnum' => $svcnum })
46     or die "Unknown svc_phone $svcnum\n";
47 }
48
49 my $config = $part_export->export_device_config($svc_phone, $phone_device);
50
51 if ($config) {
52   http_header('Content-Type' => 'application/octet-stream');
53   http_header('Content-Disposition' => 'attachment;filename="config"');
54   http_header('Content-Length' => length($config));
55 }
56
57 </%init>