allow punctuation in tax name on tax report, #33255
[freeside.git] / httemplate / search / report_tax.cgi
old mode 100755 (executable)
new mode 100644 (file)
index 08f255f..491cd42
@@ -14,7 +14,7 @@ TD.sectionhead {
 .grid TH { background-color: #cccccc; padding: 0px 3px 2px }
 .row0 TD { background-color: #eeeeee; padding: 0px 3px 2px; text-align: right}
 .row1 TD { background-color: #ffffff; padding: 0px 3px 2px; text-align: right}
-TD.rowhead { font-weight: bold; text-align: left }
+TD.rowhead { font-weight: bold; text-align: left; padding: 0px 3px }
 .bigmath { font-size: large; font-weight: bold; font: sans-serif; text-align: center }
 .total { font-style: italic }
 </STYLE>
@@ -73,8 +73,9 @@ TD.rowhead { font-weight: bold; text-align: left }
 %   # construct base links that limit to the tax rates described by this row
 %   my $rowlink = ';taxnum=' . $row->{taxnums};
 %   # and also the package class, if we're limiting package class
-%   $rowlink .= ';pkgclass='.$row->{pkgclass}
-%     if $params{breakdown}->{pkgclass};
+%   if ( $params{breakdown}->{pkgclass} ) {
+%     $rowlink .= ';classnum=' . ($row->{pkgclass} || 0);
+%   }
 %
 %   if ( $row->{total} ) {
   </TBODY><TBODY CLASS="total">
@@ -141,6 +142,23 @@ TD.rowhead { font-weight: bold; text-align: left }
 %   $rownum++;
 %   $prev_row = $row;
 % } # foreach my $row
+% # at the end of everything
+  </TBODY>
+% if ( $report->{outside} > 0 ) {
+  <TBODY CLASS="total" STYLE="background-color: #cccccc; line-height: 3">
+    <TR>
+      <TD CLASS="rowhead">
+        <% emt('Out of taxable region') %>
+      </TD>
+      <TD STYLE="text-align: right">
+        <A HREF="<% $saleslink %>;out=1;taxname=<% encode_entities($params{'taxname'}) %>">
+          <% $money_sprintf->( $report->{outside } ) %>
+        </A>
+      </TD>
+      <TD COLSPAN=0></TD>
+    </TR>
+  </TBODY>
+% }
 </TABLE>
 
 <& /elements/footer.html &>
@@ -170,12 +188,19 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
   $agentname = $agent->agentname;
 }
 
-if ( $cgi->param('taxname') =~ /^([\w ]+)$/ ) {
-  $params{taxname} = $1;
+# allow anything in here; FS::Report::Tax will treat it as unsafe
+if ( length($cgi->param('taxname')) ) {
+  $params{taxname} = $cgi->param('taxname');
 } else {
   die "taxname required";
 }
 
+if ( $cgi->param('credit_date') eq 'cust_credit_bill' ) {
+  $params{credit_date} = 'cust_credit_bill';
+} else {
+  $params{credit_date} = 'cust_bill';
+}
+
 warn "PARAMS:\n".Dumper(\%params)."\n\n" if $DEBUG;
 
 my $report = FS::Report::Tax->report_internal(%params);
@@ -187,12 +212,19 @@ my $money_sprintf = sub {
 };
 
 my $dateagentlink = "begin=$beginning;end=$ending";
-$dateagentlink .= $params{agentnum} if $params{agentnum};
+if ( $params{agentnum} ) {
+  $dateagentlink .= ';agentnum=' . $params{agentnum};
+}
 my $saleslink  = $p. "search/cust_bill_pkg.cgi?$dateagentlink;nottax=1";
 my $taxlink    = $p. "search/cust_bill_pkg.cgi?$dateagentlink;istax=1";
 my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink";
 my $creditlink = $p. "search/cust_bill_pkg.cgi?$dateagentlink;credit=1;istax=1";
 
+if ( $params{'credit_date'} eq 'cust_credit_bill' ) {
+  $creditlink =~ s/begin/credit_begin/;
+  $creditlink =~ s/end/credit_end/;
+}
+
 my %pkgclass_name = map { $_->classnum, $_->classname } qsearch('pkg_class');
 $pkgclass_name{''} = 'Unclassified';