CRM-17357 Fix php fatal error on receipt PDF creation
authorBorislav Zlatanov <borislav_zlatanov@yahoo.co.uk>
Tue, 13 Oct 2015 17:34:59 +0000 (20:34 +0300)
committerColeman Watts <coleman@civicrm.org>
Wed, 14 Oct 2015 18:43:54 +0000 (14:43 -0400)
----------------------------------------
* CRM-17357: PHP fatal error during creation of receipt PDF
  https://issues.civicrm.org/jira/browse/CRM-17357

CRM/Upgrade/4.6.10.msg_template/civicrm_msg_template.tpl [new file with mode: 0644]
CRM/Upgrade/4.6.10.msg_template/message_templates/contribution_online_receipt_html.tpl [new file with mode: 0644]
CRM/Upgrade/4.6.10.msg_template/message_templates/test_preview_html.tpl [new file with mode: 0644]
CRM/Upgrade/Incremental/sql/4.6.10.mysql.tpl
xml/templates/message_templates/contribution_online_receipt_html.tpl
xml/templates/message_templates/test_preview_html.tpl

diff --git a/CRM/Upgrade/4.6.10.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.6.10.msg_template/civicrm_msg_template.tpl
new file mode 100644 (file)
index 0000000..9a2ab52
--- /dev/null
@@ -0,0 +1,16 @@
+{php}
+    $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.6.10.msg_template/message_templates';
+    $templates = array();
+    foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
+    $parts = explode('_', basename($filename, '.tpl'));
+    $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
+    }
+    $this->assign('templates', $templates);
+{/php}
+
+{foreach from=$templates item=tpl}
+    {fetch assign=content file=$tpl.filename}
+    SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
+    SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
+    UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
+{/foreach}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.6.10.msg_template/message_templates/contribution_online_receipt_html.tpl b/CRM/Upgrade/4.6.10.msg_template/message_templates/contribution_online_receipt_html.tpl
new file mode 100644 (file)
index 0000000..ec976ed
--- /dev/null
@@ -0,0 +1,473 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+</head>
+<body>
+
+{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
+{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
+{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
+
+<center>
+ <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
+
+  <!-- BEGIN HEADER -->
+  <!-- You can add table row(s) here with logo or other header elements -->
+  <!-- END HEADER -->
+
+  <!-- BEGIN CONTENT -->
+
+  <tr>
+   <td>
+
+    {if $receipt_text}
+     <p>{$receipt_text|htmlize}</p>
+    {/if}
+
+    {if $is_pay_later}
+     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
+    {else}
+     <p>{ts}Please print this confirmation for your records.{/ts}</p>
+    {/if}
+
+   </td>
+  </tr>
+  </table>
+  <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
+
+     {if $amount}
+
+
+      <tr>
+       <th {$headerStyle}>
+        {ts}Contribution Information{/ts}
+       </th>
+      </tr>
+
+      {if $lineItem and $priceSetID and !$is_quick_config}
+
+       {foreach from=$lineItem item=value key=priceset}
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
+           <tr>
+            <th>{ts}Item{/ts}</th>
+            <th>{ts}Qty{/ts}</th>
+            <th>{ts}Each{/ts}</th>
+            {if $dataArray}
+             <th>{ts}Subtotal{/ts}</th>
+             <th>{ts}Tax Rate{/ts}</th>
+             <th>{ts}Tax Amount{/ts}</th>
+            {/if}
+            <th>{ts}Total{/ts}</th>
+           </tr>
+           {foreach from=$value item=line}
+            <tr>
+             <td>
+             {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
+             </td>
+             <td>
+              {$line.qty}
+             </td>
+             <td>
+              {$line.unit_price|crmMoney:$currency}
+             </td>
+             {if $getTaxDetails}
+              <td>
+               {$line.unit_price*$line.qty|crmMoney:$currency}
+              </td>
+              {if $line.tax_rate != "" || $line.tax_amount != ""}
+               <td>
+                {$line.tax_rate|string_format:"%.2f"}%
+               </td>
+               <td>
+                {$line.tax_amount|crmMoney:$currency}
+               </td>
+              {else}
+               <td></td>
+               <td></td>
+              {/if}
+             {/if}
+             <td>
+              {$line.line_total+$line.tax_amount|crmMoney:$currency}
+             </td>
+            </tr>
+           {/foreach}
+          </table>
+         </td>
+        </tr>
+       {/foreach}
+       {if $dataArray}
+        <tr>
+         <td {$labelStyle}>
+          {ts} Amount before Tax : {/ts}
+         </td>
+         <td {$valueStyle}>
+          {$amount-$totalTaxAmount|crmMoney:$currency}
+         </td>
+        </tr>
+
+        {foreach from=$dataArray item=value key=priceset}
+         <tr>
+          {if $priceset || $priceset == 0}
+           <td>&nbsp;{$taxTerm} {$priceset|string_format:"%.2f"}%</td>
+           <td>&nbsp;{$value|crmMoney:$currency}</td>
+          {else}
+           <td>&nbsp;{ts}No{/ts} {$taxTerm}</td>
+           <td>&nbsp;{$value|crmMoney:$currency}</td>
+          {/if}
+         </tr>
+        {/foreach}
+
+       {/if}
+       {if $totalTaxAmount}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Total Tax{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$totalTaxAmount|crmMoney:$currency}
+         </td>
+        </tr>
+       {/if}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Total Amount{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$amount|crmMoney:$currency}
+        </td>
+       </tr>
+
+      {else}
+
+      {if $totalTaxAmount}
+         <tr>
+           <td {$labelStyle}>
+             {ts}Total Tax Amount{/ts}
+           </td>
+           <td {$valueStyle}>
+             {$totalTaxAmount|crmMoney:$currency}
+           </td>
+         </tr>
+       {/if}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Amount{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$amount|crmMoney:$currency} {if $amount_level} - {$amount_level}{/if}
+        </td>
+       </tr>
+
+      {/if}
+
+     {/if}
+
+
+     {if $receive_date}
+      <tr>
+       <td {$labelStyle}>
+        {ts}Date{/ts}
+       </td>
+       <td {$valueStyle}>
+        {$receive_date|crmDate}
+       </td>
+      </tr>
+     {/if}
+
+     {if $is_monetary and $trxn_id}
+      <tr>
+       <td {$labelStyle}>
+        {ts}Transaction #{/ts}
+       </td>
+       <td {$valueStyle}>
+        {$trxn_id}
+       </td>
+      </tr>
+     {/if}
+
+     {if $is_recur}
+      {if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
+       <tr>
+        <td  colspan="2" {$labelStyle}>
+         {ts 1=$cancelSubscriptionUrl}This is a recurring contribution. You can cancel future contributions by <a href="%1">visiting this web page</a>.{/ts}
+        </td>
+        {if $updateSubscriptionBillingUrl}
+         </tr>
+         <tr>
+         <td colspan="2" {$labelStyle}>
+          {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
+         </td>
+        {/if}
+       </tr>
+       <tr>
+        <td colspan="2" {$labelStyle}>
+         {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
+        </td>
+       </tr>
+      {/if}
+     {/if}
+
+     {if $honor_block_is_active}
+      <tr>
+       <th {$headerStyle}>
+        {$soft_credit_type}
+       </th>
+      </tr>
+      {foreach from=$honoreeProfile item=value key=label}
+        <tr>
+         <td {$labelStyle}>
+          {$label}
+         </td>
+         <td {$valueStyle}>
+          {$value}
+         </td>
+        </tr>
+      {/foreach}
+      {elseif $softCreditTypes and $softCredits}
+      {foreach from=$softCreditTypes item=softCreditType key=n}
+       <tr>
+        <th {$headerStyle}>
+         {$softCreditType}
+        </th>
+       </tr>
+       {foreach from=$softCredits.$n item=value key=label}
+         <tr>
+          <td {$labelStyle}>
+           {$label}
+          </td>
+          <td {$valueStyle}>
+           {$value}
+          </td>
+         </tr>
+        {/foreach}
+       {/foreach}
+     {/if}
+
+     {if $pcpBlock}
+      <tr>
+       <th {$headerStyle}>
+        {ts}Personal Campaign Page{/ts}
+       </th>
+      </tr>
+      <tr>
+       <td {$labelStyle}>
+        {ts}Display In Honor Roll{/ts}
+       </td>
+       <td {$valueStyle}>
+        {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
+       </td>
+      </tr>
+      {if $pcp_roll_nickname}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Nickname{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$pcp_roll_nickname}
+        </td>
+       </tr>
+      {/if}
+      {if $pcp_personal_note}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Personal Note{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$pcp_personal_note}
+        </td>
+       </tr>
+      {/if}
+     {/if}
+
+     {if $onBehalfProfile}
+      <tr>
+       <th {$headerStyle}>
+        {$onBehalfProfile_grouptitle}
+       </th>
+      </tr>
+      {foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
+        <tr>
+         <td {$labelStyle}>
+          {$onBehalfName}
+         </td>
+         <td {$valueStyle}>
+          {$onBehalfValue}
+         </td>
+        </tr>
+      {/foreach}
+     {/if}
+
+     {if $isShare}
+      <tr>
+        <td colspan="2" {$valueStyle}>
+            {capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contributionPageId`" a=true fe=1 h=1}{/capture}
+            {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$contributionUrl title=$title pageURL=$contributionUrl}
+        </td>
+      </tr>
+     {/if}
+
+     {if ! ($contributeMode eq 'notify' OR $contributeMode eq 'directIPN') and $is_monetary}
+      {if $is_pay_later && !$isBillingAddressRequiredForPayLater}
+       <tr>
+        <th {$headerStyle}>
+         {ts}Registered Email{/ts}
+        </th>
+       </tr>
+       <tr>
+        <td colspan="2" {$valueStyle}>
+         {$email}
+        </td>
+       </tr>
+      {elseif $amount GT 0}
+       <tr>
+        <th {$headerStyle}>
+         {ts}Billing Name and Address{/ts}
+        </th>
+       </tr>
+       <tr>
+        <td colspan="2" {$valueStyle}>
+         {$billingName}<br />
+         {$address|nl2br}<br />
+         {$email}
+        </td>
+       </tr>
+      {/if}
+     {/if}
+
+     {if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
+      <tr>
+       <th {$headerStyle}>
+        {ts}Credit Card Information{/ts}
+       </th>
+      </tr>
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {$credit_card_type}<br />
+        {$credit_card_number}<br />
+        {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
+       </td>
+      </tr>
+     {/if}
+
+     {if $selectPremium}
+      <tr>
+       <th {$headerStyle}>
+        {ts}Premium Information{/ts}
+       </th>
+      </tr>
+      <tr>
+       <td colspan="2" {$labelStyle}>
+        {$product_name}
+       </td>
+      </tr>
+      {if $option}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Option{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$option}
+        </td>
+       </tr>
+      {/if}
+      {if $sku}
+       <tr>
+        <td {$labelStyle}>
+         {ts}SKU{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$sku}
+        </td>
+       </tr>
+      {/if}
+      {if $start_date}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Start Date{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$start_date|crmDate}
+        </td>
+       </tr>
+      {/if}
+      {if $end_date}
+       <tr>
+        <td {$labelStyle}>
+         {ts}End Date{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$end_date|crmDate}
+        </td>
+       </tr>
+      {/if}
+      {if $contact_email OR $contact_phone}
+       <tr>
+        <td colspan="2" {$valueStyle}>
+         <p>{ts}For information about this premium, contact:{/ts}</p>
+         {if $contact_email}
+          <p>{$contact_email}</p>
+         {/if}
+         {if $contact_phone}
+          <p>{$contact_phone}</p>
+         {/if}
+        </td>
+       </tr>
+      {/if}
+      {if $is_deductible AND $price}
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          <p>{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}</p>
+         </td>
+        </tr>
+      {/if}
+     {/if}
+
+     {if $customPre}
+      <tr>
+       <th {$headerStyle}>
+        {$customPre_grouptitle}
+       </th>
+      </tr>
+      {foreach from=$customPre item=customValue key=customName}
+       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
+        <tr>
+         <td {$labelStyle}>
+          {$customName}
+         </td>
+         <td {$valueStyle}>
+          {$customValue}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+     {if $customPost}
+      <tr>
+       <th {$headerStyle}>
+        {$customPost_grouptitle}
+       </th>
+      </tr>
+      {foreach from=$customPost item=customValue key=customName}
+       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
+        <tr>
+         <td {$labelStyle}>
+          {$customName}
+         </td>
+         <td {$valueStyle}>
+          {$customValue}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+  </table>
+</center>
+
+</body>
+</html>
diff --git a/CRM/Upgrade/4.6.10.msg_template/message_templates/test_preview_html.tpl b/CRM/Upgrade/4.6.10.msg_template/message_templates/test_preview_html.tpl
new file mode 100644 (file)
index 0000000..131da32
--- /dev/null
@@ -0,0 +1,10 @@
+<center>
+ <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt_test" style="font-family: Arial, Verdana, sans-serif; text-align: left">
+  <tr>
+   <td>
+    <p>{ts}Test-drive Email / Receipt{/ts}</p>
+    <p>{ts}This is a test-drive email. No live financial transaction has occurred.{/ts}</p>
+   </td>
+  </tr>
+ </table>
+</center>
index 701f51d23b24467e662281cdb1e66a6b7f5c39b3..6554f670c7ad9c01ba3bcf02f32727007316c11e 100644 (file)
@@ -8,3 +8,6 @@ WHERE n1.name = 'Support' AND n1.domain_id = {$domainID} AND n2.name = 'Support'
 -- CRM-17384 - re-add sid in case the site admin deleted the new support menu after upgrading to 4.6.9
 UPDATE civicrm_navigation SET url = 'https://civicrm.org/register-your-site?src=iam&sid={ldelim}sid{rdelim}' WHERE name = 'Register your site';
 UPDATE civicrm_navigation SET url = 'https://civicrm.org/become-a-member?src=iam&sid={ldelim}sid{rdelim}' WHERE name = 'Join CiviCRM';
+
+--CRM-17357 PHP fatal error during creation of receipt PDF
+{include file='../CRM/Upgrade/4.6.10.msg_template/civicrm_msg_template.tpl'}
index 537f2557d3900da73219d691594244c5ac06fa7b..ec976ed0e52579cd1878f42907ef7248e132ba8b 100644 (file)
          {ts 1=$cancelSubscriptionUrl}This is a recurring contribution. You can cancel future contributions by <a href="%1">visiting this web page</a>.{/ts}
         </td>
         {if $updateSubscriptionBillingUrl}
-         <tr>
          </tr>
+         <tr>
          <td colspan="2" {$labelStyle}>
           {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
          </td>
         {/if}
-       <tr>
        </tr>
+       <tr>
         <td colspan="2" {$labelStyle}>
          {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
         </td>
index 4134b9e9b457ae4149073be58bd6d6fb3b128f9e..131da32e6e8e9c321fe4e26c5a4d521e027694d8 100644 (file)
@@ -1,5 +1,5 @@
 <center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left">
+ <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt_test" style="font-family: Arial, Verdana, sans-serif; text-align: left">
   <tr>
    <td>
     <p>{ts}Test-drive Email / Receipt{/ts}</p>