projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
729eaf2
)
add pkg_svc.primary_svc flag to enable an explicit first package flag
author
ivan
<ivan>
Sat, 31 Jan 2004 06:33:40 +0000
(06:33 +0000)
committer
ivan
<ivan>
Sat, 31 Jan 2004 06:33:40 +0000
(06:33 +0000)
FS/FS/part_pkg.pm
patch
|
blob
|
history
FS/FS/pkg_svc.pm
patch
|
blob
|
history
FS/bin/freeside-setup
patch
|
blob
|
history
htetc/global.asa
patch
|
blob
|
history
htetc/handler.pl
patch
|
blob
|
history
httemplate/browse/part_pkg.cgi
patch
|
blob
|
history
httemplate/docs/schema.html
patch
|
blob
|
history
httemplate/docs/upgrade-1.4.2.html
patch
|
blob
|
history
httemplate/docs/upgrade10.html
patch
|
blob
|
history
httemplate/edit/part_pkg.cgi
patch
|
blob
|
history
httemplate/edit/process/part_pkg.cgi
patch
|
blob
|
history
diff --git
a/FS/FS/part_pkg.pm
b/FS/FS/part_pkg.pm
index
695d48c
..
dcce66b
100644
(file)
--- a/
FS/FS/part_pkg.pm
+++ b/
FS/FS/part_pkg.pm
@@
-2,7
+2,7
@@
package FS::part_pkg;
use strict;
use vars qw( @ISA );
use strict;
use vars qw( @ISA );
-use FS::Record qw( qsearch dbh );
+use FS::Record qw( qsearch dbh
dbdef
);
use FS::pkg_svc;
use FS::agent_type;
use FS::type_pkgs;
use FS::pkg_svc;
use FS::agent_type;
use FS::type_pkgs;
@@
-267,20
+267,24
@@
sub pkg_svc {
=item svcpart [ SVCDB ]
=item svcpart [ SVCDB ]
-Returns the svcpart of
a single
service definition (see L<FS::part_svc>)
+Returns the svcpart of
the primary
service definition (see L<FS::part_svc>)
associated with this billing item definition (see L<FS::pkg_svc>). Returns
associated with this billing item definition (see L<FS::pkg_svc>). Returns
-false if there not exactly one service definition with quantity 1, or if
-SVCDB is specified and does not match the svcdb of the service definition,
+false if there not a primary service definition or exactly one service
+definition with quantity 1, or if SVCDB is specified and does not match the
+svcdb of the service definition,
=cut
sub svcpart {
my $self = shift;
my $svcdb = scalar(@_) ? shift : '';
=cut
sub svcpart {
my $self = shift;
my $svcdb = scalar(@_) ? shift : '';
- my @pkg_svc = grep {
- $_->quantity == 1
- && ( $svcdb eq $_->part_svc->svcdb || !$svcdb )
- } $self->pkg_svc;
+ my @svcdb_pkg_svc =
+ grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
+ my @pkg_svc = ();
+ @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
+ if dbdef->table('pkg_svc')->column('primary_svc');
+ @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
+ unless @pkg_svc;
return '' if scalar(@pkg_svc) != 1;
$pkg_svc[0]->svcpart;
}
return '' if scalar(@pkg_svc) != 1;
$pkg_svc[0]->svcpart;
}
diff --git
a/FS/FS/pkg_svc.pm
b/FS/FS/pkg_svc.pm
index
2ac1a55
..
ea52176
100644
(file)
--- a/
FS/FS/pkg_svc.pm
+++ b/
FS/FS/pkg_svc.pm
@@
-46,6
+46,8
@@
FS::Record. The following fields are currently supported:
=item quantity - Quantity of this service definition that this billing item
definition includes
=item quantity - Quantity of this service definition that this billing item
definition includes
+=item primary_svc - primary flag, empty or 'Y'
+
=back
=head1 METHODS
=back
=head1 METHODS
@@
-108,6
+110,11
@@
sub check {
return "Unknown pkgpart!" unless $self->part_pkg;
return "Unknown svcpart!" unless $self->part_svc;
return "Unknown pkgpart!" unless $self->part_pkg;
return "Unknown svcpart!" unless $self->part_svc;
+ if ( $self->dbdef_table->column('primary_svc') ) {
+ $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
+ return $error if $error;
+ }
+
$self->SUPER::check;
}
$self->SUPER::check;
}
@@
-135,10
+142,6
@@
sub part_svc {
=back
=back
-=head1 VERSION
-
-$Id: pkg_svc.pm,v 1.4 2003-08-05 00:20:45 khoff Exp $
-
=head1 BUGS
=head1 SEE ALSO
=head1 BUGS
=head1 SEE ALSO
diff --git
a/FS/bin/freeside-setup
b/FS/bin/freeside-setup
index
b7a414a
..
72780e3
100755
(executable)
--- a/
FS/bin/freeside-setup
+++ b/
FS/bin/freeside-setup
@@
-708,6
+708,7
@@
sub tables_hash_hack {
'pkgpart', 'int', '', '',
'svcpart', 'int', '', '',
'quantity', 'int', '', '',
'pkgpart', 'int', '', '',
'svcpart', 'int', '', '',
'quantity', 'int', '', '',
+ 'primary_svc','char', 'NULL', 1,
],
'primary_key' => '',
'unique' => [ ['pkgpart', 'svcpart'] ],
],
'primary_key' => '',
'unique' => [ ['pkgpart', 'svcpart'] ],
diff --git
a/htetc/global.asa
b/htetc/global.asa
index
f550560
..
e05701d
100644
(file)
--- a/
htetc/global.asa
+++ b/
htetc/global.asa
@@
-15,7
+15,7
@@
use IO::Handle;
use IO::File;
use String::Approx qw(amatch);
use Chart::LinesPoints;
use IO::File;
use String::Approx qw(amatch);
use Chart::LinesPoints;
-use HTML::Widgets::SelectLayers 0.0
2
;
+use HTML::Widgets::SelectLayers 0.0
3
;
use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name);
use FS::Record qw(qsearch qsearchs fields dbdef);
use FS::Conf;
use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name);
use FS::Record qw(qsearch qsearchs fields dbdef);
use FS::Conf;
diff --git
a/htetc/handler.pl
b/htetc/handler.pl
index
c5f685f
..
584d930
100644
(file)
--- a/
htetc/handler.pl
+++ b/
htetc/handler.pl
@@
-73,7
+73,7
@@
sub handler
use IO::File;
use String::Approx qw(amatch);
use Chart::LinesPoints;
use IO::File;
use String::Approx qw(amatch);
use Chart::LinesPoints;
- use HTML::Widgets::SelectLayers 0.0
2
;
+ use HTML::Widgets::SelectLayers 0.0
3
;
use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name);
use FS::Record qw(qsearch qsearchs fields dbdef);
use FS::Conf;
use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name);
use FS::Record qw(qsearch qsearchs fields dbdef);
use FS::Conf;
diff --git
a/httemplate/browse/part_pkg.cgi
b/httemplate/browse/part_pkg.cgi
index
efaa59e
..
180f182
100755
(executable)
--- a/
httemplate/browse/part_pkg.cgi
+++ b/
httemplate/browse/part_pkg.cgi
@@
-78,8
+78,10
@@
print <<END;
<TH><FONT SIZE=-1>Data</FONT></TH>
<TH>Service</TH>
<TH><FONT SIZE=-1>Quan.</FONT></TH>
<TH><FONT SIZE=-1>Data</FONT></TH>
<TH>Service</TH>
<TH><FONT SIZE=-1>Quan.</FONT></TH>
- </TR>
END
END
+print '<TH><FONT SIZE=-1>Primary</FONT></TH>'
+ if dbdef->table('pkg_svc')->column('primary_svc');
+print '</TR>';
foreach my $part_pkg ( sort $sortby @part_pkg ) {
my($hashref)=$part_pkg->hashref;
foreach my $part_pkg ( sort $sortby @part_pkg ) {
my($hashref)=$part_pkg->hashref;
@@
-143,7
+145,13
@@
END
my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart });
print $n,qq!<TD><A HREF="${p}edit/part_svc.cgi?$svcpart">!,
$part_svc->getfield('svc'),"</A></TD><TD>",
my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart });
print $n,qq!<TD><A HREF="${p}edit/part_svc.cgi?$svcpart">!,
$part_svc->getfield('svc'),"</A></TD><TD>",
- $pkg_svc->getfield('quantity'),"</TD></TR>\n";
+ $pkg_svc->getfield('quantity'),"</TD>";
+ if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
+ print '<TD>';
+ print 'PRIMARY' if $pkg_svc->primary_svc =~ /^Y/i;
+ print '</TD>';
+ }
+ print "</TR>\n";
$n="<TR>";
}
$n="<TR>";
}
diff --git
a/httemplate/docs/schema.html
b/httemplate/docs/schema.html
index
06be896
..
40b211c
100644
(file)
--- a/
httemplate/docs/schema.html
+++ b/
httemplate/docs/schema.html
@@
-283,6
+283,7
@@
<li>pkgpart - <a href="#part_pkg">Package definition</a>
<li>svcpart - <a href="#part_svc">Service definition</a>
<li>quantity - quantity of this service that this package includes
<li>pkgpart - <a href="#part_pkg">Package definition</a>
<li>svcpart - <a href="#part_svc">Service definition</a>
<li>quantity - quantity of this service that this package includes
+ <li>primary_svc - blank or Y: primary service
</ul>
<li><a name="export_svc" href="man/FS/export_svc.html">export_svc</a>
<ul>
</ul>
<li><a name="export_svc" href="man/FS/export_svc.html">export_svc</a>
<ul>
diff --git
a/httemplate/docs/upgrade-1.4.2.html
b/httemplate/docs/upgrade-1.4.2.html
index
0229167
..
ea6ebe9
100644
(file)
--- a/
httemplate/docs/upgrade-1.4.2.html
+++ b/
httemplate/docs/upgrade-1.4.2.html
@@
-8,6
+8,7
@@
<li>Back up your data and current Freeside installation.
<li>Install <a href="http://search.cpan.org/search?dist=Locale-SubCountry">Locale::SubCountry</a>
<li>Install <a href="http://search.cpan.org/search?dist=IPC-ShareLite">IPC::ShareLite</a>
<li>Back up your data and current Freeside installation.
<li>Install <a href="http://search.cpan.org/search?dist=Locale-SubCountry">Locale::SubCountry</a>
<li>Install <a href="http://search.cpan.org/search?dist=IPC-ShareLite">IPC::ShareLite</a>
+ <li>Install <a href="http://search.cpan.org/search?dist=HTML-Widgets-SelectLayers">HTML::Widgets::SelectLayers</a> 0.03.
<li>CGI.pm minimum version 2.47 is required. You will probably need to install a current CGI.pm from CPAN if you are using Perl 5.005 or earlier.
<li>Run <code>make aspdocs</code> or <code>make masondocs</code>.
<li>Copy <code>aspdocs/</code> or <code>masondocs/</code> to your web server's document space.
<li>CGI.pm minimum version 2.47 is required. You will probably need to install a current CGI.pm from CPAN if you are using Perl 5.005 or earlier.
<li>Run <code>make aspdocs</code> or <code>make masondocs</code>.
<li>Copy <code>aspdocs/</code> or <code>masondocs/</code> to your web server's document space.
diff --git
a/httemplate/docs/upgrade10.html
b/httemplate/docs/upgrade10.html
index
9dc4f3d
..
e984073
100644
(file)
--- a/
httemplate/docs/upgrade10.html
+++ b/
httemplate/docs/upgrade10.html
@@
-154,6
+154,8
@@
ALTER TABLE h_cust_main ADD paycvv varchar(4) NULL;
ALTER TABLE part_referral ADD disabled char(1) NULL;
ALTER TABLE h_part_referral ADD disabled char(1) NULL;
CREATE INDEX part_referral1 ON part_referral ( disabled );
ALTER TABLE part_referral ADD disabled char(1) NULL;
ALTER TABLE h_part_referral ADD disabled char(1) NULL;
CREATE INDEX part_referral1 ON part_referral ( disabled );
+ALTER TABLE pkg_svc ADD primary_svc char(1) NULL;
+ALTER TABLE h_pkg_svc ADD primary_svc char(1) NULL;
dump database, edit:
- cust_main: increase otaker from 8 to 32
dump database, edit:
- cust_main: increase otaker from 8 to 32
diff --git
a/httemplate/edit/part_pkg.cgi
b/httemplate/edit/part_pkg.cgi
index
f2f99b7
..
8416b35
100755
(executable)
--- a/
httemplate/edit/part_pkg.cgi
+++ b/
httemplate/edit/part_pkg.cgi
@@
-152,9
+152,11
@@
print ' CHECKED' if $hashref->{disabled} eq "Y";
print '>';
print '</TD></TR></TABLE>';
print '>';
print '</TD></TR></TABLE>';
-my $thead = "\n\n". ntable('#cccccc', 2). <<END;
-<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH><TH BGCOLOR="#dcdcdc">Service</TH></TR>
-END
+my $thead = "\n\n". ntable('#cccccc', 2).
+ '<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>';
+$thead .= '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Primary</FONT></TH>'
+ if dbdef->table('pkg_svc')->column('primary_svc');
+$thead .= '<TH BGCOLOR="#dcdcdc">Service</TH></TR>';
#unless ( $cgi->param('clone') ) {
#dunno why...
#unless ( $cgi->param('clone') ) {
#dunno why...
@@
-176,9
+178,10
@@
foreach my $part_svc ( @part_svc ) {
'pkgpart' => $pkgpart,
'svcpart' => $svcpart,
} ) || new FS::pkg_svc ( {
'pkgpart' => $pkgpart,
'svcpart' => $svcpart,
} ) || new FS::pkg_svc ( {
- 'pkgpart' => $pkgpart,
- 'svcpart' => $svcpart,
- 'quantity' => 0,
+ 'pkgpart' => $pkgpart,
+ 'svcpart' => $svcpart,
+ 'quantity' => 0,
+ 'primary_svc' => '',
});
#? #next unless $pkg_svc;
});
#? #next unless $pkg_svc;
@@
-190,7
+193,13
@@
foreach my $part_svc ( @part_svc ) {
print '<TR>'; # if $count == 0 ;
print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=4 MAXLENGTH=3 VALUE="!,
$cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0,
print '<TR>'; # if $count == 0 ;
print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=4 MAXLENGTH=3 VALUE="!,
$cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0,
- qq!"></TD><TD><A HREF="part_svc.cgi?!,$part_svc->svcpart,
+ qq!"></TD>!;
+ if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
+ print qq!<TD><INPUT TYPE="radio" NAME="pkg_svc_primary" VALUE="$svcpart"!;
+ print ' CHECKED' if $pkg_svc->primary_svc =~ /^Y/i;
+ print '></TD>';
+ }
+ print qq!<TD><A HREF="part_svc.cgi?!,$part_svc->svcpart,
qq!">!, $part_svc->getfield('svc'), "</A></TD></TR>";
# print "</TABLE></TD><TD>$thead" if ++$count == int(scalar(@part_svc) / 2);
$count+=1;
qq!">!, $part_svc->getfield('svc'), "</A></TD></TR>";
# print "</TABLE></TD><TD>$thead" if ++$count == int(scalar(@part_svc) / 2);
$count+=1;
@@
-518,6
+527,10
@@
if ( $conf->exists('enable_taxclasses') ) {
push @fixups, 'taxclass'; #hidden
}
push @fixups, 'taxclass'; #hidden
}
+my @form_radio = ();
+if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
+ push @form_radio, 'pkg_svc_primary';
+}
my $widget = new HTML::Widgets::SelectLayers(
'selected_layer' => $part_pkg->plan,
my $widget = new HTML::Widgets::SelectLayers(
'selected_layer' => $part_pkg->plan,
@@
-526,7
+539,8
@@
my $widget = new HTML::Widgets::SelectLayers(
'form_action' => 'process/part_pkg.cgi',
'form_text' => [ qw(pkg comment freq clone pkgnum pkgpart), @fixups ],
'form_checkbox' => [ qw(setuptax recurtax disabled) ],
'form_action' => 'process/part_pkg.cgi',
'form_text' => [ qw(pkg comment freq clone pkgnum pkgpart), @fixups ],
'form_checkbox' => [ qw(setuptax recurtax disabled) ],
- 'form_select' => [ @form_select ],
+ 'form_radio' => \@form_radio,
+ 'form_select' => \@form_select,
'fixup_callback' => sub {
#my $ = @_;
my $html = '';
'fixup_callback' => sub {
#my $ = @_;
my $html = '';
diff --git
a/httemplate/edit/process/part_pkg.cgi
b/httemplate/edit/process/part_pkg.cgi
index
d489426
..
7eada7b
100755
(executable)
--- a/
httemplate/edit/process/part_pkg.cgi
+++ b/
httemplate/edit/process/part_pkg.cgi
@@
-62,16
+62,24
@@
if ( $error ) {
foreach my $part_svc (qsearch('part_svc',{})) {
my $quantity = $cgi->param('pkg_svc'. $part_svc->svcpart) || 0;
foreach my $part_svc (qsearch('part_svc',{})) {
my $quantity = $cgi->param('pkg_svc'. $part_svc->svcpart) || 0;
+ my $primary_svc =
+ $cgi->param('pkg_svc_primary') == $part_svc->svcpart ? 'Y' : '';
my $old_pkg_svc = qsearchs('pkg_svc', {
'pkgpart' => $pkgpart,
'svcpart' => $part_svc->svcpart,
} );
my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
my $old_pkg_svc = qsearchs('pkg_svc', {
'pkgpart' => $pkgpart,
'svcpart' => $part_svc->svcpart,
} );
my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
- next unless $old_quantity != $quantity; #!here
+ 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;
+
my $new_pkg_svc = new FS::pkg_svc( {
my $new_pkg_svc = new FS::pkg_svc( {
- 'pkgpart' => $pkgpart,
- 'svcpart' => $part_svc->svcpart,
- 'quantity' => $quantity,
+ 'pkgpart' => $pkgpart,
+ 'svcpart' => $part_svc->svcpart,
+ 'quantity' => $quantity,
+ 'primary_svc' => $primary_svc,
} );
if ( $old_pkg_svc ) {
my $myerror = $new_pkg_svc->replace($old_pkg_svc);
} );
if ( $old_pkg_svc ) {
my $myerror = $new_pkg_svc->replace($old_pkg_svc);