summaryrefslogtreecommitdiff
path: root/httemplate/view/svc_pbx.cgi
diff options
context:
space:
mode:
authorcvs2git <cvs2git>2010-11-05 19:05:57 +0000
committercvs2git <cvs2git>2010-11-05 19:05:57 +0000
commitaaf8baf3662e16e9414de236a39f8801a8c41b01 (patch)
tree2cda603e4311b3e80f79b93d9bcce3a7c7c2d053 /httemplate/view/svc_pbx.cgi
parent995a145c931164347683071c95c6754379d36604 (diff)
parent9b2de4257b6a2877434008188e52b8ef71ff339d (diff)
This commit was manufactured by cvs2svn to create branch
'FREESIDE_2_1_BRANCH'.
Diffstat (limited to 'httemplate/view/svc_pbx.cgi')
-rw-r--r--httemplate/view/svc_pbx.cgi72
1 files changed, 72 insertions, 0 deletions
diff --git a/httemplate/view/svc_pbx.cgi b/httemplate/view/svc_pbx.cgi
new file mode 100644
index 0000000..79cafed
--- /dev/null
+++ b/httemplate/view/svc_pbx.cgi
@@ -0,0 +1,72 @@
+<% include('elements/svc_Common.html',
+ 'table' => 'svc_pbx',
+ 'edit_url' => $p."edit/svc_Common.html?svcdb=svc_pbx;svcnum=",
+ 'labels' => \%labels,
+ 'html_foot' => $html_foot,
+ )
+%>
+<%init>
+
+my $fields = FS::svc_pbx->table_info->{'fields'};
+my %labels = map { $_ => ( ref($fields->{$_})
+ ? $fields->{$_}{'label'}
+ : $fields->{$_}
+ );
+ }
+ keys %$fields;
+
+my $html_foot = sub {
+ my $svc_pbx = shift;
+
+ ##
+ # CDR links
+ ##
+
+ tie my %what, 'Tie::IxHash',
+ 'pending' => 'NULL',
+ 'billed' => 'done',
+ ;
+
+ #matching as per package def cdr_svc_method
+ my $cust_pkg = $svc_pbx->cust_svc->cust_pkg;
+ return '' unless $cust_pkg;
+
+ my @voip_pkgs =
+ grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
+ if ( scalar(@voip_pkgs) > 1 ) {
+ warn "multiple voip_cdr packages bundled\n";
+ return '';
+ } elsif ( !@voip_pkgs ) {
+ warn "no voip_cdr packages\n";
+ }
+ my $voip_pkg = @voip_pkgs[0];
+
+ my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
+ || 'svc_phone.phonenum';
+ return '' unless $cdr_svc_method =~ /^svc_pbx\.(\w+)$/;
+ my $field = $1;
+
+ my $search;
+ if ( $field eq 'title' ) {
+ $search = 'charged_party='. uri_escape($svc_pbx->title);
+ } elsif ( $field eq 'svcnum' ) {
+ $search = 'svcnum='. $svc_pbx->svcnum;
+ } else {
+ warn "unknown cdr_svc_method svc_pbx.$field";
+ return '';
+ }
+
+ my @links = map {
+ qq(<A HREF="${p}search/cdr.html?cdrbatchnum=__ALL__;$search;freesidestatus=$what{$_}">).
+ "View $_ CDRs</A>";
+ } keys(%what);
+
+ ###
+ # concatenate & return
+ ###
+
+ join(' | ', @links ). '<BR>';
+
+};
+
+</%init>