summaryrefslogtreecommitdiff
path: root/httemplate/view
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-03-19 13:43:34 -0700
committerMark Wells <mark@freeside.biz>2015-03-19 13:43:34 -0700
commite18263db61c9695eb4c139f23c79730fd7659ad6 (patch)
tree04947f96c8709dbce3e136622c6c36223f3bd194 /httemplate/view
parent5886bd773a3c1fe43abcde0beafb7fb5e1991388 (diff)
correctly void invoices with fees, #32862
Diffstat (limited to 'httemplate/view')
-rwxr-xr-xhttemplate/view/cust_bill.cgi56
1 files changed, 37 insertions, 19 deletions
diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi
index 6bc499a35..f1bcf4d52 100755
--- a/httemplate/view/cust_bill.cgi
+++ b/httemplate/view/cust_bill.cgi
@@ -2,26 +2,37 @@
emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
) &>
-% if ( $conf->exists('deleteinvoices')
-% && $curuser->access_right('Delete invoices' )
-% )
-% {
-
- <SCRIPT TYPE="text/javascript">
- function areyousure(href, message) {
- if (confirm(message) == true)
- window.location.href = href;
- }
- </SCRIPT>
-
- <A HREF = "javascript:areyousure(
- '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',
- '<% mt('Are you sure you want to delete this invoice?') |h %>'
- )"
- TITLE = "<% mt('Delete this invoice from the database completely') |h %>"
- ><% mt('Delete this invoice') |h %></A>
- <BR><BR>
+<SCRIPT TYPE="text/javascript">
+function areyousure(href, message) {
+ if (confirm(message) == true)
+ window.location.href = href;
+}
+</SCRIPT>
+% if ( !$cust_bill->closed ) { # otherwise allow no changes
+% my $can_delete = $conf->exists('deleteinvoices')
+% && $curuser->access_right('Delete invoices');
+% my $can_void = $curuser->access_right('Void invoices');
+% if ( $can_void ) {
+ <& /elements/popup_link.html,
+ 'label' => emt('Void this invoice'),
+ 'actionlabel' => emt('Void this invoice'),
+ 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum,
+ &>
+% }
+% if ( $can_void and $can_delete ) {
+ &nbsp;|&nbsp;
+% }
+% if ( $can_delete ) {
+ <A href="" onclick="areyousure(\
+ '<%$p%>misc/delete-cust_bill.html?<% $invnum %>',\
+ <% mt('Are you sure you want to delete this invoice?') |js_string %>)"\
+ TITLE = "<% mt('Delete this invoice from the database completely') |h %>">\
+ <% emt('Delete this invoice') |h %></A>
+% }
+% if ( $can_void or $can_delete ) {
+ <BR><BR>
+% }
% }
% if ( $cust_bill->owed > 0
@@ -185,6 +196,13 @@ my $cust_bill = qsearchs({
'hashref' => { 'invnum' => $invnum },
'extra_sql' => ' AND '. $curuser->agentnums_sql,
});
+# if we're asked for a voided invnum, redirect appropriately
+if (!$cust_bill and FS::cust_bill_void->row_exists("invnum = $invnum") ) {
+ $m->clear_buffer;
+ my $url = $p.'view/cust_bill_void.html?'.$cgi->query_string;
+ $m->print( $cgi->redirect($url) );
+ $m->abort;
+}
die "Invoice #$invnum not found!" unless $cust_bill;
$cust_bill->set('mode' => $mode);