summaryrefslogtreecommitdiff
path: root/httemplate/misc/phone_device_config.html
diff options
context:
space:
mode:
authorjeff <jeff>2010-02-08 15:37:29 +0000
committerjeff <jeff>2010-02-08 15:37:29 +0000
commitd0221fabd4656b3a04251ca6168cc45f54d23574 (patch)
tree6edf3792883e58294de4d1c42a9ddbe52be1be85 /httemplate/misc/phone_device_config.html
parent942c8b05b17b119a3dad84d7035c76b481dc5b99 (diff)
grandstream device configuration support #4220
Diffstat (limited to 'httemplate/misc/phone_device_config.html')
-rw-r--r--httemplate/misc/phone_device_config.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/httemplate/misc/phone_device_config.html b/httemplate/misc/phone_device_config.html
new file mode 100644
index 000000000..9ea0d0d1c
--- /dev/null
+++ b/httemplate/misc/phone_device_config.html
@@ -0,0 +1,57 @@
+%if ($config) {
+<% $config %>
+%}else{
+<% include("/elements/errorpage.html", "No configuration data produced.") %>
+%}
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
+
+my $exportnum;
+if ( $cgi->param('exportnum') ) {
+ $cgi->param('exportnum') =~ /^(\d+)$/ or die "unparsable exportnum";
+ $exportnum = $1;
+}
+
+die "no export provided"
+ unless $exportnum;
+
+my $svcnum;
+if ( $cgi->param('svcnum') ) {
+ $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
+ $svcnum = $1;
+}
+
+my $devicenum;
+if ( $cgi->param('devicenum') ) {
+ $cgi->param('devicenum') =~ /^(\d+)$/ or die "unparsable devicenum";
+ $devicenum = $1;
+}
+
+die "no device or service provided"
+ unless $svcnum || $devicenum;
+
+my $part_export = qsearchs('part_export', { 'exportnum' => $exportnum })
+ or die "Unknown exportnum $exportnum\n";
+
+my $phone_device;
+my $svc_phone;
+if ($devicenum) {
+ $phone_device = qsearchs('phone_device', { 'devicenum' => $devicenum })
+ or die "Unknown device $devicenum\n";
+ $svc_phone = $phone_device->svc_phone;
+} else {
+ $svc_phone = qsearchs('svc_phone', { 'svcnum' => $svcnum })
+ or die "Unknown svc_phone $svcnum\n";
+}
+
+my $config = $part_export->export_device_config($svc_phone, $phone_device);
+
+if ($config) {
+ http_header('Content-Type' => 'application/octet-stream');
+ http_header('Content-Disposition' => 'attachment;filename="config"');
+ http_header('Content-Length' => length($config));
+}
+
+</%init>