diff options
Diffstat (limited to 'httemplate/view/cust_main/packages')
-rw-r--r-- | httemplate/view/cust_main/packages/location.html | 66 | ||||
-rw-r--r-- | httemplate/view/cust_main/packages/package.html | 264 | ||||
-rwxr-xr-x | httemplate/view/cust_main/packages/section.html | 95 | ||||
-rw-r--r-- | httemplate/view/cust_main/packages/services.html | 178 | ||||
-rw-r--r-- | httemplate/view/cust_main/packages/status.html | 488 |
5 files changed, 0 insertions, 1091 deletions
diff --git a/httemplate/view/cust_main/packages/location.html b/httemplate/view/cust_main/packages/location.html deleted file mode 100644 index 40a7de59f..000000000 --- a/httemplate/view/cust_main/packages/location.html +++ /dev/null @@ -1,66 +0,0 @@ -<TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> - -% unless ( $cust_pkg->locationnum ) { - <I><FONT SIZE=-1>(default service address)</FONT><BR> -% } - - <% $loc->location_label( 'join_string' => '<BR>', - 'double_space' => ' ', - 'escape_function' => \&encode_entities, - 'countrydefault' => $countrydefault, - ) - %> - -% unless ( $cust_pkg->locationnum ) { - </I> -% } - -% if ( ! $cust_pkg->get('cancel') -% && $FS::CurrentUser::CurrentUser->access_right('Change customer package') -% ) -% { - <FONT SIZE=-1> - ( <%pkg_change_location_link($cust_pkg)%> ) -% if ( $cust_pkg->locationnum ) { - ( <%edit_location_link($cust_pkg->locationnum)%> ) -% } - </FONT> -% } - -</TD> -<%init> - -my $conf = new FS::Conf; -my %opt = @_; - -my $bgcolor = $opt{'bgcolor'}; -my $cust_pkg = $opt{'cust_pkg'}; -my $countrydefault = $opt{'countrydefault'} || 'US'; -my $statedefault = $opt{'statedefault'} - || ($countrydefault eq 'US' ? 'CA' : ''); - -my $loc = $cust_pkg->cust_location_or_main; - -sub pkg_change_location_link { - my $cust_pkg = shift; - my $pkgpart = $cust_pkg->pkgpart; - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;". - "address1=;address2=;city=;county=;state=$statedefault;". - "zip=;country=$countrydefault", - 'label' => 'Change location', - 'actionlabel' => 'Change', - 'cust_pkg' => $cust_pkg, - ); -} - -sub edit_location_link { - my $locationnum = shift; - include( '/elements/popup_link.html', - 'action' => $p. "edit/cust_location.cgi?locationnum=$locationnum", - 'label' => 'Edit location', - 'actionlabel' => 'Edit', - ); -} - -</%init> diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html deleted file mode 100644 index 8cae5fdba..000000000 --- a/httemplate/view/cust_main/packages/package.html +++ /dev/null @@ -1,264 +0,0 @@ -<TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="top"> - <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - <TR> - <TD COLSPAN=2> - <A NAME="cust_pkg<% $cust_pkg->pkgnum %>" - ID ="cust_pkg<% $cust_pkg->pkgnum %>" - ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A> - - - <% $part_pkg->custom_comment |h %> - </TD> - </TR> - -% if ( $cust_pkg->quantity > 1 ) { - <TR> - <TD COLSPAN=2> - Quantity: - <B><% $cust_pkg->quantity %></B> - </TD> - </TR> -% } - - <TR> - <TD COLSPAN=2> - <FONT SIZE=-1> - -% unless ( $cust_pkg->get('cancel') ) { -% -% my $br = 0; -% if ( $curuser->access_right('Change customer package') ) { -% $br=1; - ( <%pkg_change_link($cust_pkg)%> ) -% } -% -% if ( $curuser->access_right('Edit customer package dates') ) { -% $br=1; - ( <%pkg_dates_link($cust_pkg)%> ) -% } -% -% if ( $curuser->access_right('Discount customer package') -% && $part_pkg->can_discount -% && ! scalar($cust_pkg->cust_pkg_discount_active) -% && ! scalar($cust_pkg->part_pkg->part_pkg_discount) -% ) -% { -% $br=1; - ( <%pkg_discount_link($cust_pkg)%> ) -% } -% -% if ( $curuser->access_right('Customize customer package') ) { -% $br=1; - ( <%pkg_customize_link($cust_pkg,$part_pkg)%> ) -% } -% - <% $br ? '<BR>' : '' %> -% } - -% if ( $cust_pkg->num_cust_event -% && ( $curuser->access_right('Billing event reports') -% || $curuser->access_right('View customer billing events') -% ) -% ) { - ( <%pkg_event_link($cust_pkg)%> ) -% } - - </FONT> - </TD> - </TR> - -% my $editi = $curuser->access_right('Edit customer package invoice details'); -% my $editc = $curuser->access_right('Edit customer package comments'); -% my @cust_pkg_detail = $cust_pkg->cust_pkg_detail; -% my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail; -% my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail; -% -% if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) { -% -% my $editlink = $p. 'edit/cust_pkg_detail?pkgnum='. $cust_pkg->pkgnum. -% ';detailtype='; - - <TR> - -% if ( @invoice_detail ) { - <TD VALIGN="top"> - <% include('/elements/table-grid.html') %> - <TR> - <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px"> - <FONT SIZE="-1"> - Invoice details -% if ( $editi && ! $cust_pkg->get('cancel') ) { - (<% include('/elements/popup_link.html', { - 'action' => $editlink. 'I', - 'label' => 'edit', - 'actionlabel' => 'Edit invoice details', - 'color' => '#333399', - 'width' => 763, - }) - %>) -% } - </FONT> - </TH> - </TR> -% foreach my $cust_pkg_detail ( @invoice_detail ) { - <TR> - <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD> - </TR> -% } - </TABLE> - </TD> -% } else { - <TD> -% if ( $editi && ! $cust_pkg->get('cancel') ) { - <FONT SIZE="-1"> - ( <% include('/elements/popup_link.html', { - 'action' => $editlink. 'I', - 'label' => 'Add invoice details', - 'actionlabel' => 'Add invoice details', - 'color' => '#333399', - 'width' => 763, - }) - %> ) - </FONT> -% } - </TD> -% } - -% if ( @comments ) { - <TD VALIGN="top"> - <% include('/elements/table-grid.html') %> - <TR> - <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px"> - <FONT SIZE="-1"> - Comments -% if ( $editc ) { - (<% include('/elements/popup_link.html', { - 'action' => $editlink. 'C', - 'label' => 'edit', - 'actionlabel' => 'Edit comments', - 'color' => '#333399', - 'width' => 763, - }) - %>) -% } - </FONT> - </TH> - </TR> -% foreach my $cust_pkg_detail ( @comments ) { - <TR> - <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD> - </TR> -% } - </TABLE> - </TD> -% } else { - <TD> -% if ( $editc ) { - <FONT SIZE="-1"> - ( <% include('/elements/popup_link.html', { - 'action' => $editlink. 'C', - 'label' => 'Add comments', - 'actionlabel' => 'Add comments', - 'color' => '#333399', - 'width' => 763, - }) - %> ) - </FONT> -% } - </TD> -% } - - </TR> -% if ( $curuser->access_right('Change customer package') and -% !$cust_pkg->get('cancel') and -% !$opt{'show_location'}) { - <TR> - <TD><FONT SIZE="-1"> - ( <% pkg_change_location_link($cust_pkg) %> ) - </FONT></TD> - </TR> -% } -% } - </TABLE> - -</TD> - -<%init> - -my %opt = @_; - -my $bgcolor = $opt{'bgcolor'}; -my $cust_pkg = $opt{'cust_pkg'}; -my $part_pkg = $opt{'part_pkg'}; - -my $curuser = $FS::CurrentUser::CurrentUser; - -my $countrydefault = $opt{'countrydefault'} || 'US'; -my $statedefault = $opt{'statedefault'} - || ($countrydefault eq 'US' ? 'CA' : ''); - -#subroutines - -#false laziness w/status.html -sub pkg_link { - my($action, $label, $cust_pkg) = @_; - return '' unless $cust_pkg; - qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!; -} - -sub pkg_change_link { - my $cust_pkg = shift; - my $locationnum = $cust_pkg->locationnum; - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum", - 'label' => 'Change package', - 'actionlabel' => 'Change', - 'cust_pkg' => $cust_pkg, - ); -} - -sub pkg_change_location_link { - my $cust_pkg = shift; - my $pkgpart = $cust_pkg->pkgpart; - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;". - "address1=;address2=;city=;county=;state=$statedefault;". - "zip=;country=$countrydefault", - 'label' => 'Change location', - 'actionlabel' => 'Change', - 'cust_pkg' => $cust_pkg, - ); -} - -sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); } - -sub pkg_discount_link { - my $cust_pkg = shift or return ''; - #my $part_pkg = shift; - #my $custnum = $cust_pkg->custnum; - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p.'edit/cust_pkg_discount.html', - 'label' => 'Discount', - 'actionlabel' => 'Discount', - 'cust_pkg' => $cust_pkg, - 'width' => 616, - ); -} - -sub pkg_customize_link { - my $cust_pkg = shift or return ''; - my $part_pkg = shift; - my $custnum = $cust_pkg->custnum; - qq!<A HREF="${p}edit/part_pkg.cgi?!. - "clone=". $part_pkg->pkgpart. ';'. - "pkgnum=". $cust_pkg->pkgnum. - qq!">Customize</A>!; -} - -sub pkg_event_link { - my($cust_pkg) = @_; - qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!. - 'View package events'. - '</a>'; -} - -</%init> diff --git a/httemplate/view/cust_main/packages/section.html b/httemplate/view/cust_main/packages/section.html deleted file mode 100755 index 45365a003..000000000 --- a/httemplate/view/cust_main/packages/section.html +++ /dev/null @@ -1,95 +0,0 @@ -% if ( @$packages ) { -% my $bgcolor1 = '#eeeeee'; -% my $bgcolor2 = '#ffffff'; -% my $bgcolor = ''; - -<TR> -% #my $width = $show_location ? 'WIDTH="25%"' : 'WIDTH="33%"'; - <TH CLASS="grid" BGCOLOR="#cccccc">Package</TH> - <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH> -% if ( $show_location ) { - <TH CLASS="grid" BGCOLOR="#cccccc">Location</TH> -% } - <TH CLASS="grid" BGCOLOR="#cccccc">Services</TH> -</TR> - -% #$FS::cust_pkg::DEBUG = 2; -% foreach my $cust_pkg (@$packages) { -% -% if ( $bgcolor eq $bgcolor1 ) { -% $bgcolor = $bgcolor2; -% } else { -% $bgcolor = $bgcolor1; -% } -% -% my %iopt = ( -% 'bgcolor' => $bgcolor, -% 'cust_pkg' => $cust_pkg, -% 'part_pkg' => $cust_pkg->part_pkg, -% %conf_opt, -% ); -% - - <!--pkgnum: <% $cust_pkg->pkgnum %>--> - <TR> - <% include('package.html', %iopt) %> - <% include('status.html', %iopt) %> -% if ( $show_location ) { - <% include('location.html', %iopt) %> -% } - <% include('services.html', %iopt) %> - </TR> - -% } #foreach $cust_pkg -%# </TABLE> -% } #if @$packages -% else { -<BR> -% } - -<%init> - -my %opt = @_; -my $conf = new FS::Conf; - -my $curuser = $FS::CurrentUser::CurrentUser; - -my $packages = $opt{'packages'}; -my $show_location = $opt{'show_location'}; - -# Sort order is hardcoded for now, can change this if needed. -@$packages = sort { - ( $a->getfield('cancel') <=> $b->getfield('cancel') ) or - ( $a->getfield('setup') <=> $b->getfield('setup') ) or - ( $a->getfield('pkgnum') <=> $b->getfield('pkgnum') ) -} @$packages; - -my $countrydefault = scalar($conf->config('countrydefault')) || 'US'; - -my %conf_opt = ( - #for services.html and status.html - 'cust_pkg-display_times' => ($conf->exists('cust_pkg-display_times') - || $curuser->option('cust_pkg-display_times')), - #for status.html - 'cust_pkg-show_autosuspend' => $conf->exists('cust_pkg-show_autosuspend'), - #for status.html pkg-balances - 'pkg-balances' => $conf->exists('pkg-balances'), - 'money_char' => ( $conf->config('money_char') || '$' ), - - #for location.html - 'countrydefault' => $countrydefault, - 'statedefault' => ( scalar($conf->config('statedefault')) - || ($countrydefault eq 'US' ? 'CA' : '') ), - #for services.html - 'svc_external-skip_manual' => $conf->exists('svc_external-skip_manual'), - 'legacy_link' => $conf->exists('legacy_link'), - 'svc_broadband-manage_link' => scalar($conf->config('svc_broadband-manage_link')), - 'maestro-status_test' => $conf->exists('maestro-status_test'), - 'cust_pkg-large_pkg_size' => $conf->config('cust_pkg-large_pkg_size'), - - # for packages.html Change location link - 'show_location' => $show_location, -); - - -</%init> diff --git a/httemplate/view/cust_main/packages/services.html b/httemplate/view/cust_main/packages/services.html deleted file mode 100644 index 512efccc4..000000000 --- a/httemplate/view/cust_main/packages/services.html +++ /dev/null @@ -1,178 +0,0 @@ -% ### -% # Services -% ### - - <TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> - <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - <SCRIPT TYPE="text/javascript"> -function clearhint_search_cust_svc(obj, str) { - if (obj.value == str) obj.value = ''; -} - </SCRIPT> - -% #foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) { -% foreach my $part_svc ( $cust_pkg->part_svc ) { - -% if ( $opt{'cust_pkg-large_pkg_size'} > 0 and -% $opt{'cust_pkg-large_pkg_size'} <= $cust_pkg->num_svcs ) { -% # summarize - <TR> - <TD ALIGN="center" VALIGN="top"> -% my $href="${p}search/cust_pkg_svc.html?svcpart=".$part_svc->svcpart. -% ";pkgnum=".$cust_pkg->pkgnum; - <A HREF="<% $href %>"><% $part_svc->svc %></A> - <A HREF="<% $href %>"><B>(view all <% $cust_pkg->num_svcs %>)</B></A> -% my $hint = $hints{$part_svc->svcdb}; -% if ( $hint ) { - <BR> - <FORM name="svcpart<%$part_svc->svcpart%>_search" STYLE="display:inline" - ACTION="<%$p%>search/cust_pkg_svc.html" METHOD="GET"> - <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%$part_svc->svcpart%>"> - <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%$cust_pkg->pkgnum%>"> - <INPUT TYPE="text" NAME="search_svc" - onfocus="clearhint_search_cust_svc(this, '<%$hint%>')" VALUE="<%$hint%>"> - <INPUT TYPE="submit" VALUE="Search"></FORM> -% } #$hint - </TD> - </TR> -% } -% else { -% foreach my $cust_svc ( @{ $part_svc->cust_pkg_svc } ) { - - <TR> - <TD ALIGN="right" VALIGN="top"><% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %></TD> - <TD STYLE="padding-bottom:0px"><B><% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %></B></TD> - <TD><% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %></TD> - </TR> - - <TR> - <TD ALIGN="right" COLSPAN="3" VALIGN="top" STYLE="padding-bottom:1px;padding-top:0px"><FONT SIZE="-2" COLOR="#FFD000"> - - <% $cust_svc->overlimit ? "Overlimit: ". time2str('%b %o %Y' . ($opt{'cust_pkg-display_times'} ? ' %l:%M %P' : ''), $cust_svc->overlimit) : '' %> - </FONT></TD> - </TR> - - <TR> - <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"><FONT SIZE="-2"> - -% if ( $curuser->access_right('Recharge customer service') -% && $part_svc->svcdb eq 'svc_acct' -% && ( $cust_svc->svc_x->seconds ne '' -% || $cust_svc->svc_x->upbytes ne '' -% || $cust_svc->svc_x->downbytes ne '' -% || $cust_svc->svc_x->totalbytes ne '' -% ) -% ) { - ( <%svc_recharge_link($cust_svc)%> ) -% } - </FONT></TD> - - <TD ALIGN="right" VALIGN="top" STYLE="padding-bottom:5px;padding-top:0px"> - -% my $ip_addr = $cust_svc->svc_x->ip_addr; - -% if ( $part_svc->svcdb eq 'svc_broadband' ) { - <FONT SIZE="-1" STYLE="float:left">( <% include('/elements/popup_link-ping.html', 'ip'=> $ip_addr ) %> )</FONT> - -% } - -% my $manage_link = $opt{'svc_broadband-manage_link'}; -% if ( $manage_link && $part_svc->svcdb eq 'svc_broadband' ) { -% my $svc_manage_link = eval(qq("$manage_link")); - <FONT SIZE="-1" STYLE="float:left">( <A HREF="<% $svc_manage_link %>">Manage Device</A> )</FONT> - -% } - -% if ( $curuser->access_right('Unprovision customer service') ) { - <FONT SIZE="-2">( <%svc_unprovision_link($cust_svc)%> )</FONT> -% } - -% if ( $part_svc->svcdb eq 'svc_pbx' && $opt{'maestro-status_test'} ){ - <FONT SIZE="-2">( <A HREF="<% $p %>misc/maestro-customer_status-test.html?<% $cust_pkg->custnum.'+'.$cust_svc->svcnum %>">Test maestro status</A> )</FONT> -% } - - </TD> - </TR> -% } #foreach $cust_svc -% } - -% if ( ! $cust_pkg->get('cancel') -% && $curuser->access_right('Provision customer service') -% && $part_svc->num_avail -% ) { - - <TR> - <TD COLSPAN=3 ALIGN="center" STYLE="padding-bottom:4px;padding-top:0px"> - <B><% svc_provision_link($cust_pkg, $part_svc, \%opt, $curuser) %></B> - </TD> - </TR> - -% } - -% } - - </TABLE> - </TD> - -<%init> - -my %opt = @_; - -my $bgcolor = $opt{'bgcolor'}; -my $cust_pkg = $opt{'cust_pkg'}; -my $part_pkg = $opt{'part_pkg'}; -my $curuser = $FS::CurrentUser::CurrentUser; - -my $conf = new FS::Conf; - -sub svc_provision_link { - my ($cust_pkg, $part_svc, $opt, $curuser) = @_; - ( my $svc_nbsp = $part_svc->svc ) =~ s/\s+/ /g; - my $num_avail = $part_svc->num_avail; - my $pkgnum_svcpart = "pkgnum=". $cust_pkg->pkgnum. ';'. - "svcpart=". $part_svc->svcpart; - my $url; - if ( $part_svc->svcdb eq 'svc_external' #could be generalized - && $opt->{'svc_external-skip_manual'} - ) { - $url = "${p}edit/process/". $part_svc->svcdb. ".cgi?$pkgnum_svcpart"; - } else { - $url = svc_url( - 'm' => $m, - 'action' => 'edit', - 'part_svc' => $part_svc, - 'query' => $pkgnum_svcpart, - ); - #$url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart"; - } - - my $link = qq!<A CLASS="provision" HREF="$url">!. - "Provision $svc_nbsp ($num_avail)</A>"; - if ( $opt->{'legacy_link'} - && $curuser->access_right('View/link unlinked services') - ) - { - $link .= '<BR>'. - qq!<A CLASS="provision" HREF="${p}misc/link.cgi?!. - qq!$pkgnum_svcpart">!. - "Link to legacy $svc_nbsp ($num_avail)</A>"; - } - $link; -} - -sub svc_unprovision_link { - my $cust_svc = shift or return ''; - qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?!. $cust_svc->svcnum. - qq!', 'Permanently unprovision and delete this service?')">Unprovision</A>!; -} - -my %hints = ( -svc_acct => '(user or email)', -svc_domain => '(domain)', -svc_broadband => '(ip or mac)', -svc_forward => '(email)', -svc_phone => '(phone)', -svc_pbx => '(phone)', -); - -</%init> diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html deleted file mode 100644 index f9198c2dc..000000000 --- a/httemplate/view/cust_main/packages/status.html +++ /dev/null @@ -1,488 +0,0 @@ -<TD CLASS="inv" BGCOLOR="<% $bgcolor %>"> - <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> - -%#this should use cust_pkg->status and cust_pkg->statuscolor eventually - -% if ( $cust_pkg->get('cancel') ) { #status: cancelled -% my $cpr = $cust_pkg->last_cust_pkg_reason('cancel'); - - <% pkg_status_row($cust_pkg, 'Cancelled', 'cancel', 'color'=>'FF0000', %opt ) %> - - <% pkg_status_row_colspan( $cust_pkg, - ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', - 'align'=>'right', 'color'=>'ff0000', 'size'=>'-2', 'colspan'=>$colspan, - %opt - ) - %> - -% unless ( $cust_pkg->get('setup') ) { - - <% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt, ) %> - -% } else { - - <% pkg_status_row( $cust_pkg, 'Setup', 'setup', %opt ) %> - <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if( $cust_pkg, 'Suspended', 'susp', %opt, curuser=>$curuser ) %> - -% } -% -% } else { -% -% if ( $cust_pkg->get('susp') ) { #status: suspended -% my $cpr = $cust_pkg->last_cust_pkg_reason('susp'); - - <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', %opt ) %> - - <% pkg_status_row_colspan( $cust_pkg, - ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', - 'align'=>'right', 'color'=>'FF9900', 'size'=>'-2', 'colspan'=>$colspan, - %opt, - ) - %> - - <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - -% unless ( $cust_pkg->get('setup') ) { - <% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt ) %> -% } else { - <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt ) %> -% } - - <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %> -% if ( $part_pkg->option('suspend_bill', 1) ) { - <% pkg_status_row_if( $cust_pkg, 'Next bill', 'bill', %opt, curuser=>$curuser ) %> -% } - <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %> - - <TR> - <TD COLSPAN=<%$colspan%>> - <FONT SIZE=-1> -% if ( $curuser->access_right('Unsuspend customer package') ) { - ( <% pkg_unsuspend_link($cust_pkg) %> ) -% } -% if ( $curuser->access_right('Cancel customer package immediately') ) { - ( <% pkg_cancel_link($cust_pkg) %> ) -% } - </FONT> - </TD> - </TR> - -% } else { #status: active -% -% unless ( $cust_pkg->get('setup') ) { #not setup -% -% unless ( $part_pkg->freq ) { - - <% pkg_status_row_colspan( $cust_pkg, 'Not yet billed (one-time charge)', '', 'colspan'=>$colspan, %opt ) %> - - <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_if( - $cust_pkg, - ( $part_pkg->freq ? 'Start billing' : 'Bill on' ), - 'start_date', - %opt - ) - %> - - <TR> - <TD COLSPAN=<%$colspan%>> - <FONT SIZE=-1> -% if ( $curuser->access_right('Cancel customer package immediately') ) { - ( <% pkg_cancel_link($cust_pkg) %> ) -% } - </FONT> - </TD> - </TR> - -% } else { - - <% pkg_status_row_colspan($cust_pkg, "Not yet billed ($billed_or_prepaid ". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %> - - <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %> - -% } -% -% } else { #setup -% -% unless ( $part_pkg->freq ) { - - <% pkg_status_row_colspan($cust_pkg, 'One-time charge', '', 'colspan'=>$colspan, %opt ) %> - - <% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %> - - <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - -% } else { -% -% if (scalar($cust_pkg->overlimit)) { - - <% pkg_status_row_colspan( $cust_pkg, - 'Overlimit', - $billed_or_prepaid. ' '. myfreq($part_pkg), - 'color'=>'FFD000', 'colspan'=>$colspan, - %opt - ) - %> - -% } else { - <% pkg_status_row_colspan( $cust_pkg, - 'Active', - $billed_or_prepaid. ' '. myfreq($part_pkg), - 'color'=>'00CC00', 'colspan'=>$colspan, - %opt - ) - %> -% } - - <% pkg_status_row_noauto( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - - <% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %> - -% } -% -% } -% -% if ( $opt{'cust_pkg-show_autosuspend'} ) { -% my $autosuspend = pkg_autosuspend_time( $cust_pkg ); -% $cust_pkg->set('autosuspend', $autosuspend) if $autosuspend; -% } - - <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %> - <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if( $cust_pkg, $next_bill_or_prepaid_until, 'bill', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if($cust_pkg, 'Will automatically suspend by', 'autosuspend', %opt) %> - <% pkg_status_row_if( $cust_pkg, 'Will suspend on', 'adjourn', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if( $cust_pkg, 'Expires', 'expire', %opt, curuser=>$curuser ) %> - <% pkg_status_row_if( $cust_pkg, 'Contract ends', 'contract_end', %opt ) %> - -% if ( $part_pkg->freq ) { - - <TR> - <TD COLSPAN=<%$colspan%>> - <FONT SIZE=-1> -% if ( $curuser->access_right('Suspend customer package') ) { - ( <% pkg_suspend_link($cust_pkg) %> ) -% } -% if ( $curuser->access_right('Suspend customer package later') ) { - ( <% pkg_adjourn_link($cust_pkg) %> ) -% } -% if ( $curuser->access_right('Delay suspension events') ) { - ( <% pkg_delay_link($cust_pkg) %> ) -% } -% if ( $curuser->access_right('Cancel customer package immediately') ) { - ( <% pkg_cancel_link($cust_pkg) %> ) -% } -% if ( $curuser->access_right('Cancel customer package later') ) { - ( <% pkg_expire_link($cust_pkg) %> ) -% } - - <FONT> - </TD> - </TR> -% } -% -% } -% } - - </TABLE> -</TD> -<%init> - -my %opt = @_; - -my $bgcolor = $opt{'bgcolor'}; -my $cust_pkg = $opt{'cust_pkg'}; -my $part_pkg = $opt{'part_pkg'}; -my $curuser = $FS::CurrentUser::CurrentUser; -my $colspan = $opt{'cust_pkg-display_times'} ? 8 : 4; -my $width = $opt{'cust_pkg-display_times'} ? '38%' : '56%'; - -#false laziness w/edit/REAL_cust_pkg.cgi -my( $billed_or_prepaid, $last_bill_or_renewed, $next_bill_or_prepaid_until ); -unless ( $part_pkg->is_prepaid ) { - $billed_or_prepaid = 'billed'; - $last_bill_or_renewed = 'Last bill'; - $next_bill_or_prepaid_until = 'Next bill'; -} else { - $billed_or_prepaid = 'prepaid'; - $last_bill_or_renewed = 'Renewed'; - $next_bill_or_prepaid_until = 'Prepaid until'; -} - -#subroutines - -sub myfreq { - my $part_pkg = shift; - my $freq = $part_pkg->freq_pretty; - $freq =~ s/ / /g; - $freq; -} - -#false laziness w/package.html -sub pkg_link { - my($action, $label, $cust_pkg) = @_; - return '' unless $cust_pkg; - qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!; -} - -sub pkg_status_row { - my( $cust_pkg, $title, $field, %opt ) = @_; - - my $color = $opt{'color'}; - - my $html = qq(<TR><TD WIDTH="<%$width%>" ALIGN="right">); - $html .= qq(<FONT COLOR="#$color"><B>) if length($color); - $html .= qq($title ); - $html .= qq(</B></FONT>) if length($color); - - if ( $opt{'pkg_balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge - $html .= ' (Balance: <B>'. $opt{'money_char'}. - $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum). - '</B>)'; - } - - $html .= qq(</TD>); - $html .= pkg_datestr($cust_pkg, $field, %opt). '</TR>'; - - $html; -} - -sub pkg_status_row_if { - my( $cust_pkg, $title, $field, %opt ) = @_; - - $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title - if ( $field eq 'adjourn' && - $opt{curuser}->access_right('Suspend customer package later') - ); - - $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title - if ( $field eq 'expire' && - $opt{curuser}->access_right('Cancel customer package later') - ); - - $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : ''; -} - -sub pkg_status_row_changed { - my( $cust_pkg, %opt ) = @_; - - return '' unless $cust_pkg->change_date; - - my $html = - pkg_status_row( $cust_pkg, 'Package changed', 'change_date', %opt ); - - my $old = $cust_pkg->old_cust_pkg; - if ( $old ) { - my $part_pkg = $old->part_pkg; - my $label = 'Changed from '. $cust_pkg->change_pkgnum. ': '. - $part_pkg->pkg_comment(nopartpkg => 1); - $html .= pkg_status_row_colspan( $cust_pkg, $label, '', - 'size' => '-1', - 'align' => 'right', - 'colspan' => $opt{'colspan'}, - #%opt, - ); - } - - $html; -} - -sub pkg_status_row_noauto { - my( $cust_pkg, %opt ) = @_; - my $part_pkg = $opt{'part_pkg'}; - return '' unless $cust_pkg->no_auto || $part_pkg->no_auto; - - #inefficient, should be passed in - my $cust_main = $cust_pkg->cust_main; - - return '' unless $cust_main->payby =~ /^(CARD|CHEK)$/; - my $what = lc(FS::payby->shortname($cust_main->payby)); - - pkg_status_row_colspan( $cust_pkg, "No automatic $what charge", '', - 'colspan' => $opt{'colspan'}, - #%opt, - ); -} - -sub pkg_status_row_discount { - my( $cust_pkg, %opt ) = @_; - - my $html; - - foreach my $cust_pkg_discount ( $cust_pkg->cust_pkg_discount_active ) { - - my $discount = $cust_pkg_discount->discount; - - my $label = '<B>Discount</B>: '. $discount->description; - if ( $discount->months ) { - my $remaining = $discount->months - $cust_pkg_discount->months_used; - $remaining = sprintf('%.2f', $remaining) if $remaining =~ /\./; - $label .= " ($remaining months remaining)" - } - - $label .= ' <FONT SIZE="-1">('. - '<A HREF="../misc/delete-cust_pkg_discount.html?'. - $cust_pkg_discount->pkgdiscountnum. - '">remove discount</A>)</FONT>'; - - $html .= pkg_status_row_colspan( $cust_pkg, $label, '', - 'colspan' => $opt{'colspan'}, - #%opt, - ); - - } - - $html; -} - -sub pkg_status_row_colspan { - my($cust_pkg, $title, $addl, %opt) = @_; - - my $colspan = $opt{'colspan'}; - - my $align = $opt{'align'} ? 'ALIGN="'. $opt{'align'}.'"' : ''; - my $color = $opt{'color'} ? 'COLOR="#'.$opt{'color'}.'"' : ''; - my $size = $opt{'size'} ? 'SIZE="'. $opt{'size'}. '"' : ''; - - my $html = qq(<TR><TD COLSPAN=$colspan $align>); - $html .= qq(<FONT $color $size>) if length($color) || $size; - $html .= qq(<B>) if $color && !$size; - $html .= $title; - $html .= qq(</B>) if $color && !$size; - $html .= qq(</FONT>) if length($color) || $size; - $html .= ", $addl" if length($addl); - - if ( $opt{'pkg-balances'} && ! $cust_pkg->{_printed_balance}++ ) { #kludge - $html .= ' (Balance: <B>'. $opt{'money_char'}. - $cust_pkg->cust_main->balance_pkgnum($cust_pkg->pkgnum). - '</B>)'; - } - - $html .= qq(</TD></TR>); - - $html; - -} - -sub pkg_datestr { - my($cust_pkg, $field, %opt) = @_ or return ''; - return ' ' unless $cust_pkg->get($field); - my $format = '<TD align="left"><B>%b</B></TD>'. - '<TD align="right"><B> %o,</B></TD>'. - '<TD align="right"><B> %Y</B></TD>'; - #$format .= ' <FONT SIZE=-3>%l:%M:%S%P %z</FONT>' - $format .= '<TD ALIGN="right"><B> %l</TD>'. - '<TD ALIGN="center"><B>:</B></TD>'. - '<TD ALIGN="left"><B>%M</B></TD>'. - '<TD ALIGN="left"><B> %P</B></TD>' - if $opt{'cust_pkg-display_times'}; - my $strip = time2str($format, $cust_pkg->get($field) ); - $strip =~ s/ (\d)/$1/g; - $strip; -} - -sub pkg_suspend_link { - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. 'misc/cancel_pkg.html?method=suspend', - 'label' => 'Suspend now', - 'actionlabel' => 'Suspend', - 'color' => '#FF9900', - 'cust_pkg' => shift, - ) -} - -sub pkg_adjourn_link { - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. 'misc/cancel_pkg.html?method=adjourn', - 'label' => 'Suspend later', - 'actionlabel' => 'Adjourn', - 'color' => '#CC6600', - 'cust_pkg' => shift, - ) -} - -sub pkg_delay_link { - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. 'misc/delay_susp_pkg.html', - 'label' => 'Delay suspend', - 'actionlabel' => 'Delay suspend for', - 'cust_pkg' => shift, - ) -} - -sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); } -sub pkg_unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); } -sub pkg_unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); } - -sub pkg_cancel_link { - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. 'misc/cancel_pkg.html?method=cancel', - 'label' => 'Cancel now', - 'actionlabel' => 'Cancel', - 'color' => '#ff0000', - 'cust_pkg' => shift, - ) -} - -sub pkg_expire_link { - include( '/elements/popup_link-cust_pkg.html', - 'action' => $p. 'misc/cancel_pkg.html?method=expire', - 'label' => 'Cancel later', - 'actionlabel' => 'Expire', #"Cancel package $num later" - 'color' => '#CC0000', - 'cust_pkg' => shift, - ) -} - -sub svc_recharge_link { - include( '/elements/popup_link-cust_svc.html', - 'action' => $p. 'misc/recharge_svc.html', - 'label' => 'Recharge', - 'actionlabel' => 'Recharge', - 'color' => '#333399', - 'cust_svc' => shift, - ) -} - -sub pkg_autosuspend_time { - my $cust_pkg = shift or return ''; - my $days = 7; - my $time = time; - my $pending_suspend = 0; - #this seems to be extremely inefficient... and is slowing down all customer - #views - while ( $days > 0 && - scalar( - grep { $_->part_event->action eq 'suspend' } - @{$cust_pkg->cust_main->due_cust_event( time => $time + 86400*$days, - testonly => 1, - ) } - ) - ) - { - $pending_suspend = 1; - $days--; - } - - $pending_suspend ? time + ($days + 1) * 86400 : ''; - -} - -</%init> |