1 <% include('/elements/header.html', "Web Hosting $action") %>
3 <% include('/elements/error.html') %>
5 <FORM ACTION="<%$p1%>process/svc_www.cgi" METHOD=POST>
7 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
8 Service #<B><% $svcnum ? $svcnum : "(NEW)" %></B>
11 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
13 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
15 % my $recnum = $svc_www->recnum;
16 % my $usersvc = $svc_www->usersvc;
18 <% &ntable("#cccccc",2) %>
21 <TD ALIGN="right">Zone</TD>
23 <SELECT NAME="recnum" SIZE=1>
24 % foreach $_ (keys %arec) {
25 <OPTION<% $_ eq $recnum ? " SELECTED" : "" %> VALUE="<%$_%>"><%$arec{$_}%>
31 % if ( $part_svc->part_svc_column('usersvc')->columnflag ne 'F'
32 % || $part_svc->part_svc_column('usersvc')->columnvalue !~ /^\s*$/) {
34 <TD ALIGN="right">Username</TD>
36 <SELECT NAME="usersvc" SIZE=1>
37 <OPTION VALUE="">(none)
38 % foreach $_ (keys %svc_acct) {
39 <OPTION<% ($_ eq $usersvc) ? " SELECTED" : "" %> VALUE="<%$_%>"><% $svc_acct{$_} %>
46 % if ( $part_svc->part_svc_column('config')->columnflag ne 'F' &&
47 % $FS::CurrentUser::CurrentUser->access_right('Edit www config') ) {
49 <TD ALIGN="right">Config lines</TD>
51 <TEXTAREA NAME="config" rows="15" cols="80"><% $config |h %></TEXTAREA>
55 <INPUT TYPE="hidden" NAME="config" VALUE="<% $config |h %>">
58 % foreach my $field ($svc_www->virtual_fields) {
59 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
60 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
61 <% $svc_www->pvf($field)->widget( 'HTML', 'edit',
62 $svc_www->getfield($field)
71 <INPUT TYPE="submit" VALUE="Submit">
75 <% include('/elements/footer.html') %>
80 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
82 my $conf = new FS::Conf;
84 my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_www, $config );
86 if ( $cgi->param('error') ) {
88 $svc_www = new FS::svc_www ( {
89 map { $_, scalar($cgi->param($_)) } fields('svc_www')
91 $svcnum = $svc_www->svcnum;
92 $pkgnum = $cgi->param('pkgnum');
93 $svcpart = $cgi->param('svcpart');
94 $config = $cgi->param('config');
95 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
96 die "No part_svc entry!" unless $part_svc;
98 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
100 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
102 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
105 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
106 die "No part_svc entry!" unless $part_svc;
108 $svc_www = new FS::svc_www { svcpart => $svcpart };
112 $svc_www->set_default_and_fixed;
116 my($query) = $cgi->keywords;
117 $query =~ /^(\d+)$/ or die "unparsable svcnum";
119 $svc_www=qsearchs('svc_www',{'svcnum'=>$svcnum})
120 or die "Unknown (svc_www) svcnum!";
122 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
123 or die "Unknown (cust_svc) svcnum!";
125 $pkgnum = $cust_svc->pkgnum;
126 $svcpart = $cust_svc->svcpart;
127 $config = $svc_www->config;
129 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
130 die "No part_svc entry!" unless $part_svc;
133 my $action = $svc_www->svcnum ? 'Edit' : 'Add';
135 my( %svc_acct, %arec );
139 foreach my $svcpart (
140 map { $_->svcpart } qsearch( 'part_svc', { 'svcdb' => 'svc_acct' } )
142 next if $conf->exists('svc_www-usersvc_svcpart')
143 && ! grep { $svcpart == $_ }
144 $conf->config('svc_www-usersvc_svcpart');
145 push @u_acct_svcparts, $svcpart;
148 my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
149 my($custnum)=$cust_pkg->getfield('custnum');
151 foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) {
152 my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum');
154 foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding
155 #record(s) in cust_svc ( for this
158 foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) {
159 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')});
160 $svc_acct{$svc_acct->getfield('svcnum')}=
161 $svc_acct->cust_svc->part_svc->svc. ': '. $svc_acct->email;
167 my($d_part_svc,@d_acct_svcparts);
168 foreach $d_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_domain'}) ) {
169 push @d_acct_svcparts,$d_part_svc->getfield('svcpart');
172 foreach $i_cust_pkg ( qsearch( 'cust_pkg', { 'custnum' => $custnum } ) ) {
173 my $cust_pkgnum = $i_cust_pkg->pkgnum;
175 foreach my $acct_svcpart (@d_acct_svcparts) {
177 foreach my $i_cust_svc (
178 qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum,
179 'svcpart' => $acct_svcpart } )
182 qsearchs( 'svc_domain', { 'svcnum' => $i_cust_svc->svcnum } );
184 my $extra_sql = "AND ( rectype = 'A' OR rectype = 'CNAME' )";
185 unless ( $conf->exists('svc_www-enable_subdomains') ) {
186 $extra_sql .= " AND ( reczone = '\@' OR reczone = '".
187 $svc_domain->domain. ".' )";
190 foreach my $domain_rec (
191 qsearch( 'domain_record',
193 'svcnum' => $svc_domain->svcnum,
199 $arec{$domain_rec->recnum} = $domain_rec->zone;
202 if ( $conf->exists('svc_www-enable_subdomains') ) {
203 $arec{'www.'. $svc_domain->domain} = 'www.'. $svc_domain->domain
204 unless qsearchs( 'domain_record', {
205 svcnum => $svc_domain->svcnum,
208 || qsearchs( 'domain_record', {
209 svcnum => $svc_domain->svcnum,
210 reczone => 'www.'.$svc_domain->domain.'.',
214 $arec{'@.'. $svc_domain->domain} = $svc_domain->domain
215 unless qsearchs('domain_record', {
216 svcnum => $svc_domain->svcnum,
219 || qsearchs('domain_record', {
220 svcnum => $svc_domain->svcnum,
221 reczone => $svc_domain->domain.'.',
229 } elsif ( $action eq 'Edit' ) {
231 my($domain_rec) = qsearchs('domain_record', { 'recnum'=>$svc_www->recnum });
232 $arec{$svc_www->recnum} = join '.', $domain_rec->recdata, $domain_rec->reczone;
235 die "\$action eq Add, but \$pkgnum is null!\n";