summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-12-30 22:14:25 -0800
committerIvan Kohler <ivan@freeside.biz>2013-12-30 22:14:25 -0800
commit1564f23d66008e6167af8b517dce364127d34c3c (patch)
tree9067b2b09072784bf01690133772993ae71d6b8b /httemplate
parent19d8baa9a52d0c40b909d5323f59237f0ad557ef (diff)
(pkg-balances) change package of unapplied payments and credits, RT#22198
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_credit-pkgnum.html69
-rwxr-xr-xhttemplate/edit/cust_pay-pkgnum.html93
-rwxr-xr-xhttemplate/edit/process/cust_credit-pkgnum.html35
-rwxr-xr-xhttemplate/edit/process/cust_pay-pkgnum.html35
-rw-r--r--httemplate/view/cust_main/payment_history/credit.html18
-rw-r--r--httemplate/view/cust_main/payment_history/payment.html18
6 files changed, 263 insertions, 5 deletions
diff --git a/httemplate/edit/cust_credit-pkgnum.html b/httemplate/edit/cust_credit-pkgnum.html
new file mode 100755
index 000000000..a7c046b48
--- /dev/null
+++ b/httemplate/edit/cust_credit-pkgnum.html
@@ -0,0 +1,69 @@
+<& /elements/header-popup.html, mt('Change credit package') &>
+
+<& /elements/error.html &>
+
+<FORM NAME="credit_popup" ACTION="<% popurl(1) %>process/cust_credit-pkgnum.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="crednum" VALUE="<% $cust_credit->crednum %>">
+
+<% ntable("#cccccc", 2) %>
+
+ <TR>
+ <TD ALIGN="right"><% mt('Date') |h %></TD>
+ <TD BGCOLOR="#eeeeee"><% time2str($date_format, $cust_credit->_date) |h %></TD>
+ </TR>
+
+ <TR>
+ <TD ALIGN="right"><% mt('Amount') |h %></TD>
+ <TD BGCOLOR="#eeeeee">
+ <% $money_char. $cust_credit->amount %>
+ </TD>
+ </TR>
+
+% if ( $cust_credit->addlinfo ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Additional info') |h %></TD>
+ <TD BGCOLOR="#eeeeee">
+ <% $cust_credit->addlinfo |h %>
+ </TD>
+ </TR>
+% }
+
+% if ( $conf->exists('pkg-balances') ) {
+% $cgi->param('pkgnum', $cust_credit->pkgnum);
+ <& /elements/tr-select-cust_pkg-balances.html,
+ 'custnum' => $cust_credit->custnum,
+ 'cgi' => $cgi
+ &>
+% } else {
+ <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
+% }
+
+</TABLE>
+
+<BR>
+
+<CENTER><INPUT TYPE="submit" ID="confirm_credit_button" VALUE="<% mt('Change credit package') |h %>"></CENTER>
+
+</FORM>
+</BODY>
+</HTML>
+<%init>
+
+my $conf = new FS::Conf;
+
+my $money_char = $conf->config('money_char') || '$';
+my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Apply credit'); #own ACL?
+
+my $cust_credit = qsearchs({
+ 'select' => 'cust_credit.*',
+ 'table' => 'cust_credit',
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+ 'hashref' => { crednum => scalar($cgi->param('crednum')), },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+})
+ or die 'unknown credit';
+
+</%init>
diff --git a/httemplate/edit/cust_pay-pkgnum.html b/httemplate/edit/cust_pay-pkgnum.html
new file mode 100755
index 000000000..adb88ab09
--- /dev/null
+++ b/httemplate/edit/cust_pay-pkgnum.html
@@ -0,0 +1,93 @@
+<& /elements/header-popup.html, 'Change payment package' &>
+
+<& /elements/error.html &>
+
+<FORM NAME="PaymentForm" ACTION="<% popurl(1) %>process/cust_pay-pkgnum.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="paynum" VALUE="<% $cust_pay->paynum %>">
+
+<BR>
+
+<% mt('Payment') |h %>
+<% ntable("#cccccc", 2) %>
+
+<TR>
+ <TD ALIGN="right"><% mt('Date') |h %></TD>
+ <TD COLSPAN=2 BGCOLOR="#eeeeee"><% time2str($date_format.' %r',$cust_pay->_date) |h %>
+ </TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right"><% mt('Amount') |h %></TD>
+ <TD COLSPAN=2 BGCOLOR="#eeeeee">
+ <% $money_char. $cust_pay->paid %>
+ <% mt('by') |h %>
+ <B><% mt(FS::payby->payname($cust_pay->payby)) |h %></B></TD>
+</TR>
+
+% if ( $cust_pay->payby eq 'BILL' ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Check #') |h %></TD>
+ <TD COLSPAN=2><% $cust_pay->payinfo |h %></TD>
+ </TR>
+% } elsif ( $cust_pay->payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Bank') |h %></TD>
+ <TD COLSPAN=3><% $cust_pay->bank |h %></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt('Check #') |h %></TD>
+ <TD COLSPAN=2><% $cust_pay->payinfo |h %></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt('Teller #') |h %></TD>
+ <TD COLSPAN=2><% $cust_pay->teller |h %></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt('Depositor') |h %></TD>
+ <TD COLSPAN=3><% $cust_pay->depositor |h %></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt('Account #') |h %></TD>
+ <TD COLSPAN=2><% $cust_pay->account |h %></TD>
+ </TR>
+% }
+
+% if ( $conf->exists('pkg-balances') ) {
+% $cgi->param('pkgnum', $cust_pay->pkgnum);
+ <& /elements/tr-select-cust_pkg-balances.html,
+ 'custnum' => $cust_pay->custnum,
+ 'cgi' => $cgi,
+ &>
+% } else {
+ <INPUT TYPE="hidden" NAME="pkgnum" VALUE="">
+% }
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="<% mt('Change payment package') |h %>">
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+
+my $conf = new FS::Conf;
+
+my $money_char = $conf->config('money_char') || '$';
+my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Apply payment'); #own ACL?
+
+my $cust_pay = qsearchs({
+ 'select' => 'cust_pay.*',
+ 'table' => 'cust_pay',
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+ 'hashref' => { paynum => scalar($cgi->param('paynum')), },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+})
+ or die 'unknown payment';
+
+</%init>
diff --git a/httemplate/edit/process/cust_credit-pkgnum.html b/httemplate/edit/process/cust_credit-pkgnum.html
new file mode 100755
index 000000000..8941cbc73
--- /dev/null
+++ b/httemplate/edit/process/cust_credit-pkgnum.html
@@ -0,0 +1,35 @@
+%if ($error) {
+% $cgi->param('error', $error);
+<% $cgi->redirect(popurl(2). 'cust_credit-pkgnum.html?'. $cgi->query_string ) %>
+%} else {
+<% header(emt('Credit package changed')) %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
+%}
+<%init>
+
+my $conf = FS::Conf->new;
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Apply credit'); #own ACL?
+
+$cgi->param('crednum') =~ /^(\d+)$/
+ or die "Illegal crednum: ". $cgi->param('crednum');
+my $crednum = $1;
+
+my $cust_credit = qsearchs({
+ 'select' => 'cust_credit.*',
+ 'table' => 'cust_credit',
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+ 'hashref' => { crednum => scalar($cgi->param('crednum')), },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+})
+ or die 'unknown credit';
+
+$cust_credit->pkgnum( $cgi->param('pkgnum') );
+my $error = $cust_credit->replace;
+
+</%init>
diff --git a/httemplate/edit/process/cust_pay-pkgnum.html b/httemplate/edit/process/cust_pay-pkgnum.html
new file mode 100755
index 000000000..d9a92a1de
--- /dev/null
+++ b/httemplate/edit/process/cust_pay-pkgnum.html
@@ -0,0 +1,35 @@
+%if ($error) {
+% $cgi->param('error', $error);
+<% $cgi->redirect(popurl(2). 'cust_pay-pkgnum.html?'. $cgi->query_string ) %>
+%} else {
+<% header(emt('Payment package changed')) %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
+%}
+<%init>
+
+my $conf = FS::Conf->new;
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Apply credit'); #own ACL?
+
+$cgi->param('paynum') =~ /^(\d+)$/
+ or die "Illegal paynum: ". $cgi->param('paynum');
+my $paynum = $1;
+
+my $cust_pay = qsearchs({
+ 'select' => 'cust_pay.*',
+ 'table' => 'cust_pay',
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+ 'hashref' => { paynum => scalar($cgi->param('paynum')), },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+})
+ or die 'unknown payment';
+
+$cust_pay->pkgnum( $cgi->param('pkgnum') );
+my $error = $cust_pay->replace;
+
+</%init>
diff --git a/httemplate/view/cust_main/payment_history/credit.html b/httemplate/view/cust_main/payment_history/credit.html
index ec5041b55..941180e80 100644
--- a/httemplate/view/cust_main/payment_history/credit.html
+++ b/httemplate/view/cust_main/payment_history/credit.html
@@ -1,5 +1,4 @@
-<% $credit %>
-<% "$reason$desc$apply$delete$unapply" %>
+<% $credit. ' '. $reason. $desc. $change_pkg. $apply. $delete. $unapply %>
<%init>
my( $cust_credit, %opt ) = @_;
@@ -113,7 +112,20 @@ if ( scalar(@cust_credit_bill) == 0
$desc .= '<BR>';
}
}
-#
+
+my $change_pkg = '';
+if ( $apply && $opt{'pkg-balances'} && $cust_credit->pkgnum ) {
+ $change_pkg =
+ ' ('. include('/elements/popup_link.html',
+ 'label' => emt('change package'),
+ 'action' => "${p}edit/cust_credit-pkgnum.html?crednum=".
+ $cust_credit->crednum,
+ 'actionlabel' => emt('Change credit package'),
+ 'width' => 763,
+ ).
+ ')';
+}
+
my $delete = '';
$delete = areyousure_link("${p}misc/delete-cust_credit.cgi?".$cust_credit->crednum,
emt('Are you sure you want to delete this credit?'),
diff --git a/httemplate/view/cust_main/payment_history/payment.html b/httemplate/view/cust_main/payment_history/payment.html
index 937920710..4ec9271ef 100644
--- a/httemplate/view/cust_main/payment_history/payment.html
+++ b/httemplate/view/cust_main/payment_history/payment.html
@@ -1,5 +1,6 @@
-<% $payment %>
-<% "$info$desc$view$apply$refund$void$delete$unapply" %>
+<% $payment. ' '. $info. $desc.
+ $view. $change_pkg. $apply. $refund. $void. $delete. $unapply
+%>
<%init>
my( $cust_pay, %opt ) = @_;
@@ -143,6 +144,19 @@ my $view =
).
')';
+my $change_pkg = '';
+if ( $apply && $opt{'pkg-balances'} && $cust_pay->pkgnum ) {
+ $change_pkg =
+ ' ('. include('/elements/popup_link.html',
+ 'label' => emt('change package'),
+ 'action' => "${p}edit/cust_pay-pkgnum.html?paynum=".
+ $cust_pay->paynum,
+ 'actionlabel' => emt('Change payment package'),
+ 'width' => 763,
+ ).
+ ')';
+}
+
my $refund = '';
my $refund_days = $opt{'card_refund-days'} || 120;
my $refund_right = '';