summaryrefslogtreecommitdiff
path: root/httemplate/view/prospect_main.html
blob: f4b2f58ee55031eadb76223dfd2d3e0c079cbc3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<% include('/elements/header.html',
             'Prospect View: '. $prospect_main->company
          )
%>

% if ( $curuser->access_right('Edit prospect') ) { 
  <A HREF="<% $p %>edit/prospect_main.html?<% $prospectnum %>">Edit this prospect</A>
% } 

<% ntable("#cccccc",2) %>

<TR>
  <TD ALIGN="right">Prospect #</TD>
  <TD BGCOLOR="#FFFFFF"><B><% $prospectnum %></B></TD>
</TR>

%unless ( scalar(@agentnums) == 1
%         && !$curuser->access_right('View customers of all agents') ) {
%  my $agent = qsearchs('agent',{ 'agentnum' => $prospect_main->agentnum } );
   <TR>
     <TD ALIGN="right">Agent</TD>
     <TD BGCOLOR="#ffffff"><% $agent->agentnum %>: <% $agent->agent %></TD>
   </TR>
%}

<TR>
  <TD ALIGN="right">Company</TD>
  <TD BGCOLOR="#FFFFFF"><B><% $prospect_main->company |h %></B></TD>
</TR>

% foreach my $contact ( $prospect_main->contact ) {
    <TR>
      <TD ALIGN="right">Contact</TD>
      <TD BGCOLOR="#FFFFFF"><% $contact->line %></TD>
    </TR>
%}

% my @cust_location =
%   qsearch('cust_location', { 'prospectnum' => $prospectnum } );
% #but only one, for now
% foreach my $cust_location (@cust_location) {
    <TR>
      <TD ALIGN="right">Address</TD>
      <TD BGCOLOR="#FFFFFF">
        <% $cust_location->location_label(
             'join_string'     => '<BR>',
             'double_space'    => ' &nbsp; ',
             'escape_function' => \&encode_entities,
           )
        %>
      </TD>
  </TR>
% }

</TABLE>

<BR>

% if ( $curuser->access_right('Qualify service') ) { 
<% include( '/elements/popup_link-prospect_main.html',
              'action'      => $p. 'misc/qual.html',
              'label'       => 'New&nbsp;Qualification',
              'actionlabel' => 'New Qualification',
              'color'       => '#333399',
              'prospect_main'   => $prospect_main,
              'closetext'   => 'Close',
              'width'       => 763,
              'height'      => 436,
          )
%>
  | <A HREF="<%$p%>search/qual.cgi?prospectnum=<% $prospect_main->prospectnum %>">View Qualifications</A>
    <BR><BR>
% }

<% ntable("#cccccc") %>

<TR>
  <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Tickets</FONT></TH>
</TR>

</TABLE>

<%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>