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