my @history = ();
my %opt = (
+
+ #config
( map { $_ => scalar($conf->config($_)) }
qw( card_refund-days date_format )
),
( map { $_ => $conf->exists($_) }
- qw( deleteinvoices deletepayments deleterefunds pkg-balances )
- )
+ qw( deleteinvoices deletepayments deleterefunds pkg-balances
+ cust_credit_bill_pkg-manual cust_bill_pay_pkg-manual
+ )
+ ),
+ 'money_char ' => $money_char,
+
+ #rights
+ ( map { $_ => $curuser->access_right($_) }
+ (
+ 'View invoices', 'Void invoices', 'Unvoid invoices', 'Delete invoices',
+ 'Apply payment', 'Refund credit card payment', 'Refund Echeck payment',
+ 'Credit card void', 'Echeck void', 'Void payments', 'Unvoid payments',
+ 'Delete payment', 'Unapply payment',
+ 'Apply credit', 'Delete Credit', 'Unapply credit',
+ 'Delete refund',
+ 'Billing event reports', 'View customer billing events',
+ )
+ ),
+
+ #customer information
+ 'total_owed' => $cust_main->total_owed,
+ 'total_unapplied_refunds' => $cust_main->total_unapplied_refunds,
);
$opt{'date_format'} ||= '%m/%d/%Y';
my $date_format = $opt{'date_format'} || '%m/%d/%Y';
-my $conf = new FS::Conf;
-my $money_char = $conf->config('money_char') || '$';
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my @cust_credit_bill = $cust_credit->cust_credit_bill;
my @cust_credit_refund = $cust_credit->cust_credit_refund;
my %cust_credit_bill_width = ('width' => 392);
my %cust_credit_bill_height = ();
-if ($conf->exists('cust_credit_bill_pkg-manual')) {
+if ( $opt{'cust_credit_bill_pkg-manual'} ) {
%cust_credit_bill_width = ('width' => 592);
%cust_credit_bill_height = ('height' => 436);
}
$credit = '<B><FONT COLOR="#FF0000">'
. emt("Unapplied Credit by [_1]", $cust_credit->otaker )
. '</FONT></B>';
- if ( $curuser->access_right('Apply credit') ) {
- if ( $cust_credit->cust_main->total_owed > 0 ) {
+ if ( $opt{'Apply credit'} ) {
+ if ( $opt{total_owed} > 0 ) {
$apply = ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply'),
).
')';
}
- if ( $cust_credit->cust_main->total_unapplied_refunds > 0 ) {
+ if ( $opt{total_unapplied_refunds} > 0 ) {
$apply.= ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply to refund'),
foreach my $app ( sort { $a->_date <=> $b->_date }
( @cust_credit_bill, @cust_credit_refund ) ) {
if ( $app->isa('FS::cust_credit_bill') ) {
- $desc .= ' ' . $money_char . $app->amount . ' '
+ $desc .= ' ' . $opt{money_char} . $app->amount . ' '
. $app->applied_to_invoice . '<BR>';
} elsif ( $app->isa('FS::cust_credit_refund') ) {
$desc .= ' ' .
- emt("[_1][_2] refunded on [_3]", $money_char, $app->amount,
+ emt("[_1][_2] refunded on [_3]", $opt{money_char}, $app->amount,
time2str($date_format, $app->_date) ) . '<BR>';
} else {
die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund";
}
}
if ( $cust_credit->credited > 0 ) {
- $desc .= ' <B><FONT COLOR="#FF0000">' .
- emt("[_1][_2] unapplied", $money_char, $cust_credit->credited) .
+ $desc .= ' <B><FONT COLOR="#FF0000">'.
+ emt("[_1][_2] unapplied",$opt{money_char},$cust_credit->credited).
'</FONT></B>';
- if ( $curuser->access_right('Apply credit') ) {
- if ( $cust_credit->cust_main->total_owed > 0 ) {
+ if ( $opt{'Apply credit'} ) {
+ if ( $opt{total_owed} > 0 ) {
$apply = ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply'),
).
')';
}
- if ( $cust_credit->cust_main->total_unapplied_refunds > 0 ) {
+ if ( $opt{total_unapplied_refunds} > 0 ) {
$apply.= ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply to refund'),
'',
emt('delete')
)
-if ( $cust_credit->closed !~ /^Y/i && $curuser->access_right('Delete credit') );
+ if $cust_credit->closed !~ /^Y/i
+ && $opt{'Delete credit'};
my $unapply = '';
$unapply = areyousure_link("${p}misc/unapply-cust_credit.cgi?".$cust_credit->crednum,
'',
emt('unapply')
)
-if ( $cust_credit->closed !~ /^Y/i && scalar(@cust_credit_bill)
- && $curuser->access_right('Unapply credit') );
+ if $cust_credit->closed !~ /^Y/i
+ && scalar(@cust_credit_bill)
+ && $opt{'Unapply credit'};
-my $reason = $cust_credit->reason
- ? ' ('. $cust_credit->reason. ')'
- : '';
+my $reason = $cust_credit->reason;
+$reason = $reason ? " ($reason)" : '';
</%init>
my( $cust_bill, %opt ) = @_;
-my $conf = new FS::Conf;
-
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my $invoice = emt("Invoice #[_1] (Balance [_2])",$cust_bill->display_invnum,$cust_bill->owed);
my $under = '';
my $invnum = $cust_bill->invnum;
-my $link = $curuser->access_right('View invoices')
+my $link = $opt{'View invoices'}
? qq!<A HREF="${p}view/cust_bill.cgi?$invnum">!
: '';
my $void = '';
-if ( $cust_bill->closed !~ /^Y/i && $curuser->access_right('Void invoices') ) {
+if ( $cust_bill->closed !~ /^Y/i && $opt{'Void invoices'} ) {
$void =
' ('. include('/elements/popup_link.html',
'label' => emt('void'),
emt('Delete this invoice from the database completely'),
emt('delete')
)
- if ( $opt{'deleteinvoices'} && $curuser->access_right('Delete invoices') );
+ if ( $opt{'deleteinvoices'} && $opt{'Delete invoices'} );
my $events = '';
-#1.9
if ( $cust_bill->num_cust_event
- && ( $curuser->access_right('Billing event reports')
- || $curuser->access_right('View customer billing events')
- )
- ) {
+ && ($opt{'Billing event reports'} || $opt{'View customer billing events'})
+ )
+{
$under .=
qq!<BR><A HREF="${p}search/cust_event.html?invnum=$invnum">( !.
emt('View invoice events').' )</A>';
my $date_format = $opt{'date_format'} || '%m/%d/%Y';
-my $conf = new FS::Conf;
-my $money_char = $conf->config('money_char') || '$';
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my @cust_bill_pay = $cust_pay->cust_bill_pay;
my @cust_pay_refund = $cust_pay->cust_pay_refund;
my %cust_bill_pay_width = ('width' => 392);
my %cust_bill_pay_height = ();
-if ($conf->exists('cust_bill_pay_pkg-manual')) {
+if ( $opt{'cust_bill_pay_pkg-manual'} ) {
%cust_bill_pay_width = ('width' => 592);
%cust_bill_pay_height = ('height' => 436);
}
$payment = emt("Unapplied Payment by [_1]",$otaker);
$payment =~ s/$otaker/<i>$otaker<\/i>/ if $italicize_otaker;
$payment = '<B><FONT COLOR="#FF0000">'.$payment.'</FONT></B>';
- if ( $curuser->access_right('Apply payment') ) {
- if ( $cust_pay->cust_main->total_owed > 0 ) {
+ if ( $opt{'Apply payment'} ) {
+ if ( $opt{total_owed} > 0 ) {
$apply = ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply'),
).
')';
}
- if ( $cust_pay->cust_main->total_unapplied_refunds > 0 ) {
+ if ( $opt{total_unapplied_refunds} > 0 ) {
$apply.= ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply to refund'),
foreach my $app ( sort { $a->_date <=> $b->_date }
( @cust_bill_pay, @cust_pay_refund ) ) {
if ( $app->isa('FS::cust_bill_pay') ) {
- $desc .= ' ' . $money_char . $app->amount . ' ' .
+ $desc .= ' ' . $opt{money_char} . $app->amount . ' ' .
$app->applied_to_invoice . '<BR>';
} elsif ( $app->isa('FS::cust_pay_refund') ) {
$desc .= ' ' .
- emt("[_1][_2] refunded on [_3]", $money_char, $app->amount,
+ emt("[_1][_2] refunded on [_3]", $opt{money_char}, $app->amount,
time2str($date_format, $app->_date) ) . '<BR>';
} else {
die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund";
}
if ( $cust_pay->unapplied > 0 ) {
$desc .= ' '.
- '<B><FONT COLOR="#FF0000">' .
- emt("[_1][_2] unapplied", $money_char, $cust_pay->unapplied) .
+ '<B><FONT COLOR="#FF0000">'.
+ emt("[_1][_2] unapplied", $opt{money_char}, $cust_pay->unapplied).
'</FONT></B>';
- if ( $curuser->access_right('Apply payment') ) {
- if ( $cust_pay->cust_main->total_owed > 0 ) {
+ if ( $opt{'Apply payment'} ) {
+ if ( $opt{total_owed} > 0 ) {
$apply = ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply'),
).
')';
}
- if ( $cust_pay->cust_main->total_unapplied_refunds > 0 ) {
+ if ( $opt{total_unapplied_refunds} > 0 ) {
$apply.= ' ('.
include( '/elements/popup_link.html',
'label' => emt('apply to refund'),
my $refund = '';
my $refund_days = $opt{'card_refund-days'} || 120;
-my @rights = ('Refund payment');
-push @rights, 'Refund credit card payment' if $payby eq 'CARD';
-push @rights, 'Refund Echeck payment' if $payby eq 'CHEK';
+my $refund_right = '';
+$refund_right = 'Refund credit card payment' if $payby eq 'CARD';
+$refund_right = 'Refund Echeck payment' if $payby eq 'CHEK';
if ( $cust_pay->closed !~ /^Y/i
&& $cust_pay->payby =~ /^(CARD|CHEK)$/
&& time-$cust_pay->_date < $refund_days*86400
&& $cust_pay->unrefunded > 0
- && $curuser->access_right(\@rights)
+ && $opt{$refund_right}
) {
$refund = qq! (<A HREF="${p}edit/cust_refund.cgi?payby=$1;!.
qq!paynum=!. $cust_pay->paynum. '"'.
emt('Void this payment from the database') . $voidmsg,
emt('void')
)
- if ( $cust_pay->closed !~ /^Y/i
- && ( ( $cust_pay->payby eq 'CARD'
- && $curuser->access_right('Credit card void')
- )
- || ( $cust_pay->payby eq 'CHEK'
- && $curuser->access_right('Echeck void')
- )
- || ( $cust_pay->payby !~ /^(CARD|CHEK)$/
- && $curuser->access_right('Void payments')
- )
- )
- );
+ if $cust_pay->closed !~ /^Y/i
+ && ( ( $cust_pay->payby eq 'CARD' && $opt{'Credit card void'} )
+ || ( $cust_pay->payby eq 'CHEK' && $opt{'Echeck void'} )
+ || ( $cust_pay->payby !~ /^(CARD|CHEK)$/ && $opt{'Void payments'} )
+ );
my $delete = '';
$delete = areyousure_link("${p}misc/delete-cust_pay.cgi?".$cust_pay->paynum,
emt('Delete this payment from the database completely - not recommended'),
emt('delete')
)
- if ( $cust_pay->closed !~ /^Y/i && $opt{'deletepayments'}
- && $curuser->access_right('Delete payment') );
+ if $cust_pay->closed !~ /^Y/i
+ && $opt{'deletepayments'}
+ && $opt{'Delete payment'};
my $unapply = '';
$unapply = areyousure_link("${p}misc/unapply-cust_pay.cgi?".$cust_pay->paynum,
emt('Keep this payment, but dissociate it from the invoices it is currently applied against'),
emt('unapply')
)
- if ( $cust_pay->closed !~ /^Y/i && scalar(@cust_bill_pay)
- && $curuser->access_right('Unapply payment') );
+ if $cust_pay->closed !~ /^Y/i
+ && scalar(@cust_bill_pay)
+ && $opt{'Unapply payment'};
</%init>
my( $cust_pay_pending, %opt ) = @_;
-my $conf = new FS::Conf;
-
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my ($payby, $payinfo) = translate_payinfo($cust_pay_pending);
my $target = "$payby$payinfo";
$payby = translate_payby($payby,$payinfo);
my( $cust_refund, %opt ) = @_;
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my $payby = $cust_refund->payby;
my $payinfo = $payby eq 'CARD'
? $cust_refund->paymask
emt('Delete this refund from the database completely - not recommended'),
emt('delete')
)
- if ( $cust_refund->closed !~ /^Y/i && $opt{'deleterefunds'}
- && $curuser->access_right('Delete refund') );
+ if $cust_refund->closed !~ /^Y/i
+ && $opt{'deleterefunds'}
+ && $opt{'Delete refund'};
</%init>
my( $cust_statement, %opt ) = @_;
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my($pre, $post) = ('', '');
#if ( $cust_statement->owed > 0 ) {
# $pre = '<B><FONT SIZE="+1" COLOR="#FF0000">Open ';
my $statementnum = $cust_statement->statementnum;
-my $link = $curuser->access_right('View invoices')
+my $link = $opt{'View invoices'}
? qq!<A HREF="${p}view/cust_statement.html?$statementnum">!
: '';
my $events = '';
#if ( $cust_statement->num_cust_event
-# && ( $curuser->access_right('Billing event reports')
-# || $curuser->access_right('View customer billing events')
-# )
+# && ($opt{'Billing event reports'} || $opt{'View customer billing events'})
# ) {
# $events =
# qq!<BR><FONT SIZE="-1"><A HREF="${p}search/cust_event.html?statementnum=!.
my $date_format = $opt{'date_format'} || '%m/%d/%Y';
-my $curuser = $FS::CurrentUser::CurrentUser;
-
#my $unvoid = ''; # not yet available
my $reason = $cust_credit_void->reason;
$reason = " ($reason)" if $reason;
my $date_format = $opt{'date_format'} || '%m/%d/%Y';
-my $conf = new FS::Conf;
-
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my $invoice = emt("Invoice #[_1] (Balance [_2])",$cust_bill_void->display_invnum, $cust_bill_void->charged);
my $under = '';
my $invnum = $cust_bill_void->invnum;
-my $link = $curuser->access_right('View invoices')
+my $link = $opt{'View invoices'}
? qq!<A HREF="${p}view/cust_bill_void.html?$invnum">!
: '';
emt('Unvoid this invoice'),
emt('unvoid')
)
- if $cust_bill_void->closed !~ /^Y/ && $curuser->access_right('Unvoid invoices');
+ if $cust_bill_void->closed !~ /^Y/ && $opt{'Unvoid invoices'};
my $delete = '';
$delete = areyousure_link("${p}misc/delete-cust_bill.html?$invnum",
emt('Delete this invoice from the database completely'),
emt('delete')
)
- if ( $opt{'deleteinvoices'} && $curuser->access_right('Delete invoices') );
+ if $opt{'deleteinvoices'} && $opt{'Delete invoices'};
my $events = '';
-#1.9
if ( $cust_bill_void->num_cust_event
- && ( $curuser->access_right('Billing event reports')
- || $curuser->access_right('View customer billing events')
- )
- ) {
+ && ($opt{'Billing event reports'} || $opt{'View customer billing events'})
+ )
+{
$under .=
qq!<BR><A HREF="${p}search/cust_event.html?invnum=$invnum">( !.
emt('View invoice events').' )</A>';
my $date_format = $opt{'date_format'} || '%m/%d/%Y';
-my $curuser = $FS::CurrentUser::CurrentUser;
-
my ($payby,$payinfo) = translate_payinfo($cust_pay_void);
$payby = translate_payby($payby,$payinfo);
my $info = $payby ? "($payby$payinfo)" : '';
emt('Unvoid this payment from the database') . $unvoidmsg,
emt('unvoid')
)
- if ( $cust_pay_void->closed !~ /^Y/i && $curuser->access_right('Unvoid payments') );
+ if $cust_pay_void->closed !~ /^Y/i && $opt{'Unvoid payments'};
</%init>