summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm4
-rw-r--r--FS/FS/cust_pkg.pm28
-rw-r--r--FS/FS/part_pkg.pm43
-rw-r--r--FS/FS/pkg_svc.pm3
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi8
-rw-r--r--httemplate/elements/tr-pkg_svc.html9
7 files changed, 67 insertions, 29 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index f63bae9..95c1ce4 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1601,6 +1601,7 @@ sub tables_hashref {
'svcpart', 'int', '', '', '', '',
'quantity', 'int', '', '', '', '',
'primary_svc','char', 'NULL', 1, '', '',
+ 'hidden', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'pkgsvcnum',
'unique' => [ ['pkgpart', 'svcpart'] ],
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 335c4b6..b3dd48a 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -4102,7 +4102,7 @@ sub _items_cust_bill_pkg {
{
push @d, map &{$escape_function}($_),
- $cust_pkg->h_labels_short($self->_date)
+ $cust_pkg->h_labels_short($self->_date, undef, 'I')
unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
if ( $multilocation ) {
@@ -4164,7 +4164,7 @@ sub _items_cust_bill_pkg {
{
push @d, map &{$escape_function}($_),
- $cust_pkg->h_labels_short(@dates)
+ $cust_pkg->h_labels_short(@dates, 'I')
#$cust_bill_pkg->edate,
#$cust_bill_pkg->sdate)
unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index ce5ee11..e0fb589 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1638,23 +1638,32 @@ sub overlimit {
grep { $_->overlimit } $self->cust_svc(@_);
}
-=item h_cust_svc END_TIMESTAMP [ START_TIMESTAMP ]
+=item h_cust_svc END_TIMESTAMP [ START_TIMESTAMP ] [ MODE ]
Returns historical services for this package created before END TIMESTAMP and
(optionally) not cancelled before START_TIMESTAMP, as FS::h_cust_svc objects
-(see L<FS::h_cust_svc>).
+(see L<FS::h_cust_svc>). If MODE is 'I' (for 'invoice'), services with the
+I<pkg_svc.hidden> flag will be omitted.
=cut
sub h_cust_svc {
my $self = shift;
+ my ($end, $start, $mode) = @_;
+ my %search = (
+ 'table' => 'h_cust_svc',
+ 'hashref' => { 'pkgnum' => $self->pkgnum }
+ );
+ @search{'select', 'extra_sql', 'cache_obj', 'addl_from'} =
+ FS::h_cust_svc->sql_h_search($end, $start);
+ if ( $mode eq 'I' ) {
+ $search{'addl_from'} .= ' JOIN cust_pkg USING (pkgnum)
+ JOIN pkg_svc USING (pkgpart, svcpart)';
+ $search{'extra_sql'} = ' AND pkg_svc.hidden IS NULL '.$search{'extra_sql'};
+ }
$self->_sort_cust_svc(
- [ qsearch( 'h_cust_svc',
- { 'pkgnum' => $self->pkgnum, },
- FS::h_cust_svc->sql_h_search(@_),
- )
- ]
+ [ qsearch(\%search) ]
);
}
@@ -1973,11 +1982,12 @@ sub labels {
map { [ $_->label ] } $self->cust_svc;
}
-=item h_labels END_TIMESTAMP [ START_TIMESTAMP ]
+=item h_labels END_TIMESTAMP [ START_TIMESTAMP ] [ MODE ]
Like the labels method, but returns historical information on services that
were active as of END_TIMESTAMP and (optionally) not cancelled before
-START_TIMESTAMP.
+START_TIMESTAMP. If MODE is 'I' (for 'invoice'), services with the
+I<pkg_svc.hidden> flag will be omitted.
Returns a list of lists, calling the label method for all (historical) services
(see L<FS::h_cust_svc>) of this billing item.
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index a073cf2..98bb74c 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -144,7 +144,9 @@ Currently available options are: I<pkg_svc>, I<primary_svc>, I<cust_pkg>,
I<custnum_ref> and I<options>.
If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
-values, appropriate FS::pkg_svc records will be inserted.
+values, appropriate FS::pkg_svc records will be inserted. I<hidden_svc> can
+be set to a hashref of svcparts and flag values ('Y' or '') to set the
+'hidden' field in these records.
If I<primary_svc> is set to the svcpart of the primary service, the appropriate
FS::pkg_svc record will be updated.
@@ -230,6 +232,7 @@ sub insert {
warn " inserting pkg_svc records" if $DEBUG;
my $pkg_svc = $options{'pkg_svc'} || {};
+ my $hidden_svc = $options{'hidden_svc'} || {};
foreach my $part_svc ( qsearch('part_svc', {} ) ) {
my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
my $primary_svc =
@@ -242,6 +245,7 @@ sub insert {
'svcpart' => $part_svc->svcpart,
'quantity' => $quantity,
'primary_svc' => $primary_svc,
+ 'hidden' => $hidden_svc->{$part_svc->svcpart},
} );
my $error = $pkg_svc->insert;
if ( $error ) {
@@ -293,10 +297,13 @@ sub delete {
Replaces OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
-Currently available options are: I<pkg_svc>, I<primary_svc> and I<options>
+Currently available options are: I<pkg_svc>, I<hidden_svc>, I<primary_svc>
+and I<options>
If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
-values, the appropriate FS::pkg_svc records will be replaced.
+values, the appropriate FS::pkg_svc records will be replaced. I<hidden_svc>
+can be set to a hashref of svcparts and flag values ('Y' or '') to set the
+'hidden' field in these records.
If I<primary_svc> is set to the svcpart of the primary service, the appropriate
FS::pkg_svc record will be updated.
@@ -379,8 +386,10 @@ sub replace {
warn " replacing pkg_svc records" if $DEBUG;
my $pkg_svc = $options->{'pkg_svc'} || {};
+ my $hidden_svc = $options->{'hidden_svc'} || {};
foreach my $part_svc ( qsearch('part_svc', {} ) ) {
my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
+ my $hidden = $hidden_svc->{$part_svc->svcpart} || '';
my $primary_svc =
( defined($options->{'primary_svc'}) && $options->{'primary_svc'}
&& $options->{'primary_svc'} == $part_svc->svcpart
@@ -388,17 +397,24 @@ sub replace {
? 'Y'
: '';
-
my $old_pkg_svc = qsearchs('pkg_svc', {
- 'pkgpart' => $old->pkgpart,
- 'svcpart' => $part_svc->svcpart,
- } );
- my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
- my $old_primary_svc =
- ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
- ? $old_pkg_svc->primary_svc
- : '';
- next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
+ 'pkgpart' => $old->pkgpart,
+ 'svcpart' => $part_svc->svcpart,
+ }
+ );
+ my $old_quantity = 0;
+ my $old_primary_svc = '';
+ my $old_hidden = '';
+ if ( $old_pkg_svc ) {
+ $old_quantity = $old_pkg_svc->quantity;
+ $old_primary_svc = $old_pkg_svc->primary_svc
+ if $old_pkg_svc->dbdef_table->column('primary_svc'); # is this needed?
+ $old_hidden = $old_pkg_svc->hidden;
+ }
+
+ next unless $old_quantity != $quantity ||
+ $old_primary_svc ne $primary_svc ||
+ $old_hidden ne $hidden;
my $new_pkg_svc = new FS::pkg_svc( {
'pkgsvcnum' => ( $old_pkg_svc ? $old_pkg_svc->pkgsvcnum : '' ),
@@ -406,6 +422,7 @@ sub replace {
'svcpart' => $part_svc->svcpart,
'quantity' => $quantity,
'primary_svc' => $primary_svc,
+ 'hidden' => $hidden,
} );
my $error = $old_pkg_svc
? $new_pkg_svc->replace($old_pkg_svc)
diff --git a/FS/FS/pkg_svc.pm b/FS/FS/pkg_svc.pm
index 9f3a4a1..f79bb5e 100644
--- a/FS/FS/pkg_svc.pm
+++ b/FS/FS/pkg_svc.pm
@@ -50,6 +50,8 @@ definition includes
=item primary_svc - primary flag, empty or 'Y'
+=item hidden - 'Y' to hide this service on invoices, null otherwise.
+
=back
=head1 METHODS
@@ -109,6 +111,7 @@ sub check {
|| $self->ut_number('pkgpart')
|| $self->ut_number('svcpart')
|| $self->ut_number('quantity')
+ || $self->ut_enum('hidden', [ '', 'Y' ] )
;
return $error if $error;
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index 97ae4e7..7248801 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -117,11 +117,11 @@ my $args_callback = sub {
#pkg_svc
###
- my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) }
- map { $_->svcpart }
- qsearch('part_svc', {} );
+ my @svcparts = map { $_->svcpart } qsearch('part_svc', {});
+ my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } @svcparts;
+ my %hidden_svc = map { $_ => scalar($cgi->param("hidden$_")) } @svcparts;
- push @args, 'pkg_svc' => \%pkg_svc;
+ push @args, 'pkg_svc' => \%pkg_svc, 'hidden_svc' => \%hidden_svc;
###
# cust_pkg and custnum_ref (inserts only)
diff --git a/httemplate/elements/tr-pkg_svc.html b/httemplate/elements/tr-pkg_svc.html
index e68ed4a..66bbddf 100644
--- a/httemplate/elements/tr-pkg_svc.html
+++ b/httemplate/elements/tr-pkg_svc.html
@@ -12,6 +12,7 @@
% 'svcpart' => $svcpart,
% 'quantity' => 0,
% 'primary_svc' => '',
+% 'hidden' => '',
% } );
% if ( $cgi->param('error') ) {
% my $primary_svc = ( $pkg_svc->primary_svc =~ /^Y/i );
@@ -43,6 +44,10 @@
<TD>
<A HREF="part_svc.cgi?<% $part_svc->svcpart %>"><% $part_svc->svc %></A> <% $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %>
</TD>
+
+ <TD>
+ <INPUT TYPE="checkbox" NAME="hidden<% $svcpart %>" VALUE="Y"<% $pkg_svc->hidden =~ /^Y/i ? ' CHECKED' : ''%>>
+ </TD>
</TR>
% foreach ( 1 .. $columns-1 ) {
% if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) {
@@ -68,7 +73,9 @@ my $cgi = $opt{'cgi'};
my $thead = "\n\n". ntable('#cccccc', 2).
'<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>'.
'<TH BGCOLOR="#dcdcdc"><FONT SIZE=-2>Primary</FONT></TH>'.
- '<TH BGCOLOR="#dcdcdc">Service</TH></TR>';
+ '<TH BGCOLOR="#dcdcdc">Service</TH>'.
+ '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Hide</FONT></TH>'.
+ '</TR>';
my $part_pkg = $opt{'object'};
my $pkgpart = $part_pkg->pkgpart;