customer view tab for an external info page, RT#8903
authormark <mark>
Tue, 3 Aug 2010 03:30:20 +0000 (03:30 +0000)
committermark <mark>
Tue, 3 Aug 2010 03:30:20 +0000 (03:30 +0000)
FS/FS/Conf.pm
FS/FS/Mason.pm
httemplate/misc/custom_link_proxy.cgi [new file with mode: 0644]
httemplate/view/cust_main.cgi
httemplate/view/cust_main/custom.html [new file with mode: 0644]

index ce8bd29..fdb6e9a 100644 (file)
@@ -3891,6 +3891,19 @@ and customer address. Include units.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cust_main-custom_link',
+    'section'     => 'UI',
+    'description' => 'URL to use as source for the "Custom" tab in the View Customer page.  The custnum will be appended.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cust_main-custom_title',
+    'section'     => 'UI',
+    'description' => 'Title for the "Custom" tab in the View Customer page.',
+    'type'        => 'text',
+  },
 
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index 0f14150..bcf727e 100644 (file)
@@ -111,6 +111,7 @@ if ( -e $addl_handler_use_file ) {
                                         #selectlayers.html
   use Locale::Country;
   use Business::US::USPS::WebTools::AddressStandardization;
+  use LWP::UserAgent;
   use FS;
   use FS::UID qw( getotaker dbh datasrc driver_name );
   use FS::Record qw( qsearch qsearchs fields dbdef
diff --git a/httemplate/misc/custom_link_proxy.cgi b/httemplate/misc/custom_link_proxy.cgi
new file mode 100644 (file)
index 0000000..e5934e4
--- /dev/null
@@ -0,0 +1,24 @@
+% if( $response->is_success ) {
+<% $response->decoded_content %>
+% }
+% else {
+<% $response->error_as_HTML %>
+% }
+<%init>
+
+my( $custnum ) = $cgi->param('custnum');
+my $cust_main = qsearchs('cust_main', { custnum => $custnum } ) 
+  or die "custnum '$custnum' not found"; # just check for existence
+
+my $conf = new FS::Conf;
+my $url = $conf->config('cust_main-custom_link') . $cust_main->custnum;
+#warn $url;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied"
+  unless $curuser->access_right('View customer');
+
+my $ua = new LWP::UserAgent;
+my $response = $ua->get($url);
+</%init>
index f6bef43..0b6148d 100755 (executable)
@@ -233,6 +233,10 @@ Comments
 <% include('cust_main/change_history.html', $cust_main ) %>     
 % }
 
+% if ( $view eq 'custom' ) { 
+<% include('cust_main/custom.html', $cust_main ) %>
+% }
+
 </DIV>
 <% include('/elements/footer.html') %>
 <%init>
@@ -273,6 +277,8 @@ $views{'Payment History'} =  'payment_history'
                                unless $conf->config('payby-default' eq 'HIDE');
 $views{'Change History'}  =  'change_history'
   if $curuser->access_right('View customer history');
+$views{$conf->config('cust_main-custom_title') || 'Custom'} =  'custom'
+  if $conf->config('cust_main-custom_link');
 $views{'Jumbo'}           =  'jumbo';
 
 my %viewname = reverse %views;
diff --git a/httemplate/view/cust_main/custom.html b/httemplate/view/cust_main/custom.html
new file mode 100644 (file)
index 0000000..8e2e07b
--- /dev/null
@@ -0,0 +1,21 @@
+<IFRAME id="customframe" 
+        src="<% $proxyurl %>" 
+        onload="resizeFrame(this)"
+        frameborder=0
+        marginheight="0px"
+        marginwidth="0px"
+        width="100%"
+        scrolling="no"
+>
+</IFRAME>
+<SCRIPT TYPE="text/javascript">
+function resizeFrame(f) {
+  f.style.height = f.contentDocument.body.scrollHeight + 'px';
+}
+</SCRIPT>
+<%init>
+
+my( $cust_main ) = @_;
+
+my $proxyurl = $p.'/misc/custom_link_proxy.cgi?custnum='.$cust_main->custnum;
+</%init>