Fix membershipType options lookup and display
authorColeman Watts <coleman@civicrm.org>
Fri, 2 Jan 2015 01:34:08 +0000 (20:34 -0500)
committerColeman Watts <coleman@civicrm.org>
Fri, 2 Jan 2015 21:38:51 +0000 (16:38 -0500)
CRM/Core/SelectValues.php
CRM/Member/Form/MembershipRenewal.php
CRM/Member/Form/MembershipType.php
CRM/Member/Page/AJAX.php
CRM/Member/Page/MembershipType.php
xml/schema/Member/MembershipType.xml

index fbbb1e2b62077a8b2bcc78e48d7bd916233ed8ec..1d8812ba1ce011457a06c13d4d45993b544a2048 100644 (file)
@@ -135,6 +135,18 @@ class CRM_Core_SelectValues {
     );
   }
 
+  /**
+   * Member auto-renew options
+   * @static
+   */
+  public static function memberAutoRenew() {
+    return array(
+      ts('No auto-renew option'),
+      ts('Give option, but not required'),
+      ts('Auto-renew required')
+    );
+  }
+
   /**
    * Various pre defined event dates
    * @static
index 8036c86772e37bc00417c7898ca01322daf8d10b..5537c55b397f999c522e4110b2556b00d42707a2 100644 (file)
@@ -266,7 +266,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     $allMembershipInfo = $membershipType = array();
 
     // auto renew options if enabled for the membership
-    $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
+    $options = CRM_Core_SelectValues::memberAutoRenew();
 
     foreach( $allMemberships as $key => $values ) {
       if (!empty($values['is_active'])) {
index 1e8a6dee72d8feca7ba20216932c7324886b0f4e..97ff8248d6a356cbb8e7764afc23b79a8b5d078b 100644 (file)
@@ -155,7 +155,7 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig {
     $options           = array();
     if (is_array($paymentProcessor) && !empty($paymentProcessor)) {
       $isAuthorize = TRUE;
-      $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
+      $options = CRM_Core_SelectValues::memberAutoRenew();
     }
 
     $this->addRadio('auto_renew', ts('Auto-renew Option'), $options);
index fb349373e8d818e510c1dd056cb87493e056744d..15b9bb002de377f1c184c8a6deb29b6f02f6c02e 100644 (file)
@@ -65,7 +65,7 @@ WHERE   id = %1";
     $details['total_amount_numeric'] = $details['total_amount'];
     // fix the display of the monetary value, CRM-4038
     $details['total_amount'] = CRM_Utils_Money::format($details['total_amount'], NULL, '%a');
-    $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
+    $options = CRM_Core_SelectValues::memberAutoRenew();
     $details['auto_renew'] = CRM_Utils_Array::value('auto_renew', $options[$details]);
     CRM_Utils_JSON::output($details);
   }
index 2b54fe0d347dbe6248808d191c1c4b76b4ce80eb..ef739c853316ed4dcb0052cd5ca77acf84ef2960 100644 (file)
@@ -115,11 +115,13 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page {
     $dao->orderBy('weight');
     $dao->find();
 
-
     while ($dao->fetch()) {
       $membershipType[$dao->id] = array();
       CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]);
 
+      $membershipType[$dao->id]['period_type'] = CRM_Utils_Array::value($dao->period_type, CRM_Core_SelectValues::periodType(), '');
+      $membershipType[$dao->id]['visibility'] = CRM_Utils_Array::value($dao->visibility, CRM_Core_SelectValues::memberVisibility(), '');
+
       //adding column for relationship type label. CRM-4178.
       if ($dao->relationship_type_id) {
         //If membership associated with 2 or more relationship then display all relationship with comma separated
index a076d0ebbc982d289ad3f8b64ec543824268fc9e..e1cca9d096b1ab0458b52a0a9c3ff2e53894455b 100644 (file)
     <name>auto_renew</name>
     <type>boolean</type>
     <default>0</default>
+    <pseudoconstant>
+      <callback>CRM_Core_SelectValues::memberAutoRenew</callback>
+    </pseudoconstant>
     <comment>0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;</comment>
     <add>3.3</add>
   </field>