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