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