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