%>
<SCRIPT>
-function cancel_areyousure(href) {
- if (confirm("Perminantly delete all services and cancel this customer?") == true)
+function areyousure(href, message) {
+ if (confirm(message) == true)
window.location.href = href;
}
</SCRIPT>
<%
-print qq! | <A HREF="javascript:cancel_areyousure('${p}misc/cust_main-cancel.cgi?$custnum')">!.
+print qq! | <A HREF="javascript:areyousure('${p}misc/cust_main-cancel.cgi?$custnum', 'Perminantly delete all services and cancel this customer?')">!.
'Cancel this customer</A>'
if $cust_main->ncancelled_pkgs;
"<a href=\"$signupurl?ref=$custnum\">$signupurl?ref=$custnum</a><BR><BR>";
}
-print '<A NAME="cust_main"></A>';
-
-print &itable(), '<TR>';
-
-print '<TD VALIGN="top">';
-
- print "Billing address", &ntable("#cccccc"), "<TR><TD>",
- &ntable("#cccccc",2),
- '<TR><TD ALIGN="right">Contact name</TD>',
- '<TD COLSPAN=3 BGCOLOR="#ffffff">',
- $cust_main->last, ', ', $cust_main->first,
- '</TD>';
-print '<TD ALIGN="right">SS#</TD><TD BGCOLOR="#ffffff">',
- $cust_main->ss || ' ', '</TD>'
- if $conf->exists('show_ss');
-
-print '</TR>',
- '<TR><TD ALIGN="right">Company</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->company,
- '</TD></TR>',
- '<TR><TD ALIGN="right">Address</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->address1,
- '</TD></TR>',
- ;
- print '<TR><TD ALIGN="right"> </TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->address2, '</TD></TR>'
- if $cust_main->address2;
- print '<TR><TD ALIGN="right">City</TD><TD BGCOLOR="#ffffff">',
- $cust_main->city,
- '</TD><TD ALIGN="right">State</TD><TD BGCOLOR="#ffffff">',
- $cust_main->state,
- '</TD><TD ALIGN="right">Zip</TD><TD BGCOLOR="#ffffff">',
- $cust_main->zip, '</TD></TR>',
- '<TR><TD ALIGN="right">Country</TD><TD BGCOLOR="#ffffff">',
- $cust_main->country,
- '</TD></TR>',
- ;
- my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone';
- my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone';
- print '<TR><TD ALIGN="right">'. $daytime_label.
- '</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->daytime || ' ', '</TD></TR>',
- '<TR><TD ALIGN="right">'. $night_label.
- '</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->night || ' ', '</TD></TR>',
- '<TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->fax || ' ', '</TD></TR>',
- '</TABLE>', "</TD></TR></TABLE>"
- ;
-
- if ( defined $cust_main->dbdef_table->column('ship_last') ) {
-
- my $pre = $cust_main->ship_last ? 'ship_' : '';
-
- print "<BR>Service address", &ntable("#cccccc"), "<TR><TD>",
- &ntable("#cccccc",2),
- '<TR><TD ALIGN="right">Contact name</TD>',
- '<TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}last"), ', ', $cust_main->get("${pre}first"),
- '</TD></TR>',
- '<TR><TD ALIGN="right">Company</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}company"),
- '</TD></TR>',
- '<TR><TD ALIGN="right">Address</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}address1"),
- '</TD></TR>',
- ;
- print '<TR><TD ALIGN="right"> </TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}address2"), '</TD></TR>'
- if $cust_main->get("${pre}address2");
- print '<TR><TD ALIGN="right">City</TD><TD BGCOLOR="#ffffff">',
- $cust_main->get("${pre}city"),
- '</TD><TD ALIGN="right">State</TD><TD BGCOLOR="#ffffff">',
- $cust_main->get("${pre}state"),
- '</TD><TD ALIGN="right">Zip</TD><TD BGCOLOR="#ffffff">',
- $cust_main->get("${pre}zip"), '</TD></TR>',
- '<TR><TD ALIGN="right">Country</TD><TD BGCOLOR="#ffffff">',
- $cust_main->get("${pre}country"),
- '</TD></TR>',
- ;
- print '<TR><TD ALIGN="right">'. $daytime_label. '</TD>',
- '<TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}daytime") || ' ', '</TD></TR>',
- '<TR><TD ALIGN="right">'. $night_label. '</TD>'.
- '<TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}night") || ' ', '</TD></TR>',
- '<TR><TD ALIGN="right">Fax</TD><TD COLSPAN=5 BGCOLOR="#ffffff">',
- $cust_main->get("${pre}fax") || ' ', '</TD></TR>',
- '</TABLE>', "</TD></TR></TABLE>"
- ;
-
- }
+%>
-print '</TD>';
+<A NAME="cust_main"></A>
+<%= &itable() %>
+<TR>
+ <TD VALIGN="top">
+ <%= include('cust_main/contacts.html', $cust_main ) %>
+ </TD>
+ <TD VALIGN="top">
+ <%= include('cust_main/misc.html', $cust_main ) %>
+ <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
+ <BR>
+ <%= include('cust_main/billing.html', $cust_main ) %>
+ <% } %>
+ </TD>
+</TR>
+</TABLE>
-print '<TD VALIGN="top">';
+<%
+if ( defined $cust_main->dbdef_table->column('comments')
+ && $cust_main->comments =~ /[^\s\n\r]/ ) {
+%>
+<BR>
+Comments
+<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
+<TR>
+ <TD BGCOLOR="#ffffff">
+ <PRE><%= encode_entities($cust_main->comments) %></PRE>
+ </TD>
+</TR>
+</TABLE></TABLE>
+<% } %>
- print &ntable("#cccccc"), "<TR><TD>", &ntable("#cccccc",2),
- '<TR><TD ALIGN="right">Customer number</TD><TD BGCOLOR="#ffffff">',
- $custnum, '</TD></TR>',
- ;
+<% if ( $conf->config('ticket_system') ) { %>
+ <BR>
+ <%= include('cust_main/tickets.html', $cust_main ) %>
+<% } %>
- my @agents = qsearch( 'agent', {} );
- my $agent;
- unless ( scalar(@agents) == 1 ) {
- $agent = qsearchs('agent',{ 'agentnum' => $cust_main->agentnum } );
- print '<TR><TD ALIGN="right">Agent</TD><TD BGCOLOR="#ffffff">',
- $agent->agentnum, ": ", $agent->agent, '</TD></TR>';
+<BR>
+<SCRIPT TYPE="text/javascript">
+function enable_order_pkg () {
+ if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
+ document.OrderPkgForm.submit.disabled = false;
} else {
- $agent = $agents[0];
- }
- my @referrals = qsearch( 'part_referral', {} );
- unless ( scalar(@referrals) == 1 ) {
- my $referral = qsearchs('part_referral', {
- 'refnum' => $cust_main->refnum
- } );
- print '<TR><TD ALIGN="right">Advertising source</TD><TD BGCOLOR="#ffffff">',
- $referral->refnum, ": ", $referral->referral, '</TD></TR>';
- }
- print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
- $cust_main->otaker, '</TD></TR>';
-
- print '<TR><TD ALIGN="right">Referring Customer</TD><TD BGCOLOR="#ffffff">';
- my $referring_cust_main = '';
- if ( $cust_main->referral_custnum
- && ( $referring_cust_main =
- qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
- )
- ) {
- print '<A HREF="'. popurl(1). 'cust_main.cgi?'.
- $cust_main->referral_custnum. '">'.
- $cust_main->referral_custnum. ': '.
- ( $referring_cust_main->company
- ? $referring_cust_main->company. ' ('.
- $referring_cust_main->last. ', '. $referring_cust_main->first.
- ')'
- : $referring_cust_main->last. ', '. $referring_cust_main->first
- ).
- '</A>';
- }
- print '</TD></TR>';
-
- print '</TABLE></TD></TR></TABLE>';
-
-print '<BR>';
-
-if ( $conf->config('payby-default') ne 'HIDE' ) {
-
- my @invoicing_list = $cust_main->invoicing_list;
- print "Billing information (",
- qq!<A HREF="!, popurl(2), qq!misc/bill.cgi?$custnum">!, "Bill now</A>)",
- &ntable("#cccccc"), "<TR><TD>", &ntable("#cccccc",2),
- '<TR><TD ALIGN="right">Tax exempt</TD><TD BGCOLOR="#ffffff">',
- $cust_main->tax ? 'yes' : 'no',
- '</TD></TR>',
- '<TR><TD ALIGN="right">Postal invoices</TD><TD BGCOLOR="#ffffff">',
- ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no',
- '</TD></TR>',
- '<TR><TD ALIGN="right">Email invoices</TD><TD BGCOLOR="#ffffff">',
- join(', ', grep { $_ ne 'POST' } @invoicing_list ) || 'no',
- '</TD></TR>',
- '<TR><TD ALIGN="right">Billing type</TD><TD BGCOLOR="#ffffff">',
- ;
-
- if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
- my $payinfo = $cust_main->payinfo;
- $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4));
- print 'Credit card ',
- ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ),
- '</TD></TR>',
- '<TR><TD ALIGN="right">Card number</TD><TD BGCOLOR="#ffffff">',
- $payinfo, '</TD></TR>',
- '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">',
- $cust_main->paydate, '</TD></TR>',
- '<TR><TD ALIGN="right">Name on card</TD><TD BGCOLOR="#ffffff">',
- $cust_main->payname, '</TD></TR>'
- ;
- } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
- my( $account, $aba ) = split('@', $cust_main->payinfo );
- print 'Electronic check ',
- ( $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' ),
- '</TD></TR>',
- '<TR><TD ALIGN="right">Account number</TD><TD BGCOLOR="#ffffff">',
- $account, '</TD></TR>',
- '<TR><TD ALIGN="right">ABA/Routing code</TD><TD BGCOLOR="#ffffff">',
- $aba, '</TD></TR>',
- '<TR><TD ALIGN="right">Bank name</TD><TD BGCOLOR="#ffffff">',
- $cust_main->payname, '</TD></TR>'
- ;
- } elsif ( $cust_main->payby eq 'LECB' ) {
- $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
- my $payinfo = "$1-$2-$3";
- print 'Phone bill billing</TD></TR>',
- '<TR><TD ALIGN="right">Phone number</TD><TD BGCOLOR="#ffffff">',
- $payinfo, '</TD></TR>',
- ;
- } elsif ( $cust_main->payby eq 'BILL' ) {
- print 'Billing</TD></TR>';
- print '<TR><TD ALIGN="right">P.O. </TD><TD BGCOLOR="#ffffff">',
- $cust_main->payinfo, '</TD></TR>',
- if $cust_main->payinfo;
- print '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">',
- $cust_main->paydate, '</TD></TR>',
- '<TR><TD ALIGN="right">Attention</TD><TD BGCOLOR="#ffffff">',
- $cust_main->payname, '</TD></TR>',
- ;
- } elsif ( $cust_main->payby eq 'COMP' ) {
- print 'Complimentary</TD></TR>',
- '<TR><TD ALIGN="right">Authorized by</TD><TD BGCOLOR="#ffffff">',
- $cust_main->payinfo, '</TD></TR>',
- '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">',
- $cust_main->paydate, '</TD></TR>',
- ;
+ document.OrderPkgForm.submit.disabled = true;
}
-
- print "</TABLE></TD></TR></TABLE>";
-
}
+</SCRIPT>
+<FORM NAME="OrderPkgForm" ACTION="<%= $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>">
+<SELECT NAME="pkgpart" onChange="enable_order_pkg()"><OPTION>Order additional package
-print '</TD></TR></TABLE>';
+<%
-if ( defined $cust_main->dbdef_table->column('comments')
- && $cust_main->comments =~ /[^\s\n\r]/ )
-{
- print "<BR>Comments". &ntable("#cccccc"). "<TR><TD>".
- &ntable("#cccccc",2).
- '<TR><TD BGCOLOR="#ffffff"><PRE>'.
- encode_entities($cust_main->comments).
- '</PRE></TD></TR></TABLE></TABLE>';
+my @agents = qsearch( 'agent', {} );
+my $agent;
+unless ( scalar(@agents) == 1 ) {
+ $agent = qsearchs('agent',{ 'agentnum' => $cust_main->agentnum } );
+} else {
+ $agent = $agents[0];
}
-print '</TD></TR></TABLE>';
-
-print '<BR>'.
- '<FORM ACTION="'.popurl(2).'edit/process/quick-cust_pkg.cgi" METHOD="POST">'.
- qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!.
- '<SELECT NAME="pkgpart"><OPTION> ';
-
foreach my $part_pkg (
qsearch( 'part_pkg', { 'disabled' => '' }, '',
' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '.
' AND type_pkgs.pkgpart = part_pkg.pkgpart )'
)
) {
- print '<OPTION VALUE="'. $part_pkg->pkgpart. '">'. $part_pkg->pkg. ' - '.
- $part_pkg->comment;
-}
+%>
+<OPTION VALUE="<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkg %> - <%= $part_pkg->comment %>
+<% } %>
+
+</SELECT><INPUT NAME="submit" TYPE="submit" VALUE="Order Package" disabled></FORM>
-print '</SELECT><INPUT TYPE="submit" VALUE="Order Package"></FORM><BR>';
+<%
if ( $conf->config('payby-default') ne 'HIDE' ) {
}
-%>
-
-<SCRIPT>
-function cust_pkg_areyousure(href) {
- if (confirm("Permanently delete included services and cancel this package?") == true)
- window.location.href = href;
-}
-function svc_areyousure(href) {
- if (confirm("Permanently unprovision and delete this service?") == true)
- window.location.href = href;
-}
-</SCRIPT>
-
-<%
-
print qq!<A NAME="cust_pkg">Packages</A> !,
- qq!( <A HREF="!, popurl(2), qq!edit/cust_pkg.cgi?$custnum">Order and cancel packages</A> (preserves services) )!,
+ qq!( <A HREF="!, popurl(2), qq!edit/cust_pkg.cgi?$custnum">Bulk order and cancel packages</A> (preserves services) )!,
;
#begin display packages
#}
print "<TD ROWSPAN=$rowspan>". &itable('');
- sub freq {
-
- #false laziness w/edit/part_pkg.cgi
- my %freq = ( #move this
- '1d' => 'daily',
- '1w' => 'weekly',
- '2w' => 'biweekly (every 2 weeks)',
- '1' => 'monthly',
- '2' => 'bimonthly (every 2 months)',
- '3' => 'quarterly (every 3 months)',
- '6' => 'semiannually (every 6 months)',
- '12' => 'annually',
- '24' => 'biannually (every 2 years)',
- );
-
- my $freq = shift;
- exists $freq{$freq} ? $freq{$freq} : "every $freq months";
+ sub myfreq {
+ my $part_pkg = shift;
+ my $freq = $part_pkg->freq_pretty;
+ $freq =~ s/ / /g;
+ $freq;
}
- #eomove
-
if ( $pkg->{cancel} ) { #status: cancelled
print '<TR><TD><FONT COLOR="#ff0000"><B>Cancelled </B></FONT></TD>'.
print '<TR><TD COLSPAN=2>( '. pkg_cancel_link($pkg).
' )</TD</TR>';
} else {
- print 'billed '. freq($pkg->{freq}). ')</TD></TR>';
+ print 'billed '. myfreq($pkg->{part_pkg}). ')</TD></TR>';
}
} else { #setup
pkg_datestr($pkg,'setup',$conf). '</TD></TR>';
} else {
print '<TR><TD COLSPAN=2><FONT COLOR="#00CC00"><B>Active</B></FONT>'.
- ', billed '. freq($pkg->{freq}). '</TD></TR>'.
+ ', billed '. myfreq($pkg->{part_pkg}). '</TD></TR>'.
'<TR><TD>Setup </TD><TD>'.
pkg_datestr($pkg, 'setup',$conf). '</TD></TR>';
}
#end display packages
%>
-<SCRIPT>
-function cust_pay_areyousure(href) {
- if (confirm("Are you sure you want to delete this payment?")
- == true)
- window.location.href = href;
-}
-function cust_pay_unapply_areyousure(href) {
- if (confirm("Are you sure you want to unapply this payment?")
- == true)
- window.location.href = href;
-}
-function cust_credit_unapply_areyousure(href) {
- if (confirm("Are you sure you want to unapply this credit?")
- == true)
- window.location.href = href;
-}
-function cust_credit_areyousure(href) {
- if (confirm("Are you sure you want to delete this credit?")
- == true)
- window.location.href = href;
-}
-</SCRIPT>
-
<% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
<BR><BR><A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
foreach my $cust_pay ($cust_main->cust_pay) {
my $payby = $cust_pay->payby;
- my $payinfo = $cust_pay->payinfo;
+ my $payinfo = $payby eq 'CARD'
+ ? $cust_pay->payinfo_masked
+ : $cust_pay->payinfo;
my @cust_bill_pay = $cust_pay->cust_bill_pay;
+ my @cust_pay_refund = $cust_pay->cust_pay_refund;
- $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4))
- if $payby eq 'CARD';
my $target = "$payby$payinfo";
$payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^CHEK$/Electronic check /;
$payby =~ s/^BILL$//;
$payby =~ s/^(CARD|COMP)$/$1 /;
my $info = $payby ? " ($payby$payinfo)" : '';
my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' );
- if ( scalar(@cust_bill_pay) == 0 ) {
+ if ( scalar(@cust_bill_pay) == 0
+ && scalar(@cust_pay_refund) == 0 ) {
#completely unapplied
$pre = '<B><FONT COLOR="#FF0000">Unapplied ';
$post = '</FONT></B>';
$apply = qq! (<A HREF="${p}edit/cust_bill_pay.cgi?!.
$cust_pay->paynum. '">apply</A>)';
- } elsif ( scalar(@cust_bill_pay) == 1 && $cust_pay->unapplied == 0 ) {
- #applied to one invoice
+ } elsif ( scalar(@cust_bill_pay) == 1
+ && scalar(@cust_pay_refund) == 0
+ && $cust_pay->unapplied == 0 ) {
+ #applied to one invoice, the usual situation
$desc = ' applied to Invoice #'. $cust_bill_pay[0]->invnum;
+ } elsif ( scalar(@cust_bill_pay) == 0
+ && scalar(@cust_pay_refund) == 1
+ && $cust_pay->unapplied == 0 ) {
+ #applied to one refund
+ $desc = ' refunded on '. time2str("%D", $cust_pay_refund[0]->_date);
} else {
#complicated
$desc = '<BR>';
- foreach my $cust_bill_pay (@cust_bill_pay) {
- $desc .= ' '.
- '$'. $cust_bill_pay->amount.
- ' applied to Invoice #'. $cust_bill_pay->invnum.
- '<BR>';
- #' on '. time2str("%D", $cust_bill_pay->_date).
-
+ foreach my $app ( sort { $a->_date <=> $b->_date }
+ ( @cust_bill_pay, @cust_pay_refund ) ) {
+ if ( $app->isa('FS::cust_bill_pay') ) {
+ $desc .= ' '.
+ '$'. $app->amount.
+ ' applied to Invoice #'. $app->invnum.
+ '<BR>';
+ #' on '. time2str("%D", $cust_bill_pay->_date).
+ } elsif ( $app->isa('FS::cust_pay_refund') ) {
+ $desc .= ' '.
+ '$'. $app->amount.
+ ' refunded on'. time2str("%D", $app->_date).
+ '<BR>';
+ } else {
+ die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund";
+ }
}
if ( $cust_pay->unapplied > 0 ) {
$desc .= ' '.
}
}
+ my $refund = '';
+ my $refund_days = $conf->config('card_refund-days') || 120;
+ if ( $cust_pay->closed !~ /^Y/i
+ && $cust_pay->payby =~ /^(CARD|CHEK)$/
+ && time-$cust_pay->_date < $refund_days*86400
+ && $cust_pay->unrefunded > 0
+ ) {
+ $refund = qq! (<A HREF="!. qq!${p}edit/cust_refund.cgi?payby=$1;!.
+ qq!paynum=!. $cust_pay->paynum. qq!">refund</A>)!;
+ }
+
+ my $void = '';
+ if ( $cust_pay->closed !~ /^Y/i
+ && $cust_pay->payby !~ /^(CARD|CHEK)$/
+ ) {
+ $void = qq! (<A HREF="javascript:areyousure('!.
+ qq!${p}misc/void-cust_pay.cgi?!. $cust_pay->paynum.
+ qq!', 'Are you sure you want to void this payment?')">!.
+ qq!void</A>)!;
+ }
+
my $delete = '';
if ( $cust_pay->closed !~ /^Y/i && $conf->exists('deletepayments') ) {
- $delete = qq! (<A HREF="javascript:cust_pay_areyousure('!.
+ $delete = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/delete-cust_pay.cgi?!. $cust_pay->paynum.
- qq!')">delete</A>)!;
+ qq!', 'Are you sure you want to delete this payment?')">!.
+ qq!delete</A>)!;
}
my $unapply = '';
if ( $cust_pay->closed !~ /^Y/i
&& $conf->exists('unapplypayments')
&& scalar(@cust_bill_pay) ) {
- $unapply = qq! (<A HREF="javascript:cust_pay_unapply_areyousure('!.
+ $unapply = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/unapply-cust_pay.cgi?!. $cust_pay->paynum.
- qq!')">unapply</A>)!;
+ qq!', 'Are you sure you want to unapply this payment?')">!.
+ qq!unapply</A>)!;
}
push @history, {
'date' => $cust_pay->_date,
'desc' => $pre. "Payment$post$info$desc".
- "$apply$delete$unapply",
+ "$apply$refund$void$delete$unapply",
'payment' => $cust_pay->paid,
'target' => $target,
};
}
+ #voided payments
+ foreach my $cust_pay_void ($cust_main->cust_pay_void) {
+
+ my $payby = $cust_pay_void->payby;
+ my $payinfo = $payby eq 'CARD'
+ ? $cust_pay_void->payinfo_masked
+ : $cust_pay_void->payinfo;
+
+ $payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^CHEK$/Electronic check /;
+ $payby =~ s/^BILL$//;
+ $payby =~ s/^(CARD|COMP)$/$1 /;
+ my $info = $payby ? " ($payby$payinfo)" : '';
+
+ push @history, {
+ 'date' => $cust_pay_void->_date,
+ 'desc' => "<DEL>Payment $info</DEL> <I>voided ".
+ time2str("%D", $cust_pay_void->void_date).
+ " by ". $cust_pay_void->otaker. '</i>',
+ 'void_payment' => $cust_pay_void->paid,
+ };
+
+ }
+
#credits (some false laziness w/payments)
foreach my $cust_credit ($cust_main->cust_credit) {
} elsif ( scalar(@cust_credit_bill) == 1
&& scalar(@cust_credit_refund) == 0
&& $cust_credit->credited == 0 ) {
- #applied to one invoice
+ #applied to one invoice, the usual situation
$desc = ' applied to Invoice #'. $cust_credit_bill[0]->invnum;
} elsif ( scalar(@cust_credit_bill) == 0
&& scalar(@cust_credit_refund) == 1
}
}
if ( $cust_credit->credited > 0 ) {
- $desc .= ' - <B><FONT COLOR="#FF0000">$'.
+ $desc .= ' <B><FONT COLOR="#FF0000">$'.
$cust_credit->credited. ' unapplied</FONT></B>'.
qq! (<A HREF="${p}edit/cust_credit_bill.cgi?!.
$cust_credit->crednum. '">apply</A>)'.
#
my $delete = '';
if ( $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') ) {
- $delete = qq! (<A HREF="javascript:cust_credit_areyousure('!.
+ $delete = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/delete-cust_credit.cgi?!. $cust_credit->crednum.
- qq!')">delete</A>)!;
+ qq!', 'Are you sure you want to delete this credit?')">!.
+ qq!delete</A>)!;
}
my $unapply = '';
if ( $cust_credit->closed !~ /^Y/i
&& $conf->exists('unapplycredits')
&& scalar(@cust_credit_bill) ) {
- $unapply = qq! (<A HREF="javascript:cust_credit_unapply_areyousure('!.
+ $unapply = qq! (<A HREF="javascript:areyousure('!.
qq!${p}misc/unapply-cust_credit.cgi?!. $cust_credit->crednum.
- qq!')">unapply</A>)!;
+ qq!', 'Are you sure you want to unapply this credit?')">!.
+ qq!unapply</A>)!;
}
push @history, {
foreach my $cust_refund ($cust_main->cust_refund) {
my $payby = $cust_refund->payby;
- my $payinfo = $cust_refund->payinfo;
+ my $payinfo = $payby eq 'CARD'
+ ? $cust_refund->payinfo_masked
+ : $cust_refund->payinfo;
- $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4))
- if $payby eq 'CARD';
$payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^CHEK$/Electronic check /;
$payby =~ s/^(CARD|COMP)$/$1 /;
push @history, {
my $payment = exists($item->{'payment'})
? sprintf('- $%.2f', $item->{'payment'})
: '';
+ $payment ||= sprintf('<DEL>- $%.2f</DEL>', $item->{'void_payment'})
+ if exists($item->{'void_payment'});
my $credit = exists($item->{'credit'})
? sprintf('- $%.2f', $item->{'credit'})
: '';
) {
my $part_pkg = $cust_pkg->part_pkg;
-
+
my %pkg = ();
+
+ #to get back to the original object... should use it in the first place!!
+ $pkg{cust_pkg} = $cust_pkg;
+ $pkg{part_pkg} = $part_pkg;
+
$pkg{pkgnum} = $cust_pkg->pkgnum;
$pkg{pkg} = $part_pkg->pkg;
$pkg{pkgpart} = $part_pkg->pkgpart;
$pkg{susp} = $cust_pkg->getfield('susp');
$pkg{expire} = $cust_pkg->getfield('expire');
$pkg{cancel} = $cust_pkg->getfield('cancel');
-
- my %svcparts = ();
- foreach my $pkg_svc (
- qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart })
- ) {
-
- next if ($pkg_svc->quantity == 0);
-
- my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart });
- my $svcpart = {};
- $svcpart->{svcpart} = $part_svc->svcpart;
- $svcpart->{svc} = $part_svc->svc;
- $svcpart->{svcdb} = $part_svc->svcdb;
- $svcpart->{quantity} = $pkg_svc->quantity;
- $svcpart->{count} = 0;
-
- $svcpart->{services} = [];
-
- $svcparts{$svcpart->{svcpart}} = $svcpart;
-
- }
-
- foreach my $cust_svc (
- qsearch( 'cust_svc', {
- 'pkgnum' => $cust_pkg->pkgnum,
- #'svcpart' => $part_svc->svcpart,
- }
- )
- ) {
-
- warn "svcnum ". $cust_svc->svcnum. " / svcpart ". $cust_svc->svcpart. "\n";
+ my %svcparts = map {
+ $_->svcpart => {
+ $_->part_svc->hash,
+ 'quantity' => $_->quantity,
+ 'count' => $cust_pkg->num_cust_svc($_->svcpart),
+ #'services' => [],
+ };
+ } $part_pkg->pkg_svc;
+
+ foreach my $cust_svc ( $cust_pkg->cust_svc ) {
+ #warn "svcnum ". $cust_svc->svcnum. " / svcpart ". $cust_svc->svcpart. "\n";
my $svc = {
'svcnum' => $cust_svc->svcnum,
'label' => ($cust_svc->label)[1],
#false laziness with above, to catch extraneous services. whole
#damn thing should be OO...
my $svcpart = ( $svcparts{$cust_svc->svcpart} ||= {
- 'svcpart' => $cust_svc->svcpart,
- 'svc' => $cust_svc->part_svc->svc,
- 'svcdb' => $cust_svc->part_svc->svcdb,
+ $cust_svc->part_svc->hash,
'quantity' => 0,
- 'count' => 0,
- 'services' => [],
+ 'count' => $cust_pkg->num_cust_svc($cust_svc->svcpart),
+ #'services' => [],
} );
push @{$svcpart->{services}}, $svc;
- $svcpart->{count}++;
-
}
$pkg{svcparts} = [ values %svcparts ];
sub svc_provision_link {
my ($pkg, $svcpart, $conf) = @_;
( my $svc_nbsp = $svcpart->{svc} ) =~ s/\s+/ /g;
- my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}";
my $num_left = $svcpart->{quantity} - $svcpart->{count};
+ my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}";
- my $link = qq!<A CLASS="provision" HREF="${p}edit/$svcpart->{svcdb}.cgi?!.
- qq!$pkgnum_svcpart">!.
+ my $url;
+ if ( $svcpart->{svcdb} eq 'svc_external'
+ && $conf->exists('svc_external-skip_manual')
+ ) {
+ $url = "${p}edit/process/$svcpart->{svcdb}.cgi?".
+ "pkgnum=$pkg->{pkgnum}&".
+ "svcpart=$svcpart->{svcpart}";
+ } else {
+ $url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart";
+ }
+
+ my $link = qq!<A CLASS="provision" HREF="$url">!.
"Provision $svc_nbsp ($num_left)</A>";
if ( $conf->exists('legacy_link') ) {
$link .= '<BR>'.
sub svc_unprovision_link {
my $svc = shift or return '';
- return qq!<A HREF="javascript:svc_areyousure('${p}misc/unprovision.cgi?$svc->{svcnum}')">Unprovision</A>!;
+ qq!<A HREF="javascript:areyousure('${p}misc/unprovision.cgi?$svc->{svcnum}',!.
+ qq!'Permanently unprovision and delete this service?')">Unprovision</A>!;
}
# This should be generalized to use config options to determine order.
sub pkg_change_link {
my $pkg = shift or return '';
- return qq!<a href="${p}misc/change_pkg.cgi?$pkg->{pkgnum}">Change package</a>!;
+ return qq!<a href="${p}misc/change_pkg.cgi?$pkg->{pkgnum}">!.
+ qq!Change package</a>!;
}
sub pkg_suspend_link {
sub pkg_cancel_link {
my $pkg = shift or return '';
- qq!<A HREF="javascript:cust_pkg_areyousure('${p}misc/cancel_pkg.cgi?$pkg->{pkgnum}')">Cancel now</A> | !.
+ qq!<A HREF="javascript:areyousure('${p}misc/cancel_pkg.cgi?$pkg->{pkgnum}', !.
+ qq!'Permanently delete included services and cancel this package?')">!.
+ qq!Cancel now</A> | !.
qq!<A HREF="${p}misc/expire_pkg.cgi?$pkg->{pkgnum}">Cancel later</A>!;
}
sub pkg_dates_link {
my $pkg = shift or return '';
- return qq!<A HREF="${p}edit/REAL_cust_pkg.cgi?$pkg->{pkgnum}">Edit dates</A>!;
+ qq!<A HREF="${p}edit/REAL_cust_pkg.cgi?$pkg->{pkgnum}">Edit dates</A>!;
}
sub pkg_customize_link {
my $pkg = shift or return '';
my $custnum = shift;
- return qq!<A HREF="${p}edit/part_pkg.cgi?keywords=$custnum;clone=$pkg->{pkgpart};pkgnum=$pkg->{pkgnum}">Customize</A>!;
+ qq!<A HREF="${p}edit/part_pkg.cgi?keywords=$custnum;clone=$pkg->{pkgpart};!.
+ qq!pkgnum=$pkg->{pkgnum}">Customize</A>!;
}
%>