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