% include('/elements/header.html',
             'Prospect View: '. $prospect_main->company
          )
%>
% if ( $curuser->access_right('Edit prospect') ) { 
  Edit this prospect
% } 
<% ntable("#cccccc",2) %>
  | Prospect # | 
  <% $prospectnum %> | 
%unless ( scalar(@agentnums) == 1
%         && !$curuser->access_right('View customers of all agents') ) {
%  my $agent = qsearchs('agent',{ 'agentnum' => $prospect_main->agentnum } );
   
     | Agent | 
     <% $agent->agentnum %>: <% $agent->agent %> | 
   
%}
% if ( $prospect_main->company ) { 
  
    | Company | 
    <% $prospect_main->company |h %> | 
  
% }
% foreach my $contact ( $prospect_main->contact ) {
    
      | Contact | 
      <% $contact->line %> | 
    
%}
% my @cust_location =
%   qsearch('cust_location', { 'prospectnum' => $prospectnum } );
% #but only one, for now
% foreach my $cust_location (@cust_location) {
    
      | Address | 
      
        <% $cust_location->location_label(
             'join_string'     => ' ',
             'double_space'    => '   ',
             'escape_function' => \&encode_entities,
           )
        %>
       | 
    
%   if ( $cust_location->latitude && $cust_location->longitude ) {
      <& /elements/tr-coords.html, $cust_location->latitude,
                                   $cust_location->longitude,
                                   $prospect_main->name,
      &>
%   }
% }
% if ( $curuser->access_right('Qualify service') ) { 
<% include( '/elements/popup_link-prospect_main.html',
              'action'        => $p. 'misc/qual.html',
              'label'         => 'New Qualification',
              'actionlabel'   => 'New Qualification',
              'color'         => '#333399',
              'prospect_main' => $prospect_main,
              'closetext'     => 'Close',
              'width'         => 763,
              'height'        => 436,
          )
%>
  | View Qualifications
    
% }
<% ntable("#cccccc") %>
  | Tickets | 
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
  unless $curuser->access_right('View prospect');
my $prospectnum;
if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
  $prospectnum = $1;
} else {
  die "No prospect specified (bad URL)!" unless $cgi->keywords;
  my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
  $query =~ /^(\d+)$/;
  $prospectnum = $1;
}
my $prospect_main = qsearchs( {
  'table'     => 'prospect_main',
  'hashref'   => { 'prospectnum' => $prospectnum },
  'extra_sql' => ' AND '. $curuser->agentnums_sql,
});
die "Prospect not found!" unless $prospect_main;
my @agentnums = $curuser->agentnums;
%init>