enable CardFortress in test database, #71513
[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 %     my $query = 'quotationnum=' . $quotation->get('quotationnum');
27 %     if ($quotation->custnum) {
28 %       $query .= ';custnum=' . $quotation->custnum;
29 %     } else {
30 %       $query .= ';prospectnum=' . $quotation->prospectnum;
31 %     }
32       <A HREF="<% $fsurl . 'edit/quick-charge.html?' . $query %>"><% emt('One-time charge') %></A>
33 %     $inrow++;
34 %   }
35
36 %   if ( $can_generate_quotation ) {
37       <% $inrow ? ' | ' : '' %>
38       <A HREF="<%$p%>edit/quotation.html?quotationnum=<% $quotation->quotationnum %>">Edit quotation fields</A>
39 %     $inrow++;
40 %   }
41
42     <% $inrow ? '<BR><BR>' : '' %>
43
44 %   if ( 1 ) { #if ( $curuser->access_right('Send quotations') )
45
46       <& /elements/popup_link.html,
47            'action'      => "${p}misc/email-quotation.html".
48                               "?quotationnum=$quotationnum",
49            'label'       => emt('Email this quotation'),
50            'actionlabel' => emt('Select recipients'),
51            #'width'       => 540,
52            #'height'      => 336,
53       &>
54
55 %#      <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
56
57 %#%     if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
58 %#           | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
59 %#%     } 
60
61 %   }
62
63 %   if ( $conf->exists('quotation_latex') ) { 
64       | <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
65 %   }
66
67     <BR><BR>
68
69 %   if ( $curuser->access_right('New customer') && $quotation->quotation_pkg ) {
70 %     # if we end up with more than one option, combine these links and add an interstitial screen
71       <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
72       | <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>&onhold=1">Order on hold</A>
73       <BR><BR>
74 %   }
75
76 % }
77
78 % if ( $curuser->access_right('Disable quotation') ) {
79 %   if ( $quotation->disabled eq 'Y' ) {
80       <A HREF="<%$p%>misc/enable-quotation.html?quotationnum=<% $quotation->quotationnum %>" TITLE="<% emt('Enable this quotation') %>"><% emt('Enable this quotation') %></A>
81 %   } else {
82       <% areyousure_link(
83            "${p}misc/disable-quotation.html?quotationnum=". $quotation->quotationnum,
84            emt('Are you sure you want to disable this quotation?'),
85            emt('Disable this quotation'), #tooltip
86            emt('Disable this quotation'), #link
87       ) %>
88 %   }
89   <BR><BR>
90 % }
91
92 % if ( $error ) {
93 <DIV CLASS="error"><% emt('Error calculating quotation: [_1]', $error) %></DIV>
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 $error = $quotation->estimate;
149
150 my $menubar = menubar( $quotation->cust_or_prospect_label_link($p) );
151
152 my $link = "quotationnum=$quotationnum";
153 #$link .= ';template='. uri_escape($template) if $template;
154 #$link .= ';notice_name='. $notice_name if $notice_name;
155
156 my $preref_callback = sub {
157   my $quotation_pkg = shift;
158   $can_generate_quotation ?
159   areyousure_link("${p}misc/delete-quotation_pkg.html?". $quotation_pkg->quotationpkgnum,
160                   emt('Are you sure you want to remove this package from the quotation?'),
161                   emt('Remove this package'), #tooltip
162                   qq(<img src="${p}images/cross.png">), #link
163                  ) .
164   include('/elements/popup_link.html',
165     action      => "${p}edit/quotation_pkg_detail.html?pkgnum=" .
166                    $quotation_pkg->quotationpkgnum,
167     html_label  => qq(<IMG SRC="${p}images/Actions-document-edit-icon.png">),
168     title       => emt('Edit quotation details'),
169     actionlabel => emt('Edit quotation details'),
170     color       => '#333399',
171     width       => 763,
172   )
173   : '';
174 };
175
176 sub areyousure_link {
177     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
178     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
179 }
180
181 </%init>