CRM-15066 fix - Choose to cancel one recurring contribution plan, but Civi cancels...
authormonishdeb <monish.deb@webaccessglobal.com>
Fri, 8 Aug 2014 14:46:43 +0000 (20:16 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Fri, 8 Aug 2014 14:46:43 +0000 (20:16 +0530)
https://issues.civicrm.org/jira/browse/CRM-15066

CRM/Contribute/BAO/ContributionRecur.php
api/v3/ContributionRecur.php
js/jquery/jquery.crmeditable.js
templates/CRM/Contribute/Page/ContributionRecur.tpl
templates/CRM/common/enableDisableApi.tpl

index 3a2e828003a19c4d8fdef1771638dffdc556bc8f..c9a1feca184b1250ee888c7af579b9bd83d7e2ee 100644 (file)
@@ -361,22 +361,6 @@ SELECT r.payment_processor_id
     return $params;
   }
 
-  /**
-   * update the is_active flag in the db
-   *
-   * @param int      $id        id of the database record
-   * @param boolean  $is_active value we want to set the is_active field
-   *
-   * @return Object             DAO object on success, null otherwise
-   * @static
-   */
-  static function setIsActive($id, $is_active) {
-    if (!$is_active) {
-      return self::cancelRecurContribution($id, CRM_Core_DAO::$_nullObject);
-    }
-    return FALSE;
-  }
-
   /**
    * @param $entityID
    * @param string $entity
@@ -477,4 +461,3 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
     }
   }
 }
-
index 3eda5882eea522eb02323e42119629364cab3bfb..ae5f7a21cc10e13683307046a1860629b6e51580 100644 (file)
@@ -76,6 +76,19 @@ function civicrm_api3_contribution_recur_get($params) {
   return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
+/**
+ * Cancel a recurring contribution of existing contribution_recur.id
+ *
+ * @param array    $params (reference) array containing id of the recurring contribution
+ *
+ * @return boolean  returns true is successfully cancelled
+ */
+
+function civicrm_api3_contribution_recur_cancel($params) {
+  civicrm_api3_verify_one_mandatory($params, NULL, array('id'));
+  return call_user_func_array(array(_civicrm_api3_get_BAO(__FUNCTION__), 'cancelRecurContribution'), array($params['id'], CRM_Core_DAO::$_nullObject));
+}
+
 /**
  * delete an existing contribution_recur
  *
@@ -93,4 +106,3 @@ function civicrm_api3_contribution_recur_get($params) {
 function civicrm_api3_contribution_recur_delete($params) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
-
index b581ec4adc641e58fe311aae56441cfeb7e28d4f..0fa6da5f9acdc58f5c731cbd2a30773630ba872d 100644 (file)
       el = this[0],
       ret = {},
       $row = this.first().closest('.crm-entity');
-    ret.entity = $row.data('entity') || $row[0].id.split('-')[0];
-    ret.id = $row.data('id') || $row[0].id.split('-')[1];
+      ret.entity = $row.data('entity') || $row[0].id.split('-')[0];
+      ret.id = $row.data('id') || $row[0].id.split('-')[1];
+      ret.action = $row.data('entity-action') || $row[0].id.split('-')[2] || 'setvalue';
+
     if (!ret.entity || !ret.id) {
       return false;
     }
index fd5be220e08822eac6460273a2479374d27007e4..dc538eff90f06a0b61811b36a165464580c291d1 100644 (file)
@@ -69,7 +69,7 @@
 
         {foreach from=$recurRows item=row}
             {assign var=id value=$row.id}
-            <tr id="contribution_recur-{$row.id}" class="crm-entity {cycle values="even-row,odd-row"}{if NOT $row.is_active} disabled{/if}">
+            <tr id="contribution_recur-{$row.id}-cancel" class="crm-entity {cycle values="even-row,odd-row"}{if NOT $row.is_active} disabled{/if}">
                 <td>{$row.amount|crmMoney}{if $row.is_test} ({ts}test{/ts}){/if}</td>
                 <td>{ts}Every{/ts} {$row.frequency_interval} {$row.frequency_unit} </td>
                 <td>{$row.start_date|crmDate}</td>
index 83a9964c39e27e9e75e596aba4c42a2f66d361ed..fd5f454c8492e613666a46ad7150e9d2c6bd1e06 100644 (file)
@@ -41,7 +41,7 @@
 
     function save() {
       $row.closest('table').block();
-      CRM.api3(info.entity, 'setvalue', {id: info.id, field: 'is_active', value: enabled ? 0 : 1}, {success: successMsg}).done(refresh);
+      CRM.api3(info.entity, info.action, {id: info.id, field: 'is_active', value: enabled ? 0 : 1}, {success: successMsg}).done(refresh);
       if (enabled) {
         $(this).dialog('close');
       }