diff options
Diffstat (limited to 'httemplate/edit/svc_domain.cgi')
-rwxr-xr-x | httemplate/edit/svc_domain.cgi | 132 |
1 files changed, 68 insertions, 64 deletions
diff --git a/httemplate/edit/svc_domain.cgi b/httemplate/edit/svc_domain.cgi index 60c67a005..56ba604bf 100755 --- a/httemplate/edit/svc_domain.cgi +++ b/httemplate/edit/svc_domain.cgi @@ -1,67 +1,3 @@ -%my($svcnum, $pkgnum, $svcpart, $kludge_action, $purpose, $part_svc, -% $svc_domain); -%if ( $cgi->param('error') ) { -% -% $svc_domain = new FS::svc_domain ( { -% map { $_, scalar($cgi->param($_)) } fields('svc_domain') -% } ); -% $svcnum = $svc_domain->svcnum; -% $pkgnum = $cgi->param('pkgnum'); -% $svcpart = $cgi->param('svcpart'); -% $kludge_action = $cgi->param('action'); -% $purpose = $cgi->param('purpose'); -% $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } ); -% die "No part_svc entry!" unless $part_svc; -% -%} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding -% -% $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum'; -% $pkgnum = $1; -% $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart'; -% $svcpart = $1; -% -% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); -% die "No part_svc entry!" unless $part_svc; -% -% $svc_domain = new FS::svc_domain({}); -% -% $svcnum=''; -% -% $svc_domain->set_default_and_fixed; -% -%} else { #editing -% -% $kludge_action = ''; -% $purpose = ''; -% my($query) = $cgi->keywords; -% $query =~ /^(\d+)$/ or die "unparsable svcnum"; -% $svcnum=$1; -% $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) -% or die "Unknown (svc_domain) svcnum!"; -% -% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) -% or die "Unknown (cust_svc) svcnum!"; -% -% $pkgnum=$cust_svc->pkgnum; -% $svcpart=$cust_svc->svcpart; -% -% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); -% die "No part_svc entry!" unless $part_svc; -% -%} -%my $action = $svcnum ? 'Edit' : 'Add'; -% -%my $svc = $part_svc->getfield('svc'); -% -%my $otaker = getotaker; -% -%my $domain = $svc_domain->domain; -% -%my $p1 = popurl(1); -% -% - - <% include('/elements/header.html', "$action $svc", '') %> <% include('/elements/error.html') %> @@ -85,3 +21,71 @@ </FORM> <% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +my($svcnum, $pkgnum, $svcpart, $kludge_action, $purpose, $part_svc, + $svc_domain); +if ( $cgi->param('error') ) { + + $svc_domain = new FS::svc_domain ( { + map { $_, scalar($cgi->param($_)) } fields('svc_domain') + } ); + $svcnum = $svc_domain->svcnum; + $pkgnum = $cgi->param('pkgnum'); + $svcpart = $cgi->param('svcpart'); + $kludge_action = $cgi->param('action'); + $purpose = $cgi->param('purpose'); + $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } ); + die "No part_svc entry!" unless $part_svc; + +} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding + + $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum'; + $pkgnum = $1; + $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart'; + $svcpart = $1; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + + $svc_domain = new FS::svc_domain({}); + + $svcnum=''; + + $svc_domain->set_default_and_fixed; + +} else { #editing + + $kludge_action = ''; + $purpose = ''; + my($query) = $cgi->keywords; + $query =~ /^(\d+)$/ or die "unparsable svcnum"; + $svcnum=$1; + $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) + or die "Unknown (svc_domain) svcnum!"; + + my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) + or die "Unknown (cust_svc) svcnum!"; + + $pkgnum=$cust_svc->pkgnum; + $svcpart=$cust_svc->svcpart; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + +} +my $action = $svcnum ? 'Edit' : 'Add'; + +my $svc = $part_svc->getfield('svc'); + +my $otaker = getotaker; + +my $domain = $svc_domain->domain; + +my $p1 = popurl(1); + +</%init> |