CRM-13929 Refactor membership forms
authorColeman Watts <coleman@civicrm.org>
Mon, 17 Feb 2014 05:31:44 +0000 (21:31 -0800)
committerColeman Watts <coleman@civicrm.org>
Mon, 17 Feb 2014 23:59:24 +0000 (15:59 -0800)
CRM/Member/Form.php
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php
templates/CRM/Member/Form/Membership.tpl
templates/CRM/Member/Form/MembershipRenewal.tpl
xml/schema/Contribute/ContributionSoft.xml

index 81c983504066f89fa409755aced11bea530d472d..a0cdb0de9c6604e27706ccf98ab37dd1aa4d63f0 100644 (file)
@@ -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 );
     }
index 96b64b17360081e336ad30d847450cf62769fdb1..22e350e1b25b7094984052a2bc427cb82a4e8f3f 100644 (file)
@@ -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;
     }
index c6bb45caf009cb20c8a875a5f6998771815a7721..2449a80ab2cc50d414f7ee6c528437a033c1e3b0 100644 (file)
@@ -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));
   }
     }
 
index a02eb03e4ab36b1686075cf5604ec302e0f9f2ff..80c8161a2e0aca94b94ee93164c907bc14b9a7e9 100644 (file)
           <tr>
             <td class="font-size12pt label"><strong>{ts}Member{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
           </tr>
-          {else}
+        {else}
           {if !$membershipMode and !$emailExists and $outBound_option != 2}
             {assign var='profileCreateCallback' value=1 }
           {/if}
-        {include file="CRM/Contact/Form/NewContact.tpl"}
+          <td class="label">{$form.contact_id.label}</td>
+          <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>
               <td>&nbsp;</td>
               <td>
                 <table class="compressed">
-                  <tr class="crm-membership-form-block-honor-type">
+                  <tr class="crm-membership-form-block-soft-credit-type">
                     <td class="label">{$form.soft_credit_type.label}</td>
                     <td>{$form.soft_credit_type.html}</td>
                   </tr>
-                  <tr id ='contributionContact' class="crm-membership-form-block-contribution-type">
-                  {include file="CRM/Contact/Form/NewContact.tpl"}
+                  <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>
                   <td>&nbsp;</td>
                   <td>
                     <table class="compressed">
-                      <tr class="crm-membership-form-block-honor-type">
+                      <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 id ='contributionContact' class="crm-membership-form-block-contribution-type">
-                      {include file="CRM/Contact/Form/NewContact.tpl"}
+                      <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>
index b3da8fc1d55746b317ff5fc5ed6e03de1092e689..db321c931a5e66e9731ae251783a955cd3045e19 100644 (file)
                     <td>&nbsp;</td>
                     <td>
                       <table class="compressed">
-                        <tr class="crm-membership-form-block-honor-type">
+                        <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 id='contributionContact' class="crm-membership-form-block-contribution-type">
-                          {include file="CRM/Contact/Form/NewContact.tpl"}
+                        <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>
             <td>&nbsp;</td>
             <td>
               <table class="form-layout-compressed">
-                <tr class="crm-membership-form-block-honor-type">
-                  <td class="label">{$form.honor_type_id.label}</td>
-                  <td>{$form.honor_type_id.html}</td>
+                <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 id='contributionContact' class="crm-membership-form-block-contribution-type">
-                  {include file="CRM/Contact/Form/NewContact.tpl"}
+                <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>
index 22dba59d50cc5cc76e763d2c657378aefb7f0c00..46590049957a7a98df2c592997dd24b4ea5149ad 100644 (file)
        <name>soft_credit_type_id</name>
        <type>int unsigned</type>
        <default>NULL</default>
-       <title>Soft Credit Type ID</title>
+       <title>Soft Credit Type</title>
        <pseudoconstant>
          <optionGroupName>soft_credit_type</optionGroupName>
        </pseudoconstant>