[freeside-commits] branch FREESIDE_3_BRANCH updated. fa868107440f645205e7943fd370fb48e677f091
Jeremy Davis
jeremyd at 420.am
Tue Dec 9 10:49:56 PST 2014
The branch, FREESIDE_3_BRANCH has been updated
via fa868107440f645205e7943fd370fb48e677f091 (commit)
from 0f69a0c57be1409ddc1714eec396f1bc4080b75d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fa868107440f645205e7943fd370fb48e677f091
Author: Ivan Kohler <ivan at freeside.biz>
Date: Thu Dec 4 14:47:49 2014 -0800
backdate credits, RT#32320
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 9e35aac..04106dc 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -218,6 +218,7 @@ tie my %rights, 'Tie::IxHash',
###
'Customer credit and refund rights' => [
'Post credit',
+ { rightname=>'Backdate credit', desc=>'Enable credits to be posted for days other than today.' },
'Credit line items', #NEWNEWNEW
'Apply credit', #NEWNEW
{ rightname=>'Unapply credit', desc=>'Enable "unapplication" of unclosed credits.' }, #aka unapplycredits
@@ -443,6 +444,7 @@ sub default_superuser_rights {
'Credit card void',
'Echeck void',
'Void invoices',#people are overusing this when credits are more appropriate
+ 'Backdate credit',
);
no warnings 'uninitialized';
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 0be3b23..8a086a7 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -246,6 +246,7 @@ sub _upgrade_data { # class method
'Edit package definition costs' => 'View package definition costs',
'List prospects' => 'List contacts',
'List customers' => 'List contacts',
+ 'Backdate payment' => 'Backdate credit',
);
# foreach my $old_acl ( keys %onetime ) {
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi
index e6eb97d..c8e6978 100755
--- a/httemplate/edit/cust_credit.cgi
+++ b/httemplate/edit/cust_credit.cgi
@@ -6,16 +6,26 @@
<INPUT TYPE="hidden" NAME="crednum" VALUE="">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum |h %>">
<INPUT TYPE="hidden" NAME="paybatch" VALUE="">
-<INPUT TYPE="hidden" NAME="_date" VALUE="<% $_date %>">
<INPUT TYPE="hidden" NAME="credited" VALUE="">
<INPUT TYPE="hidden" NAME="otaker" VALUE="<% $otaker %>">
<% ntable("#cccccc", 2) %>
- <TR>
- <TD ALIGN="right"><% mt('Date') |h %></TD>
- <TD BGCOLOR="#ffffff"><% time2str($date_format, $_date) %></TD>
- </TR>
+% my %date_args = (
+% 'name' => '_date',
+% 'label' => emt('Date'),
+% 'value' => $_date,
+% 'format' => $date_format. ' %r',
+% );
+% if ( $FS::CurrentUser::CurrentUser->access_right('Backdate credit') ) {
+
+ <& /elements/tr-input-date-field.html, \%date_args &>
+
+% } else {
+
+ <& /elements/tr-fixed-date.html, \%date_args &>
+
+% }
<TR>
<TD ALIGN="right"><% mt('Amount') |h %></TD>
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index ec7391b..888335f 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -23,37 +23,26 @@
<% mt('Payment') |h %>
<% ntable("#cccccc", 2) %>
+% my %date_args = (
+% 'name' => '_date',
+% 'label' => emt('Date'),
+% 'value' => $_date,
+% 'format' => $date_format. ' %r',
+% 'colspan' => 2,
+% );
% if ( $FS::CurrentUser::CurrentUser->access_right('Backdate payment') ) {
-<TR>
- <TD ALIGN="right"><% mt('Date') |h %></TD>
- <TD COLSPAN=2>
- <INPUT TYPE="text" NAME="_date" ID="_date_text" VALUE="<% time2str($date_format.' %r',$_date) %>">
- <IMG SRC="../images/calendar.png" ID="_date_button" STYLE="cursor: pointer" TITLE="<% mt('Select date') |h %>">
- </TD>
-</TR>
-<SCRIPT TYPE="text/javascript">
- Calendar.setup({
- inputField: "_date_text",
- ifFormat: "<% $date_format %>",
- button: "_date_button",
- align: "BR"
- });
-</SCRIPT>
-% }
-% else {
-<TR>
- <TD ALIGN="right"><% mt('Date') |h %></TD>
- <TD COLSPAN=2>
- <% time2str($date_format.' %r',$_date) %>
- </TD>
-</TR>
+ <& /elements/tr-input-date-field.html, \%date_args &>
+
+% } else {
+
+ <& /elements/tr-fixed-date.html, \%date_args &>
+
% }
<TR>
<TD ALIGN="right"><% mt('Amount') |h %></TD>
- <TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char %></TD>
- <TD><INPUT TYPE="text" NAME="paid" ID="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
+ <TD BGCOLOR="#ffffff"><% $money_char |h %><INPUT TYPE="text" NAME="paid" ID="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
</TR>
% if ( $conf->exists('part_pkg-term_discounts') ) {
diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi
index e442d7f..39c6f19 100755
--- a/httemplate/edit/process/cust_credit.cgi
+++ b/httemplate/edit/process/cust_credit.cgi
@@ -42,11 +42,20 @@ if (!$reasonnum) {
}
$cgi->param('reasonnum', $reasonnum) unless $error;
+my $_date;
+if ( $FS::CurrentUser::CurrentUser->access_right('Backdate credit') ) {
+ $_date = parse_datetime($cgi->param('_date'));
+}
+else {
+ $_date = time;
+}
+
+my @fields = grep { $_ ne '_date' } fields('cust_credit');
+
unless ($error) {
my $new = new FS::cust_credit ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('cust_credit')
+ _date => $_date,
+ map { $_ => scalar($cgi->param($_)) } @fields
} );
$error = $new->insert;
}
diff --git a/httemplate/elements/tr-fixed-date.html b/httemplate/elements/tr-fixed-date.html
index 716e5ce..ef59979 100644
--- a/httemplate/elements/tr-fixed-date.html
+++ b/httemplate/elements/tr-fixed-date.html
@@ -1,12 +1,18 @@
<% include('tr-fixed.html', %opt ) %>
<%init>
-my %opt = @_;
+my %opt;
+if ( ref($_[0]) ) {
+ my $hashref = shift;
+ %opt = %$hashref;
+} else {
+ %opt = @_;
+}
my $value = $opt{'curr_value'} || $opt{'value'};
my $conf = new FS::Conf;
-my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+my $date_format = $opt{'format'} || $conf->config('date_format') || '%m/%d/%Y';
$opt{'formatted_value'} = time2str($date_format, $value);
-----------------------------------------------------------------------
Summary of changes:
FS/FS/AccessRight.pm | 2 ++
FS/FS/access_right.pm | 1 +
httemplate/edit/cust_credit.cgi | 20 ++++++++++++----
httemplate/edit/cust_pay.cgi | 39 +++++++++++--------------------
httemplate/edit/process/cust_credit.cgi | 15 +++++++++---
httemplate/elements/tr-fixed-date.html | 10 ++++++--
6 files changed, 52 insertions(+), 35 deletions(-)
More information about the freeside-commits
mailing list