Will things ever be the same again?
[freeside.git] / httemplate / misc / link.cgi
index fee02dd..1d1f5e1 100755 (executable)
@@ -1,89 +1,84 @@
-<%
-#
-# $Id: link.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $
-#
-# ivan@voicenet.com 97-feb-5
-#
-# rewrite ivan@sisd.com 98-mar-17
-#
-# can also link on some other fields now (about time) ivan@sisd.com 98-jun-24
-#
-# $Log: link.cgi,v $
-# Revision 1.1  2001-07-30 07:36:04  ivan
-# templates!!!
-#
-# Revision 1.7  1999/04/08 11:31:40  ivan
-# *** empty log message ***
-#
-# Revision 1.6  1999/02/28 00:03:51  ivan
-# removed misleading comments
-#
-# Revision 1.5  1999/01/19 05:14:06  ivan
-# for mod_perl: no more top-level my() variables; use vars instead
-# also the last s/create/new/;
-#
-# Revision 1.4  1999/01/18 09:41:36  ivan
-# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
-# (good idea anyway)
-#
-# Revision 1.3  1998/12/23 03:03:39  ivan
-# $cgi->keywords instead of $cgi->query_string
-#
-# Revision 1.2  1998/12/17 09:12:45  ivan
-# s/CGI::(Request|Base)/CGI.pm/;
-#
+<!-- mason kludge -->
+%
+%
+%my %link_field = (
+%  'svc_acct'    => 'username',
+%  'svc_domain'  => 'domain',
+%);
+%
+%my %link_field2 = (
+%  'svc_acct'    => { label => 'Domain',
+%                     field => 'domsvc',
+%                     type  => 'select',
+%                     select_table => 'svc_domain',
+%                     select_key   => 'svcnum',
+%                     select_label => 'domain'
+%                   },
+%);
+%
+%my($query) = $cgi->keywords;
+%my($pkgnum, $svcpart) = ('', '');
+%foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart
+%  $pkgnum=$1 if /^pkgnum(\d+)$/;
+%  $svcpart=$1 if /^svcpart(\d+)$/;
+%}
+%
+%my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart});
+%my $svc = $part_svc->getfield('svc');
+%my $svcdb = $part_svc->getfield('svcdb');
+%my $link_field = $link_field{$svcdb};
+%my $link_field2 = $link_field2{$svcdb};
+%
+%
 
-use strict;
-use vars qw ( %link_field $cgi $pkgnum $svcpart $query $part_svc $svc $svcdb 
-              $link_field );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
-use FS::CGI qw(popurl header);
-use FS::Record qw(qsearchs);
 
-%link_field = (
-  'svc_acct'    => 'username',
-  'svc_domain'  => 'domain',
-  'svc_acct_sm' => '',
-  'svc_charge'  => '',
-  'svc_wo'      => '',
-);
+<% include("/elements/header.html","Link to existing $svc") %>
+<FORM ACTION="<% popurl(1) %>process/link.cgi" METHOD=POST>
+% if ( $link_field ) { 
 
-$cgi = new CGI;
-cgisuidsetup($cgi);
+  <INPUT TYPE="hidden" NAME="svcnum" VALUE="">
+  <INPUT TYPE="hidden" NAME="link_field" VALUE="<% $link_field %>">
+  <% $link_field %> of existing service: <INPUT TYPE="text" NAME="link_value">
+  <BR>
+% if ( $link_field2 ) { 
 
-($query) = $cgi->keywords;
-foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart
-  $pkgnum=$1 if /^pkgnum(\d+)$/;
-  $svcpart=$1 if /^svcpart(\d+)$/;
-}
+    <INPUT TYPE="hidden" NAME="link_field2" VALUE="<% $link_field2->{field} %>">
+    <% $link_field2->{'label'} %> of existing service: 
+% if ( $link_field2->{'type'} eq 'select' ) { 
+% if ( $link_field2->{'select_table'} ) { 
 
-$part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart});
-$svc = $part_svc->getfield('svc');
-$svcdb = $part_svc->getfield('svcdb');
-$link_field = $link_field{$svcdb};
+        <SELECT NAME="link_value2">
+        <OPTION> </OPTION>
+% foreach my $r ( qsearch( $link_field2->{'select_table'}, {})) { 
+% my $key = $link_field2->{'select_key'}; 
+% my $label = $link_field2->{'select_label'}; 
 
-print $cgi->header( '-expires' => 'now' ), header("Link to existing $svc"),
-      qq!<FORM ACTION="!, popurl(1), qq!process/link.cgi" METHOD=POST>!;
+          <OPTION VALUE="<% $r->$key() %>"><% $r->$label() %></OPTION>
+% } 
 
-if ( $link_field ) { 
-  print <<END;
-  <INPUT TYPE="hidden" NAME="svcnum" VALUE="">
-  <INPUT TYPE="hidden" NAME="link_field" VALUE="$link_field">
-  $link_field of existing service: <INPUT TYPE="text" NAME="link_value">
-END
-} else {
-  print qq!Service # of existing service: <INPUT TYPE="text" NAME="svcnum" VALUE="">!;
-}
+        </SELECT>
+% } else { 
+
+        Don't know how to process secondary link field for <% $svcdb %>
+        (type=>select but no select_table)
+% } 
+% } else { 
+
+      Don't know how to process secondary link field for <% $svcdb %>
+        (unknown type <% $link_field2->{'type'} %>)
+% } 
 
-print <<END;
-<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
-<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
-<P><CENTER><INPUT TYPE="submit" VALUE="Link"></CENTER>
+    <BR>
+% } 
+% } else { 
+
+  Service # of existing service: <INPUT TYPE="text" NAME="svcnum" VALUE="">
+% } 
+
+
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+<BR><INPUT TYPE="submit" VALUE="Link">
     </FORM>
   </BODY>
 </HTML>
-END
-
-%>