3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class contains functions that are called using AJAX.
21 class CRM_Batch_Page_AJAX
{
26 public function batchSave() {
27 // save the entered information in 'data' column
28 $batchId = CRM_Utils_Type
::escape($_POST['batch_id'], 'Positive');
30 unset($_POST['qfKey']);
31 CRM_Core_DAO
::setFieldValue('CRM_Batch_DAO_Batch', $batchId, 'data', json_encode(['values' => $_POST]));
33 CRM_Utils_System
::civiExit();
37 * This function uses the deprecated v1 datatable api and needs updating. See CRM-16353.
40 public static function getBatchList() {
41 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric');
42 if ($context != 'financialBatch') {
48 4 => 'status_id.label',
49 5 => 'created_id.sort_name',
55 2 => 'payment_instrument_id.label',
58 5 => 'status_id.label',
59 6 => 'created_id.sort_name',
62 $sEcho = CRM_Utils_Type
::escape($_REQUEST['sEcho'], 'Integer');
63 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type
::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
64 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type
::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
65 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array
::value(CRM_Utils_Type
::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
66 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type
::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
69 if ($sort && $sortOrder) {
70 $params['sortBy'] = $sort . ' ' . $sortOrder;
73 $params['page'] = ($offset / $rowCount) +
1;
74 $params['rp'] = $rowCount;
76 if ($context != 'financialBatch') {
77 // data entry status batches
78 $params['status_id'] = CRM_Core_PseudoConstant
::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry');
81 $params['context'] = $context;
84 $batches = CRM_Batch_BAO_Batch
::getBatchListSelector($params);
86 $iFilteredTotal = $iTotal = $params['total'];
88 if ($context == 'financialBatch') {
101 $selectorElements = [
111 CRM_Utils_System
::setHttpHeader('Content-Type', 'application/json');
112 echo CRM_Utils_JSON
::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
113 CRM_Utils_System
::civiExit();