<%= sub ws_pkglink { my($cat,$count,$link) = (shift,shift,shift); return "0 $cat
" unless $count->{$cat}; return qq! $count->{$cat} $cat
!; } sub ws_pkgstatus { my $pkg = shift; $status = "unbilled"; $status = "active" if ( $pkg->{setup} && !$pkg->{cancel} && !$pkg->{susp} ); $status = "suspended" if ( $pkg->{susp} && !$pkg->{cancel} ); $status = "cancelled" if $pkg->{cancel}; $status; } sub pdate { my($field,$date_format) = (shift,shift); return "".Date::Format::time2str($date_format,$field)."" if $field && $field > 0; ''; } if ( $pkgpart ) { $OUT .= qq!

Package | Status !; $OUT .= " | Setup | Last Bill | Next Bill | Adjourn"; $OUT .= " | Suspend | Expire | Contract End"; $OUT .= " | Cancel | Services
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
"; foreach my $pkg ( @cust_pkg ) { my $part_pkg = $pkg->{part_pkg}[0]; $status = ws_pkgstatus($pkg); if($pkg->{pkgpart} == $pkgpart && ( ($filter && $filter eq $status) || !$filter) ) { $OUT .= "
$part_pkg->{pkg} | $status"; $OUT .= pdate($pkg->{setup},$date_format); $OUT .= pdate($pkg->{last_bill},$date_format); $OUT .= pdate($pkg->{bill},$date_format); $OUT .= pdate($pkg->{adjourn},$date_format); $OUT .= pdate($pkg->{susp},$date_format); $OUT .= pdate($pkg->{expire},$date_format); $OUT .= pdate($pkg->{contract_end},$date_format); $OUT .= pdate($pkg->{cancel},$date_format); $OUT .= " | "; my @cust_svc = @{$pkg->{cust_svc}}; foreach my $cust_svc ( @cust_svc ) { my @label = @{$cust_svc->{'label'}}; $OUT .= qq!$label[0]: $label[1] !; } my @part_svc = @{$pkg->{part_svc}}; foreach my $part_svc ( @part_svc ) { my $link = qq!Setup ! . qq!$part_svc->{'svc'} ($part_svc->{'num_avail'}! . qq! available) !; $OUT .= $link if $part_svc->{'can_get_dids'}; if($part_svc->{'svcdb'} eq 'svc_phone' && $lnp) { $OUT .= qq!Port-In $part_svc->{'svc'}!; } } $OUT .= "
"; } } $OUT .= "

"; } else { my %pkgparts; foreach my $pkg ( @cust_pkg ) { my $status = ws_pkgstatus($pkg); $pkgparts{$pkg->{pkgpart}}{$status}++; my $part_pkg = $pkg->{part_pkg}[0]; $pkgparts{$pkg->{pkgpart}}{pkg} = $part_pkg->{pkg}; } $OUT .= "

"; $OUT .= qq!
Package | Status
--- | ---
!; my($pkgpart,$counts); while(($pkgpart,$count) = each %pkgparts){ my $link = "${url}provision;pkgpart=$pkgpart"; $OUT .= qq!
$count->{pkg} | !; $OUT .= ws_pkglink("unbilled",$count,$link); $OUT .= ws_pkglink("active",$count,$link); $OUT .= ws_pkglink("suspended",$count,$link); $OUT .= ws_pkglink("cancelled",$count,$link); $OUT .= "
"; } $OUT .= " "; $OUT .= qq! | !; if ( @login_svcpart ) { $OUT .= "Self-service accounts "; foreach my $pkg ( @cust_pkg ) { @cust_svc = @{$pkg->{cust_svc}}; @part_svc = @{$pkg->{part_svc}}; foreach my $cust_svc ( @cust_svc ) { $svcpart = $cust_svc->{'svcpart'}; next unless grep($_ eq $svcpart, @login_svcpart); @label = @{$cust_svc->{'label'}}; $OUT .= $label[1] . " "; unless ( $cust_svc->{'svcnum'} == $svcnum ) { $OUT .= qq!!. 'Delete'; } $OUT .= " "; } foreach my $part_svc ( @part_svc ) { $svcpart = $part_svc->{'svcpart'}; next unless grep($_ eq $svcpart, @login_svcpart); $link = "${url}provision_svc;pkgnum=$pkg->{'pkgnum'};". "svcpart=$part_svc->{'svcpart'}"; $OUT .= qq!!. 'Setup '. $part_svc->{'svc'}. ' ('. $part_svc->{'num_avail'}. ' available)' if $part_svc->{'svcdb'} eq 'svc_acct'; } } # foreach cust_pkg } # login_svcpart my $hasPhone = 0; foreach my $pkg ( @cust_pkg ) { @cust_svc = @{$pkg->{cust_svc}}; foreach my $cust_svc ( @cust_svc ) { @label = @{$cust_svc->{'label'}}; $hasPhone = 1 if $label[2] eq 'svc_phone'; } } if ( $hasPhone ) { $link = "${url}didreport;type="; $OUT .= " Download currently allocated DIDs: "; $OUT .= qq! CSV | Excel!; $OUT .= " Download recently allocated DIDs: "; $OUT .= qq! CSV | Excel!; } $OUT .= "

"; } %>