CRM-16504 fix recurring option to show on membership renewal
authorEileen McNaughton <eileen@fuzion.co.nz>
Thu, 14 May 2015 11:59:02 +0000 (23:59 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 14 May 2015 11:59:46 +0000 (23:59 +1200)
This patch also moves a lot of template code that is shared between the backoffice
membership renewal and the backoffice membership receipt. From what I can tell the rest of the
file could pretty much be shared code and I think there is some invoice functionality
missing from renewals as I spotted a case where there was an invoice related class
on the member form but not the renewal (that is now in the shared code)
I also found (& fixed) a situation where the amount shows for people with membership but not contribution
permissions. It is now suppressed like other contribution fields

The next step towards bringing these closer is to use the same email field name on both.

In fact the templates look for either {receipt_test_signup} or {receipt_text_renew} so
it makes sense to just set {receipt_text} - although that involves a change to the msg
template so I don't know how off-putting that is

CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php
templates/CRM/Member/Form/Membership.tpl
templates/CRM/Member/Form/MembershipCommon.tpl [new file with mode: 0644]
templates/CRM/Member/Form/MembershipRenewal.tpl

index 1aa6cd1e0f3392f02aa070487c2fc8d9de36c048..fa2b46befbf30ed1ba6f3c3fa1bf77164d4e70f7 100644 (file)
@@ -177,7 +177,8 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       $this->assign('cdType', TRUE);
       return CRM_Custom_Form_CustomData::preProcess($this);
     }
-
+    // This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
+    $this->assign('formClass', 'membership');
     parent::preProcess();
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
@@ -751,9 +752,8 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
     );
 
-    //CRM-10223 - allow contribution to be recorded against different contact
-    // causes a conflict in standalone mode so skip in standalone for now
     $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
+
     $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
     $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
 
@@ -765,7 +765,7 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
 
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
 
-    $this->add('textarea', 'receipt_text_signup', ts('Receipt Message'));
+    $this->add('textarea', 'receipt_text', ts('Receipt Message'));
 
     // Retrieve the name and email of the contact - this will be the TO for receipt email
     if ($this->_contactID) {
@@ -1688,7 +1688,10 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
     if (!empty($formValues['send_receipt']) && $receiptSend) {
       $formValues['contact_id'] = $this->_contactID;
       $formValues['contribution_id'] = $contributionId;
-
+      // We really don't need a distinct receipt_text_signup vs receipt_text_renewal as they are
+      // handled in the receipt. But by setting one we avoid breaking templates for now
+      // although at some point we should switch in the templates.
+      $formValues['receipt_text_signup'] = $formValues['receipt_text'];
       // send email receipt
       $mailSend = self::emailReceipt($this, $formValues, $membership);
     }
index 8f19fdfc3464d86a8f29ba35f9d4ccc22d532417..b5616c595377eaba748a88d8ee734d3016739f42 100644 (file)
@@ -110,6 +110,8 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
       CRM_Custom_Form_CustomData::preProcess($this);
     }
 
+    // This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
+    $this->assign('formClass', 'membershiprenew');
     parent::preProcess();
     // check for edit permission
     if (!CRM_Core_Permission::check('edit memberships')) {
@@ -425,6 +427,9 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       $this->_contributorEmail
       ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
     $this->assign('email', $this->_contributorEmail);
+    // The member form uses emailExists. Assigning both while we transition / synchronise.
+    $this->assign('emailExists', $this->_contributorEmail);
+
 
     $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
       'mailing_backend'
@@ -439,13 +444,10 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
       }
     }
     $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule'));
-    if ($this->_context != 'standalone') {
-      //CRM-10223 - allow contribution to be recorded against different contact
-      // causes a conflict in standalone mode so skip in standalone for now
-      $this->addElement('checkbox', 'contribution_contact', ts('Record Payment from a Different Contact?'));
-      $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
-      $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
-    }
+    $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different
+      Contact?'));
+    $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
+    $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
   }
 
   /**
@@ -800,12 +802,13 @@ WHERE   id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
         $this->assign('isAmountzero', 0);
         $this->assign('is_pay_later', 0);
         $this->assign('isPrimary', 1);
+        $this->assign(['receipt_text_renewal'], $this->_params['receipt_text']);
         if ($this->_mode == 'test') {
           $this->assign('action', '1024');
         }
       }
 
-      list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
+      list($mailSend) = CRM_Core_BAO_MessageTemplate::sendTemplate(
         array(
           'groupName' => 'msg_tpl_workflow_membership',
           'valueName' => 'membership_offline_receipt',
index 37df7b3056aa0a20a7666b8dae3a1b5314addaf6..59f64ef730cc0f7f98283d81b584dc3f73575eee 100644 (file)
           <td>{$form.contact_id.html}</td>
         {/if}
         {if $membershipMode}
-          <tr><td class="label">{$form.payment_processor_id.label}</td><td>{$form.payment_processor_id.html}</td></tr>
+          <tr>
+            <td class="label">{$form.payment_processor_id.label}</td>
+            <td>{$form.payment_processor_id.html}</td>
+          </tr>
         {/if}
         <tr class="crm-membership-form-block-membership_type_id">
           <td class="label">{$form.membership_type_id.label}</td>
             <span class="description">{ts}Latest membership period expiration date. End Date will be automatically set based on Membership Type if you don't select a date.{/ts}</span>
           </td>
         </tr>
-        {if !empty($form.auto_renew)}
-          <tr id="autoRenew" class="crm-membership-form-block-auto_renew">
-            <td class="label"> {$form.auto_renew.label} {help id="id-auto_renew" file="CRM/Member/Form/Membership.hlp" action=$action} </td>
-            <td> {$form.auto_renew.html} </td>
-          </tr>
-        {/if}
         {if !$membershipMode}
           <tr><td class="label">{$form.is_override.label} {help id="id-status-override"}</td><td>{$form.is_override.html}</td></tr>
-        {/if}
-
-        {if ! $membershipMode}
           {* Show read-only Status block - when action is UPDATE and is_override is FALSE *}
           <tr id="memberStatus_show">
             {if $action eq 2}
           {* Show editable status field when is_override is TRUE *}
           <tr id="memberStatus"><td class="label">{$form.status_id.label}</td><td>{$form.status_id.html}<br />
             <span class="description">{ts}If <strong>Status Override</strong> is checked, the selected status will remain in force (it will NOT be modified by the automated status update script).{/ts}</span></td></tr>
-
-          {elseif $membershipMode}
-          <tr class="crm-membership-form-block-financial_type_id-mode">
-            <td class="label">{$form.financial_type_id.label}</td>
-            <td>{$form.financial_type_id.html}<br />
-              <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
-          </tr>
-          <tr class="crm-membership-form-block-total_amount">
-            <td class="label">{$form.total_amount.label}</td>
-            <td>{$form.total_amount.html}<br />
-              <span class="description">{ts}Membership payment amount.{/ts}</span><div class="totaltaxAmount"></div></td>
-          </tr>
-          <tr class="crm-membership-form-block-contribution-contact">
-            <td class="label">{$form.is_different_contribution_contact.label}</td>
-            <td>{$form.is_different_contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
-          </tr>
-          <tr id="record-different-contact">
-            <td>&nbsp;</td>
-            <td>
-              <table class="compressed">
-                <tr class="crm-membership-form-block-soft-credit-type">
-                {*CRM-15366*}
-                  <td class="label">{$form.soft_credit_type_id.label}</td>
-                  <td>{$form.soft_credit_type_id.html}</td>
-                </tr>
-                <tr class="crm-membership-form-block-soft-credit-contact-id">
-                  <td class="label">{$form.soft_credit_contact_id.label}</td>
-                  <td>{$form.soft_credit_contact_id.html}</td>
-                </tr>
-              </table>
-            </td>
-          </tr>
-          <tr class="crm-membership-form-block-billing">
-            <td colspan="2">
-            {include file='CRM/Core/BillingBlock.tpl'}
-            </td>
-          </tr>
         {/if}
-        {if $accessContribution and ! $membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
+
+        {if $accessContribution and !$membershipMode AND ($action neq 2 or (!$rows.0.contribution_id AND !$softCredit) or $onlinePendingContributionId)}
           <tr id="contri">
             <td class="label">{if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if}</td>
             <td>{$form.record_contribution.html}<br />
           </tr>
           <tr class="crm-membership-form-block-record_contribution"><td colspan="2">
             <fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
-              <table>
-                <tr class="crm-membership-form-block-contribution-contact">
-                  <td class="label">{$form.is_different_contribution_contact.label}</td>
-                  <td>{$form.is_different_contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
-                </tr>
-                <tr id="record-different-contact">
-                  <td>&nbsp;</td>
-                  <td>
-                    <table class="compressed">
-                      <tr class="crm-membership-form-block-soft-credit-type">
-                        <td class="label">{$form.soft_credit_type_id.label}</td>
-                        <td>{$form.soft_credit_type_id.html}</td>
-                      </tr>
-                      <tr class="crm-membership-form-block-soft-credit-contact-id">
-                        <td class="label">{$form.soft_credit_contact_id.label}</td>
-                        <td>{$form.soft_credit_contact_id.html}</td>
-                      </tr>
-                    </table>
-                  </td>
-                </tr>
-                  <tr class="crm-membership-form-block-financial_type_id">
-                      <td class="label">{$form.financial_type_id.label}</td>
-                      <td>{$form.financial_type_id.html}<br />
-                      <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
-                </tr>
-                <tr class="crm-membership-form-block-total_amount">
-                  <td class="label">{$form.total_amount.label}</td>
-                  <td>{$form.total_amount.html}<br />
-                    <span class="description">{ts}Membership payment amount. A contribution record will be created for this amount.{/ts}</span><div class="totaltaxAmount"></div></td>
-                </tr>
-                <tr class="crm-membership-form-block-receive_date">
-                  <td class="label">{$form.receive_date.label}</td>
-                  <td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
-                </tr>
-                <tr class="crm-membership-form-block-payment_instrument_id">
-                  <td class="label">{$form.payment_instrument_id.label}<span class="marker"> *</span></td>
-                  <td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td>
-                </tr>
-                <tr id="checkNumber" class="crm-membership-form-block-check_number">
-                  <td class="label">{$form.check_number.label}</td>
-                  <td>{$form.check_number.html|crmAddClass:six}</td>
-                </tr>
-                {if $action neq 2 }
-                  <tr class="crm-membership-form-block-trxn_id">
-                    <td class="label">{$form.trxn_id.label}</td>
-                    <td>{$form.trxn_id.html}</td>
-                  </tr>
-                {/if}
-                <tr class="crm-membership-form-block-contribution_status_id">
-                  <td class="label">{$form.contribution_status_id.label}</td>
-                  <td>{$form.contribution_status_id.html}</td>
-                </tr>
-              </table>
-            </fieldset>
-          </td></tr>
-          {else}
-          <div class="spacer"></div>
-        {/if}
+         {/if}
+        {include file="CRM/Member/Form/MembershipCommon.tpl"}
 
-        {if $emailExists and $outBound_option != 2 }
+        {if $emailExists and $outBound_option != 2}
           <tr id="send-receipt" class="crm-membership-form-block-send_receipt">
             <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
             <span class="description">{ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1?{/ts}</span></td>
           </tr>
-          {elseif $context eq 'standalone' and $outBound_option != 2 }
+          {elseif $context eq 'standalone' and $outBound_option != 2}
           <tr id="email-receipt" style="display:none;">
             <td class="label">{$form.send_receipt.label}</td><td>{$form.send_receipt.html}<br />
             <span class="description">{ts}Automatically email a membership confirmation and receipt to {/ts}<span id="email-address"></span>?</span></td>
           <td>{$form.from_email_address.html}</td>
         </tr>
         <tr id='notice' style="display:none;">
-          <td class="label">{$form.receipt_text_signup.label}</td>
+          <td class="label">{$form.receipt_text.label}</td>
           <td class="html-adjust"><span class="description">{ts}If you need to include a special message for this member, enter it here. Otherwise, the confirmation email will include the standard receipt message configured under System Message Templates.{/ts}</span>
-            {$form.receipt_text_signup.html|crmAddClass:huge}</td>
+            {$form.receipt_text.html|crmAddClass:huge}</td>
         </tr>
       </table>
       <div id="customData"></div>
       cj('#is_different_contribution_contact').change( function() {
         setDifferentContactBlock();
       });
-      
+
       // give option to override end-date for auto-renew memberships
       {/literal}
       {if $isRecur && $endDate}
         cj('#record-different-contact').hide();
       }
     }
-    
+
     </script>
     {/literal}
 
diff --git a/templates/CRM/Member/Form/MembershipCommon.tpl b/templates/CRM/Member/Form/MembershipCommon.tpl
new file mode 100644 (file)
index 0000000..39af164
--- /dev/null
@@ -0,0 +1,106 @@
+{if !$membershipMode}
+  {if $accessContribution}
+    <table>
+      <tr class="crm-{$formClass}-form-block-contribution-contact">
+        <td class="label">{$form.is_different_contribution_contact.label}</td>
+        <td>{$form.is_different_contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
+      </tr>
+      <tr id="record-different-contact">
+        <td>&nbsp;</td>
+        <td>
+          <table class="compressed">
+            <tr class="crm-{$formClass}-form-block-soft-credit-type">
+              <td class="label">{$form.soft_credit_type_id.label}</td>
+              <td>{$form.soft_credit_type_id.html}</td>
+            </tr>
+            <tr class="crm-{$formClass}-form-block-soft-credit-contact-id">
+              <td class="label">{$form.soft_credit_contact_id.label}</td>
+              <td>{$form.soft_credit_contact_id.html}</td>
+            </tr>
+          </table>
+        </td>
+      </tr>
+
+        <tr class="crm-{$formClass}-form-block-total_amount">
+          <td class="label">{$form.total_amount.label}</td>
+          <td>{$form.total_amount.html}<br />
+            <span class="description">{ts}Membership payment amount. A contribution record will be created for this amount.{/ts}</span><div class="totaltaxAmount"></div></td>
+        </tr>
+        <tr class="crm-{$formClass}-form-block-receive_date">
+          <td class="label">{$form.receive_date.label}</td>
+          <td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
+        </tr>
+        <tr class="crm-{$formClass}-form-block-financial_type_id">
+          <td class="label">{$form.financial_type_id.label}</td>
+          <td>{$form.financial_type_id.html}<br/>
+            <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span>
+          </td>
+        </tr>
+        <tr class="crm-{$formClass}-form-block-payment_instrument_id">
+          <td class="label">{$form.payment_instrument_id.label}<span class='marker'>*</span></td>
+          <td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td>
+        </tr>
+        <tr id="checkNumber" class="crm-{$formClass}-form-block-check_number">
+          <td class="label">{$form.check_number.label}</td>
+          <td>{$form.check_number.html|crmAddClass:six}</td>
+        </tr>
+
+        {if $action neq 2 }
+          <tr class="crm-{$formClass}-form-block-trxn_id">
+            <td class="label">{$form.trxn_id.label}</td>
+            <td>{$form.trxn_id.html}</td>
+          </tr>
+        {/if}
+        <tr class="crm-{$formClass}-form-block-contribution_status_id">
+          <td class="label">{$form.contribution_status_id.label}</td>
+          <td>{$form.contribution_status_id.html}</td>
+        </tr>
+      </table>
+    </fieldset></td></tr>
+  {/if}
+
+{else}
+  {if !empty($form.auto_renew)}
+    <tr id="autoRenew" class="crm-{$formClass}-form-block-auto_renew">
+      <td class="label"> {$form.auto_renew.label} {help id="id-auto_renew" file="CRM/Member/Form/Membership.hlp" action=$action} </td>
+      <td> {$form.auto_renew.html} </td>
+    </tr>
+  {/if}
+  <tr class="crm-member-{$formClass}-form-block-financial_type_id">
+    <td class="label">{$form.financial_type_id.label}</td>
+    <td>{$form.financial_type_id.html}<br/>
+      <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
+  </tr>
+  <tr class="crm-{$formClass}-form-block-total_amount">
+    <td class="label">{$form.total_amount.label}</td>
+    <td>{$form.total_amount.html}<br />
+      <span class="description">{ts}Membership payment amount.{/ts}</span><div class="totaltaxAmount"></div>
+    </td>
+  </tr>
+  <tr class="crm-membership-form-block-contribution-contact">
+    <td class="label">{$form.is_different_contribution_contact.label}</td>
+    <td>{$form.is_different_contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
+  </tr>
+  <tr id="record-different-contact">
+    <td>&nbsp;</td>
+    <td>
+      <table class="compressed">
+        <tr class="crm-membership-form-block-soft-credit-type">
+          {*CRM-15366*}
+          <td class="label">{$form.soft_credit_type_id.label}</td>
+          <td>{$form.soft_credit_type_id.html}</td>
+        </tr>
+        <tr class="crm-membership-form-block-soft-credit-contact-id">
+          <td class="label">{$form.soft_credit_contact_id.label}</td>
+          <td>{$form.soft_credit_contact_id.html}</td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr class="crm-membership-form-block-billing">
+    <td colspan="2">
+      {include file='CRM/Core/BillingBlock.tpl'}
+    </td>
+  </tr>
+  <div class="spacer"></div>
+{/if}
index ac3bf9eef9aae1e9da2405956efcb6f5ee4cb00f..c373eb4661a46fd22ac61d57635aa6bb7bab1d52 100644 (file)
         <td class="label">{$form.renewal_date.label}</td>
         <td>{include file="CRM/common/jcalendar.tpl" elementName=renewal_date}</td>
       </tr>
-      {if $membershipMode}
-        <tr class="crm-member-membershiprenew-form-block-financial_type_id">
-          <td class="label">{$form.financial_type_id.label}</td>
-          <td>{$form.financial_type_id.html}<br/>
-            <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
-        </tr>
-      {/if}
       {if $accessContribution and ! $membershipMode}
         <tr class="crm-member-membershiprenew-form-block-record_contribution">
           <td class="label">{$form.record_contribution.label}</td>
                       class="description">{ts}Extend the membership end date by this many membership periods. Make sure the appropriate corresponding fee is entered below.{/ts}</span>
                   </td>
                 </tr>
-                {if $context neq 'standalone'}
-                  <tr class="crm-membership-form-block-contribution-contact">
-                    <td class="label">{$form.contribution_contact.label}</td>
-                    <td>{$form.contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
-                  </tr>
-                  <tr id="record-different-contact">
-                    <td>&nbsp;</td>
-                    <td>
-                      <table class="compressed">
-                        <tr class="crm-membership-form-block-soft-credit-type">
-                          <td class="label">{$form.soft_credit_type_id.label}</td>
-                          <td>{$form.soft_credit_type_id.html}</td>
-                        </tr>
-                        <tr class="crm-membership-form-block-soft-credit-contact-id">
-                          <td class="label">{$form.soft_credit_contact_id.label}</td>
-                          <td>{$form.soft_credit_contact_id.html}</td>
-                        </tr>
-                      </table>
-                    </td>
-                  </tr>
-                {/if}
-                <tr class="crm-member-membershiprenew-form-block-financial_type_id">
-                  <td class="label">{$form.financial_type_id.label}</td>
-                  <td>{$form.financial_type_id.html}<br/>
-                    <span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span>
-                  </td>
-                </tr>
-                <tr class="crm-member-membershiprenew-form-block-total_amount">
-                  <td class="label">{$form.total_amount.label}</td>
-                  <td>{$form.total_amount.html}<br/>
-                    <span
-                      class="description">{ts}Membership payment amount. A contribution record will be created for this amount.{/ts}</span>
-                  </td>
-                </tr>
-                <tr class="crm-membershiprenew-form-block-receive_date">
-                  <td class="label">{$form.receive_date.label}</td>
-                  <td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
-                </tr>
-                <tr class="crm-member-membershiprenew-form-block-payment_instrument_id">
-                  <td class="label">{$form.payment_instrument_id.label}<span class='marker'>*</span></td>
-                  <td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td>
-                </tr>
-                <tr id="checkNumber" class="crm-member-membershiprenew-form-block-check_number">
-                  <td class="label">{$form.check_number.label}</td>
-                  <td>{$form.check_number.html|crmAddClass:six}</td>
-                </tr>
-                <tr class="crm-member-membershiprenew-form-block-trxn_id">
-                  <td class="label">{$form.trxn_id.label}</td>
-                  <td>{$form.trxn_id.html}</td>
-                </tr>
-                <tr class="crm-member-membershiprenew-form-block-contribution_status_id">
-                  <td class="label">{$form.contribution_status_id.label}</td>
-                  <td>{$form.contribution_status_id.html}</td>
-                </tr>
-              </table>
-            </fieldset>
-          </td>
-        </tr>
-      {else}
-        <tr class="crm-member-membershiprenew-form-block-total_amount">
-          <td class="label">{$form.total_amount.label}</td>
-          <td>{$form.total_amount.html}<br/>
-            <span
-              class="description">{ts}Membership payment amount. A contribution record will be created for this amount.{/ts}</span>
-          </td>
-        </tr>
       {/if}
-    </table>
-    {if $membershipMode}
-      {if $context neq 'standalone'}
-        <table class="form-layout-compressed">
-          <tr class="crm-membership-form-block-contribution-contact">
-            <td class="label">{$form.contribution_contact.label}</td>
-            <td>{$form.contribution_contact.html}&nbsp;&nbsp;{help id="id-contribution_contact"}</td>
-          </tr>
-          <tr id="record-different-contact">
-            <td>&nbsp;</td>
-            <td>
-              <table class="form-layout-compressed">
-                <tr class="crm-membership-form-block-soft-credit-type">
-                  <td class="label">{$form.soft_credit_type_id.label}</td>
-                  <td>{$form.soft_credit_type_id.html}</td>
-                </tr>
-                <tr class="crm-membership-form-soft-credit-contact-id">
-                  <td class="label">{$form.soft_credit_contact_id.label}</td>
-                  <td>{$form.soft_credit_contact_id.html}</td>
-                </tr>
-              </table>
-            </td>
-          </tr>
-        </table>
-      {/if}
-      <div class="spacer"></div>
-      {include file='CRM/Core/BillingBlock.tpl'}
-    {/if}
-    {if $email and $outBound_option != 2}
+      {include file="CRM/Member/Form/MembershipCommon.tpl"}
+      {if $emailExists and $outBound_option != 2}
       <table class="form-layout">
-        <tr class="crm-member-membershiprenew-form-block-send_receipt">
+        <tr class="crm-{$formClass}-form-block-send_receipt">
           <td class="label">{$form.send_receipt.label}</td>
           <td>{$form.send_receipt.html}<br/>
-            <span
-              class="description">{ts 1=$email}Automatically email a membership confirmation and receipt to %1?{/ts}</span>
+            <span class="description">{ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1?{/ts}</span>
           </td>
         </tr>
         <tr id="fromEmail">
 
     // show/hide different contact section
     setDifferentContactBlock();
-    cj('#contribution_contact').change(function () {
+    cj('#is_different_contribution_contact').change(function () {
       setDifferentContactBlock();
     });
 
     function setDifferentContactBlock() {
       //get the
-      if (cj('#contribution_contact').prop('checked')) {
+      if (cj('#is_different_contribution_contact').prop('checked')) {
         cj('#record-different-contact').show();
       }
       else {