Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / elements / quotations.html
1 % if ( $curuser->access_right('Generate quotation') ) { 
2
3   <FONT CLASS="fsinnerbox-title"><% mt( 'Quotations' ) |h %></FONT>
4   <A HREF="<%$p%>edit/quotation.html?<% $new_query %>">Create new quotation</A>
5
6 % if ( @quotations ) {
7     <& /elements/table-grid.html &>
8 %     my $bgcolor1 = '#eeeeee';
9 %     my $bgcolor2 = '#ffffff';
10 %     my $bgcolor = '';
11       <THEAD>
12       <TR>
13         <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
14         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Setup') |h %></TH>
15         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Recurring') |h %></TH>
16         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
17         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Description') |h %></TH>
18         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Close date') |h %></TH>
19         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Confidence') |h %></TH>
20         <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
21       </TR>
22       </THEAD>
23 %     foreach my $quotation (@quotations) {
24 %       if ( $bgcolor eq $bgcolor1 ) {
25 %         $bgcolor = $bgcolor2;
26 %       } else {
27 %         $bgcolor = $bgcolor1;
28 %       }
29 %       my $a = qq(<A HREF="$p/view/quotation.html?quotationnum=). #"
30 %               $quotation->quotationnum. '">';
31         <TR>
32           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->quotationnum %></A></TD>
33           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN=right><% $a %><% $money_char.$quotation->total_setup |h %></A></TD>
34           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN=right><% $a %><% $money_char.$quotation->total_recur |h %></A></TD>
35           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% time2str('%b %d %Y', $quotation->_date) |h %></A></TD>
36           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->quotation_description |h %></A></TD>
37           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->close_date ? time2str('%b %d %Y', $quotation->close_date) : '' |h %></A></TD>
38           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN=right><% $a %><% length($quotation->confidence) ? $quotation->confidence . '%' : '' |h %></A></TD>
39           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>"><% $opt{convert_label} || 'Convert to customer' %></A></TD>
40         </TR>
41 %     }
42     </TABLE>
43 % }
44     <BR><BR>
45
46 % }
47 <%init>
48
49 my $curuser = $FS::CurrentUser::CurrentUser;
50
51 #die "access denied"
52 #  unless $curuser->access_right('Generate quotation');
53
54 my $conf = new FS::Conf;
55
56 my $money_char = $conf->config('money_char') || '$';
57
58 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
59
60 my %opt = @_;
61
62 my $new_query;
63 my @quotations;
64 if ( $opt{cust_main} ) {
65   $new_query = 'custnum='. $opt{cust_main}->custnum;
66   @quotations = $opt{cust_main}->quotation;
67 } elsif ( $opt{prospect_main} ) {
68   $new_query = 'prospectnum='. $opt{prospect_main}->prospectnum;
69   @quotations = $opt{prospect_main}->quotation;
70 } else {
71   die 'guru meditation #&&: neither cust_main nor prospect_main specified';
72 }
73
74 @quotations = grep ! $_->disabled, @quotations;
75
76 </%init>