},
{
+ 'key' => 'voip-cust_cdr_squelch',
+ 'section' => '',
+ 'description' => 'Enable the per-customer option for not printing CDR on invoices.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'svc_forward-arbitrary_dst',
'section' => '',
'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses. Only used when using forwards for weird, non-email things.",
'referral_custnum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
'spool_cdr','char', 'NULL', 1, '', '',
+ 'squelch_cdr','char', 'NULL', 1, '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'custnum',
cid -
+unsquelch_cdr - overrides any per customer cdr squelching when true
+
=cut
sub print_generic {
$options{'section'} = $section if $multisection;
$options{'format'} = $format;
$options{'escape_function'} = $escape_function;
+ $options{'format_function'} = sub { () }
+ unless $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
foreach my $line_item ( $self->_items_pkg(%options) ) {
my $detail = {
my $format = $opt{format} || '';
my $escape_function = $opt{escape_function} || sub { shift };
+ my $format_function = $opt{format_function} || '';
my @b = ();
foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
my %details_opt = ( 'format' => $format,
'escape_function' => $escape_function,
+ 'format_function' => $format_function,
);
if ( $cust_bill_pkg->pkgnum > 0 ) {
}
if $format eq 'latex';
+ $format_sub = $opt{format_function} if $opt{format_function};
+
map { ( $_->format eq 'C'
? &{$format_sub}( $_->detail )
: &{$escape_function}( $_->detail )
=item spool_cdr - Enable individual CDR spooling, empty or `Y'
+=item squelch_cdr - Discourage individual CDR printing, empty or `Y'
+
=back
=head1 METHODS
$self->payname($1);
}
- foreach my $flag (qw( tax spool_cdr )) {
+ foreach my $flag (qw( tax spool_cdr squelch_cdr )) {
$self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag();
$self->$flag($1);
}
my $output_format = $self->option('output_format', 'Hush!')
|| 'simple';
+ eval "use Text::CSV_XS;";
+ die $@ if $@;
+ my $csv = new Text::CSV_XS;
+
foreach my $cust_svc (
grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc
) {
$charge = sprintf('%.2f', $cdr->upstream_price);
$charges += $charge;
-
+
@call_details = (
#time2str("%Y %b %d - %r", $cdr->calldate_unix ),
time2str("%c", $cdr->calldate_unix), #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot
if ( $self->option('rating_method') eq 'upstream_simple' ) {
$call_details = [ 'C', $call_details[0] ];
}else{
- $call_details = join(' - ', @call_details );
+ $csv->combine(@call_details);
+ $call_details = [ 'C', $csv->string ];
}
- warn " adding details on charge to invoice: $call_details"
- if ( $DEBUG && !ref($call_details) );
warn " adding details on charge to invoice: [ ".
join(', ', @{$call_details} ). " ]"
if ( $DEBUG && ref($call_details) );
'quantity' => $cust_pkg->quantity,
'sdate' => $$sdate,
'edate' => $cust_pkg->bill, # already fiddled
- 'itemdesc' => 'Call details', # configurable?
+ 'itemdesc' => 'Usage charges', # configurable?
'details' => \@details,
};
.invoice_longtable table { cellspacing: none }
.invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
.invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
+.invoice_desc_more TD { font-weight: bold; font-size: 10pt }
.invoice_extdesc TD { font-size: 8pt }
.invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
</STYLE>
'<th align="right">Amount</th>'.
'</tr>';
+ my $lastref = 0;
foreach my $line (
grep { ( scalar(@sections) > 1
? $section->{'description'} eq $_->{'section'}->{'description'}
@detail_items )
{
$OUT .=
- '<tr class="invoice_desc">'.
- '<td align="center">'. $line->{'ref'}. '</td>'.
+ '<tr class="invoice_desc'.
+ ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
+ '">'.
+ '<td align="center">'.
+ ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
'<td align="left">'. $line->{'description'}. '</td>'.
( $unitprices
? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
'<td align="right">'. $line->{'amount'}. '</td>'.
'</tr>'
;
+ $lastref = $line->{'ref'};
if ( @{$line->{'ext_description'} } ) {
$OUT .= '<tr class="invoice_extdesc"><td></td><td';
$OUT .= $unitprices ? ' colspan=3>' : '>';
$OUT .= '\hline';\r
$OUT .= '\endlastfoot';\r
\r
+ my $lastref = 0;\r
foreach my $line (\r
grep { ( scalar( @sections ) > 1 \r
? $section->{'description'} eq $_->{'section'}->{'description'}\r
# Don't break-up small packages.\r
my $rowbreak = @$ext_description < 5 ? '*' : '';\r
\r
- $OUT .= "\\hline\n";\r
- $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
+ $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);\r
+ $OUT .= '\FSdesc'.\r
+ '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.\r
+ '{' . $line->{'description'} . '}' .\r
'{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
'{' . ( $unitprices ? $line->{'quantity'} : '' ) . '}' .\r
'{' . $line->{'amount'} . "}${rowbreak}\n";\r
+ $lastref = $line->{'ref'};\r
\r
foreach my $ext_desc (@$ext_description) {\r
if ( $ext_desc !~ /[^\\]&/ ) {\r
'tax',
'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
'invoice_terms',
- 'spool_cdr'
+ 'spool_cdr',
+ 'squelch_cdr'
);
for ( f=0; f < topvars.length; f++ ) {
% 'tax',
% 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX',
% 'invoice_terms',
-% 'spool_cdr'
+% 'spool_cdr',
+% 'squelch_cdr'
% ) {
%
<INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
% }
+% if ( $conf->exists('voip-cust_cdr_squelch') ) {
+ <TR>
+ <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="squelch_cdr" VALUE="Y" <% $cust_main->squelch_cdr eq "Y" ? 'CHECKED' : '' %>> Omit CDRs from invoices</TD>
+ </TR>
+% } else {
+
+ <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
+% }
+
</TABLE>
</FORM>
</TR>
% }
+% if ( $conf->exists('voip-cust_cdr_squelch') ) {
+ <TR>
+ <TD ALIGN="right">Print CDRs</TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
+ </TR>
+% }
+
</TABLE></TD></TR></TABLE>
<%once>