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