本文整理汇总了PHP中CRM_Contact_BAO_Contact_Utils::getImage方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Utils::getImage方法的具体用法?PHP CRM_Contact_BAO_Contact_Utils::getImage怎么用?PHP CRM_Contact_BAO_Contact_Utils::getImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact_Utils
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact_Utils::getImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
//.........这里部分代码省略.........
} else {
if (substr($key, 0, 4) == 'cmr_') {
//for readers group
$name = array($key => array('newName' => $key, 'groupName' => substr($key, 0, -3)));
} else {
$name = array($key => array('newName' => $key, 'groupName' => $key));
}
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$key] = $paramsNew[$key];
} else {
if (isset($tmfFields) && $tmfFields && array_key_exists($property, $tmfFields) || substr($property, 0, 12) == 'participant_') {
if (substr($property, -3) == '_id') {
$key = substr($property, 0, -3);
$paramsNew = array($key => $result->{$property});
$name = array($key => array('newName' => $key, 'groupName' => $key));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, false);
$row[$key] = $paramsNew[$key];
} else {
$row[$property] = $result->{$property};
}
} else {
if (strpos($property, '-im')) {
$row[$property] = $result->{$property};
if (!empty($result->{$property})) {
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$providerId = $property . "-provider_id";
$providerName = $imProviders[$result->{$providerId}];
$row[$property] = $result->{$property} . " ({$providerName})";
}
} else {
if (in_array($property, array('addressee', 'email_greeting', 'postal_greeting'))) {
$greeting = $property . '_display';
$row[$property] = $result->{$greeting};
} else {
$row[$property] = $result->{$property};
}
}
}
}
}
if (!empty($result->{$property})) {
$empty = false;
}
}
if (!empty($result->postal_code_suffix)) {
$row['postal_code'] .= "-" . $result->postal_code_suffix;
}
if ($output != CRM_Core_Selector_Controller::EXPORT && $this->_searchContext == 'smog') {
if (empty($result->status) && $groupID) {
$contactID = $result->contact_id;
if ($contactID) {
$gcParams = array('contact_id' => $contactID, 'group_id' => $groupID);
$gcDefaults = array();
CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_GroupContact', $gcParams, $gcDefaults);
if (empty($gcDefaults)) {
$row['status'] = ts('Smart');
} else {
$row['status'] = $gc[$gcDefaults['status']];
}
} else {
$row['status'] = null;
}
} else {
$row['status'] = $gc[$result->status];
}
}
if ($output != CRM_Core_Selector_Controller::EXPORT) {
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contact_id;
if (is_numeric(CRM_Utils_Array::value('geo_code_1', $row)) || $config->mapGeoCoding && CRM_Utils_Array::value('city', $row) && $row['state_province']) {
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->contact_id));
} else {
$row['action'] = CRM_Core_Action::formLink($links, $mapMask, array('id' => $result->contact_id));
}
// allow components to add more actions
CRM_Core_Component::searchAction($row, $result->contact_id);
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
$row['contact_id'] = $result->contact_id;
$row['sort_name'] = $result->sort_name;
if (array_key_exists('id', $row)) {
$row['id'] = $result->contact_id;
}
}
// Dedupe contacts
if (!$empty) {
$duplicate = false;
foreach ($rows as $checkRow) {
if ($checkRow['contact_id'] == $row['contact_id']) {
$duplicate = true;
}
}
if (!$duplicate) {
$rows[] = $row;
}
}
}
//CRM_Core_Error::debug( '$rows', $rows );
return $rows;
}
示例2: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause);
// process the result of the query
$rows = array();
//lets handle view, edit and delete separately. CRM-4418
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit event participants')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$statusTypes = CRM_Event_PseudoConstant::participantStatus();
$statusClasses = CRM_Event_PseudoConstant::participantStatusClass();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->participant_campaign_id;
// gross hack to show extra information for pending status
$statusClass = NULL;
if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) {
$statusClass = $statusClasses[$statusId];
}
$row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE;
if (!empty($row['participant_is_test'])) {
$row['participant_status'] .= ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id;
$links = self::links($this->_key, $this->_context, $this->_compContext);
if ($statusTypes[$row['participant_status_id']] == 'Partially paid') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment'));
}
if ($statusTypes[$row['participant_status_id']] == 'Pending refund') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund'));
}
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']);
if (!empty($row['participant_fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']);
}
if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
// add line item details if applicable
$lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
}
if (!empty($row['participant_role_id'])) {
$viewRoles = array();
foreach (explode($sep, $row['participant_role_id']) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$row['participant_role_id'] = implode(', ', $viewRoles);
}
$rows[] = $row;
}
CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems);
return $rows;
}
示例3: getCases
/**
* Retrieve cases related to particular contact or whole contact
* used in Dashboad and Tab
*
* @param boolean $allCases
*
* @param int $userID
*
* @param String $type /upcoming,recent,all/
*
* @param string $context
*
* @return array Array of Cases
*
* @access public
*/
static function getCases($allCases = TRUE, $userID = NULL, $type = 'upcoming', $context = 'dashboard')
{
$condition = NULL;
$casesList = array();
//validate access for own cases.
if (!self::accessCiviCase()) {
return $casesList;
}
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
}
//validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
$allCases = FALSE;
}
$condition = " AND civicrm_case.is_deleted = 0 ";
if (!$allCases) {
$condition .= " AND case_relationship.contact_id_b = {$userID} ";
}
if ($type == 'upcoming' || $type == 'any') {
$closedId = CRM_Core_OptionGroup::getValue('case_status', 'Closed', 'name');
$condition .= "\nAND civicrm_case.status_id != {$closedId}";
}
$query = self::getCaseActivityQuery($type, $userID, $condition);
$queryParams = array();
$result = CRM_Core_DAO::executeQuery($query, $queryParams);
$caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND v.name = 'Urgent' ");
$resultFields = array('contact_id', 'contact_type', 'sort_name', 'phone', 'case_id', 'case_subject', 'case_type', 'case_type_id', 'status_id', 'case_status', 'case_status_name', 'activity_type_id', 'case_start_date', 'case_role');
if ($type == 'upcoming') {
$resultFields[] = 'case_scheduled_activity_date';
$resultFields[] = 'case_scheduled_activity_type_name';
$resultFields[] = 'case_scheduled_activity_type';
$resultFields[] = 'case_scheduled_activity_id';
} elseif ($type == 'recent') {
$resultFields[] = 'case_recent_activity_date';
$resultFields[] = 'case_recent_activity_type_name';
$resultFields[] = 'case_recent_activity_type';
$resultFields[] = 'case_recent_activity_id';
} elseif ($type == 'any') {
$resultFields[] = 'case_activity_date';
$resultFields[] = 'case_activity_type_name';
$resultFields[] = 'case_activity_type';
$resultFields[] = 'case_activity_id';
}
// we're going to use the usual actions, so doesn't make sense to duplicate definitions
$actions = CRM_Case_Selector_Search::links();
// check is the user has view/edit signer permission
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('access all cases and activities') || !$allCases && CRM_Core_Permission::check('access my cases and activities')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviCase')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
while ($result->fetch()) {
foreach ($resultFields as $donCare => $field) {
$casesList[$result->case_id][$field] = $result->{$field};
if ($field == 'contact_type') {
$casesList[$result->case_id]['contact_type_icon'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
$casesList[$result->case_id]['action'] = CRM_Core_Action::formLink($actions['primaryActions'], $mask, array('id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => $context), ts('more'), FALSE, 'case.actions.primary', 'Case', $result->case_id);
$casesList[$result->case_id]['moreActions'] = CRM_Core_Action::formLink($actions['moreActions'], $mask, array('id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => $context), ts('more'), TRUE, 'case.actions.more', 'Case', $result->case_id);
} elseif ($field == 'case_status') {
if (in_array($result->{$field}, $caseStatus)) {
$casesList[$result->case_id]['class'] = "status-urgent";
} else {
$casesList[$result->case_id]['class'] = "status-normal";
}
}
}
//CRM-4510.
$caseTypes = CRM_Case_PseudoConstant::caseType('name');
$caseManagerContact = self::getCaseManagerContact($caseTypes[$result->case_type_id], $result->case_id);
if (!empty($caseManagerContact)) {
$casesList[$result->case_id]['casemanager_id'] = CRM_Utils_Array::value('casemanager_id', $caseManagerContact);
$casesList[$result->case_id]['casemanager'] = CRM_Utils_Array::value('casemanager', $caseManagerContact);
}
//do check user permissions for edit/view activity.
if (($actId = CRM_Utils_Array::value('case_scheduled_activity_id', $casesList[$result->case_id])) || ($actId = CRM_Utils_Array::value('case_recent_activity_id', $casesList[$result->case_id]))) {
$casesList[$result->case_id]["case_{$type}_activity_editable"] = self::checkPermission($actId, 'edit', $casesList[$result->case_id]['activity_type_id'], $userID);
$casesList[$result->case_id]["case_{$type}_activity_viewable"] = self::checkPermission($actId, 'view', $casesList[$result->case_id]['activity_type_id'], $userID);
}
}
//.........这里部分代码省略.........
示例4: getContactRelationshipSelector
/**
* Wrapper for contact relationship selector.
*
* @param array $params
* Associated array for params record id.
*
* @return array
* associated array of contact relationships
*/
public static function getContactRelationshipSelector(&$params)
{
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
if ($params['context'] == 'past') {
$relationshipStatus = CRM_Contact_BAO_Relationship::INACTIVE;
} elseif ($params['context'] == 'all') {
$relationshipStatus = CRM_Contact_BAO_Relationship::ALL;
} else {
$relationshipStatus = CRM_Contact_BAO_Relationship::CURRENT;
}
// check logged in user for permission
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
if ($page->_permission == CRM_Core_Permission::EDIT) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$permissionedContacts = TRUE;
if ($params['context'] != 'user') {
$links = CRM_Contact_Page_View_Relationship::links();
} else {
$links = CRM_Contact_Page_View_UserDashBoard::links();
$mask = NULL;
}
// get contact relationships
$relationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], $relationshipStatus, $params['rp'], 0, 0, $links, $mask, $permissionedContacts, $params);
$contactRelationships = array();
$params['total'] = 0;
if (!empty($relationships)) {
// FIXME: we cannot directly determine total permissioned relationship, hence re-fire query
$permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], $relationshipStatus, 0, 0, 0, NULL, NULL, $permissionedContacts);
$params['total'] = count($permissionedRelationships);
// format params
foreach ($relationships as $relationshipId => $values) {
$relationship = array();
$relationship['DT_RowId'] = $values['id'];
$relationship['DT_RowClass'] = 'crm-entity';
if ($values['is_active'] == 0) {
$relationship['DT_RowClass'] .= ' disabled';
}
$relationship['DT_RowAttr'] = array();
$relationship['DT_RowAttr']['data-entity'] = 'relationship';
$relationship['DT_RowAttr']['data-id'] = $values['id'];
//Add image icon for related contacts: CRM-14919
$icon = CRM_Contact_BAO_Contact_Utils::getImage($values['contact_type'], FALSE, $values['cid']);
$relationship['sort_name'] = $icon . ' ' . CRM_Utils_System::href($values['name'], 'civicrm/contact/view', "reset=1&cid={$values['cid']}");
$relationship['relation'] = CRM_Utils_System::href($values['relation'], 'civicrm/contact/view/rel', "action=view&reset=1&cid={$values['cid']}&id={$values['id']}&rtype={$values['rtype']}");
if ($params['context'] == 'current') {
if ($params['contact_id'] == $values['contact_id_a'] and $values['is_permission_a_b'] == 1 or $params['contact_id'] == $values['contact_id_b'] and $values['is_permission_b_a'] == 1) {
$relationship['sort_name'] .= '<span id="permission-a-b" class="crm-marker permission-relationship"> *</span>';
}
if ($values['cid'] == $values['contact_id_a'] and $values['is_permission_a_b'] == 1 or $values['cid'] == $values['contact_id_b'] and $values['is_permission_b_a'] == 1) {
$relationship['relation'] .= '<span id="permission-b-a" class="crm-marker permission-relationship"> *</span>';
}
}
if (!empty($values['description'])) {
$relationship['relation'] .= "<p class='description'>{$values['description']}</p>";
}
$relationship['start_date'] = CRM_Utils_Date::customFormat($values['start_date']);
$relationship['end_date'] = CRM_Utils_Date::customFormat($values['end_date']);
$relationship['city'] = $values['city'];
$relationship['state'] = $values['state'];
$relationship['email'] = $values['email'];
$relationship['phone'] = $values['phone'];
$relationship['links'] = $values['action'];
array_push($contactRelationships, $relationship);
}
}
$relationshipsDT = array();
$relationshipsDT['data'] = $contactRelationships;
$relationshipsDT['recordsTotal'] = $params['total'];
$relationshipsDT['recordsFiltered'] = $params['total'];
return $relationshipsDT;
}
示例5: testGetDisplayAndImage
/**
* Test case for getDisplayAndImage( ).
*/
public function testGetDisplayAndImage()
{
//get the contact params
$params = $this->contactParams();
//create contact
$contact = CRM_Contact_BAO_Contact::create($params);
$contactId = $contact->id;
//get DisplayAndImage.
list($displayName, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($contactId);
$checkImage = CRM_Contact_BAO_Contact_Utils::getImage($params['contact_type'], FALSE, $contactId);
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
$suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
//build display name
$paramsDisplayName = $prefix[$params['prefix_id']] . ' ' . $params['first_name'] . ' ' . $params['last_name'] . ' ' . $suffix[$params['suffix_id']];
$this->assertEquals($displayName, $paramsDisplayName, 'Check For Display Name');
$this->assertEquals($image, $checkImage, 'Check For Image');
//cleanup DB by deleting the contact
$this->contactDelete($contactId);
}
示例6: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_contributionClause);
// process the result of the query
$rows = array();
require_once 'CRM/Event/BAO/Participant.php';
require_once 'CRM/Contact/BAO/Contact/Utils.php';
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = null;
if ($this->_context != 'contribute') {
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, null, false, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', false, false, false, null, 'name', false);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (Pay Later)';
} else {
if (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (Incomplete Transaction)';
}
}
if ($row['is_test']) {
$row['contribution_type'] = $row['contribution_type'] . ' (test)';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink(self::links($componentId, $componentAction, $qfKey, $componentContext), $mask, $actions);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, false, $result->contact_id);
if (CRM_Utils_Array::value('amount_level', $row)) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例7: implode
/**
* Get the information to map a contact.
*
* @param array $ids
* The list of ids for which we want map info.
* $param int $locationTypeID
*
* @param int $locationTypeID
* @param bool $imageUrlOnly
*
* @return null|string
* display name of the contact if found
*/
public static function &getMapInfo($ids, $locationTypeID = NULL, $imageUrlOnly = FALSE)
{
$idString = ' ( ' . implode(',', $ids) . ' ) ';
$sql = "\n SELECT civicrm_contact.id as contact_id,\n civicrm_contact.contact_type as contact_type,\n civicrm_contact.contact_sub_type as contact_sub_type,\n civicrm_contact.display_name as display_name,\n civicrm_address.street_address as street_address,\n civicrm_address.supplemental_address_1 as supplemental_address_1,\n civicrm_address.supplemental_address_2 as supplemental_address_2,\n civicrm_address.city as city,\n civicrm_address.postal_code as postal_code,\n civicrm_address.postal_code_suffix as postal_code_suffix,\n civicrm_address.geo_code_1 as latitude,\n civicrm_address.geo_code_2 as longitude,\n civicrm_state_province.abbreviation as state,\n civicrm_country.name as country,\n civicrm_location_type.name as location_type\n FROM civicrm_contact\nLEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id\nLEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id\nLEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id\nLEFT JOIN civicrm_location_type ON civicrm_location_type.id = civicrm_address.location_type_id\nWHERE civicrm_address.geo_code_1 IS NOT NULL\nAND civicrm_address.geo_code_2 IS NOT NULL\nAND civicrm_contact.id IN {$idString} ";
$params = array();
if (!$locationTypeID) {
$sql .= " AND civicrm_address.is_primary = 1";
} else {
$sql .= " AND civicrm_address.location_type_id = %1";
$params[1] = array($locationTypeID, 'Integer');
}
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$locations = array();
$config = CRM_Core_Config::singleton();
while ($dao->fetch()) {
$location = array();
$location['contactID'] = $dao->contact_id;
$location['displayName'] = addslashes($dao->display_name);
$location['city'] = $dao->city;
$location['state'] = $dao->state;
$location['postal_code'] = $dao->postal_code;
$location['lat'] = $dao->latitude;
$location['lng'] = $dao->longitude;
$location['marker_class'] = $dao->contact_type;
$address = '';
CRM_Utils_String::append($address, '<br />', array($dao->street_address, $dao->supplemental_address_1, $dao->supplemental_address_2, $dao->city));
CRM_Utils_String::append($address, ', ', array($dao->state, $dao->postal_code));
CRM_Utils_String::append($address, '<br /> ', array($dao->country));
$location['address'] = addslashes($address);
$location['displayAddress'] = str_replace('<br />', ', ', addslashes($address));
$location['url'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $dao->contact_id);
$location['location_type'] = $dao->location_type;
$location['image'] = CRM_Contact_BAO_Contact_Utils::getImage(isset($dao->contact_sub_type) ? $dao->contact_sub_type : $dao->contact_type, $imageUrlOnly, $dao->contact_id);
$locations[] = $location;
}
return $locations;
}
示例8: voterList
public function voterList()
{
//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];
}
}
//format multi-select group and contact types.
foreach (array('group', 'contact_type') as $param) {
$paramValue = CRM_Utils_Array::value($param, $params);
if ($paramValue) {
unset($params[$param]);
$paramValue = explode(',', $paramValue);
foreach ($paramValue as $key => $value) {
$params[$param][$value] = 1;
}
}
}
$voterClauseParams = array();
foreach (array('campaign_survey_id', 'survey_interviewer_id', 'campaign_search_voter_for') as $fld) {
$voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params);
}
$interviewerId = $surveyTypeId = $surveyId = NULL;
$searchVoterFor = $params['campaign_search_voter_for'];
if ($searchVoterFor == 'reserve') {
if (!empty($params['campaign_survey_id'])) {
$survey = new CRM_Campaign_DAO_Survey();
$survey->id = $surveyId = $params['campaign_survey_id'];
$survey->selectAdd('campaign_id, activity_type_id');
$survey->find(TRUE);
$campaignId = $survey->campaign_id;
$surveyTypeId = $survey->activity_type_id;
//allow voter search in sub-part of given constituents,
//but make sure in case user does not select any group.
//get all associated campaign groups in where filter, CRM-7406
$groups = CRM_Utils_Array::value('group', $params);
if ($campaignId && CRM_Utils_System::isNull($groups)) {
$campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
foreach ($campaignGroups as $id => $group) {
$params['group'][$id] = 1;
}
}
//apply filter of survey contact type for search.
$contactType = CRM_Campaign_BAO_Survey::getSurveyContactType($surveyId);
if ($contactType) {
$params['contact_type'][$contactType] = 1;
}
unset($params['campaign_survey_id']);
}
unset($params['survey_interviewer_id']);
} else {
//get the survey status in where clause.
$scheduledStatusId = array_search('Scheduled', CRM_Core_PseudoConstant::activityStatus('name'));
if ($scheduledStatusId) {
$params['survey_status_id'] = $scheduledStatusId;
}
//BAO/Query knows reserve/release/interview processes.
if ($params['campaign_search_voter_for'] == 'gotv') {
$params['campaign_search_voter_for'] = 'release';
}
}
$selectorCols = array('sort_name', 'street_address', 'street_name', 'street_number', 'street_unit');
// 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' => 'sort_name'), 'sortOrder' => array('name' => 'sSortDir_0', 'type' => 'String', 'default' => 'asc'));
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}];
}
}
}
$queryParams = CRM_Contact_BAO_Query::convertFormValues($params);
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CAMPAIGN, TRUE);
//get the voter clause to restrict and validate search.
$voterClause = CRM_Campaign_BAO_Query::voterClause($voterClauseParams);
$searchCount = $query->searchQuery(0, 0, NULL, TRUE, FALSE, FALSE, FALSE, FALSE, CRM_Utils_Array::value('whereClause', $voterClause), NULL, CRM_Utils_Array::value('fromClause', $voterClause));
$iTotal = $searchCount;
$selectorCols = array('contact_type', 'sort_name', 'street_address', 'street_name', 'street_number', 'street_unit');
$extraVoterColName = 'is_interview_conducted';
if ($params['campaign_search_voter_for'] == 'reserve') {
$extraVoterColName = 'reserve_voter';
}
if ($searchCount > 0) {
if ($searchCount < $offset) {
$offset = 0;
}
$config = CRM_Core_Config::singleton();
// get the result of the search
$result = $query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, CRM_Utils_Array::value('whereClause', $voterClause), $sortOrder, CRM_Utils_Array::value('fromClause', $voterClause));
while ($result->fetch()) {
$contactID = $result->contact_id;
$typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$searchRows[$contactID] = array('id' => $contactID);
foreach ($selectorCols as $col) {
//.........这里部分代码省略.........
示例9: array
//.........这里部分代码省略.........
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "website-{$id}-{$fieldName}";
}
} elseif ($field['name'] == 'id') {
$names[] = 'contact_id';
} else {
$names[] = $field['name'];
}
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$multiRecordTableId = NULL;
if ($this->_multiRecordTableName) {
$multiRecordTableId = "{$this->_multiRecordTableName}_id";
}
// we need to determine of overlay profile should be shown
$showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
while ($result->fetch()) {
$this->_query->convertToPseudoNames($result);
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n = CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = TRUE;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
if ($result->sort_name) {
$row[] = $result->sort_name;
$empty = FALSE;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$typeId = substr($name, 0, -4) . "-website_type_id";
$typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->{$typeId});
if ($typeName) {
$row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
} else {
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
}
} elseif ($name == 'preferred_language') {
$row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->{$name});
} elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
$paramsNew = array($name => $result->{$name});
$name = array($name => array('newName' => $name, 'groupName' => $name));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[] = $paramsNew[$key];
} elseif (strpos($name, '-im')) {
if (!empty($result->{$name})) {
$providerId = $name . "-provider_id";
$providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->{$providerId});
$row[] = $result->{$name} . " ({$providerName})";
} else {
$row[] = '';
示例10: array
//.........这里部分代码省略.........
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
if ($this->_includeSoftCredits) {
// especial sort order when rows include soft credits
$sort = "civicrm_contribution.receive_date DESC, civicrm_contribution.id, civicrm_contribution_soft.id";
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$links = self::links($componentId, $componentAction, $qfKey, $componentContext);
$checkLineItem = FALSE;
$row = array();
// Now check for lineItems
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id);
foreach ($lineItems as $items) {
if (!CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
$checkLineItem = TRUE;
break;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
if ($checkLineItem) {
continue;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
} elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
}
if ($row['is_test']) {
$row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink($links, $mask, $actions, ts('more'), FALSE, 'contribution.selector.row', 'Contribution', $result->contribution_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
if (!empty($row['amount_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}
示例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: 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');
$currentContactId = CRM_Utils_Type::escape($_REQUEST['cid'], 'Integer');
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);
$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);
}
}
// exclude current contact
$searchValues[] = array('contact_id', '!=', $currentContactId, 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;
$duplicateRelationship = 0;
$contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
$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) {
$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 . ' />';
}
}
$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();
}
示例13: getCases
/**
* Retrieve cases related to particular contact or whole contact
* used in Dashboad and Tab
*
* @param boolean $allCases
*
* @param int $userID
*
* @param String $type /upcoming,recent,all/
*
* @return array Array of Cases
*
* @access public
*
*/
function getCases($allCases = true, $userID = null, $type = 'upcoming')
{
$condition = null;
if (!$allCases) {
$condition = " AND case_relationship.contact_id_b = {$userID}";
}
$condition .= " \nAND civicrm_activity.is_deleted = 0\nAND civicrm_case.is_deleted = 0";
if ($type == 'upcoming') {
$closedId = CRM_Core_OptionGroup::getValue('case_status', 'Closed', 'name');
$condition .= "\nAND civicrm_case.status_id != {$closedId}";
}
$query = self::getCaseActivityQuery($type, $userID, $condition);
$queryParams = array();
$result = CRM_Core_DAO::executeQuery($query, $queryParams);
require_once 'CRM/Core/OptionGroup.php';
$caseStatus = CRM_Core_OptionGroup::values('case_status', false, false, false, " AND v.name = 'Urgent' ");
$resultFields = array('contact_id', 'contact_type', 'sort_name', 'phone', 'case_id', 'case_type', 'case_type_name', 'status_id', 'case_status', 'case_status_name', 'activity_type_id', 'case_role');
if ($type == 'upcoming') {
$resultFields[] = 'case_scheduled_activity_date';
$resultFields[] = 'case_scheduled_activity_type_name';
$resultFields[] = 'case_scheduled_activity_type';
$resultFields[] = 'case_scheduled_activity_id';
} else {
if ($type == 'recent') {
$resultFields[] = 'case_recent_activity_date';
$resultFields[] = 'case_recent_activity_type_name';
$resultFields[] = 'case_recent_activity_type';
$resultFields[] = 'case_recent_activity_id';
}
}
// we're going to use the usual actions, so doesn't make sense to duplicate definitions
require_once 'CRM/Case/Selector/Search.php';
$actions = CRM_Case_Selector_Search::links();
require_once "CRM/Contact/BAO/Contact/Utils.php";
$casesList = array();
// check is the user has view/edit signer permission
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit cases')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviCase')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
while ($result->fetch()) {
foreach ($resultFields as $donCare => $field) {
$casesList[$result->case_id][$field] = $result->{$field};
if ($field == 'contact_type') {
$casesList[$result->case_id]['contact_type_icon'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type);
$casesList[$result->case_id]['action'] = CRM_Core_Action::formLink($actions, $mask, array('id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => 'dashboard'));
} elseif ($field == 'case_status') {
if (in_array($result->{$field}, $caseStatus)) {
$casesList[$result->case_id]['class'] = "status-urgent";
} else {
$casesList[$result->case_id]['class'] = "status-normal";
}
}
}
//CRM-4510.
$caseManagerContact = self::getCaseManagerContact($result->case_type_name, $result->case_id);
if (!empty($caseManagerContact)) {
$casesList[$result->case_id]['casemanager_id'] = CRM_Utils_Array::value('casemanager_id', $caseManagerContact);
$casesList[$result->case_id]['casemanager'] = CRM_Utils_Array::value('casemanager', $caseManagerContact);
}
}
return $casesList;
}
示例14: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_additionalClause);
// process the result of the query
$rows = array();
// get all pledge status
$pledgeStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
//4418 check for view, edit and delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit pledges')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviPledge')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->pledge_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->pledge_campaign_id;
// add pledge status name
$row['pledge_status_name'] = CRM_Utils_Array::value($row['pledge_status_id'], $pledgeStatuses);
// append (test) to status label
if (!empty($row['pledge_is_test'])) {
$row['pledge_status'] .= ' (test)';
}
$hideOption = array();
if (CRM_Utils_Array::key('Cancelled', $row) || CRM_Utils_Array::key('Completed', $row)) {
$hideOption[] = 'Cancel';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->pledge_id;
$row['action'] = CRM_Core_Action::formLink(self::links($hideOption, $this->_key), $mask, array('id' => $result->pledge_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'pledge.selector.row', 'Pledge', $result->pledge_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$rows[] = $row;
}
return $rows;
}
示例15: array_values
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$includeContactIDs = FALSE;
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIDs = TRUE;
}
$sql = $this->_search->all($offset, $rowCount, $sort, $includeContactIDs);
// contact query object used for creating $sql
$contactQueryObj = NULL;
if (method_exists($this->_search, 'getQueryObj') && is_a($this->_search->getQueryObj(), 'CRM_Contact_BAO_Query')) {
$contactQueryObj = $this->_search->getQueryObj();
}
$dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
$columns = $this->_search->columns();
$columnNames = array_values($columns);
$links = self::links($this->_key);
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$alterRow = FALSE;
if (method_exists($this->_customSearchClass, 'alterRow')) {
$alterRow = TRUE;
}
$image = FALSE;
if (is_a($this->_search, 'CRM_Contact_Form_Search_Custom_Basic')) {
$image = TRUE;
}
// process the result of the query
$rows = array();
while ($dao->fetch()) {
$row = array();
$empty = TRUE;
// if contact query object present
// process pseudo constants
if ($contactQueryObj) {
$contactQueryObj->convertToPseudoNames($dao);
}
// the columns we are interested in
foreach ($columnNames as $property) {
$row[$property] = $dao->{$property};
if (!empty($dao->{$property})) {
$empty = FALSE;
}
}
if (!$empty) {
$contactID = isset($dao->contact_id) ? $dao->contact_id : NULL;
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $contactID;
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $contactID), ts('more'), FALSE, 'contact.custom.actions', 'Contact', $contactID);
$row['contact_id'] = $contactID;
if ($alterRow) {
$this->_search->alterRow($row);
}
if ($image) {
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($dao->contact_sub_type ? $dao->contact_sub_type : $dao->contact_type, FALSE, $contactID);
}
$rows[] = $row;
}
}
$this->buildPrevNextCache($sort);
return $rows;
}