From: Eileen McNaughton Date: Thu, 14 May 2015 11:59:02 +0000 (+1200) Subject: CRM-16504 fix recurring option to show on membership renewal X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=186a737c2a94cfb96be6825afe5b44ad283eb0f5;p=civicrm-core.git CRM-16504 fix recurring option to show on membership renewal 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 --- diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 1aa6cd1e0f..fa2b46befb 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -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); } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 8f19fdfc34..b5616c5953 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -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', diff --git a/templates/CRM/Member/Form/Membership.tpl b/templates/CRM/Member/Form/Membership.tpl index 37df7b3056..59f64ef730 100644 --- a/templates/CRM/Member/Form/Membership.tpl +++ b/templates/CRM/Member/Form/Membership.tpl @@ -86,7 +86,10 @@ {$form.contact_id.html} {/if} {if $membershipMode} - {$form.payment_processor_id.label}{$form.payment_processor_id.html} + + {$form.payment_processor_id.label} + {$form.payment_processor_id.html} + {/if} {$form.membership_type_id.label} @@ -148,17 +151,8 @@ {ts}Latest membership period expiration date. End Date will be automatically set based on Membership Type if you don't select a date.{/ts} - {if !empty($form.auto_renew)} - - {$form.auto_renew.label} {help id="id-auto_renew" file="CRM/Member/Form/Membership.hlp" action=$action} - {$form.auto_renew.html} - - {/if} {if !$membershipMode} {$form.is_override.label} {help id="id-status-override"}{$form.is_override.html} - {/if} - - {if ! $membershipMode} {* Show read-only Status block - when action is UPDATE and is_override is FALSE *} {if $action eq 2} @@ -169,45 +163,9 @@ {* Show editable status field when is_override is TRUE *} {$form.status_id.label}{$form.status_id.html}
{ts}If Status Override is checked, the selected status will remain in force (it will NOT be modified by the automated status update script).{/ts} - - {elseif $membershipMode} - - {$form.financial_type_id.label} - {$form.financial_type_id.html}
- {ts}Select the appropriate financial type for this payment.{/ts} - - - {$form.total_amount.label} - {$form.total_amount.html}
- {ts}Membership payment amount.{/ts}
- - - {$form.is_different_contribution_contact.label} - {$form.is_different_contribution_contact.html}  {help id="id-contribution_contact"} - - -   - - - - {*CRM-15366*} - - - - - - - -
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
- - - - - {include file='CRM/Core/BillingBlock.tpl'} - - {/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)} {if $onlinePendingContributionId}{ts}Update Payment Status{/ts}{else}{$form.record_contribution.label}{/if} {$form.record_contribution.html}
@@ -215,71 +173,15 @@
{ts}Membership Payment and Receipt{/ts} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {if $action neq 2 } - - - - - {/if} - - - - -
{$form.is_different_contribution_contact.label}{$form.is_different_contribution_contact.html}  {help id="id-contribution_contact"}
  - - - - - - - - - -
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
-
{$form.financial_type_id.label}{$form.financial_type_id.html}
- {ts}Select the appropriate financial type for this payment.{/ts}
{$form.total_amount.label}{$form.total_amount.html}
- {ts}Membership payment amount. A contribution record will be created for this amount.{/ts}
{$form.receive_date.label}{include file="CRM/common/jcalendar.tpl" elementName=receive_date}
{$form.payment_instrument_id.label} *{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}
{$form.check_number.label}{$form.check_number.html|crmAddClass:six}
{$form.trxn_id.label}{$form.trxn_id.html}
{$form.contribution_status_id.label}{$form.contribution_status_id.html}
-
- - {else} -
- {/if} + {/if} + {include file="CRM/Member/Form/MembershipCommon.tpl"} - {if $emailExists and $outBound_option != 2 } + {if $emailExists and $outBound_option != 2} {$form.send_receipt.label}{$form.send_receipt.html}
{ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1?{/ts} - {elseif $context eq 'standalone' and $outBound_option != 2 } + {elseif $context eq 'standalone' and $outBound_option != 2} {$form.send_receipt.label}{$form.send_receipt.html}
{ts}Automatically email a membership confirmation and receipt to {/ts}? @@ -290,9 +192,9 @@ {$form.from_email_address.html} - {$form.receipt_text_signup.label} + {$form.receipt_text.label} {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} - {$form.receipt_text_signup.html|crmAddClass:huge} + {$form.receipt_text.html|crmAddClass:huge}
@@ -442,7 +344,7 @@ cj('#is_different_contribution_contact').change( function() { setDifferentContactBlock(); }); - + // give option to override end-date for auto-renew memberships {/literal} {if $isRecur && $endDate} @@ -471,7 +373,7 @@ cj('#record-different-contact').hide(); } } - + {/literal} diff --git a/templates/CRM/Member/Form/MembershipCommon.tpl b/templates/CRM/Member/Form/MembershipCommon.tpl new file mode 100644 index 0000000000..39af164a1d --- /dev/null +++ b/templates/CRM/Member/Form/MembershipCommon.tpl @@ -0,0 +1,106 @@ +{if !$membershipMode} + {if $accessContribution} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if $action neq 2 } + + + + + {/if} + + + + +
{$form.is_different_contribution_contact.label}{$form.is_different_contribution_contact.html}  {help id="id-contribution_contact"}
  + + + + + + + + + +
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
+
{$form.total_amount.label}{$form.total_amount.html}
+ {ts}Membership payment amount. A contribution record will be created for this amount.{/ts}
{$form.receive_date.label}{include file="CRM/common/jcalendar.tpl" elementName=receive_date}
{$form.financial_type_id.label}{$form.financial_type_id.html}
+ {ts}Select the appropriate financial type for this payment.{/ts} +
{$form.payment_instrument_id.label}*{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}
{$form.check_number.label}{$form.check_number.html|crmAddClass:six}
{$form.trxn_id.label}{$form.trxn_id.html}
{$form.contribution_status_id.label}{$form.contribution_status_id.html}
+ + {/if} + +{else} + {if !empty($form.auto_renew)} + + {$form.auto_renew.label} {help id="id-auto_renew" file="CRM/Member/Form/Membership.hlp" action=$action} + {$form.auto_renew.html} + + {/if} + + {$form.financial_type_id.label} + {$form.financial_type_id.html}
+ {ts}Select the appropriate financial type for this payment.{/ts} + + + {$form.total_amount.label} + {$form.total_amount.html}
+ {ts}Membership payment amount.{/ts}
+ + + + {$form.is_different_contribution_contact.label} + {$form.is_different_contribution_contact.html}  {help id="id-contribution_contact"} + + +   + + + + {*CRM-15366*} + + + + + + + +
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
+ + + + + {include file='CRM/Core/BillingBlock.tpl'} + + +
+{/if} diff --git a/templates/CRM/Member/Form/MembershipRenewal.tpl b/templates/CRM/Member/Form/MembershipRenewal.tpl index ac3bf9eef9..c373eb4661 100644 --- a/templates/CRM/Member/Form/MembershipRenewal.tpl +++ b/templates/CRM/Member/Form/MembershipRenewal.tpl @@ -93,13 +93,6 @@ {$form.renewal_date.label} {include file="CRM/common/jcalendar.tpl" elementName=renewal_date} - {if $membershipMode} - - {$form.financial_type_id.label} - {$form.financial_type_id.html}
- {ts}Select the appropriate financial type for this payment.{/ts} - - {/if} {if $accessContribution and ! $membershipMode} {$form.record_contribution.label} @@ -127,108 +120,14 @@ class="description">{ts}Extend the membership end date by this many membership periods. Make sure the appropriate corresponding fee is entered below.{/ts} - {if $context neq 'standalone'} - - {$form.contribution_contact.label} - {$form.contribution_contact.html}  {help id="id-contribution_contact"} - - -   - - - - - - - - - - -
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
- - - {/if} - - {$form.financial_type_id.label} - {$form.financial_type_id.html}
- {ts}Select the appropriate financial type for this payment.{/ts} - - - - {$form.total_amount.label} - {$form.total_amount.html}
- {ts}Membership payment amount. A contribution record will be created for this amount.{/ts} - - - - {$form.receive_date.label} - {include file="CRM/common/jcalendar.tpl" elementName=receive_date} - - - {$form.payment_instrument_id.label}* - {$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"} - - - {$form.check_number.label} - {$form.check_number.html|crmAddClass:six} - - - {$form.trxn_id.label} - {$form.trxn_id.html} - - - {$form.contribution_status_id.label} - {$form.contribution_status_id.html} - - - - - - {else} - - {$form.total_amount.label} - {$form.total_amount.html}
- {ts}Membership payment amount. A contribution record will be created for this amount.{/ts} - - {/if} - - {if $membershipMode} - {if $context neq 'standalone'} - - - - - - - - - -
{$form.contribution_contact.label}{$form.contribution_contact.html}  {help id="id-contribution_contact"}
  - - - - - - - - - -
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
-
- {/if} -
- {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} - + @@ -393,13 +292,13 @@ // 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 {
{$form.send_receipt.label} {$form.send_receipt.html}
- {ts 1=$email}Automatically email a membership confirmation and receipt to %1?{/ts} + {ts 1=$emailExists}Automatically email a membership confirmation and receipt to %1?{/ts}