diff options
author | ivan <ivan> | 2002-02-09 17:45:26 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-02-09 17:45:26 +0000 |
commit | 4c18a45810f000bb013d23d4738cfca012794c4b (patch) | |
tree | 84e8d9b4245795193672dd858eda6949d61246fd | |
parent | 5bb9eff0716710611f50071bec6167b4514edb48 (diff) |
have FS::cust_svc::check look up & check pkg_svc.quantity
like httemplate/view/cust_pkg.cgi (closes: Bug#43)
-rw-r--r-- | FS/FS/cust_svc.pm | 27 | ||||
-rwxr-xr-x | httemplate/misc/process/link.cgi | 9 |
2 files changed, 25 insertions, 11 deletions
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 541f0c801..a81e3bb32 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -7,6 +7,7 @@ use FS::Record qw( qsearchs dbh ); use FS::cust_pkg; use FS::part_pkg; use FS::part_svc; +use FS::pkg_svc; use FS::svc_acct; use FS::svc_acct_sm; use FS::svc_domain; @@ -111,12 +112,24 @@ sub check { ; return $error if $error; - return "Unknown pkgnum" - unless ! $self->pkgnum - || qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } ); - - return "Unknown svcpart" unless - qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } ); + my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } ); + return "Unknown svcpart" unless $part_svc; + + if ( $self->pkgnum ) { + my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } ); + return "Unknown pkgnum" unless $cust_pkg; + my $pkg_svc = qsearchs( 'pkg_svc', { + 'pkgpart' => $cust_pkg->pkgpart, + 'svcpart' => $self->svcpart, + }); + my @cust_svc = qsearch('cust_svc', { + 'pkgnum' => $self->pkgnum, + 'svcpart' => $self->svcpart, + }); + return "Already ". scalar(@cust_svc). " ". $part_svc->svc. + " services for pkgnum ". $self->pkgnum + if $pkg_svc->quantity >= scalar(@cust_svc); + } ''; #no error } @@ -232,7 +245,7 @@ sub seconds_since { =head1 VERSION -$Id: cust_svc.pm,v 1.9 2002-01-29 16:33:15 ivan Exp $ +$Id: cust_svc.pm,v 1.10 2002-02-09 17:45:26 ivan Exp $ =head1 BUGS diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 80a5de81f..f8b7812e1 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -1,4 +1,4 @@ -<!-- $Id: link.cgi,v 1.3 2002-01-30 14:18:09 ivan Exp $ --> +<!-- $Id: link.cgi,v 1.4 2002-02-09 17:45:26 ivan Exp $ --> <% $cgi->param('pkgnum') =~ /^(\d+)$/; @@ -12,13 +12,14 @@ unless ( $svcnum ) { my($part_svc) = qsearchs('part_svc',{'svcpart'=>$svcpart}); my($svcdb) = $part_svc->getfield('svcdb'); $cgi->param('link_field') =~ /^(\w+)$/; my($link_field)=$1; - my($svc_acct)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); - eidiot("$link_field not found!") unless $svc_acct; - $svcnum=$svc_acct->svcnum; + my($svc_x)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); + eidiot("$link_field not found!") unless $svc_x; + $svcnum=$svc_x->svcnum; } my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "svcnum not found!" unless $old; +#die "svcnum $svcnum already linked to package ". $old->pkgnum if $old->pkgnum; my $new = new FS::cust_svc ({ 'svcnum' => $svcnum, 'pkgnum' => $pkgnum, |