CRM-13863 - Consolidate livePage.js handling in parent page class
[civicrm-core.git] / CRM / Contribute / Page / Tab.php
index 85a969589e1e6e7563a6c8ef484bd1c6bd788180..1fe52f33d7e2140c1328d1449b256d460a5e1a7a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -41,48 +41,11 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
    * @static
    */
   static $_links = NULL;
-  static $_honorLinks = NULL;
   static $_recurLinks = NULL;
   public $_permission = NULL;
   public $_contactId = NULL;
   public $_crid = NULL;
 
-  /**
-   * This method returns the links that are given for honor search row.
-   * currently the links added for each row are
-   *
-   * - View
-   * - Edit
-   *
-   * @return array
-   * @access public
-   *
-   */
-  static function &honorLinks() {
-    if (!(self::$_honorLinks)) {
-      self::$_honorLinks = array(
-        CRM_Core_Action::VIEW => array(
-          'name' => ts('View'),
-          'url' => 'civicrm/contact/view/contribution',
-          'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&honorId=%%honorId%%&action=view&context=%%cxt%%&selectedChild=contribute',
-          'title' => ts('View Contribution'),
-        ),
-        CRM_Core_Action::UPDATE => array(
-          'name' => ts('Edit'),
-          'url' => 'civicrm/contact/view/contribution',
-          'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&honorId=%%honorId%%&context=%%cxt%%&subType=%%contributionType%%',
-          'title' => ts('Edit Contribution'),
-        ),
-        CRM_Core_Action::DELETE => array(
-          'name' => ts('Delete'),
-          'url' => 'civicrm/contact/view/contribution',
-          'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&honorId=%%honorId%%&context=%%cxt%%',
-          'title' => ts('Delete Contribution'),
-        ),
-      );
-    }
-    return self::$_honorLinks;
-  }
   //end of function
 
   /**
@@ -114,8 +77,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
         CRM_Core_Action::DISABLE => array(
           'name' => ts('Cancel'),
           'title' => ts('Cancel'),
-          'extra' => 'onclick = "enableDisable( %%crid%%,\'' . 'CRM_Contribute_BAO_ContributionRecur' . '\',\'' . 'enable-disable' . '\' );"',
-          'ref' => 'disable-action',
+          'ref' => 'crm-enable-disable',
         ),
       );
     }
@@ -147,7 +109,6 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
    * @access public
    */
   function browse() {
-
     // add annual contribution
     $annual = array();
     list($annual['count'],
@@ -166,7 +127,8 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     $controller->reset();
     $controller->set('cid', $this->_contactId);
     $controller->set('crid', $this->_crid);
-    $controller->set('context', 'contribution');
+    $controller->set('context', 'Search');
+    $controller->set('limit', 50);
     $controller->process();
     $controller->run();
 
@@ -193,7 +155,12 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
               'cid' => $this->_contactId,
               'crid' => $ids,
               'cxt' => 'contribution',
-            )
+            ),
+            ts('more'),
+            FALSE,
+            'contribution.selector.recurring',
+            'Contribution',
+            $ids
           );
         }
       }
@@ -203,33 +170,6 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
       $this->assign('recur', TRUE);
     }
 
-    //add honor block
-    // form all action links
-    $action = array_sum(array_keys($this->honorLinks()));
-
-    $params = array();
-    $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
-    if (!empty($params)) {
-      foreach ($params as $ids => $honorId) {
-        $params[$ids]['action'] = CRM_Core_Action::formLink(
-          self::honorLinks(),
-          $action,
-          array(
-            'cid' => $honorId['honorId'],
-            'id' => $ids,
-            'cxt' => 'contribution',
-            'contributionType' => $honorId['type_id'],
-            'honorId' => $this->_contactId,
-          )
-        );
-      }
-
-      // assign vars to templates
-      $this->assign('action', $this->_action);
-      $this->assign('honorRows', $params);
-      $this->assign('honor', TRUE);
-    }
-
     //enable/disable soft credit records for test contribution
     $isTest = 0;
     if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
@@ -255,6 +195,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     if ($this->_contactId) {
       $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
       $this->assign('displayName', $displayName);
+      $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
     }
   }
 
@@ -398,17 +339,8 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
         break;
 
       case 'contribution':
-        $honorId = CRM_Utils_Request::retrieve('honorId', 'Positive', $this, FALSE);
-
-        if ($honorId) {
-          $cid = $honorId;
-        }
-        else {
-          $cid = $this->_contactId;
-        }
-
         $url = CRM_Utils_System::url('civicrm/contact/view',
-          "reset=1&force=1&cid={$cid}&selectedChild=contribute"
+          "reset=1&force=1&cid={$this->_contactId}&selectedChild=contribute"
         );
         break;