b93b80bb7078ff0452df7566eca42ab10ba86464
[freeside.git] / httemplate / misc / email-quotation.html
1 <& /elements/header-popup.html, mt('Select recipients') &>
2
3 <% include('/elements/error.html') %>
4
5 <FORM NAME="OneTrueForm" METHOD="POST" ACTION="process/email-quotation.html" onSubmit="document.OneTrueForm.submit.disabled=true; document.OneTrueForm.submit.style.display='none'; document.getElementById('emailingwait').style.display='';">
6 <INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
7
8 <% ntable("#cccccc", 2) %>
9
10 % my $emails = 0;
11
12 % if ( my $cust_main = $quotation->cust_main ) {
13 %   foreach my $email ( $cust_main->invoicing_list_emailonly ) {
14 %     $emails++;
15       <& .emailrow, $email &>
16 %   }
17 % }
18
19 % my @contact = $quotation->custnum ? $quotation->cust_main->cust_contact
20 %                                   : $quotation->prospect_main->contact;
21 % foreach my $contact ( @contact ) {
22 %    foreach my $contact_email ( $contact->contact_email ) {
23 %      $emails++;
24        <& .emailrow, $contact_email->emailaddress, $contact->firstlast &>
25 %    }
26 % }
27
28 <%def .emailrow>
29 % my( $email, $name ) = @_;
30 % if ( $name ) { 
31 %   $name = "$name <$email>";
32 % } else { 
33 %   $name = $email;
34 % }
35   <TR>
36     <TD><INPUT TYPE="checkbox" NAME="emailaddress" VALUE="<% $email |h %>"></TD>
37     <TD><% $name |h %></TD>
38   </TR>
39 </%def>
40
41 </TABLE>
42
43 <BR>
44
45 <CENTER>
46 % if ( $emails ) {
47   <BUTTON TYPE="submit" NAME="submit" ID="submit">Email quotation</BUTTON>
48   <DIV ID="emailingwait" STYLE="display:none">
49     <IMG SRC="<%$p%>images/wait-orange.gif"> <B>Sending...</B>
50   </DIV>
51 % } else {
52   <FONT SIZE="+1" COLOR="#ff0000"><% mt('Add a contact email address first') |h %></FONT>
53 % }
54 </CENTER>
55
56 </FORM>
57
58 <& /elements/footer-popup.html &>
59 <%init>
60
61 #die "access denied"
62 #  unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation'); #separate rights to generate vs send/email?
63
64 $cgi->param('quotationnum') =~ /^(\d+)$/ or die "Illegal quotationnum";
65 my $quotationnum = $1;
66
67 #XXX agent-virt
68 my $quotation = qsearchs('quotation', { 'quotationnum'=>$quotationnum })
69   or die "Unknown quotationnum";
70
71 </%init>