diff options
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/view/cust_bill.cgi | 56 |
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 ) { + | +% } +% 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); |