Merge pull request #4373 from civicrm/4.5
[civicrm-core.git] / CRM / Financial / Page / AJAX.php
index 4b12cf42d1d8a466f3c0c2dcfc6a6ea1b1c97ee2..1dc6a320430767e7ac086f21642f527e8796255e 100644 (file)
@@ -43,6 +43,9 @@ class CRM_Financial_Page_AJAX {
    * $financialAccountType array with key account relationship and value financial account type option groups
    *
    */
+  /**
+   * @param $config
+   */
   static function jqFinancial($config) {
     if (!isset($_GET['_value']) ||
       empty($_GET['_value'])) {
@@ -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);
@@ -87,10 +91,12 @@ class CRM_Financial_Page_AJAX {
         ) + $selectedArray;
       }
     }
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 
+  /**
+   * @param $config
+   */
   static function jqFinancialRelation($config) {
     if (!isset($_GET['_value']) ||
       empty($_GET['_value'])) {
@@ -144,10 +150,12 @@ class CRM_Financial_Page_AJAX {
         }
       }
     }
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 
+  /**
+   * @param $config
+   */
   static function jqFinancialType($config) {
     if (! isset($_GET['_value']) ||
       empty($_GET['_value'])) {
@@ -155,8 +163,7 @@ class CRM_Financial_Page_AJAX {
     }
 
     $elements = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Product', $_GET['_value'], 'financial_type_id');
-    echo json_encode($elements);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($elements);
   }
 
   /**
@@ -248,8 +255,7 @@ class CRM_Financial_Page_AJAX {
         }
       }
     }
-    echo json_encode($response);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($response);
   }
 
   static function getFinancialTransactionsList() {
@@ -481,8 +487,7 @@ class CRM_Financial_Page_AJAX {
     else {
       $status = array('status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", array( 1 => $paymentInstrument)));
     }
-    echo json_encode($status);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($status);
   }
 
   static function getBatchSummary() {
@@ -503,7 +508,6 @@ class CRM_Financial_Page_AJAX {
         'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date),
       );
 
-    echo json_encode($batchSummary);
-    CRM_Utils_System::civiExit();
+    CRM_Utils_JSON::output($batchSummary);
   }
 }