summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_pay.cgi10
-rw-r--r--httemplate/edit/process/cust_pay-no_auto_apply.cgi48
-rwxr-xr-xhttemplate/edit/process/cust_pay.cgi1
-rw-r--r--httemplate/misc/batch-cust_pay.html10
-rw-r--r--httemplate/misc/process/batch-cust_pay.cgi1
-rw-r--r--httemplate/search/elements/cust_main_dayranges.html5
-rw-r--r--httemplate/search/elements/search.html24
-rw-r--r--httemplate/view/cust_main/payment_history/payment.html103
8 files changed, 130 insertions, 72 deletions
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index 888335fbb..5d74365e7 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -87,15 +87,17 @@
<TD ALIGN="right"><% mt('Auto-apply to invoices') |h %></TD>
<TD COLSPAN=2>
<SELECT NAME="apply">
- <OPTION VALUE="yes" SELECTED><% mt('yes') |h %>
- <OPTION><% mt('no') |h %></SELECT>
- </TD>
+ <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
+ <OPTION VALUE=""><% mt('not now') |h %></OPTION>
+ <OPTION VALUE="never"><% mt('never') |h %></OPTION>
+ </SELECT>
+ </TD>
% } elsif ( $link eq 'invnum' ) {
<TD ALIGN="right"><% mt('Apply to') |h %></TD>
<TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD>
- <INPUT TYPE="hidden" NAME="apply" VALUE="no">
+ <INPUT TYPE="hidden" NAME="apply" VALUE="">
% }
</TR>
diff --git a/httemplate/edit/process/cust_pay-no_auto_apply.cgi b/httemplate/edit/process/cust_pay-no_auto_apply.cgi
new file mode 100644
index 000000000..ccbd2d7b5
--- /dev/null
+++ b/httemplate/edit/process/cust_pay-no_auto_apply.cgi
@@ -0,0 +1,48 @@
+<%doc>
+Quick process for toggling no_auto_apply field in cust_pay.
+
+Requires paynum and no_auto_apply ('Y' or '') in cgi.
+
+Requires 'Apply payment' acl.
+</%doc>
+
+% if ($error) {
+
+<P STYLE="color: #FF0000"><% emt($error) %></P>
+
+% } else {
+
+<P STYLE="font-weight: bold;"><% emt($message) %></P>
+<P><% emt('Please wait while the page reloads.') %></P>
+<SCRIPT TYPE="text/javascript">
+window.top.location.reload();
+</SCRIPT>
+
+% }
+
+<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Apply payment');
+
+my $paynum = $cgi->param('paynum');
+my $noauto = $cgi->param('no_auto_apply');
+
+my $error = '';
+my $message = '';
+my $cust_pay = qsearchs('cust_pay',{ paynum => $paynum });
+if ($cust_pay) {
+ if (($noauto eq 'Y') || (defined($noauto) && (length($noauto) == 0))) {
+ $cust_pay->no_auto_apply($noauto);
+ $error = $cust_pay->replace;
+ $message = $noauto ?
+ q(Payment will not be automatically applied to open invoices, must be applied manually) :
+ q(Payment will be automatically applied to open invoices the next time this customer's payments are processed);
+ } else {
+ $error = 'no_auto_apply not specified';
+ }
+} else {
+ $error .= 'Payment could not be found in database';
+}
+
+
+</%init>
diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi
index a002fa181..56d3f2ff1 100755
--- a/httemplate/edit/process/cust_pay.cgi
+++ b/httemplate/edit/process/cust_pay.cgi
@@ -50,6 +50,7 @@ else {
my $new = new FS::cust_pay ( {
$field => $linknum,
_date => $_date,
+ no_auto_apply => ($cgi->param('apply') eq 'never') ? 'Y' : '',
map {
$_, scalar($cgi->param($_));
} qw( paid payby payinfo paybatch
diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html
index 3b0ebc112..9f2540cc7 100644
--- a/httemplate/misc/batch-cust_pay.html
+++ b/httemplate/misc/batch-cust_pay.html
@@ -461,6 +461,16 @@ push @footer, '';
push @footer_align, '';
push @onchange, 'toggle_application_row';
+push @header, 'No Auto Allocate';
+push @fields, 'no_auto_apply';
+push @types, 'checkbox';
+push @align, 'c';
+push @sizes, '0';
+push @colors, '';
+push @footer, '';
+push @footer_align, '';
+push @onchange, '';
+
#push @header, 'Error';
push @header, '';
push @fields, 'error';
diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi
index bb4b9733c..ff7886239 100644
--- a/httemplate/misc/process/batch-cust_pay.cgi
+++ b/httemplate/misc/process/batch-cust_pay.cgi
@@ -40,6 +40,7 @@ foreach my $row ( map /^custnum(\d+)$/, keys %$param ) {
'payinfo' => $param->{"payinfo$row"},
'discount_term' => $param->{"discount_term$row"},
'paybatch' => $paybatch,
+ 'no_auto_apply' => exists($param->{"no_auto_apply$row"}) ? 'Y' : '',
}
if $param->{"custnum$row"}
|| $param->{"paid$row"}
diff --git a/httemplate/search/elements/cust_main_dayranges.html b/httemplate/search/elements/cust_main_dayranges.html
index e5b1f478c..951eff29d 100644
--- a/httemplate/search/elements/cust_main_dayranges.html
+++ b/httemplate/search/elements/cust_main_dayranges.html
@@ -21,7 +21,7 @@ Example:
'query' => $sql_query,
'count_query' => $count_sql,
'header' => [
- @act_blank,
+ @act_head,
@cust_header,
'0-30',
'30-60',
@@ -248,7 +248,7 @@ if($opt{'payment_links'} && $curuser->access_right('Process payment') && @payby)
@payby );
}
-my (@act_blank, @act_fields, $act_align, $html_foot);
+my (@act_head, @act_blank, @act_fields, $act_align, $html_foot);
if (delete($opt{'email_checkboxes'})) {
my $email_link = q!var url = toCGIString(); !;
$email_link .= q/if (!url) { alert('No customers selected'); return false; }; /;
@@ -271,6 +271,7 @@ if (delete($opt{'email_checkboxes'})) {
qq!<input type="checkbox" name="custnum" value="$custnum">!;
};
$act_align = 'l';
+ push @act_head, {nodownload => 1};
push @act_blank, '';
}
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index f136832a2..beb017300 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -222,6 +222,18 @@ if ( !$curuser->access_right('Download report data') ) {
$type = 'html';
}
+# split/map aligns here before doing anything else
+my %align = (
+ 'l' => 'left',
+ 'r' => 'right',
+ 'c' => 'center',
+ ' ' => '',
+ '.' => '',
+);
+
+$opt{align} = [ map $align{$_}, split(//, $opt{align}) ],
+ unless !$opt{align} || ref($opt{align});
+
if($type =~ /csv|xls/) {
my $h = $opt{'header'};
my @del;
@@ -245,18 +257,6 @@ $opt{disable_download} = 0
$opt{disable_download} = 1
if $opt{really_disable_download};
-# split/map aligns here, so that agent_virt can add a column
-# (search-html.html will split aligns also if they aren't already split)
-my %align = (
- 'l' => 'left',
- 'r' => 'right',
- 'c' => 'center',
- ' ' => '',
- '.' => '',
-);
-$opt{align} = [ map $align{$_}, split(//, $opt{align}) ],
- unless !$opt{align} || ref($opt{align});
-
# get our queries ready
my $query = $opt{query} or die "query required";
my $count_query = $opt{count_query} or die "count_query required";
diff --git a/httemplate/view/cust_main/payment_history/payment.html b/httemplate/view/cust_main/payment_history/payment.html
index 4ec9271ef..bf88a6607 100644
--- a/httemplate/view/cust_main/payment_history/payment.html
+++ b/httemplate/view/cust_main/payment_history/payment.html
@@ -9,6 +9,7 @@ my $date_format = $opt{'date_format'} || '%m/%d/%Y';
my @cust_bill_pay = $cust_pay->cust_bill_pay;
my @cust_pay_refund = $cust_pay->cust_pay_refund;
+my $unapplied = $cust_pay->unapplied;
my ($payby,$payinfo) = translate_payinfo($cust_pay);
my $target = "$payby$payinfo";
@@ -50,39 +51,14 @@ if ( scalar(@cust_bill_pay) == 0
$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 ( $opt{'Apply payment'} ) {
- if ( $opt{total_owed} > 0 ) {
- $apply = ' ('.
- include( '/elements/popup_link.html',
- 'label' => emt('apply'),
- 'action' => "${p}edit/cust_bill_pay.cgi?".
- $cust_pay->paynum,
- 'actionlabel' => emt('Apply payment'),
- %cust_bill_pay_width,
- %cust_bill_pay_height,
- ).
- ')';
- }
- if ( $opt{total_unapplied_refunds} > 0 ) {
- $apply.= ' ('.
- include( '/elements/popup_link.html',
- 'label' => emt('apply to refund'),
- 'action' => "${p}edit/cust_pay_refund.cgi?".
- $cust_pay->paynum,
- 'actionlabel' => emt('Apply payment to refund'),
- 'width' => 392,
- ).
- ')';
- }
- }
} elsif ( scalar(@cust_bill_pay) == 1
&& scalar(@cust_pay_refund) == 0
- && $cust_pay->unapplied == 0 ) {
+ && $unapplied == 0 ) {
#applied to one invoice, the usual situation
$desc .= ' '. $cust_bill_pay[0]->applied_to_invoice;
} elsif ( scalar(@cust_bill_pay) == 0
&& scalar(@cust_pay_refund) == 1
- && $cust_pay->unapplied == 0 ) {
+ && $unapplied == 0 ) {
#applied to one refund
$desc .= emt(" refunded on [_1]", time2str($date_format, $cust_pay_refund[0]->_date) );
} else {
@@ -101,40 +77,59 @@ if ( scalar(@cust_bill_pay) == 0
die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund";
}
}
- if ( $cust_pay->unapplied > 0 ) {
+ if ( $unapplied > 0 ) {
$desc .= '&nbsp;&nbsp;'.
'<B><FONT COLOR="#FF0000">'.
- emt("[_1][_2] unapplied", $opt{money_char}, $cust_pay->unapplied).
+ emt("[_1][_2] unapplied", $opt{money_char}, $unapplied).
'</FONT></B>';
- if ( $opt{'Apply payment'} ) {
- if ( $opt{total_owed} > 0 ) {
- $apply = ' ('.
- include( '/elements/popup_link.html',
- 'label' => emt('apply'),
- 'action' => "${p}edit/cust_bill_pay.cgi?".
- $cust_pay->paynum,
- 'actionlabel' => emt('Apply payment'),
- %cust_bill_pay_width,
- %cust_bill_pay_height,
- ).
- ')';
- }
- if ( $opt{total_unapplied_refunds} > 0 ) {
- $apply.= ' ('.
- include( '/elements/popup_link.html',
- 'label' => emt('apply to refund'),
- 'action' => "${p}edit/cust_pay_refund.cgi?".
- $cust_pay->paynum,
- 'actionlabel' => emt('Apply payment to refund'),
- 'width' => 392,
- ).
- ')';
- }
- }
$desc .= '<BR>';
}
}
+if ($unapplied > 0) {
+ if ( $opt{'Apply payment'} ) {
+ if ( $opt{total_owed} > 0 ) {
+ $apply = ' ('.
+ include( '/elements/popup_link.html',
+ 'label' => emt('apply'),
+ 'action' => "${p}edit/cust_bill_pay.cgi?".
+ $cust_pay->paynum,
+ 'actionlabel' => emt('Apply payment'),
+ %cust_bill_pay_width,
+ %cust_bill_pay_height,
+ ).
+ ')';
+ }
+ if ( $opt{total_unapplied_refunds} > 0 ) {
+ $apply.= ' ('.
+ include( '/elements/popup_link.html',
+ 'label' => emt('apply to refund'),
+ 'action' => "${p}edit/cust_pay_refund.cgi?".
+ $cust_pay->paynum,
+ 'actionlabel' => emt('Apply payment to refund'),
+ 'width' => 392,
+ ).
+ ')';
+ }
+ $apply .= ' (auto&#8209;apply:&nbsp;'
+ . ($cust_pay->no_auto_apply ? 'no' : 'yes')
+ . '&nbsp;|&nbsp;'
+ . include( '/elements/popup_link.html',
+ 'label' => emt($cust_pay->no_auto_apply ? 'yes' : 'no'),
+ 'action' => "${p}edit/process/cust_pay-no_auto_apply.cgi?paynum="
+ . $cust_pay->paynum
+ . '&no_auto_apply='
+ . ($cust_pay->no_auto_apply ? '' : 'Y'),
+ 'actionlabel' => emt('Toggle Auto-Apply'),
+ 'width' => 392,
+ 'height' => 200,
+ )
+ . ')';
+ } else { # end if $opt('Apply payment')
+ $apply .= ' (no auto-apply)' if $cust_pay->no_auto_apply;
+ }
+} # end if $unapplied > 0
+
my $view =
' ('. include('/elements/popup_link.html',
'label' => emt('view receipt'),