C is for Cookie^WControl
[freeside.git] / httemplate / view / svc_domain.cgi
1 <% include("/elements/header.html",'Domain View', menubar(
2   ( ( $pkgnum || $custnum )
3     ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
4       )
5     : ( "Delete this (unaudited) domain" =>
6           "javascript:areyousure('${p}misc/cancel-unaudited.cgi?$svcnum', 'Delete $domain and all records?' )" )
7   ),
8   "Main menu" => $p,
9 )) %>
10
11 Service #<% $svcnum %>
12 <BR>Service: <B><% $part_svc->svc %></B>
13 <BR>Domain name: <B><% $domain %></B>
14 <BR>Catch all email <A HREF="<% ${p} %>misc/catchall.cgi?<% $svcnum %>">(change)</A>:
15 <% $email ? "<B>$email</B>" : "<I>(none)<I>" %>
16 <BR><BR><A HREF="<% ${p} %>misc/whois.cgi?custnum=<%$custnum%>;svcnum=<%$svcnum%>;domain=<%$domain%>">View whois information.</A>
17 <BR><BR>
18 <SCRIPT>
19   function areyousure(href, message) {
20     if ( confirm(message) == true )
21       window.location.href = href;
22   }
23   function slave_areyousure() {
24     return confirm("Remove all records and slave from " + document.SlaveForm.recdata.value + "?");
25   }
26 </SCRIPT>
27
28 % my @records; if ( @records = $svc_domain->domain_record ) { 
29
30   <% include('/elements/table-grid.html') %>
31
32 % my $bgcolor1 = '#eeeeee';
33 %     my $bgcolor2 = '#ffffff';
34 %     my $bgcolor = $bgcolor2;
35
36   <tr>
37     <th CLASS="grid" BGCOLOR="#cccccc">Zone</th>
38     <th CLASS="grid" BGCOLOR="#cccccc">Type</th>
39     <th CLASS="grid" BGCOLOR="#cccccc">Data</th>
40   </tr>
41
42 % foreach my $domain_record ( @records ) {
43 %       my $type = $domain_record->rectype eq '_mstr'
44 %                    ? "(slave)"
45 %                    : $domain_record->recaf. ' '. $domain_record->rectype;
46
47
48     <tr>
49       <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->reczone %></td>
50       <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $type %></td>
51       <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->recdata %>
52
53 % unless ( $domain_record->rectype eq 'SOA' ) { 
54       (<A HREF="javascript:areyousure('<%$p%>misc/delete-domain_record.cgi?<%$domain_record->recnum%>', 'Delete \'<% $domain_record->reczone %> <% $type %> <% $domain_record->recdata %>\' ?' )">delete</A>)
55 % } 
56       </td>
57     </tr>
58
59
60 %   if ( $bgcolor eq $bgcolor1 ) {
61 %      $bgcolor = $bgcolor2;
62 %    } else {
63 %      $bgcolor = $bgcolor1;
64 %    }
65
66 % } 
67
68   </table>
69 % } 
70
71
72 <BR>
73 <FORM METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
74 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
75 <INPUT TYPE="text" NAME="reczone"> 
76 <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> IN 
77  <SELECT NAME="rectype">
78 % foreach (qw( A NS CNAME MX PTR TXT) ) { 
79
80   <OPTION VALUE="<%$_%>"><%$_%></OPTION>
81 % } 
82
83  </SELECT>
84 <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Add record">
85 </FORM><BR><BR>or<BR><BR>
86 <FORM NAME="SlaveForm" METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
87 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
88 % if ( @records ) { 
89  Delete all records and 
90 % } 
91
92 Slave from nameserver IP 
93 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
94 <INPUT TYPE="hidden" NAME="reczone" VALUE="@"> 
95 <INPUT TYPE="hidden" NAME="recaf" VALUE="IN">
96 <INPUT TYPE="hidden" NAME="rectype" VALUE="_mstr">
97 <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Slave domain" onClick="return slave_areyousure()">
98 </FORM>
99 <BR><BR><% joblisting({'svcnum'=>$svcnum}, 1) %>
100
101 <% include('/elements/footer.html') %>
102 <%init>
103
104 die "access denied"
105   unless $FS::CurrentUser::CurrentUser->access_right('View customer services')
106       || $FS::CurrentUser::CurrentUser->access_right('View customer'); #XXX remove me
107
108 my($query) = $cgi->keywords;
109 $query =~ /^(\d+)$/;
110 my $svcnum = $1;
111 my $svc_domain = qsearchs({
112   'select'    => 'svc_domain.*',
113   'table'     => 'svc_domain',
114   'addl_from' => ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
115                  ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
116                  ' LEFT JOIN cust_main USING ( custnum ) ',
117   'hashref'   => {'svcnum'=>$svcnum},
118   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
119 });
120 die "Unknown svcnum" unless $svc_domain;
121
122 my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
123 my $pkgnum = $cust_svc->getfield('pkgnum');
124 my($cust_pkg, $custnum);
125 if ($pkgnum) {
126   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
127   $custnum=$cust_pkg->getfield('custnum');
128 } else {
129   $cust_pkg = '';
130   $custnum = '';
131 }
132
133 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
134 die "Unknown svcpart" unless $part_svc;
135
136 my $email = '';
137 if ($svc_domain->catchall) {
138   my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } );
139   die "Unknown svcpart" unless $svc_acct;
140   $email = $svc_acct->email;
141 }
142
143 my $domain = $svc_domain->domain;
144
145 </%init>