1d80a48ea8416431792e7128754b484be1e27417
[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 %>">New quotation</A>
5
6 % if ( @quotations ) {
7     <& /elements/table-grid.html &>
8 %     my $bgcolor1 = '#eeeeee';
9 %     my $bgcolor2 = '#ffffff';
10 %     my $bgcolor = '';
11       <TR>
12         <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
13         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></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"></TH>
17       </TR>
18 %     foreach my $quotation (@quotations) {
19 %       if ( $bgcolor eq $bgcolor1 ) {
20 %         $bgcolor = $bgcolor2;
21 %       } else {
22 %         $bgcolor = $bgcolor1;
23 %       }
24 %       my $a = qq(<A HREF="$p/view/quotation.html?quotationnum=). #"
25 %               $quotation->quotationnum. '">';
26         <TR>
27           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->quotationnum %></A></TD>
28           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% time2str($date_format, $quotation->_date) |h %></A></TD>
29           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->total_setup |h %></A></TD>
30           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->total_recur |h %></A></TD>
31           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>"><% $opt{convert_label} || 'Convert to customer' %></A></TD>
32         </TR>
33 %     }
34     </TABLE>
35 % }
36     <BR><BR>
37
38 % }
39 <%init>
40
41 my $curuser = $FS::CurrentUser::CurrentUser;
42
43 #die "access denied"
44 #  unless $curuser->access_right('Generate quotation');
45
46 my $conf = new FS::Conf;
47
48 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
49
50 my %opt = @_;
51
52 my $new_query;
53 my @quotations;
54 if ( $opt{cust_main} ) {
55   $new_query = 'custnum='. $opt{cust_main}->custnum;
56   @quotations = $opt{cust_main}->quotation;
57 } elsif ( $opt{prospect_main} ) {
58   $new_query = 'prospectnum='. $opt{prospect_main}->prospectnum;
59   @quotations = $opt{prospect_main}->quotation;
60 } else {
61   die 'guru meditation #&&: neither cust_main nor prospect_main specified';
62 }
63
64 @quotations = grep ! $_->disabled, @quotations;
65
66 </%init>