fix javascript confirmation for domain records with " in them...
[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 %   ( my $recdata = $domain_record->recdata ) =~ s/"/\\'\\'/g;
55       (<A HREF="javascript:areyousure('<%$p%>misc/delete-domain_record.cgi?<%$domain_record->recnum%>', 'Delete \'<% $domain_record->reczone %> <% $type %> <% $recdata %>\' ?' )">delete</A>)
56 % } 
57       </td>
58     </tr>
59
60
61 %   if ( $bgcolor eq $bgcolor1 ) {
62 %      $bgcolor = $bgcolor2;
63 %    } else {
64 %      $bgcolor = $bgcolor1;
65 %    }
66
67 % } 
68
69   </table>
70 % } 
71
72
73 <BR>
74 <FORM METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
75 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
76 <INPUT TYPE="text" NAME="reczone"> 
77 <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> IN 
78  <SELECT NAME="rectype">
79 % foreach (qw( A NS CNAME MX PTR TXT) ) { 
80
81   <OPTION VALUE="<%$_%>"><%$_%></OPTION>
82 % } 
83
84  </SELECT>
85 <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Add record">
86 </FORM><BR><BR>or<BR><BR>
87 <FORM NAME="SlaveForm" METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
88 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
89 % if ( @records ) { 
90  Delete all records and 
91 % } 
92
93 Slave from nameserver IP 
94 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
95 <INPUT TYPE="hidden" NAME="reczone" VALUE="@"> 
96 <INPUT TYPE="hidden" NAME="recaf" VALUE="IN">
97 <INPUT TYPE="hidden" NAME="rectype" VALUE="_mstr">
98 <INPUT TYPE="text" NAME="recdata"> <INPUT TYPE="submit" VALUE="Slave domain" onClick="return slave_areyousure()">
99 </FORM>
100 <BR><BR><% joblisting({'svcnum'=>$svcnum}, 1) %>
101
102 <% include('/elements/footer.html') %>
103 <%init>
104
105 die "access denied"
106   unless $FS::CurrentUser::CurrentUser->access_right('View customer services')
107       || $FS::CurrentUser::CurrentUser->access_right('View customer'); #XXX remove me
108
109 my($query) = $cgi->keywords;
110 $query =~ /^(\d+)$/;
111 my $svcnum = $1;
112 my $svc_domain = qsearchs({
113   'select'    => 'svc_domain.*',
114   'table'     => 'svc_domain',
115   'addl_from' => ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
116                  ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
117                  ' LEFT JOIN cust_main USING ( custnum ) ',
118   'hashref'   => {'svcnum'=>$svcnum},
119   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
120 });
121 die "Unknown svcnum" unless $svc_domain;
122
123 my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
124 my $pkgnum = $cust_svc->getfield('pkgnum');
125 my($cust_pkg, $custnum);
126 if ($pkgnum) {
127   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
128   $custnum=$cust_pkg->getfield('custnum');
129 } else {
130   $cust_pkg = '';
131   $custnum = '';
132 }
133
134 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
135 die "Unknown svcpart" unless $part_svc;
136
137 my $email = '';
138 if ($svc_domain->catchall) {
139   my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } );
140   die "Unknown svcpart" unless $svc_acct;
141   $email = $svc_acct->email;
142 }
143
144 my $domain = $svc_domain->domain;
145
146 </%init>