From 1564f23d66008e6167af8b517dce364127d34c3c Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 30 Dec 2013 22:14:25 -0800 Subject: [PATCH] (pkg-balances) change package of unapplied payments and credits, RT#22198 --- httemplate/edit/cust_credit-pkgnum.html | 69 ++++++++++++++++ httemplate/edit/cust_pay-pkgnum.html | 93 ++++++++++++++++++++++ httemplate/edit/process/cust_credit-pkgnum.html | 35 ++++++++ httemplate/edit/process/cust_pay-pkgnum.html | 35 ++++++++ .../view/cust_main/payment_history/credit.html | 18 ++++- .../view/cust_main/payment_history/payment.html | 18 ++++- 6 files changed, 263 insertions(+), 5 deletions(-) create mode 100755 httemplate/edit/cust_credit-pkgnum.html create mode 100755 httemplate/edit/cust_pay-pkgnum.html create mode 100755 httemplate/edit/process/cust_credit-pkgnum.html create mode 100755 httemplate/edit/process/cust_pay-pkgnum.html 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 &> + +
+ + +<% ntable("#cccccc", 2) %> + + + <% mt('Date') |h %> + <% time2str($date_format, $cust_credit->_date) |h %> + + + + <% mt('Amount') |h %> + + <% $money_char. $cust_credit->amount %> + + + +% if ( $cust_credit->addlinfo ) { + + <% mt('Additional info') |h %> + + <% $cust_credit->addlinfo |h %> + + +% } + +% 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 { + +% } + + + +
+ +
+ +
+ + +<%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'; + + 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 &> + +
+ + +
+ +<% mt('Payment') |h %> +<% ntable("#cccccc", 2) %> + + + <% mt('Date') |h %> + <% time2str($date_format.' %r',$cust_pay->_date) |h %> + + + + + <% mt('Amount') |h %> + + <% $money_char. $cust_pay->paid %> + <% mt('by') |h %> + <% mt(FS::payby->payname($cust_pay->payby)) |h %> + + +% if ( $cust_pay->payby eq 'BILL' ) { + + <% mt('Check #') |h %> + <% $cust_pay->payinfo |h %> + +% } elsif ( $cust_pay->payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) { + + <% mt('Bank') |h %> + <% $cust_pay->bank |h %> + + + <% mt('Check #') |h %> + <% $cust_pay->payinfo |h %> + + + <% mt('Teller #') |h %> + <% $cust_pay->teller |h %> + + + <% mt('Depositor') |h %> + <% $cust_pay->depositor |h %> + + + <% mt('Account #') |h %> + <% $cust_pay->account |h %> + +% } + +% 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 { + +% } + + + +
+ + +
+ + + +<%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'; + + 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')) %> + + + +%} +<%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; + + 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')) %> + + + +%} +<%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; + + 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 .= '
'; } } -# + +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 = ''; -- 2.11.0