summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-12-04 14:47:49 -0800
committerIvan Kohler <ivan@freeside.biz>2014-12-04 14:47:49 -0800
commit7dd8215a91ca6ca4a9988a0108647ada7f2a11d8 (patch)
tree0a00d42d12a5e606995374ebe0f0464856fbd373 /httemplate/edit
parent61e2f89c40a50478d12b4818400caff32d20f61a (diff)
backdate credits, RT#32320
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-xhttemplate/edit/cust_credit.cgi20
-rwxr-xr-xhttemplate/edit/cust_pay.cgi39
-rwxr-xr-xhttemplate/edit/process/cust_credit.cgi15
3 files changed, 41 insertions, 33 deletions
diff --git a/httemplate/edit/cust_credit.cgi b/httemplate/edit/cust_credit.cgi
index 29801efef..18416c5fb 100755
--- a/httemplate/edit/cust_credit.cgi
+++ b/httemplate/edit/cust_credit.cgi
@@ -6,15 +6,25 @@
<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="">
<% 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 ec7391b20..888335fbb 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 e442d7fa6..39c6f1997 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;
}