本文整理匯總了PHP中CRM_Utils_JSON::encodeDataTableSelector方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_JSON::encodeDataTableSelector方法的具體用法?PHP CRM_Utils_JSON::encodeDataTableSelector怎麽用?PHP CRM_Utils_JSON::encodeDataTableSelector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Utils_JSON
的用法示例。
在下文中一共展示了CRM_Utils_JSON::encodeDataTableSelector方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCaseActivity
static function getCaseActivity()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array(0 => 'display_date', 1 => 'ca.subject', 2 => 'ca.activity_type_id', 3 => 'acc.sort_name', 4 => 'cc.sort_name', 5 => 'ca.status_id');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortname'] = $sort;
$params['sortorder'] = $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
// get the activities related to given case
require_once "CRM/Case/BAO/Case.php";
$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
require_once "CRM/Utils/JSON.php";
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('display_date', 'subject', 'type', 'with_contacts', 'reporter', 'status', 'links', 'class');
echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例2: getBatchList
/**
* Retrieve records.
*/
public static function getBatchList()
{
$sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => '');
$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;
$params = $_REQUEST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
if ($context != 'financialBatch') {
// data entry status batches
$params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
}
$params['context'] = $context;
// get batch list
$batches = CRM_Batch_BAO_Batch::getBatchListSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
if ($context == 'financialBatch') {
$selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links');
} else {
$selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links');
}
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例3: getContactMailings
/**
* Function to retrieve contact mailings
*/
public static function getContactMailings()
{
$contactID = CRM_Utils_Type::escape($_GET['contact_id'], 'Integer');
$sortMapper = array(0 => 'subject', 1 => 'creator_name', 2 => '', 3 => 'start_date', 4 => '', 5 => 'links');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact mailings
$mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('subject', 'mailing_creator', 'recipients', 'start_date', 'openstats', 'links');
header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($mailings, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例4: getTeamList
/**
* Get list of teams.
*
* @return array
*/
public static function getTeamList()
{
$params = $_REQUEST;
if (isset($params['parent_id'])) {
// requesting child groups for a given parent
$params['page'] = 1;
$params['rp'] = 0;
$groups = self::getTeamListSelector($params);
CRM_Utils_JSON::output($groups);
} else {
$sortMapper = array(0 => 'groups.title', 1 => 'count', 2 => 'createdBy.sort_name', 3 => '', 4 => 'groups.group_type', 5 => 'groups.visibility');
$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';
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['group_type'] = teamGroupType();
// restrict to teams logged in user may access
$contact = billing_contact_get();
//@todo remove for admin
if (!CRM_Core_Permission::check('edit all contacts')) {
$params['created_by'] = $contact['sort_name'];
}
// get team list
$groups = self::getTeamListSelector($params);
// if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
// go ahead with flat hierarchy
if (empty($groups)) {
$groupsAccessible = CRM_Core_PseudoConstant::group();
$parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
if (!empty($groupsAccessible) && $parentsOnly) {
// recompute group list with flat hierarchy
$params['parentsOnly'] = 0;
$groups = self::getTeamListSelector($params);
}
}
$iFilteredTotal = $iTotal = count($groups);
//$params['total'];
$selectorElements = array('group_name', 'count', 'created_by', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class');
if (empty($params['showOrgInfo'])) {
unset($selectorElements[6]);
}
//add setting so this can be tested by unit test
//@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
// from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
if (!empty($params['is_unit_test'])) {
return array($groups, $iFilteredTotal);
}
header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
}
示例5: getOptionList
/**
* This function uses the deprecated v1 datatable api and needs updating. See CRM-16353.
* @deprecated
*/
public static function getOptionList()
{
$params = $_REQUEST;
$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;
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$options = CRM_Core_BAO_CustomOption::getOptionListSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('label', 'value', 'is_default', 'is_active', 'links', 'class');
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($options, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例6: getGroupList
static function getGroupList()
{
$params = $_REQUEST;
if (isset($params['parent_id'])) {
// requesting child groups for a given parent
$params['page'] = 1;
$params['rp'] = 25;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
echo json_encode($groups);
CRM_Utils_System::civiExit();
} else {
$sortMapper = array(0 => 'groups.title', 1 => 'groups.id', 2 => 'createdBy.sort_name', 3 => '', 4 => 'groups.group_type', 5 => 'groups.visibility');
$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';
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
// get group list
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
// if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
// go ahead with flat hierarchy, CRM-12225
if (empty($groups)) {
$groupsAccessible = CRM_Core_PseudoConstant::group();
$parentsOnly = CRM_Utils_Array::value('parentsOnly', $params);
if (!empty($groupsAccessible) && $parentsOnly) {
// recompute group list with flat hierarchy
$params['parentsOnly'] = 0;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
}
}
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('group_name', 'group_id', 'created_by', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class');
if (empty($params['showOrgInfo'])) {
unset($selectorElements[6]);
}
echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
}
示例7: getBatchList
static function getBatchList()
{
$sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => '');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
// get batch list
$batches = CRM_Core_BAO_Batch::getBatchListSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('batch_name', 'batch_type', 'item_count', 'total_amount', 'status', 'created_by', 'links');
echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例8: getGroupList
static function getGroupList()
{
$sortMapper = array(0 => 'groups.title', 1 => 'groups.id', 2 => '', 3 => 'groups.group_type', 4 => 'groups.visibility');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
// get group list
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('group_name', 'group_id', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class');
if (!CRM_Utils_Array::value('showOrgInfo', $params)) {
unset($selectorElements[5]);
}
echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例9: getDedupes
public static function getDedupes()
{
$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 = 'sort_name';
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0;
$rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0;
$contactType = '';
if ($rgid) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
}
$cacheKeyString = "merge {$contactType}_{$rgid}_{$gid}";
$searchRows = array();
$selectorElements = array('src', 'dst', 'weight', 'actions');
$join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND\n pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
$iFilteredTotal = $iTotal = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, $join, $where);
$mainContacts = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, $offset, $rowCount);
foreach ($mainContacts as $mainId => $main) {
$searchRows[$mainId]['src'] = CRM_Utils_System::href($main['srcName'], 'civicrm/contact/view', "reset=1&cid={$main['srcID']}");
$searchRows[$mainId]['dst'] = CRM_Utils_System::href($main['dstName'], 'civicrm/contact/view', "reset=1&cid={$main['dstID']}");
$searchRows[$mainId]['weight'] = CRM_Utils_Array::value('weight', $main);
if (!empty($main['canMerge'])) {
$mergeParams = "reset=1&cid={$main['srcID']}&oid={$main['dstID']}&action=update&rgid={$rgid}";
if ($gid) {
$mergeParams .= "&gid={$gid}";
}
$searchRows[$mainId]['actions'] = '<a class="action-item crm-hover-button" href="' . CRM_Utils_System::url('civicrm/contact/merge', $mergeParams) . '">' . ts('merge') . '</a>';
$searchRows[$mainId]['actions'] .= "<a class='action-item crm-hover-button crm-notDuplicate' href='#' onClick=\"processDupes( {$main['srcID']}, {$main['dstID']}, 'dupe-nondupe', 'dupe-listing'); return false;\">" . ts('not a duplicate') . "</a>";
} else {
$searchRows[$mainId]['actions'] = '<em>' . ts('Insufficient access rights - cannot merge') . '</em>';
}
}
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例10: petitionList
/**
* This function uses the deprecated v1 datatable api and needs updating. See CRM-16353.
* @deprecated
*/
public function petitionList()
{
//get the search criteria params.
$searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST');
$searchParams = explode(',', $searchCriteria);
$params = $searchRows = array();
foreach ($searchParams as $param) {
if (!empty($_POST[$param])) {
$params[$param] = $_POST[$param];
}
}
//this is sequence columns on datatable.
$selectorCols = array('id', 'title', 'campaign_id', 'campaign', 'activity_type_id', 'activity_type', 'is_default', 'is_active', 'isActive', 'action');
// get the data table params.
$dataTableParams = array('sEcho' => array('name' => 'sEcho', 'type' => 'Integer', 'default' => 0), 'offset' => array('name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0), 'rowCount' => array('name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25), 'sort' => array('name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'created_date'), 'sortOrder' => array('name' => 'sSortDir_0', 'type' => 'String', 'default' => 'desc'));
foreach ($dataTableParams as $pName => $pValues) {
${$pName} = $pValues['default'];
if (!empty($_POST[$pValues['name']])) {
${$pName} = CRM_Utils_Type::escape($_POST[$pValues['name']], $pValues['type']);
if ($pName == 'sort') {
${$pName} = $selectorCols[${$pName}];
}
}
}
foreach (array('sort', 'offset', 'rowCount', 'sortOrder') as $sortParam) {
$params[$sortParam] = ${$sortParam};
}
$petitions = CRM_Campaign_Page_DashBoard::getPetitionSummary($params);
$searchCount = CRM_Campaign_BAO_Petition::getPetitionSummary($params, TRUE);
$iTotal = $searchCount;
if ($searchCount > 0) {
if ($searchCount < $offset) {
$offset = 0;
}
foreach ($petitions as $petitionID => $values) {
foreach ($selectorCols as $col) {
$searchRows[$petitionID][$col] = CRM_Utils_Array::value($col, $values);
}
}
}
$selectorElements = $selectorCols;
$iFilteredTotal = $iTotal;
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例11: getFinancialTransactionsList
//.........這裏部分代碼省略.........
$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;
$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');
$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['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['context'] = $context;
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$params['total'] = 0;
// get batch list
if (isset($notPresent)) {
$financialItem = CRM_Batch_BAO_Batch::getBatchFinancialItems($entityID, $returnvalues, $notPresent, $params);
if ($search) {
$unassignedTransactions = CRM_Batch_BAO_Batch::getBatchFinancialItems($entityID, $returnvalues, $notPresent, $params, TRUE);
} else {
$unassignedTransactions = CRM_Batch_BAO_Batch::getBatchFinancialItems($entityID, $returnvalues, $notPresent, NULL, TRUE);
}
while ($unassignedTransactions->fetch()) {
$unassignedTransactionsCount[] = $unassignedTransactions->id;
}
if (!empty($unassignedTransactionsCount)) {
$params['total'] = count($unassignedTransactionsCount);
}
} else {
$financialItem = CRM_Batch_BAO_Batch::getBatchFinancialItems($entityID, $returnvalues, NULL, $params);
$assignedTransactions = CRM_Batch_BAO_Batch::getBatchFinancialItems($entityID, $returnvalues);
while ($assignedTransactions->fetch()) {
$assignedTransactionsCount[] = $assignedTransactions->id;
}
if (!empty($assignedTransactionsCount)) {
$params['total'] = count($assignedTransactionsCount);
}
}
$financialitems = array();
while ($financialItem->fetch()) {
$row[$financialItem->id] = array();
foreach ($columnHeader as $columnKey => $columnValue) {
if ($financialItem->contact_sub_type && $columnKey == 'contact_type') {
$row[$financialItem->id][$columnKey] = $financialItem->contact_sub_type;
continue;
}
$row[$financialItem->id][$columnKey] = $financialItem->{$columnKey};
if ($columnKey == 'sort_name' && $financialItem->{$columnKey}) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=" . $financialItem->contact_id);
$row[$financialItem->id][$columnKey] = '<a href=' . $url . '>' . $financialItem->{$columnKey} . '</a>';
} elseif ($columnKey == 'payment_method' && $financialItem->{$columnKey}) {
$row[$financialItem->id][$columnKey] = CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $financialItem->{$columnKey});
if ($row[$financialItem->id][$columnKey] == 'Check') {
$checkNumber = $financialItem->check_number ? ' (' . $financialItem->check_number . ')' : '';
$row[$financialItem->id][$columnKey] = $row[$financialItem->id][$columnKey] . $checkNumber;
}
} elseif ($columnKey == 'amount' && $financialItem->{$columnKey}) {
$row[$financialItem->id][$columnKey] = CRM_Utils_Money::format($financialItem->{$columnKey}, $financialItem->currency);
} elseif ($columnKey == 'transaction_date' && $financialItem->{$columnKey}) {
$row[$financialItem->id][$columnKey] = CRM_Utils_Date::customFormat($financialItem->{$columnKey});
} elseif ($columnKey == 'status' && $financialItem->{$columnKey}) {
$row[$financialItem->id][$columnKey] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $financialItem->{$columnKey});
}
}
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]['action'] = CRM_Core_Action::formLink(CRM_Financial_Form_BatchTransaction::links(), NULL, array('id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id), ts('more'), FALSE, 'financialItem.batch.row', 'FinancialItem', $financialItem->id);
} 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]['action'] = CRM_Core_Action::formLink(CRM_Financial_Page_BatchTransaction::links(), NULL, array('id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id), ts('more'), FALSE, 'financialItem.batch.row', 'FinancialItem', $financialItem->id);
}
} else {
$row[$financialItem->id]['check'] = NULL;
$tempBAO = new CRM_Financial_Page_BatchTransaction();
$links = $tempBAO->links();
unset($links['remove']);
$row[$financialItem->id]['action'] = CRM_Core_Action::formLink($links, NULL, array('id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id), ts('more'), FALSE, 'financialItem.batch.row', 'FinancialItem', $financialItem->id);
}
$row[$financialItem->id]['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage(CRM_Utils_Array::value('contact_sub_type', $row[$financialItem->id]) ? CRM_Utils_Array::value('contact_sub_type', $row[$financialItem->id]) : CRM_Utils_Array::value('contact_type', $row[$financialItem->id]), FALSE, $financialItem->contact_id);
$financialitems = $row;
}
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('check', 'contact_type', 'sort_name', 'amount', 'trxn_id', 'transaction_date', 'payment_method', 'status', 'name', 'action');
if ($return) {
return CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
}
CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例12: getContactActivity
public static function getContactActivity()
{
$contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array(0 => 'activity_type', 1 => 'subject', 2 => 'source_contact_name', 3 => '', 4 => '', 5 => 'activity_date_time', 6 => 'status_id');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact activities
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
foreach ($activities as $key => $value) {
//Check if recurring activity
if (!empty($value['is_recurring_activity'])) {
$repeat = $value['is_recurring_activity'];
$activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
}
}
// store the activity filter preference CRM-11761
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID) {
//flush cache before setting filter to account for global cache (memcache)
$domainID = CRM_Core_Config::domainID();
$cacheKey = CRM_Core_BAO_Setting::inCache(CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, TRUE, $domainID, TRUE);
if ($cacheKey) {
CRM_Core_BAO_Setting::flushCache($cacheKey);
}
$activityFilter = array('activity_type_filter_id' => empty($params['activity_type_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'), 'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'));
CRM_Core_BAO_Setting::setItem($activityFilter, CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, $userID);
}
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('activity_type', 'subject', 'source_contact', 'target_contact', 'assignee_contact', 'activity_date', 'status', 'links', 'class');
header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例13: relationshipContacts
static function relationshipContacts()
{
$data = $searchValues = $searchRows = array();
$addCount = 0;
$relType = CRM_Utils_Type::escape($_REQUEST['relType'], 'String');
$typeName = isset($_REQUEST['typeName']) ? CRM_Utils_Type::escape($_REQUEST['typeName'], 'String') : '';
$relContact = CRM_Utils_Type::escape($_REQUEST['relContact'], 'String');
$excludedContactIds = isset($_REQUEST['cid']) ? array(CRM_Utils_Type::escape($_REQUEST['cid'], 'Integer')) : array();
if (in_array($typeName, array('Employee of', 'Employer of'))) {
$addCount = 1;
}
$sortMapper = array(1 => 'sort_name', 2 + $addCount => 'city', 3 + $addCount => 'state_province', 4 + $addCount => 'email', 5 + $addCount => 'phone');
$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']) ? $sortMapper[CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer')] : 'sort_name';
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$searchValues[] = array('sort_name', 'LIKE', $relContact, 0, 1);
list($rid, $direction) = explode('_', $relType, 2);
require_once 'CRM/Contact/DAO/RelationshipType.php';
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Contact/BAO/Query.php';
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $rid;
if ($relationshipType->find(true)) {
if ($direction == 'a_b') {
$type = $relationshipType->contact_type_b;
$subType = $relationshipType->contact_sub_type_b;
} else {
$type = $relationshipType->contact_type_a;
$subType = $relationshipType->contact_sub_type_a;
}
if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') {
$searchValues[] = array('contact_type', '=', $type, 0, 0);
$contactTypeAdded = true;
}
if ($subType) {
$searchValues[] = array('contact_sub_type', '=', $subType, 0, 0);
}
}
$contactBAO = new CRM_Contact_BAO_Contact();
$query = new CRM_Contact_BAO_Query($searchValues);
$searchCount = $query->searchQuery(0, 0, null, true);
$iTotal = $searchCount;
if ($searchCount > 0) {
// get the result of the search
$result = $query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, null, $sortOrder);
$config =& CRM_Core_Config::singleton();
//variable is set if only one record is foun and that record already has relationship with the contact
$duplicateRelationship = 0;
while ($result->fetch()) {
$contactID = $result->contact_id;
if (in_array($contactID, $excludedContactIds)) {
$duplicateRelationship++;
continue;
}
$duplicateRelationship = 0;
$contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, false, $contactID);
$searchRows[$contactID]['id'] = $contactID;
$searchRows[$contactID]['name'] = $typeImage . ' ' . $result->sort_name;
$searchRows[$contactID]['city'] = $result->city;
$searchRows[$contactID]['state'] = $result->state_province;
$searchRows[$contactID]['email'] = $result->email;
$searchRows[$contactID]['phone'] = $result->phone;
}
}
foreach ($searchRows as $cid => $row) {
if ($sEcho == 1 && count($searchRows) == 1) {
$searchRows[$cid]['check'] = '<input type="checkbox" id="contact_check[' . $cid . ']" name="contact_check[' . $cid . ']" value=' . $cid . ' checked />';
} else {
$searchRows[$cid]['check'] = '<input type="checkbox" id="contact_check[' . $cid . ']" name="contact_check[' . $cid . ']" value=' . $cid . ' />';
}
if ($typeName == 'Employee of') {
$searchRows[$cid]['employee_of'] = '<input type="radio" name="employee_of" value=' . $cid . ' >';
} elseif ($typeName == 'Employer of') {
$searchRows[$cid]['employer_of'] = '<input type="checkbox" name="employer_of[' . $cid . ']" value=' . $cid . ' />';
}
}
require_once "CRM/Utils/JSON.php";
$selectorElements = array('check', 'name');
if ($typeName == 'Employee of') {
$selectorElements[] = 'employee_of';
} elseif ($typeName == 'Employer of') {
$selectorElements[] = 'employer_of';
}
$selectorElements = array_merge($selectorElements, array('city', 'state', 'email', 'phone'));
$iFilteredTotal = $iTotal;
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例14: getContactRelationships
/**
* Function to retrieve contact relationships
*/
public static function getContactRelationships()
{
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$context = CRM_Utils_Type::escape($_GET['context'], 'String');
$sortMapper = array(0 => 'relation', 1 => 'sort_name', 2 => 'start_date', 3 => 'end_date', 4 => 'city', 5 => 'state', 6 => 'email', 7 => 'phone', 8 => 'links', 9 => '', 10 => '');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact relationships
$relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('relation', 'name', 'start_date', 'end_date', 'city', 'state', 'email', 'phone', 'links', 'id', 'is_active');
echo CRM_Utils_JSON::encodeDataTableSelector($relationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例15: getContactActivity
static function getContactActivity()
{
$contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array(0 => 'activity_type', 1 => 'subject', 2 => 'source_contact_name', 3 => '', 4 => '', 5 => 'activity_date_time', 6 => 'status_id');
$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';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact activities
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('activity_type', 'subject', 'source_contact', 'target_contact', 'assignee_contact', 'activity_date', 'status', 'links', 'class');
echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}