Merge remote branch 'canonical/master' into merge-forward
[civicrm-core.git] / CRM / Financial / Page / AJAX.php
index f84df53c7cb0e4281490f23082ec463891c5a5cf..fb6d48fef3af76a2a2ece8530391626cb075c941 100644 (file)
@@ -43,7 +43,10 @@ class CRM_Financial_Page_AJAX {
    * $financialAccountType array with key account relationship and value financial account type option groups
    *
    */
-  function jqFinancial($config) {
+  /**
+   * @param $config
+   */
+  static function jqFinancial($config) {
     if (!isset($_GET['_value']) ||
       empty($_GET['_value'])) {
       CRM_Utils_System::civiExit();
@@ -61,6 +64,7 @@ class CRM_Financial_Page_AJAX {
         '7' => 4, //cost of sales
         '8' => 1, //premium inventory
         '9' => 3, //discount account is
+        '10' => 2, //sales tax liability
       );
       $financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType);
       $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
@@ -91,7 +95,10 @@ class CRM_Financial_Page_AJAX {
     CRM_Utils_System::civiExit();
   }
 
-  function jqFinancialRelation($config) {
+  /**
+   * @param $config
+   */
+  static function jqFinancialRelation($config) {
     if (!isset($_GET['_value']) ||
       empty($_GET['_value'])) {
       CRM_Utils_System::civiExit();
@@ -148,7 +155,10 @@ class CRM_Financial_Page_AJAX {
     CRM_Utils_System::civiExit();
   }
 
-  function jqFinancialType($config) {
+  /**
+   * @param $config
+   */
+  static function jqFinancialType($config) {
     if (! isset($_GET['_value']) ||
       empty($_GET['_value'])) {
       CRM_Utils_System::civiExit();
@@ -214,9 +224,9 @@ class CRM_Financial_Page_AJAX {
             // Update totals when closing a batch
             $params = $totals[$recordID];
           case 'reopen':
-            $status = $op == 'close' ? 'Closed' : 'Open';
+            $status = $op == 'close' ? 'Closed' : 'Reopened';
             $ids['batchID'] = $recordID;
-            $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
+            $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
             $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus);
             $session = CRM_Core_Session::singleton();
             $params['modified_date'] = date('YmdHis');
@@ -506,4 +516,16 @@ class CRM_Financial_Page_AJAX {
     echo json_encode($batchSummary);
     CRM_Utils_System::civiExit();
   }
+
+  /**
+   * Callback to perform action on Print Invoice button.
+   */
+  static function getPrintPDF() {
+
+    $contribIDs = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
+    $contributionIDs = array($contribIDs);
+    $contactIds = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
+    $params = array('output' => 'pdf_invoice');
+    CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs , $params, $contactIds);
+  }
 }