email quotations, RT#22232, RT#20688
[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       <BR><BR>
21 %   }
22
23 %   if ( 1 ) { #if ( $curuser->access_right('Send quotations') )
24
25       <& /elements/popup_link.html,
26            'action'      => "${p}misc/email-quotation.html".
27                               "?quotationnum=$quotationnum",
28            'label'       => emt('Email this quotation'),
29            'actionlabel' => emt('Select recipients'),
30            #'width'       => 540,
31            #'height'      => 336,
32       &>
33
34 %#      <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
35
36 %#%     if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
37 %#           | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
38 %#%     } 
39
40 %   }
41
42 %   if ( $conf->exists('quotation_latex') ) { 
43       | <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
44 %   }
45
46     <BR><BR>
47
48 %   if ( $curuser->access_right('New customer') && $quotation->quotation_pkg ) {
49       <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
50       <BR><BR>
51 %   }
52
53 % }
54
55 % if ( $curuser->access_right('Disable quotation') ) {
56 %   if ( $quotation->disabled eq 'Y' ) {
57       <A HREF="<%$p%>misc/enable-quotation.html?quotationnum=<% $quotation->quotationnum %>" TITLE="<% emt('Enable this quotation') %>"><% emt('Enable this quotation') %></A>
58 %   } else {
59       <% areyousure_link(
60            "${p}misc/disable-quotation.html?quotationnum=". $quotation->quotationnum,
61            emt('Are you sure you want to disable this quotation?'),
62            emt('Disable this quotation'), #tooltip
63            emt('Disable this quotation'), #link
64       ) %>
65 %   }
66   <BR><BR>
67 % }
68
69
70 % if ( $conf->exists('quotation_html') ) { 
71     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
72 % } else { 
73 %   die "quotation_html config missing";
74 % }
75 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
76
77 <& /elements/footer.html &>
78 <%init>
79
80 my $curuser = $FS::CurrentUser::CurrentUser;
81
82 #die "access denied"
83 #  unless $curuser->access_right('View quotations');
84
85 my $quotationnum;
86 my($query) = $cgi->keywords;
87 if ( $query =~ /^(\d+)$/ ) {
88   $quotationnum = $1;
89 } else {
90   $quotationnum = $cgi->param('quotationnum');
91 }
92
93 my $conf = new FS::Conf;
94
95 my $quotation = qsearchs({
96   'select'    => 'quotation.*',
97   'table'     => 'quotation',
98   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
99   'hashref'   => { 'quotationnum' => $quotationnum },
100   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
101 });
102 die "Quotation #$quotationnum not found!" unless $quotation;
103
104 my $menubar = menubar( $quotation->cust_or_prospect_label_link($p) );
105
106 my $link = "quotationnum=$quotationnum";
107 #$link .= ';template='. uri_escape($template) if $template;
108 #$link .= ';notice_name='. $notice_name if $notice_name;
109
110 my $preref_callback = sub {
111   areyousure_link("${p}misc/delete-quotation_pkg.html?". shift->quotationpkgnum,
112                   emt('Are you sure you want to remove this package from the quotation?'),
113                   emt('Remove this package'), #tooltip
114                   qq(<img src="${p}images/cross.png">), #link
115                  );
116 };
117
118 sub areyousure_link {
119     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
120     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
121 }
122
123 </%init>