quotations, RT#16996
[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         <TR>
82           <TD CLASS="grid" BGCOLOR="#cccccc"><% $quotation->quotationnum %></TD>
83           <TD CLASS="grid" BGCOLOR="#cccccc"><% time2str($date_format, $quotation->_date) |h %></TD>
84         </TR>
85 %     }
86     </TABLE>
87 % }
88     <BR><BR>
89 % }
90
91
92 % if ( $curuser->access_right('Qualify service') ) { 
93 <% include( '/elements/popup_link-prospect_main.html',
94               'action'        => $p. 'misc/qual.html',
95               'label'         => 'New&nbsp;Qualification',
96               'actionlabel'   => 'New Qualification',
97               'color'         => '#333399',
98               'prospect_main' => $prospect_main,
99               'closetext'     => 'Close',
100               'width'         => 763,
101               'height'        => 436,
102           )
103 %>
104   | <A HREF="<%$p%>search/qual.cgi?prospectnum=<% $prospect_main->prospectnum %>">View Qualifications</A>
105     <BR><BR>
106 % }
107
108 <!--
109 <% ntable("#cccccc") %>
110
111 <TR>
112   <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Tickets</FONT></TH>
113 </TR>
114
115 </TABLE>
116 -->
117
118 <%init>
119
120 my $curuser = $FS::CurrentUser::CurrentUser;
121
122 die "access denied"
123   unless $curuser->access_right('View prospect');
124
125 my $conf = new FS::Conf;
126
127 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
128
129 my $prospectnum;
130 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
131   $prospectnum = $1;
132 } else {
133   die "No prospect specified (bad URL)!" unless $cgi->keywords;
134   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
135   $query =~ /^(\d+)$/;
136   $prospectnum = $1;
137 }
138
139 my $prospect_main = qsearchs( {
140   'table'     => 'prospect_main',
141   'hashref'   => { 'prospectnum' => $prospectnum },
142   'extra_sql' => ' AND '. $curuser->agentnums_sql,
143 });
144 die "Prospect not found!" unless $prospect_main;
145
146 my @agentnums = $curuser->agentnums;
147
148 </%init>