contacts can be shared among customers / "duplicate contact emails", RT#27943
[freeside.git] / httemplate / view / prospect_main.html
1 <& /elements/header.html, 'Prospect View: '. $prospect_main->company &>
2
3 % if ( $curuser->access_right('Edit prospect') ) { 
4   <A HREF="<% $p %>edit/prospect_main.html?<% $prospectnum %>">Edit this prospect</A>
5 % } 
6
7 <% ntable("#cccccc",2) %>
8
9 <TR>
10   <TD ALIGN="right">Prospect #</TD>
11   <TD BGCOLOR="#FFFFFF"><B><% $prospectnum %></B>
12 %   if ( $prospect_main->disabled ) {
13       <B>(DISABLED)</B>
14 %   }
15   </TD>
16 </TR>
17
18 %unless ( scalar(@agentnums) == 1
19 %         && !$curuser->access_right('View customers of all agents') ) {
20 %  my $agent = qsearchs('agent',{ 'agentnum' => $prospect_main->agentnum } );
21    <TR>
22      <TD ALIGN="right">Agent</TD>
23      <TD BGCOLOR="#ffffff"><% $agent->agentnum %>: <% $agent->agent |h %></TD>
24    </TR>
25 %}
26
27 %unless ( ! $prospect_main->refnum ) { # || scalar(@part_referral) == 1 ) {
28 %  my $part_referral = qsearchs('part_referral',{ 'refnum' => $prospect_main->refnum } );
29    <TR>
30      <TD ALIGN="right">Advertising source</TD>
31      <TD BGCOLOR="#ffffff"><% $part_referral->referral |h %></TD>
32    </TR>
33 %}
34
35 % if ( $prospect_main->company ) { 
36   <TR>
37     <TD ALIGN="right">Company</TD>
38     <TD BGCOLOR="#FFFFFF"><B><% $prospect_main->company |h %></B></TD>
39   </TR>
40 % }
41
42 % foreach my $prospect_contact ( $prospect_main->prospect_contact ) {
43 %   my $contact = $prospect_contact->contact;
44     <TR>
45       <TD ALIGN="right"><% $prospect_contact->contact_classname %> Contact</TD>
46       <TD BGCOLOR="#FFFFFF"><% $contact->line %></TD>
47     </TR>
48 %}
49
50 % my @cust_location =
51 %   qsearch('cust_location', { 'prospectnum' => $prospectnum } );
52 % #but only one, for now
53 % foreach my $cust_location (@cust_location) {
54     <TR>
55       <TD ALIGN="right">Address</TD>
56       <TD BGCOLOR="#FFFFFF">
57         <% $cust_location->location_label(
58              'join_string'     => '<BR>',
59              'double_space'    => ' &nbsp; ',
60              'escape_function' => \&encode_entities,
61            )
62         %>
63       </TD>
64     </TR>
65 %   if ( $cust_location->latitude && $cust_location->longitude ) {
66       <& /elements/tr-coords.html, $cust_location->latitude,
67                                    $cust_location->longitude,
68                                    $prospect_main->name,
69       &>
70 %   }
71 % }
72
73 </TABLE>
74
75 <BR>
76
77 <& /elements/quotations.html, prospect_main=>$prospect_main &>
78
79 % if ( $curuser->access_right('Qualify service') ) { 
80 <% include( '/elements/popup_link-prospect_main.html',
81               'action'        => $p. 'misc/qual.html',
82               'label'         => 'New&nbsp;Qualification',
83               'actionlabel'   => 'New Qualification',
84               'color'         => '#333399',
85               'prospect_main' => $prospect_main,
86               'closetext'     => 'Close',
87               'width'         => 763,
88               'height'        => 436,
89           )
90 %>
91   | <A HREF="<%$p%>search/qual.cgi?prospectnum=<% $prospect_main->prospectnum %>">View Qualifications</A>
92     <BR><BR>
93 % }
94
95 <!--
96 <% ntable("#cccccc") %>
97
98 <TR>
99   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Tickets</FONT></TH>
100 </TR>
101
102 </TABLE>
103 -->
104
105 <%init>
106
107 my $curuser = $FS::CurrentUser::CurrentUser;
108
109 die "access denied"
110   unless $curuser->access_right('View prospect');
111
112 my $prospectnum;
113 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
114   $prospectnum = $1;
115 } else {
116   die "No prospect specified (bad URL)!" unless $cgi->keywords;
117   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
118   $query =~ /^(\d+)$/;
119   $prospectnum = $1;
120 }
121
122 my $prospect_main = qsearchs( {
123   'table'     => 'prospect_main',
124   'hashref'   => { 'prospectnum' => $prospectnum },
125   'extra_sql' => ' AND '. $curuser->agentnums_sql,
126 });
127 die "Prospect not found!" unless $prospect_main;
128
129 my @agentnums = $curuser->agentnums;
130
131 </%init>