Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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   <BR><BR>
45 % } 
46
47 % if ( $conf->exists('quotation_html') ) { 
48     <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
49 % } else { 
50 %   die "quotation_html config missing";
51 % }
52 % #plaintext quotations? <PRE><% join('', $quotation->print_text() ) %></PRE>
53
54 <& /elements/footer.html &>
55 <%init>
56
57 my $curuser = $FS::CurrentUser::CurrentUser;
58
59 #die "access denied"
60 #  unless $curuser->access_right('View quotations');
61
62 my $quotationnum;
63 my($query) = $cgi->keywords;
64 if ( $query =~ /^(\d+)$/ ) {
65   $quotationnum = $1;
66 } else {
67   $quotationnum = $cgi->param('quotationnum');
68 }
69
70 my $conf = new FS::Conf;
71
72 my $quotation = qsearchs({
73   'select'    => 'quotation.*',
74   'table'     => 'quotation',
75   #'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
76   'hashref'   => { 'quotationnum' => $quotationnum },
77   #'extra_sql' => ' AND '. $curuser->agentnums_sql,
78 });
79 die "Quotation #$quotationnum not found!" unless $quotation;
80
81 my $menubar;
82 if ( my $custnum = $quotation->custnum ) {
83   my $display_custnum = $quotation->cust_main->display_custnum;
84   $menubar = menubar(
85     emt("View this customer (#[_1])",$display_custnum) => "${p}view/cust_main.cgi?$custnum",
86   );
87 } elsif ( my $prospectnum = $quotation->prospectnum ) {
88   $menubar = menubar(
89     emt("View this prospect (#[_1])",$prospectnum) => "${p}view/prospect_main.html?$prospectnum",
90   );
91 }
92
93 my $link = "quotationnum=$quotationnum";
94 #$link .= ';template='. uri_escape($template) if $template;
95 #$link .= ';notice_name='. $notice_name if $notice_name;
96
97 my $preref_callback = sub {
98   areyousure_link("${p}misc/delete-quotation_pkg.html?". shift->quotationpkgnum,
99                   emt('Are you sure you want to remove this package from the quotation?'),
100                   emt('Remove this package'), #tooltip
101                   qq(<img src="${p}images/cross.png">), #link
102                  );
103 };
104
105 sub areyousure_link {
106     my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
107     '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
108 }
109
110 </%init>