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