4c913257eb681469820c8857d365174f043a726a
[freeside.git] / httemplate / view / quotation.html
1 <& /elements/header.html, mt('Quotation View'), $menubar &>
2
3 <SCRIPT TYPE="text/javascript">
4 function areyousure(href, message) {
5   if (confirm(message) == true)
6     window.location.href = href;
7 }
8 </SCRIPT>
9
10 %#XXX link to order...
11
12 <%doc>
13
14 XXX resending quotations
15
16 % if ( $curuser->access_right('Resend invoices') ) {
17
18     <A HREF="<% $p %>misc/send-invoice.cgi?method=print;<% $link %>"><% mt('Re-print this invoice') |h %></A>
19
20 %   if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { 
21         | <A HREF="<% $p %>misc/send-invoice.cgi?method=email;<% $link %>"><% mt('Re-email this invoice') |h %></A>
22 %   } 
23
24 %   if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { 
25         | <A HREF="<% $p %>misc/send-invoice.cgi?method=fax;<% $link %>"><% mt('Re-fax this invoice') |h %></A>
26 %   } 
27
28     <BR><BR>
29
30 % } 
31
32 </%doc>
33
34 % if ( $curuser->access_right('Order customer package') ) {
35   <& /elements/order_pkg_link.html,
36        'label'       => emt('Add package'),
37        'actionlabel' => emt('Add package'),
38        map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum )
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 % if ( $curuser->access_right('New customer') && $quotation->quotation_pkg ) {
47   | <A HREF="<%$p%>edit/process/quotation_convert.html?quotationnum=<% $quotation->quotationnum %>">Place order</A>
48 % }
49
50 <BR><BR>
51
52 % if ( $conf->exists('quotation_html') ) { 
53     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
54 % } else { 
55 %   die "quotation_html config missing";
56 % }
57 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
58
59 <& /elements/footer.html &>
60 <%init>
61
62 my $curuser = $FS::CurrentUser::CurrentUser;
63
64 #die "access denied"
65 #  unless $curuser->access_right('View quotations');
66
67 my $quotationnum;
68 my($query) = $cgi->keywords;
69 if ( $query =~ /^(\d+)$/ ) {
70   $quotationnum = $1;
71 } else {
72   $quotationnum = $cgi->param('quotationnum');
73 }
74
75 my $conf = new FS::Conf;
76
77 my $quotation = qsearchs({
78   'select'    => 'quotation.*',
79   'table'     => 'quotation',
80   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
81   'hashref'   => { 'quotationnum' => $quotationnum },
82   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
83 });
84 die "Quotation #$quotationnum not found!" unless $quotation;
85
86 my $menubar;
87 if ( my $custnum = $quotation->custnum ) {
88   my $display_custnum = $quotation->cust_main->display_custnum;
89   $menubar = menubar(
90     emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
91   );
92 } elsif ( my $prospectnum = $quotation->prospectnum ) {
93   $menubar = menubar(
94     emt("View this prospect (#[_1])",$prospectnum) => "${p}view/prospect_main.html?$prospectnum",
95   );
96 }
97
98 my $link = "quotationnum=$quotationnum";
99 #$link .= ';template='. uri_escape($template) if $template;
100 #$link .= ';notice_name='. $notice_name if $notice_name;
101
102 my $preref_callback = sub {
103   areyousure_link("${p}misc/delete-quotation_pkg.html?". shift->quotationpkgnum,
104                   emt('Are you sure you want to remove this package from the quotation?'),
105                   emt('Remove this package'), #tooltip
106                   qq(<img src="${p}images/cross.png">), #link
107                  );
108 };
109
110 sub areyousure_link {
111     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
112     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
113 }
114
115 </%init>