From 4c7aa1f73bc8be9bbb1ededd6229b029c27200a0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 16 Feb 2014 21:31:44 -0800 Subject: [PATCH] CRM-13929 Refactor membership forms --- CRM/Member/Form.php | 12 ++++++------ CRM/Member/Form/Membership.php | 12 +++--------- CRM/Member/Form/MembershipRenewal.php | 6 ++---- templates/CRM/Member/Form/Membership.tpl | 19 +++++++++++-------- .../CRM/Member/Form/MembershipRenewal.tpl | 18 ++++++++++-------- xml/schema/Contribute/ContributionSoft.xml | 2 +- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 81c9835040..a0cdb0de9c 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -168,13 +168,13 @@ class CRM_Member_Form extends CRM_Core_Form { * then they weill differ * * @param $formValues array values from form. The important values we are looking for are - * - contact_select_id[1] - * - contribution_contact_select_id[1] + * - contact_id + * - soft_credit_contact_id */ function storeContactFields($formValues){ // in a 'standalone form' (contact id not in the url) the contact will be in the form values - if (!empty($formValues['contact_select_id'])) { - $this->_contactID = $formValues['contact_select_id'][1]; + if (!empty($formValues['contact_id'])) { + $this->_contactID = $formValues['contact_id']; } list($this->_memberDisplayName, @@ -183,8 +183,8 @@ class CRM_Member_Form extends CRM_Core_Form { //CRM-10375 Where the payer differs to the member the payer should get the email. // here we store details in order to do that - if (!empty($formValues['contribution_contact_select_id']) && !empty($formValues['contribution_contact_select_id']['1'])) { - $this->_receiptContactId = $this->_contributorContactID = $formValues['contribution_contact_select_id'][1]; + if (!empty($formValues['soft_credit_contact_id'])) { + $this->_receiptContactId = $this->_contributorContactID = $formValues['soft_credit_contact_id']; list( $this->_contributorDisplayName, $this->_contributorEmail ) = CRM_Contact_BAO_Contact_Location::getEmailDetails( $this->_contributorContactID ); } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 96b64b1736..22e350e1b2 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -546,7 +546,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } if ($this->_context == 'standalone') { - CRM_Contact_Form_NewContact::buildQuickForm($this); + $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE), TRUE); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); @@ -771,9 +771,8 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; //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->add('select', 'soft_credit_type_id', ts('Membership payment is : '), - array('' => ts('- Select - ')) + CRM_Core_OptionGroup::values("soft_credit_type", FALSE)); - CRM_Contact_Form_NewContact::buildQuickForm($this, 1, NULL, FALSE, 'contribution_'); + $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', @@ -914,11 +913,6 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } } - //check if contact is selected in standalone mode - if (isset($params['contact_select_id'][1]) && !$params['contact_select_id'][1]) { - $errors['contact[1]'] = ts('Please select a contact or create new contact'); - } - if (!empty($errors)) { return $errors; } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index c6bb45caf0..2449a80ab2 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -515,10 +515,8 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; //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->add('select', 'soft_credit_type_id', ts('Membership payment is : '), - array('' => ts('- Select - ')) + CRM_Core_OptionGroup::values("soft_credit_type", FALSE)); - require_once 'CRM/Contact/Form/NewContact.php'; - CRM_Contact_Form_NewContact::buildQuickForm($this,1, null, false,'contribution_'); + $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft')); + $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE)); } } diff --git a/templates/CRM/Member/Form/Membership.tpl b/templates/CRM/Member/Form/Membership.tpl index a02eb03e4a..80c8161a2e 100644 --- a/templates/CRM/Member/Form/Membership.tpl +++ b/templates/CRM/Member/Form/Membership.tpl @@ -84,11 +84,12 @@ {ts}Member{/ts}{$displayName} - {else} + {else} {if !$membershipMode and !$emailExists and $outBound_option != 2} {assign var='profileCreateCallback' value=1 } {/if} - {include file="CRM/Contact/Form/NewContact.tpl"} + {$form.contact_id.label} + {$form.contact_id.html} {/if} {if $membershipMode} {$form.payment_processor_id.label}{$form.payment_processor_id.html} @@ -183,12 +184,13 @@   - + - - {include file="CRM/Contact/Form/NewContact.tpl"} + + +
{$form.soft_credit_type.label} {$form.soft_credit_type.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
@@ -217,12 +219,13 @@   - + - - {include file="CRM/Contact/Form/NewContact.tpl"} + + +
{$form.soft_credit_type_id.label} {$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
diff --git a/templates/CRM/Member/Form/MembershipRenewal.tpl b/templates/CRM/Member/Form/MembershipRenewal.tpl index b3da8fc1d5..db321c931a 100644 --- a/templates/CRM/Member/Form/MembershipRenewal.tpl +++ b/templates/CRM/Member/Form/MembershipRenewal.tpl @@ -137,12 +137,13 @@   - + - - {include file="CRM/Contact/Form/NewContact.tpl"} + + +
{$form.soft_credit_type_id.label} {$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
@@ -206,12 +207,13 @@   - - - + + + - - {include file="CRM/Contact/Form/NewContact.tpl"} + + +
{$form.honor_type_id.label}{$form.honor_type_id.html}
{$form.soft_credit_type_id.label}{$form.soft_credit_type_id.html}
{$form.soft_credit_contact_id.label}{$form.soft_credit_contact_id.html}
diff --git a/xml/schema/Contribute/ContributionSoft.xml b/xml/schema/Contribute/ContributionSoft.xml index 22dba59d50..4659004995 100644 --- a/xml/schema/Contribute/ContributionSoft.xml +++ b/xml/schema/Contribute/ContributionSoft.xml @@ -123,7 +123,7 @@ soft_credit_type_id int unsigned NULL - Soft Credit Type ID + Soft Credit Type soft_credit_type -- 2.25.1