custom_link interpolation, #14895
[freeside.git] / httemplate / misc / custom_link_proxy.cgi
1 % if( $response->is_success ) {
2 <% $response->decoded_content %>
3 % }
4 % else {
5 <% $response->error_as_HTML %>
6 % }
7 <%init>
8
9 my( $custnum ) = $cgi->param('custnum');
10 my $cust_main = qsearchs('cust_main', { custnum => $custnum } ) 
11   or die "custnum '$custnum' not found"; # just check for existence
12
13 my $conf = new FS::Conf;
14 my $url = $conf->config('cust_main-custom_link');
15
16 my $agentnum = $cust_main->agentnum;
17 # like eval(qq("$url")) but with fewer things that can go wrong
18 # and if $custnum isn't mentioned, assume it goes at the end
19 $url =~ s/\$custnum/$custnum/ or $url .= $custnum;
20 $url =~ s/\$agentnum/$agentnum/;
21
22 #warn $url;
23
24 my $curuser = $FS::CurrentUser::CurrentUser;
25
26 die "access denied"
27   unless $curuser->access_right('View customer');
28
29 my $ua = new LWP::UserAgent;
30 my $response = $ua->get($url);
31 </%init>