1

Civi 4.6.18 using WordPress

I am working on creating a year-end statement for donors with all their donations for this year on it. I am using the "Thank You letter" to do so.
1. I select Group by = Contact 2. I select Separator = Table Cell.

My results are Comma Separated. How do I get them into separate table cells?
Screenshot of results

Here is my source code for the letter.

<p>Dear {contact.first_name}</p>

<p>&nbsp;</p>

<table align="left" border="1" cellpadding="2" cellspacing="0" class="table" style="width: 500px;">
    <tbody>
        <tr>
            <th>Date</th>
            <th>Amount</th>
            <th>Receipt Number</th>
        </tr>
        <!--
    {foreach from=$contributions item=contribution} {assign
    var="date" value=$contribution.receive_date|date_format:"%d %B
    %Y"}
  -->
        <tr>
            <td>{contribution.receive_date}</td>
            <td>{contribution.total_amount}</td>
            <td>{contribution.contribution_id}</td>
        </tr>
        <!--
    {/foreach}

 -->
    </tbody>
</table>

I got my original information from here. https://github.com/civicrm/civicrm-user-guide/blob/master/docs/contributions/manual-receipts-and-thank-yous.md

1

A big Thank-You to Karen with Greenleaf Advancement for helping me out with this.

There is a bug in Civi that does not allow the Table Cell separator to function. Karen helped we with some base code that works around the issue, I was able to tweek it from there to work for our situation. Paste the code in the Source of the letter. We use Line Items with all our donations. You will have to re-work the code a little if you do not use Price Sets. You may also want some additional columns ore in a different order. Just edit the code to your liking.

    <table align="left" cellpadding="4" cellspacing="0" class="table" style="width: 700px;border: 1px solid #281c1d;">
    <tbody>
        <tr style="padding: 8px; border: 1px solid #281c1d;color:white; background-color: #70551F;">
            <th style="padding: 8px;">Date</th>
            <th style="padding: 8px;">Cont ID</th>
            <th style="padding: 8px;">Contribution Designation</th>
            <th style="padding: 8px;">Amount</th>
        </tr>
        <!--

    {foreach from=$contributions item=contribution} {assign
    var="date" value=$contribution.receive_date|date_format:"%B %d %Y"}
{crmAPI var='result' entity='LineItem' action='get' contribution_id=$contribution.id} 
  {foreach from=$result.values item=lineitem} 

  -->
        <tr style="padding: 4px; border: 1px solid #281c1d;">
            <td style="padding: 4px; border: 1px solid #281c1d;">{$date}</td>
            <td style="padding: 4px; border: 1px solid #281c1d;">{$contribution.id}</td>
            <td style="padding: 4px; border: 1px solid #281c1d;">{$lineitem.label}</td>
            <td style="text-align:right;padding: 4px; border: 1px solid #281c1d;">$ {$lineitem.line_total}</td>
        </tr>
        <!--
    {/foreach}{/foreach}

 -->
        <tr style="padding: 4px; border: 1px solid #281c1d;text-align:right;padding-top:20px;">
            <th colspan="3" style="padding: 4px; border: 1px solid #281c1d;text-align:right;padding-top:20px;padding-right:20px;">2016 Total Contributions</th>
            <td style="padding-right: 4px; border: 1px solid #281c1d;padding-top:20px;text-align:right;">$ {$contribution_aggregate}.00</td>
        </tr>
    </tbody>
</table>
1

This patch (which is now part of core in 4.7) adds a linebreak option which makes it simple to create such tables

https://github.com/civicrm/civicrm-core/pull/8804/files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.