throw an exception if Avalara is misconfigured, and clean up exception handling for...
[freeside.git] / httemplate / view / quotation.html
1 <& /elements/header.html, mt('Quotation View'), $menubar &>
2
3 <& /elements/init_overlib.html &>
4
5 <SCRIPT TYPE="text/javascript">
6 function areyousure(href, message) {
7   if (confirm(message) == true)
8     window.location.href = href;
9 }
10 </SCRIPT>
11
12 % unless ( $quotation->disabled eq 'Y' ) {
13
14 %   if ( $curuser->access_right('Order customer package') ) {
15       <& /elements/order_pkg_link.html,
16            'label'       => emt('Add package'),
17            'actionlabel' => emt('Add package'),
18            map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum )
19       &>
20 %   }
21
22 %   if ( $curuser->access_right('One-time charge') ) {
23       | <& /elements/one_time_charge_link.html,
24              map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum )
25         &>
26 %   }
27       <BR><BR>
28
29 %   if ( 1 ) { #if ( $curuser->access_right('Send quotations') )
30
31       <& /elements/popup_link.html,
32            'action'      => "${p}misc/email-quotation.html".
33                               "?quotationnum=$quotationnum",
34            'label'       => emt('Email this quotation'),
35            'actionlabel' => emt('Select recipients'),
36            #'width'       => 540,
37            #'height'      => 336,
38       &>
39
40 %#      <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
41
42 %#%     if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
43 %#           | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
44 %#%     } 
45
46 %   }
47
48 %   if ( $conf->exists('quotation_latex') ) { 
49       | <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
50 %   }
51
52     <BR><BR>
53
54 %   if ( $curuser->access_right('New customer') && $quotation->quotation_pkg ) {
55       <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
56       <BR><BR>
57 %   }
58
59 % }
60
61 % if ( $curuser->access_right('Disable quotation') ) {
62 %   if ( $quotation->disabled eq 'Y' ) {
63       <A HREF="<%$p%>misc/enable-quotation.html?quotationnum=<% $quotation->quotationnum %>" TITLE="<% emt('Enable this quotation') %>"><% emt('Enable this quotation') %></A>
64 %   } else {
65       <% areyousure_link(
66            "${p}misc/disable-quotation.html?quotationnum=". $quotation->quotationnum,
67            emt('Are you sure you want to disable this quotation?'),
68            emt('Disable this quotation'), #tooltip
69            emt('Disable this quotation'), #link
70       ) %>
71 %   }
72   <BR><BR>
73 % }
74
75 % if ( $error ) {
76 <DIV CLASS="error"><% emt('Error calculating quotation: [_1]', $error) %></DIV>
77 % }
78
79 % if ( $conf->exists('quotation_html') ) { 
80     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
81 % } else { 
82 %   die "quotation_html config missing";
83 % }
84 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
85
86 <& /elements/footer.html &>
87 <%init>
88
89 my $curuser = $FS::CurrentUser::CurrentUser;
90
91 #die "access denied"
92 #  unless $curuser->access_right('View quotations');
93
94 my $quotationnum;
95 my($query) = $cgi->keywords;
96 if ( $query =~ /^(\d+)$/ ) {
97   $quotationnum = $1;
98 } else {
99   $quotationnum = $cgi->param('quotationnum');
100 }
101
102 my $conf = new FS::Conf;
103
104 my $quotation = qsearchs({
105   'select'    => 'quotation.*',
106   'table'     => 'quotation',
107   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
108   'hashref'   => { 'quotationnum' => $quotationnum },
109   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
110 });
111 die "Quotation #$quotationnum not found!" unless $quotation;
112
113 my $error = $quotation->estimate;
114
115 my $menubar = menubar( $quotation->cust_or_prospect_label_link($p) );
116
117 my $link = "quotationnum=$quotationnum";
118 #$link .= ';template='. uri_escape($template) if $template;
119 #$link .= ';notice_name='. $notice_name if $notice_name;
120
121 my $preref_callback = sub {
122   areyousure_link("${p}misc/delete-quotation_pkg.html?". shift->quotationpkgnum,
123                   emt('Are you sure you want to remove this package from the quotation?'),
124                   emt('Remove this package'), #tooltip
125                   qq(<img src="${p}images/cross.png">), #link
126                  );
127 };
128
129 sub areyousure_link {
130     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
131     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
132 }
133
134 </%init>