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