Option to ignore old CDRs, RT#81480
[freeside.git] / httemplate / view / quotation.html
1 % if ( $quotation->custnum ) {
2 <& /elements/header-cust_main.html, view=>'quotations', custnum=>$quotation->custnum &>
3 <h2>Quotation #<% $quotationnum %>
4 % if ($quotation->quotation_description) {
5 (<% $quotation->quotation_description |h %>)  
6 % } 
7 </h2>
8 % } else { #eventually, header-prospect_main.html
9 <& /elements/header.html, mt('Quotation View'), $menubar &>
10 <& /elements/init_overlib.html &>
11
12 <SCRIPT TYPE="text/javascript">
13 function areyousure(href, message) {
14   if (confirm(message) == true)
15     window.location.href = href;
16 }
17 </SCRIPT>
18
19 % }
20
21 % unless ( $quotation->disabled eq 'Y' ) {
22
23 %   my $inrow = 0;
24 %   if ( $curuser->access_right('Order customer package') ) {
25       <& /elements/order_pkg_link.html,
26            'label'       => emt('Add package'),
27            'actionlabel' => emt('Add package'),
28            map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum )
29       &>
30 %     $inrow++;
31 %   }
32
33 %   if ( $curuser->access_right('One-time charge') ) {
34       <% $inrow ? ' | ' : '' %>
35 %     my $query = 'quotationnum=' . $quotation->get('quotationnum');
36 %     if ($quotation->custnum) {
37 %       $query .= ';custnum=' . $quotation->custnum;
38 %     } else {
39 %       $query .= ';prospectnum=' . $quotation->prospectnum;
40 %     }
41       <A HREF="<% $fsurl . 'edit/quick-charge.html?' . $query %>"><% emt('One-time charge') %></A>
42 %     $inrow++;
43 %   }
44
45 %   if ( $can_generate_quotation ) {
46       <% $inrow ? ' | ' : '' %>
47       <A HREF="<%$p%>edit/quotation.html?quotationnum=<% $quotation->quotationnum %>">Edit quotation fields</A>
48 %     $inrow++;
49 %   }
50
51     <% $inrow ? '<BR><BR>' : '' %>
52
53 %   if ( 1 ) { #if ( $curuser->access_right('Send quotations') )
54
55       <& /elements/popup_link.html,
56            'action'      => "${p}misc/email-quotation.html".
57                               "?quotationnum=$quotationnum",
58            'label'       => emt('Email this quotation'),
59            'actionlabel' => emt('Select recipients'),
60            #'width'       => 540,
61            #'height'      => 336,
62       &>
63
64 %#      <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
65
66 %#%     if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
67 %#           | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
68 %#%     } 
69
70 %   }
71
72 %   if ( $conf->exists('quotation_latex') ) { 
73       | <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
74 %   }
75
76     <BR><BR>
77
78 %   if ( $curuser->access_right('New customer') && $quotation->quotation_pkg ) {
79 %     # if we end up with more than one option, combine these links and add an interstitial screen
80       <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
81       | <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>&onhold=1">Order on hold</A>
82       <BR><BR>
83 %   }
84
85 % }
86
87 % if ( $curuser->access_right('Disable quotation') ) {
88 %   if ( $quotation->disabled eq 'Y' ) {
89       <A HREF="<%$p%>misc/enable-quotation.html?quotationnum=<% $quotation->quotationnum %>" TITLE="<% emt('Enable this quotation') %>"><% emt('Enable this quotation') %></A>
90 %   } else {
91       <% areyousure_link(
92            "${p}misc/disable-quotation.html?quotationnum=". $quotation->quotationnum,
93            emt('Are you sure you want to disable this quotation?'),
94            emt('Disable this quotation'), #tooltip
95            emt('Disable this quotation'), #link
96       ) %>
97 %   }
98   <BR><BR>
99 % }
100
101 % if ( $error ) {
102 <DIV CLASS="error"><% emt('Error calculating quotation: [_1]', $error) %></DIV>
103 % }
104
105 % my $close_date = $quotation->close_date;
106 % my $confidence = $quotation->confidence;
107 % if ($close_date or length($confidence)) {
108 <TABLE>
109 %   if ($close_date) {
110 <TR>
111   <TH STYLE="text-align: right;">Close Date:</TH>
112   <TD><% time2str($conf->config('date_format') || '%m/%d/%Y',$close_date) %></TD>
113 </TR>
114 %   }
115 %   if (length($confidence)) {
116 <TR><TH STYLE="text-align: right;">Confidence:</TH><TD><% $confidence %>%</TD></TR>
117 %   }
118 </TABLE>
119 % }
120
121 % if ( $conf->exists('quotation_html') ) { 
122     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
123 % } else { 
124 %   die "quotation_html config missing";
125 % }
126 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
127
128 % if ( $quotation->custnum ) {
129   <& /elements/footer-cust_main.html &>
130 % } else {
131   <& /elements/footer.html &>
132 % }
133 <%init>
134
135 my $curuser = $FS::CurrentUser::CurrentUser;
136
137 #die "access denied"
138 #  unless $curuser->access_right('View quotations');
139
140 my $can_generate_quotation = $curuser->access_right('Generate quotation');
141
142 my $quotationnum;
143 my($query) = $cgi->keywords;
144 if ( $query =~ /^(\d+)$/ ) {
145   $quotationnum = $1;
146 } else {
147   $quotationnum = $cgi->param('quotationnum');
148 }
149
150 my $conf = new FS::Conf;
151
152 my $quotation = qsearchs({
153   'select'    => 'quotation.*',
154   'table'     => 'quotation',
155   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
156   'hashref'   => { 'quotationnum' => $quotationnum },
157   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
158 });
159 die "Quotation #$quotationnum not found!" unless $quotation;
160
161 my $error = $quotation->estimate;
162
163 my $menubar = menubar( $quotation->cust_or_prospect_label_link($p) );
164
165 my $link = "quotationnum=$quotationnum";
166 #$link .= ';template='. uri_escape($template) if $template;
167 #$link .= ';notice_name='. $notice_name if $notice_name;
168
169 my $preref_callback = sub {
170   my $quotation_pkg = shift;
171   $can_generate_quotation ?
172   areyousure_link("${p}misc/delete-quotation_pkg.html?". $quotation_pkg->quotationpkgnum,
173                   emt('Are you sure you want to remove this package from the quotation?'),
174                   emt('Remove this package'), #tooltip
175                   qq(<img src="${p}images/cross.png">), #link
176                  ) .
177   include('/elements/popup_link.html',
178     action      => "${p}edit/quotation_pkg_detail.html?pkgnum=" .
179                    $quotation_pkg->quotationpkgnum,
180     html_label  => qq(<IMG SRC="${p}images/Actions-document-edit-icon.png">),
181     title       => emt('Edit quotation details'),
182     actionlabel => emt('Edit quotation details'),
183     color       => '#333399',
184     width       => 763,
185   )
186   : '';
187 };
188
189 sub areyousure_link {
190     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
191     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
192 }
193
194 </%init>