<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* This class contains all the function that are called using AJAX
*/
class CRM_Financial_Page_AJAX {
- /*
+
+ /**
* get financial accounts of required account relationship
* $financialAccountType array with key account relationship and value financial account type option groups
*
- */
- /**
* @param $config
*/
public static function jqFinancial($config) {
if (!isset($_GET['_value']) ||
- empty($_GET['_value'])) {
+ empty($_GET['_value'])
+ ) {
CRM_Utils_System::civiExit();
}
$defaultId = NULL;
}
$elements = array(
array(
- 'name' => ts('- select -'),
+ 'name' => ts('- select -'),
'value' => 'select',
- )
+ ),
);
if (!empty($result)) {
$selectedArray['selected'] = 'Selected';
}
$elements[] = array(
- 'name' => $name,
+ 'name' => $name,
'value' => $id,
) + $selectedArray;
}
*/
public static function jqFinancialRelation($config) {
if (!isset($_GET['_value']) ||
- empty($_GET['_value'])) {
+ empty($_GET['_value'])
+ ) {
CRM_Utils_System::civiExit();
}
$elements = array(
array(
- 'name' => ts('- Select Financial Account Relationship -'),
+ 'name' => ts('- Select Financial Account Relationship -'),
'value' => 'select',
- )
+ ),
);
$countResult = count($financialAccountType[$financialAccountTypeId]);
if (!empty($result)) {
foreach ($result as $id => $name) {
- if (in_array($id, $financialAccountType[$financialAccountTypeId]) && $_GET['_value'] != 'select') {
+ if (in_array($id, $financialAccountType[$financialAccountTypeId]) && $_GET['_value'] != 'select') {
if ($countResult != 1) {
$elements[] = array(
- 'name' => $name,
+ 'name' => $name,
'value' => $id,
);
}
else {
$elements[] = array(
- 'name' => $name,
- 'value' => $id,
+ 'name' => $name,
+ 'value' => $id,
'selected' => 'Selected',
);
}
}
elseif ($_GET['_value'] == 'select') {
$elements[] = array(
- 'name' => $name,
+ 'name' => $name,
'value' => $id,
);
}
* @param $config
*/
public static function jqFinancialType($config) {
- if (! isset($_GET['_value']) ||
- empty($_GET['_value'])) {
+ if (!isset($_GET['_value']) ||
+ empty($_GET['_value'])
+ ) {
CRM_Utils_System::civiExit();
}
}
}
- $entityID = CRM_Utils_Array::value('entityID', $_POST);
+ $entityID = CRM_Utils_Array::value('entityID', $_POST);
$methods = array(
'assign' => 'addBatchEntity',
'remove' => 'removeBatchEntity',
}
public static function getFinancialTransactionsList() {
- $sortMapper =
- array(
- 0 => '',
- 1 => '',
- 2 => 'sort_name',
- 3 => 'amount',
- 4 => 'trxn_id',
- 5 => 'transaction_date',
- 6 => 'payment_method',
- 7 => 'status',
- 8 => 'name',
- );
+ $sortMapper = array(
+ 0 => '',
+ 1 => '',
+ 2 => 'sort_name',
+ 3 => 'amount',
+ 4 => 'trxn_id',
+ 5 => 'transaction_date',
+ 6 => 'payment_method',
+ 7 => 'status',
+ 8 => 'name',
+ );
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
+ $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
+ $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
+ $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
+ $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
- $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL;
- $entityID = isset($_REQUEST['entityID']) ? CRM_Utils_Type::escape($_REQUEST['entityID'], 'String') : NULL;
+ $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL;
+ $entityID = isset($_REQUEST['entityID']) ? CRM_Utils_Type::escape($_REQUEST['entityID'], 'String') : NULL;
$notPresent = isset($_REQUEST['notPresent']) ? CRM_Utils_Type::escape($_REQUEST['notPresent'], 'String') : NULL;
- $statusID = isset($_REQUEST['statusID']) ? CRM_Utils_Type::escape($_REQUEST['statusID'], 'String') : NULL;
- $search = isset($_REQUEST['search']) ? TRUE : FALSE;
+ $statusID = isset($_REQUEST['statusID']) ? CRM_Utils_Type::escape($_REQUEST['statusID'], 'String') : NULL;
+ $search = isset($_REQUEST['search']) ? TRUE : FALSE;
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
- $returnvalues =
- array(
- 'civicrm_financial_trxn.payment_instrument_id as payment_method',
- 'civicrm_contribution.contact_id as contact_id',
- 'civicrm_contribution.id as contributionID',
- 'contact_a.sort_name',
- 'civicrm_financial_trxn.total_amount as amount',
- 'civicrm_financial_trxn.trxn_id as trxn_id',
- 'contact_a.contact_type',
- 'contact_a.contact_sub_type',
- 'civicrm_financial_trxn.trxn_date as transaction_date',
- 'name',
- 'civicrm_contribution.currency as currency',
- 'civicrm_financial_trxn.status_id as status',
- 'civicrm_financial_trxn.check_number as check_number',
- );
+ $returnvalues = array(
+ 'civicrm_financial_trxn.payment_instrument_id as payment_method',
+ 'civicrm_contribution.contact_id as contact_id',
+ 'civicrm_contribution.id as contributionID',
+ 'contact_a.sort_name',
+ 'civicrm_financial_trxn.total_amount as amount',
+ 'civicrm_financial_trxn.trxn_id as trxn_id',
+ 'contact_a.contact_type',
+ 'contact_a.contact_sub_type',
+ 'civicrm_financial_trxn.trxn_date as transaction_date',
+ 'name',
+ 'civicrm_contribution.currency as currency',
+ 'civicrm_financial_trxn.status_id as status',
+ 'civicrm_financial_trxn.check_number as check_number',
+ );
- $columnHeader =
- array(
- 'contact_type' => '',
- 'sort_name' => ts('Contact Name'),
- 'amount' => ts('Amount'),
- 'trxn_id' => ts('Trxn ID'),
- 'transaction_date' => ts('Received'),
- 'payment_method' => ts('Payment Method'),
- 'status' => ts('Status'),
- 'name' => ts('Type'),
- );
+ $columnHeader = array(
+ 'contact_type' => '',
+ 'sort_name' => ts('Contact Name'),
+ 'amount' => ts('Amount'),
+ 'trxn_id' => ts('Trxn ID'),
+ 'transaction_date' => ts('Received'),
+ 'payment_method' => ts('Payment Method'),
+ 'status' => ts('Status'),
+ 'name' => ts('Type'),
+ );
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
$params['rp'] = $rowCount;
$params['context'] = $context;
- $params['offset'] = ($params['page'] - 1) * $params['rp'];
+ $params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
- $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
- $params['total'] = 0;
+ $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
+ $params['total'] = 0;
// get batch list
if (isset($notPresent)) {
if ($statusID == CRM_Core_OptionGroup::getValue('batch_status', 'Open')) {
if (isset($notPresent)) {
$js = "enableActions('x')";
- $row[$financialItem->id]['check'] = "<input type='checkbox' id='mark_x_" . $financialItem->id . "' name='mark_x_" . $financialItem->id . "' value='1' onclick={$js}></input>";
+ $row[$financialItem->id]['check'] = "<input type='checkbox' id='mark_x_" . $financialItem->id . "' name='mark_x_" . $financialItem->id . "' value='1' onclick={$js}></input>";
$row[$financialItem->id]['action'] = CRM_Core_Action::formLink(
CRM_Financial_Form_BatchTransaction::links(),
NULL,
array(
'id' => $financialItem->id,
'contid' => $financialItem->contributionID,
- 'cid' => $financialItem->contact_id
+ 'cid' => $financialItem->contact_id,
),
ts('more'),
FALSE,
}
else {
$js = "enableActions('y')";
- $row[$financialItem->id]['check'] = "<input type='checkbox' id='mark_y_" . $financialItem->id . "' name='mark_y_" . $financialItem->id . "' value='1' onclick={$js}></input>";
+ $row[$financialItem->id]['check'] = "<input type='checkbox' id='mark_y_" . $financialItem->id . "' name='mark_y_" . $financialItem->id . "' value='1' onclick={$js}></input>";
$row[$financialItem->id]['action'] = CRM_Core_Action::formLink(
CRM_Financial_Page_BatchTransaction::links(),
NULL,
array(
'id' => $financialItem->id,
'contid' => $financialItem->contributionID,
- 'cid' => $financialItem->contact_id
+ 'cid' => $financialItem->contact_id,
),
ts('more'),
FALSE,
array(
'id' => $financialItem->id,
'contid' => $financialItem->contributionID,
- 'cid' => $financialItem->contact_id
+ 'cid' => $financialItem->contact_id,
),
ts('more'),
FALSE,
}
$iFilteredTotal = $iTotal = $params['total'];
- $selectorElements =
- array(
- 'check', 'contact_type', 'sort_name',
- 'amount', 'trxn_id', 'transaction_date', 'payment_method', 'status', 'name', 'action',
- );
+ $selectorElements = array(
+ 'check',
+ 'contact_type',
+ 'sort_name',
+ 'amount',
+ 'trxn_id',
+ 'transaction_date',
+ 'payment_method',
+ 'status',
+ 'name',
+ 'action',
+ );
echo CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
public static function bulkAssignRemove() {
$checkIDs = $_REQUEST['ID'];
$entityID = CRM_Utils_Type::escape($_REQUEST['entityID'], 'String');
- $action = CRM_Utils_Type::escape($_REQUEST['action'], 'String');
+ $action = CRM_Utils_Type::escape($_REQUEST['action'], 'String');
foreach ($checkIDs as $key => $value) {
if ((substr($value, 0, 7) == "mark_x_" && $action == 'Assign') || (substr($value, 0, 7) == "mark_y_" && $action == 'Remove')) {
$contributions = explode("_", $value);
$paymentInstrument = CRM_Core_OptionGroup::getLabel('payment_instrument', $batchPID);
foreach ($cIDs as $key => $value) {
$recordPID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $value, 'payment_instrument_id');
- if ($action == 'Remove' || ($recordPID == $batchPID && $action == 'Assign') || !isset($batchPID)) {
- $params =
- array(
- 'entity_id' => $value,
- 'entity_table' => 'civicrm_financial_trxn',
- 'batch_id' => $entityID,
- );
+ if ($action == 'Remove' || ($recordPID == $batchPID && $action == 'Assign') || !isset($batchPID)) {
+ $params = array(
+ 'entity_id' => $value,
+ 'entity_table' => 'civicrm_financial_trxn',
+ 'batch_id' => $entityID,
+ );
if ($action == 'Assign') {
$updated = CRM_Batch_BAO_Batch::addBatchEntity($params);
}
$params = array('id' => $batchID);
$batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value);
$batchTotals = CRM_Batch_BAO_Batch::batchTotals(array($batchID));
- $batchSummary =
- array(
- 'created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id),
- 'status' => CRM_Core_OptionGroup::getLabel('batch_status', $batchInfo->status_id),
- 'description' => $batchInfo->description,
- 'payment_instrument' => CRM_Core_OptionGroup::getLabel('payment_instrument', $batchInfo->payment_instrument_id),
- 'item_count' => $batchInfo->item_count,
- 'assigned_item_count' => $batchTotals[$batchID]['item_count'],
- 'total' => CRM_Utils_Money::format($batchInfo->total),
- 'assigned_total' => CRM_Utils_Money::format($batchTotals[$batchID]['total']),
- 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date),
- );
+ $batchSummary = array(
+ 'created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id),
+ 'status' => CRM_Core_OptionGroup::getLabel('batch_status', $batchInfo->status_id),
+ 'description' => $batchInfo->description,
+ 'payment_instrument' => CRM_Core_OptionGroup::getLabel('payment_instrument', $batchInfo->payment_instrument_id),
+ 'item_count' => $batchInfo->item_count,
+ 'assigned_item_count' => $batchTotals[$batchID]['item_count'],
+ 'total' => CRM_Utils_Money::format($batchInfo->total),
+ 'assigned_total' => CRM_Utils_Money::format($batchTotals[$batchID]['total']),
+ 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date),
+ );
CRM_Utils_JSON::output($batchSummary);
}
+
}