{
'key' => 'log_sent_mail',
'section' => 'notification',
- 'description' => 'Enable logging of template-generated email.',
+ 'description' => 'Enable logging of all sent email.',
'type' => 'checkbox',
},
my ($taxname, $country, %breakdown);
- # purify taxname properly here, as we're going to include it in lots of
- # SQL statements using single quotes only
- if ( $opt{taxname} =~ /^([\w\s]+)$/ ) {
- $taxname = $1;
- } else {
- die "taxname required"; # UI prevents this
- }
+ # taxname can contain arbitrary punctuation; escape it properly and
+ # include $taxname unquoted elsewhere
+ $taxname = dbh->quote($opt{'taxname'});
if ( $opt{country} =~ /^(\w\w)$/ ) {
$country = $1;
GROUP BY billpkgnum, taxnum";
my $where = "WHERE cust_bill._date >= $beginning AND cust_bill._date <= $ending ".
- "AND COALESCE(cust_main_county.taxname,'Tax') = '$taxname' ".
+ "AND COALESCE(cust_main_county.taxname,'Tax') = $taxname ".
"AND cust_main_county.country = '$country'";
# SELECT/GROUP clauses for first-level queries
my $select = "SELECT ";
SELECT 1 FROM cust_tax_exempt_pkg
JOIN cust_main_county USING (taxnum)
WHERE cust_tax_exempt_pkg.billpkgnum = cust_bill_pkg.billpkgnum
- AND COALESCE(cust_main_county.taxname,'Tax') = '$taxname'
+ AND COALESCE(cust_main_county.taxname,'Tax') = $taxname
AND cust_tax_exempt_pkg.creditbillpkgnum IS NULL
)
AND NOT EXISTS(
SELECT 1 FROM cust_bill_pkg_tax_location
JOIN cust_main_county USING (taxnum)
WHERE cust_bill_pkg_tax_location.taxable_billpkgnum = cust_bill_pkg.billpkgnum
- AND COALESCE(cust_main_county.taxname,'Tax') = '$taxname'
+ AND COALESCE(cust_main_county.taxname,'Tax') = $taxname
)
";
warn "\nOUTSIDE:\n$sql_outside\n" if $DEBUG;
'cust_main_note' => {
'columns' => [
- 'notenum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- 'classnum', 'int', 'NULL', '', '', '',
- '_date', @date_type, '', '',
- 'otaker', 'varchar', 'NULL', 32, '', '',
- 'usernum', 'int', 'NULL', '', '', '',
- 'comments', 'text', 'NULL', '', '', '',
+ 'notenum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
+ '_date', @date_type, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'comments', 'text', 'NULL', '', '', '',
+ 'sticky', 'int', '', '', 0, '',
],
'primary_key' => 'notenum',
'unique' => [],
if ( $format eq 'latex' && grep { /^%%Detail/ } @invoice_template ) {
#change this to a die when the old code is removed
- # it's been almost ten years, changing it to a die on the next release.
- warn "old-style invoice template $templatefile; ".
+ # it's been almost ten years, changing it to a die
+ die "old-style invoice template $templatefile; ".
"patch with conf/invoice_latex.diff or use new conf/invoice_latex*\n";
#$old_latex = 'true';
#@invoice_template = _translate_old_latex_format(@invoice_template);
join(', ', map "$_=>".$line_item->{$_}, keys %$line_item). "\n"
if $DEBUG > 1;
+ push @buf, ( [ $line_item->{'description'},
+ $money_char. sprintf("%10.2f", $line_item->{'amount'}),
+ ],
+ map { [ " ". $_, '' ] } @{$line_item->{'ext_description'}},
+ );
+
$line_item->{'ref'} = $line_item->{'pkgnum'};
$line_item->{'product_code'} = $line_item->{'pkgpart'} || 'N/A'; # mt()?
$line_item->{'section'} = $section;
$line_item->{'ext_description'} ||= [];
push @detail_items, $line_item;
- push @buf, ( [ $line_item->{'description'},
- $money_char. sprintf("%10.2f", $line_item->{'amount'}),
- ],
- map { [ " ". $_, '' ] } @{$line_item->{'ext_description'}},
- );
}
if ( $section->{'description'} ) {
ext_description => \@ext,
};
foreach my $cust_bill_pkg_discount (@discounts) {
- my $def = $cust_bill_pkg_discount->cust_pkg_discount->discount;
- push @ext, &{$escape_function}( $def->description );
+ my $discount = $cust_bill_pkg_discount->cust_pkg_discount->discount;
+ my $discount_desc = $discount->description_short;
+
+ if ($discount->months) {
+
+ # calculate months remaining after this invoice
+ my $used = FS::Record->scalar_sql(
+ 'SELECT SUM(months) FROM cust_bill_pkg_discount
+ JOIN cust_bill_pkg USING (billpkgnum)
+ JOIN cust_bill USING (invnum)
+ WHERE pkgdiscountnum = ? AND _date <= ?',
+ $cust_bill_pkg_discount->pkgdiscountnum,
+ $self->_date
+ );
+ $used ||= 0;
+ my $remaining = sprintf('%.2f', $discount->months - $used);
+ # append "for X months (Y months remaining)"
+ $discount_desc .= $self->mt(' for [quant,_1,month] ([quant,_2,month] remaining)',
+ $cust_bill_pkg_discount->months,
+ $remaining
+ );
+ } # else it's not time-limited
+ push @ext, &{$escape_function}($discount_desc);
}
}
use base qw( FS::Record );
use strict;
+use FS::Msgcat qw( gettext );
=head1 NAME
sub notes {
my($self,$orderby_classnum) = (shift,shift);
- my $orderby = "_DATE DESC";
- $orderby = "CLASSNUM ASC, $orderby" if $orderby_classnum;
+ my $orderby = "sticky DESC, _date DESC";
+ $orderby = "classnum ASC, $orderby" if $orderby_classnum;
qsearch( 'cust_main_note',
{ 'custnum' => $self->custnum },
'',
|| $self->ut_numbern('_date')
|| $self->ut_textn('otaker')
|| $self->ut_anything('comments')
+ || $self->ut_numbern('sticky')
;
return $error if $error;
#not the most efficient, but hey, it only has to run once
- my $where = "WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) ".
- " AND usernum IS NULL ".
- " AND 0 < ( SELECT COUNT(*) FROM cust_main ".
- " WHERE cust_main.custnum = cust_pay.custnum ) ";
+ my $where = " WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' )
+ AND usernum IS NULL
+ AND EXISTS ( SELECT 1 FROM cust_main
+ WHERE cust_main.custnum = cust_pay.custnum )
+ ";
my $count_sql = "SELECT COUNT(*) FROM cust_pay $where";
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
- my $desc = $self->name ? $self->name.': ' : '';
+ my $desc;
+ if ( $self->name ) {
+ $desc = $self->name . ': ';
+ } else {
+ $desc = 'Discount of ';
+ }
$desc .= $money_char. sprintf('%.2f/month', $self->amount)
if $self->amount > 0;
}
+# stub this so that calling ->cust_bill doesn't return an empty string
+sub cust_bill {
+ return;
+}
+
=back
=head1 BUGS
<BR>
% }
-% if( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) {
- <TEXTAREA NAME="comment_plain" ROWS="12" COLS="60"><%
- join '', split /<br \/>| /, $comment
- %></TEXTAREA>
-% }
-% else {
-<% include('/elements/htmlarea.html', 'field' => 'comment_html',
- 'curr_value' => $comment) %>
+% if ( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) {
+ <TEXTAREA NAME="comment_plain" ROWS="12" COLS="60"><%
+ join '', split /<br \/>| /, $comment
+ %></TEXTAREA>
+% } else {
+ <& /elements/htmlarea.html, 'field' => 'comment_html',
+ 'curr_value' => $comment
+ &>
% }
-<BR><BR>
+<BR>
+
+<& /elements/checkbox.html, 'field' => 'sticky',
+ 'value' => 1,
+ 'curr_value' => $sticky,
+&>
+Sticky note<BR><BR>
+
<INPUT TYPE="submit" VALUE="<% $notenum ? emt("Apply changes") : emt("Add Note") %>">
</FORM>
my $comment;
my $notenum = '';
my $classnum;
+my $sticky = 0;
if ( $cgi->param('error') ) {
$comment = $cgi->param('comment');
$classnum = $cgi->param('classnum');
die "no such note: ". $notenum unless $note;
$comment = $note->comments;
$classnum = $note->classnum;
+ $sticky = $note->sticky;
}
$comment =~ s/\r//g; # remove weird line breaks to protect FCKeditor
'msg' => q|You must set the 'suspend_credit_type' option in Configuration->Settings to gain access to this option.|,
'are_met' => sub{
my $conf = new FS::conf;
- my @suspend_credit_type_conf = qsearch('conf', { 'name' => 'suspend_credit_type' } );
- return 1 if (exists($suspend_credit_type_conf[0]) && $suspend_credit_type_conf[0]->{Hash}{value});
+ my @conf_info = qsearch('conf', { 'name' => 'suspend_credit_type' } );
+ return 1 if (exists($conf_info[0]) && $conf_info[0]->{Hash}{value});
+ return 0;
+ }
+ },
+ 'unused_credit_cancel' => {
+ 'msg' => q|You must set the 'cancel_credit_type' option in Configuration->Settings to gain access to this option.|,
+ 'are_met' => sub{
+ my $conf = new FS::conf;
+ my @conf_info = qsearch('conf', { 'name' => 'cancel_credit_type' } );
+ return 1 if (exists($conf_info[0]) && $conf_info[0]->{Hash}{value});
return 0;
}
}
errorpage("There are only $num_avail available")
if $end - $start + 1 > $num_avail;
-foreach my $phonenum ( $start .. $end ) {
+foreach my $phonenum ( "$start" .. "$end" ) {
my $svc_phone = new FS::svc_phone {
'phonenum' => $phonenum,
_date => time,
usernum => $FS::CurrentUser::CurrentUser->usernum,
comments => $comment,
+ sticky => scalar( $cgi->param('sticky') ),
} );
my $error;
<% emt('Out of taxable region') %>
</TD>
<TD STYLE="text-align: right">
- <A HREF="<% $saleslink %>;out=1;taxname=<% $params{taxname} %>">
+ <A HREF="<% $saleslink %>;out=1;taxname=<% encode_entities($params{'taxname'}) %>">
<% $money_sprintf->( $report->{outside } ) %>
</A>
</TD>
$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";
}
% my $bgcolor1 = '#eeeeee';
% my $bgcolor2 = '#ffffff';
+% my %sticky_color = ( '#eeeeee' => '#ffff66',
+% '#ffffff' => '#ffffb8',
+% );
+%
% my $bgcolor = '';
% my $last_classnum = -1;
% my $skipheader = 0;
% ";notenum=$notenum",
% 'actionlabel' => emt('Edit customer note'),
% 'width' => 616,
-% 'height' => 538, #575
+% 'height' => 575,
% 'frame' => 'top',
% );
% my $clickjs = qq!onclick="$onclick"!;
% $last_classnum = $note->classnum;
% }
+% my $color = $note->sticky ? $sticky_color{$bgcolor} : $bgcolor;
+
<TR>
- <% note_datestr($note,$conf,$bgcolor) %>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% note_datestr($note,$conf,$color) %>
+ <TD CLASS="grid" BGCOLOR="<% $color %>">
<% $note->usernum ? $note->access_user->name : $note->otaker %>
</TD>
% if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <TD CLASS="grid" BGCOLOR="<% $color %>">
<% $note->classname %>
</TD>
% }
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <TD CLASS="grid" BGCOLOR="<% $color %>">
<% $note->comments | defang %>
</TD>
% if($edit) {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $edit %></TD>
+ <TD CLASS="grid" BGCOLOR="<% $color %>"><% $edit %></TD>
% }
</TR>
<DEL><% $link %><% $invoice %><% $link ? '</A>' : '' %></DEL>
-<I><% mt("voided [_1]", time2str($date_format, $cust_bill_void->void_date) ) |h %>
+<I><% mt("voided ([_1]) [_2]", $cust_bill_void->reason, time2str($date_format, $cust_bill_void->void_date) ) |h %>
% my $void_user = $cust_bill_void->void_access_user;
% if ($void_user) {
by <% $void_user->username %></I>
<DEL><% mt("Payment [_1] by [_2]", $info, $cust_pay_void->otaker ) |h %></DEL>
-<I><% mt("voided [_1]", time2str($date_format, $cust_pay_void->void_date) ) |h %>
+<I><% mt("voided ([_1]) [_2]", $cust_pay_void->reason, time2str($date_format, $cust_pay_void->void_date) ) |h %>
% my $void_user = $cust_pay_void->void_access_user;
% if ($void_user) {
by <% $void_user->username %></I>