66873616b2334883c90c5428c1a0f516195654f8
[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 %     # if we end up with more than one option, combine these links and add an interstitial screen
67       <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
68       | <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>&onhold=1">Order on hold</A>
69       <BR><BR>
70 %   }
71
72 % }
73
74 % if ( $curuser->access_right('Disable quotation') ) {
75 %   if ( $quotation->disabled eq 'Y' ) {
76       <A HREF="<%$p%>misc/enable-quotation.html?quotationnum=<% $quotation->quotationnum %>" TITLE="<% emt('Enable this quotation') %>"><% emt('Enable this quotation') %></A>
77 %   } else {
78       <% areyousure_link(
79            "${p}misc/disable-quotation.html?quotationnum=". $quotation->quotationnum,
80            emt('Are you sure you want to disable this quotation?'),
81            emt('Disable this quotation'), #tooltip
82            emt('Disable this quotation'), #link
83       ) %>
84 %   }
85   <BR><BR>
86 % }
87
88
89 % my $close_date = $quotation->close_date;
90 % my $confidence = $quotation->confidence;
91 % if ($close_date or length($confidence)) {
92 <TABLE>
93 %   if ($close_date) {
94 <TR>
95   <TH STYLE="text-align: right;">Close Date:</TH>
96   <TD><% time2str($conf->config('date_format') || '%m/%d/%Y',$close_date) %></TD>
97 </TR>
98 %   }
99 %   if (length($confidence)) {
100 <TR><TH STYLE="text-align: right;">Confidence:</TH><TD><% $confidence %>%</TD></TR>
101 %   }
102 </TABLE>
103 % }
104
105 % if ( $conf->exists('quotation_html') ) { 
106     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
107 % } else { 
108 %   die "quotation_html config missing";
109 % }
110 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
111
112 <& /elements/footer.html &>
113 <%init>
114
115 my $curuser = $FS::CurrentUser::CurrentUser;
116
117 #die "access denied"
118 #  unless $curuser->access_right('View quotations');
119
120 my $can_generate_quotation = $curuser->access_right('Generate quotation');
121
122 my $quotationnum;
123 my($query) = $cgi->keywords;
124 if ( $query =~ /^(\d+)$/ ) {
125   $quotationnum = $1;
126 } else {
127   $quotationnum = $cgi->param('quotationnum');
128 }
129
130 my $conf = new FS::Conf;
131
132 my $quotation = qsearchs({
133   'select'    => 'quotation.*',
134   'table'     => 'quotation',
135   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
136   'hashref'   => { 'quotationnum' => $quotationnum },
137   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
138 });
139 die "Quotation #$quotationnum not found!" unless $quotation;
140
141 my $menubar = menubar( $quotation->cust_or_prospect_label_link($p) );
142
143 my $link = "quotationnum=$quotationnum";
144 #$link .= ';template='. uri_escape($template) if $template;
145 #$link .= ';notice_name='. $notice_name if $notice_name;
146
147 my $preref_callback = sub {
148   my $quotation_pkg = shift;
149   $can_generate_quotation ?
150   areyousure_link("${p}misc/delete-quotation_pkg.html?". $quotation_pkg->quotationpkgnum,
151                   emt('Are you sure you want to remove this package from the quotation?'),
152                   emt('Remove this package'), #tooltip
153                   qq(<img src="${p}images/cross.png">), #link
154                  ) .
155   include('/elements/popup_link.html',
156     action      => "${p}edit/quotation_pkg_detail.html?pkgnum=" .
157                    $quotation_pkg->quotationpkgnum,
158     html_label  => qq(<IMG SRC="${p}images/Actions-document-edit-icon.png">),
159     title       => emt('Edit quotation details'),
160     actionlabel => emt('Edit quotation details'),
161     color       => '#333399',
162     width       => 763,
163   )
164   : '';
165 };
166
167 sub areyousure_link {
168     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
169     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
170 }
171
172 </%init>