• ApolloS
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies

Please forgive me for absolute newbishness. Only have done couple of Visualforce pages for e-mail templates and some validation rules. Now I need to get this trigger done.

 

I need to have a custom field in Leads that has a count of Activities in Activity History. Usually I would do that with roll-up field, but it is not available in leads.

 

I found a trigger in these forums:

trigger Activity_count on Task (after insert, after update) {
List<Lead> uplist=new List<Lead>();
List<Lead> lelist=[select id,Activity_count__c from Lead];
List<AggregateResult> st=new List<AggregateResult>();
st=[select count(Id),whoid from task where id=:Trigger.new and status='Completed' group by whoid];
for(Integer i=0;i<st.size();i++)
{
for(Lead l:lelist)
{
if(l.id==st[i].get('whoid'))
{
l.Activity_count__c=(Integer)st[i].get('expr0')+l.Activity_count__c;
uplist.add(l);
}
}
}
update uplist;
}

 But problem is that I get following error:

Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Could you help me out?

We are missing bunch of dupes, because deafault setting of Find Duplicates button in Leads does not have all the options checked.

 

By deafault only Name, Company, E-mail, and Phone are checked. I would like all the options checked (default ones and Last Name + E-mail Domain)

 

Does anyone have a Visualforce code willing to share with me that would accomplish that?

What I am trying to accomplish (given all the SF EE and my skill limitations) is to pull up in a formula field for Account total Amount of only the 1st Closed Won opportunity associated with that account. It basically will tell sales folks (and provide data for reports) that shows how much customers usually spend the first time they buy.

 

So how do I write a condition that shows only the first "Closed Won" opportunity for the Account?

I apologize in advance for being new to this.

 

Under Contacts and Account for the Activities I have "Log A Call" and "Send An E-mail" buttons.

 

I need to re-do Log A Call button, so it does the same thing it does not, but it also needs to set a value in custom Activity picklist Activity_Type__c to "Spoke"

 

I also need to clone that button and create Log Voicemail, which would do the same thing as Log A Call, but set the custom Activity picklist Activity_Type__c to "LVM"

 

Lastly, is there any way to have "Send An E-mail" button to set the Activity custom picklist Activity_Type__c to "Emailed"?
I can't see where to tweak that layout, since it does not show the picklist now.

I am doing this all to make it easier to track how my team is reaching out to our customers.

Thanks for all your help!

 

Right now we have Log a Call and Send an Email buttons under our Accounts, Contacts, and Opportunities.

 

I would like to add two more buttons.

 

Left Voicemail - sets Activity custom picklist field Activity_Type__c to value LVM and Subject to LVM

Bad Number - sets Activity custom picklist field Activity_Type__c to BadNum and Subject to Bad Number

 

How do I do that?

We have a business rule, that if 1st Opportunity created under the Account has a Primary Campaign Source set to a certain Campaign, then every opportunity after has to have save Primary Campaign Source.

Issue is, sales people forget to enter that, or don't bother looking it up, if they are in a rush.

So I need a trigger, that looks up 1st Opportunity under the Account (which is set to Type = New Business) and copies the Primary Campaign Source from that Opportunity, to any subsequent Opportunities under the same Account.

How do I go about doing that?

This is my first attempt at tweaking an APEX. It is a e-mail template for Invoice which is generated from "Send E-mail" within Opportunity. I am getting: " Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity' " when I am trying to save. What am I missing here?

 

 <messaging:emailTemplate subject="Your invoice" recipientType="Contact"  
relatedToType="Opportunity">
<messaging:htmlEmailBody >
 
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title=" Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
    </font>
    </td>  
</tr> 
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:htmlEmailBody>
 
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">  
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title="Pixability Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
</font>
    </td>  
</tr>
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:attachment>      
</messaging:emailTemplate>

 

 

This is my first attempt at tweaking an APEX. It is a e-mail template for Invoice which is generated from "Send E-mail" within Opportunity. I am getting: " Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity' " when I am trying to save. What am I missing here?

 

 <messaging:emailTemplate subject="Your invoice" recipientType="Contact"  
relatedToType="Opportunity">
<messaging:htmlEmailBody >
 
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title=" Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
    </font>
    </td>  
</tr> 
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:htmlEmailBody>
 
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">  
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title="Pixability Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
</font>
    </td>  
</tr>
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:attachment>      
</messaging:emailTemplate>

 

 

Please forgive me for absolute newbishness. Only have done couple of Visualforce pages for e-mail templates and some validation rules. Now I need to get this trigger done.

 

I need to have a custom field in Leads that has a count of Activities in Activity History. Usually I would do that with roll-up field, but it is not available in leads.

 

I found a trigger in these forums:

trigger Activity_count on Task (after insert, after update) {
List<Lead> uplist=new List<Lead>();
List<Lead> lelist=[select id,Activity_count__c from Lead];
List<AggregateResult> st=new List<AggregateResult>();
st=[select count(Id),whoid from task where id=:Trigger.new and status='Completed' group by whoid];
for(Integer i=0;i<st.size();i++)
{
for(Lead l:lelist)
{
if(l.id==st[i].get('whoid'))
{
l.Activity_count__c=(Integer)st[i].get('expr0')+l.Activity_count__c;
uplist.add(l);
}
}
}
update uplist;
}

 But problem is that I get following error:

Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Could you help me out?

What I am trying to accomplish (given all the SF EE and my skill limitations) is to pull up in a formula field for Account total Amount of only the 1st Closed Won opportunity associated with that account. It basically will tell sales folks (and provide data for reports) that shows how much customers usually spend the first time they buy.

 

So how do I write a condition that shows only the first "Closed Won" opportunity for the Account?

This is my first attempt at tweaking an APEX. It is a e-mail template for Invoice which is generated from "Send E-mail" within Opportunity. I am getting: " Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity' " when I am trying to save. What am I missing here?

 

 <messaging:emailTemplate subject="Your invoice" recipientType="Contact"  
relatedToType="Opportunity">
<messaging:htmlEmailBody >
 
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title=" Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
    </font>
    </td>  
</tr> 
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:htmlEmailBody>
 
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">  
<table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center">
<tr>
    <td width="230">
        <img src='{!URLFOR($Resource.PixLogo70pix)}' title="Pixability Logo" />
    </td>
    <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br />
</font>
    </td>  
</tr>
</table>
<center>
    <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p>
</center>
<br/>
 
<table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center">
<tr>    <td valign="top">
    <font face="Arial" size="2" color="#666666">
    Bill To:</font><br />
    <font face="Arial" size="2">
    {!Opportunity.Account.Name}<br/>
    {!Opportunity.Account.BillingStreet}<br/>
    {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/>
    {!Opportunity.Account.BillingCountry}<br/>
  </font>
</td> 
        <td>&nbsp;</td>
   <td valign="top">
     <font face="Arial" size="2">
   <font color="#666666">Account Name:</font> <br/>
   {!Opportunity.Account.Name}<br/>
   <font color="#666666">Invoice Number:</font> <br/>
   {!Opportunity.Project_number__c}<br/>
   <font color="#666666">Invoice Date:</font> <br/>
   {!Opportunity.CloseDate}<br />
   <font color="#666666">Payment Terms:</font> <br/>
   <font color="#FF3300">Due Upon Receipt</font></font></td>    
</tr>
</table>
<br/>
 
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4">
<tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666">
       <td>Product</td>
      <td>Description</td>
       <td>Quantity</td>
       <td>Unit Price</td>
       <td>Total Price</td>
       </font>
</tr>
<tr><font face="Arial" size="2" color="#000000">
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.Description}</td>           
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>  
       </font>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Sub-total:&nbsp;<apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial" size="2">Discounts:&nbsp;<apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#FFFFFF" align="right" colspan="5">
       <font face="Arial">Tax:&nbsp;<apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td>
</tr>
<tr>
       <td bgcolor="#E5E5E5" align="right" colspan="5">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
 
<p align="center"><font face="Arial">Thank you very much for you business!<br />
{!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName}
</font></p>
</messaging:attachment>      
</messaging:emailTemplate>