+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
- * This class contains the functions for Case Management
+ * This class contains the functions for Case Management.
*
*/
class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
- * Static field for all the case information that we can potentially export
+ * Static field for all the case information that we can potentially export.
*
* @var array
*/
static $_exportableFields = NULL;
/**
+ * Class constructor.
*/
public function __construct() {
parent::__construct();
}
/**
- * Takes an associative array and creates a case object
+ * Create a case object.
*
- * the function extract all the params it needs to initialize the create a
+ * The function extracts all the params it needs to initialize the create a
* case object. the params array could contain additional unused name/value
* pairs
*
/**
* Given the list of params in the params array, fetch the object
- * and store the values in the values array
+ * and store the values in the values array.
*
* @param array $params
* Input parameters to find object.
* @param array $ids
* The array that holds all the db ids.
*
- * @return CRM_Case_BAO_Case|null the found object or null
+ * @return CRM_Case_BAO_Case|null
+ * The found object or null
*/
public static function &getValues(&$params, &$values, &$ids) {
$case = new CRM_Case_BAO_Case();
}
/**
- * Takes an associative array and creates a case object
+ * Takes an associative array and creates a case object.
*
* @param array $params
- * (reference ) an assoc array of name/value pairs.
+ * (reference) an assoc array of name/value pairs.
*
* @return CRM_Case_BAO_Case
*/
}
/**
- * Create case contact record
+ * Create case contact record.
*
* @param array $params
* case_id, contact_id
}
/**
- * Delet case contact record
+ * Delete case contact record.
*
* @param int $caseID
- *
- * @return void
*/
public static function deleteCaseContact($caseID) {
$caseContact = new CRM_Case_DAO_CaseContact();
}
/**
- * convert associative array names to values
- * and vice-versa.
+ * Convert associative array names to values and vice-versa.
*
* This function is used by both the web form layer and the api. Note that
* the api needs the name => value conversion, also the view layer typically
* requires value => name conversion
+ *
+ * @param array $defaults
+ * @param string $property
+ * @param array $lookup
+ * @param bool $reverse
+ *
+ * @return bool
*/
public static function lookupValue(&$defaults, $property, &$lookup, $reverse) {
$id = $property . '_id';
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. We'll tweak this function to be more
- * full featured over a period of time. This is the inverse function of
- * create. It also stores all the retrieved values in the default array
+ * Retrieve DB object based on input parameters.
+ *
+ * It also stores all the retrieved values in the default array.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
}
/**
- * Get the case subject for Activity
+ * Get the case subject for Activity.
*
* @param int $activityId
* Activity id.
}
/**
- * Delete the record that are associated with this case
+ * Delete the record that are associated with this case.
* record are deleted from case
*
* @param int $caseId
}
/**
- * Enable disable case related relationships
+ * Enable disable case related relationships.
*
* @param int $caseId
* Case id.
}
/**
- * Delete the activities related to case
+ * Delete the activities related to case.
*
* @param int $activityId
* Id of the activity.
}
/**
- * Retrieve contact_id by case_id
+ * Retrieve contact_id by case_id.
*
* @param int $caseId
* ID of the case.
}
/**
- * Look up a case using an activity ID
+ * Look up a case using an activity ID.
*
* @param int $activityId
*
}
/**
- * Retrieve contact names by caseId
+ * Retrieve contact names by caseId.
*
* @param int $caseId
* ID of the case.
}
/**
- * Retrieve case_id by contact_id
+ * Retrieve case_id by contact_id.
*
* @param int $contactID
* @param bool $includeDeleted
}
/**
- * Retrieve cases related to particular contact or whole contact
- * used in Dashboad and Tab
+ * Retrieve cases related to particular contact or whole contact used in Dashboard and Tab.
*
* @param bool $allCases
*
}
/**
- * Get Case roles
+ * Get Case roles.
*
* @param int $contactID
* Contact id.
}
/**
- * Get Case Activities
+ * Get Case Activities.
*
* @param int $caseID
* Case id.
// CRM-5081 - formatting the dates to omit seconds.
// Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
- $select = "SELECT count(ca.id) as ismultiple, ca.id as id,
- ca.activity_type_id as type,
- ca.activity_type_id as activity_type_id,
- cc.sort_name as reporter,
- cc.id as reporter_id,
- acc.sort_name AS assignee,
- acc.id AS assignee_id,
- DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,
- ca.activity_date_time,
- DATE_ADD(NOW(), INTERVAL 1 YEAR)
- ), '%Y%m%d%H%i00') as overdue_date,
- DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,
- ca.status_id as status,
- ca.subject as subject,
- ca.is_deleted as deleted,
- ca.priority_id as priority,
- ca.weight as weight,
- GROUP_CONCAT(ef.file_id) as attachment_ids ";
+ $select = "
+ SELECT COUNT(ca.id) AS ismultiple,
+ ca.id AS id,
+ ca.activity_type_id AS type,
+ ca.activity_type_id AS activity_type_id,
+ tcc.sort_name AS target_contact_name,
+ tcc.id AS target_contact_id,
+ scc.sort_name AS source_contact_name,
+ scc.id AS source_contact_id,
+ acc.sort_name AS assignee_contact_name,
+ acc.id AS assignee_contact_id,
+ DATE_FORMAT(
+ IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,
+ ca.activity_date_time,
+ DATE_ADD(NOW(), INTERVAL 1 YEAR)
+ ), '%Y%m%d%H%i00') AS overdue_date,
+ DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') AS display_date,
+ ca.status_id AS status,
+ ca.subject AS subject,
+ ca.is_deleted AS deleted,
+ ca.priority_id AS priority,
+ ca.weight AS weight,
+ GROUP_CONCAT(ef.file_id) AS attachment_ids ";
$from = "
- FROM civicrm_case_activity cca
- INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id
- INNER JOIN civicrm_activity_contact cac ON cac.activity_id = ca.id AND cac.record_type_id = {$sourceID}
- INNER JOIN civicrm_contact cc ON cc.id = cac.contact_id
- INNER JOIN civicrm_option_group cog ON cog.name = 'activity_type'
- INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id
- AND cov.value = ca.activity_type_id AND cov.is_active = 1
- LEFT JOIN civicrm_entity_file ef on ef.entity_table = 'civicrm_activity' AND ef.entity_id = ca.id
- LEFT OUTER JOIN civicrm_option_group og ON og.name = 'activity_status'
- LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name = 'Scheduled'
- LEFT JOIN civicrm_activity_contact caa
- ON caa.activity_id = ca.id AND caa.record_type_id = {$assigneeID}
- LEFT JOIN civicrm_contact acc ON acc.id = caa.contact_id ";
-
- $where = 'WHERE cca.case_id= %1
- AND ca.is_current_revision = 1';
-
- if (!empty($params['reporter_id'])) {
- $where .= " AND cac.contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
+ FROM civicrm_case_activity cca
+ INNER JOIN civicrm_activity ca
+ ON ca.id = cca.activity_id
+ INNER JOIN civicrm_activity_contact cas
+ ON cas.activity_id = ca.id
+ AND cas.record_type_id = {$sourceID}
+ INNER JOIN civicrm_contact scc
+ ON scc.id = cas.contact_id
+ LEFT JOIN civicrm_activity_contact caa
+ ON caa.activity_id = ca.id
+ AND caa.record_type_id = {$assigneeID}
+ LEFT JOIN civicrm_contact acc
+ ON acc.id = caa.contact_id
+ LEFT JOIN civicrm_activity_contact cat
+ ON cat.activity_id = ca.id
+ AND cat.record_type_id = {$targetID}
+ LEFT JOIN civicrm_contact tcc
+ ON tcc.id = cat.contact_id
+ INNER JOIN civicrm_option_group cog
+ ON cog.name = 'activity_type'
+ INNER JOIN civicrm_option_value cov
+ ON cov.option_group_id = cog.id
+ AND cov.value = ca.activity_type_id
+ AND cov.is_active = 1
+ LEFT JOIN civicrm_entity_file ef
+ ON ef.entity_table = 'civicrm_activity'
+ AND ef.entity_id = ca.id
+ LEFT OUTER JOIN civicrm_option_group og
+ ON og.name = 'activity_status'
+ LEFT OUTER JOIN civicrm_option_value ov
+ ON ov.option_group_id=og.id
+ AND ov.name = 'Scheduled'";
+
+ $where = '
+ WHERE cca.case_id= %1
+ AND ca.is_current_revision = 1';
+
+ if (!empty($params['source_contact_id'])) {
+ $where .= "
+ AND cas.contact_id = " . CRM_Utils_Type::escape($params['source_contact_id'], 'Integer');
}
if (!empty($params['status_id'])) {
- $where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
+ $where .= "
+ AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (!empty($params['activity_deleted'])) {
- $where .= " AND ca.is_deleted = 1";
+ $where .= "
+ AND ca.is_deleted = 1";
}
else {
- $where .= " AND ca.is_deleted = 0";
+ $where .= "
+ AND ca.is_deleted = 0";
}
if (!empty($params['activity_type_id'])) {
- $where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
+ $where .= "
+ AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (!empty($params['activity_date_low'])) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
+ if (!empty($fromActivityDate)) {
+ $where .= "
+ AND ca.activity_date_time >= '{$fromActivityDate}'";
+ }
+
if (!empty($params['activity_date_high'])) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : NULL;
}
-
- if (!empty($fromActivityDate)) {
- $where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
- }
-
if (!empty($toActivityDate)) {
- $where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
+ $where .= "
+ AND ca.activity_date_time <= '{$toActivityDate}'";
}
- // hack to handle to allow initial sorting to be done by query
- if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
- $params['sortname'] = NULL;
- }
+ $groupBy = "
+ GROUP BY ca.id ";
- if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
- $params['sortorder'] = NULL;
- }
-
- $sortname = CRM_Utils_Array::value('sortname', $params);
- $sortorder = CRM_Utils_Array::value('sortorder', $params);
-
- $groupBy = " GROUP BY ca.id ";
-
- if (!$sortname AND !$sortorder) {
+ $sortBy = CRM_Utils_Array::value('sortBy', $params);
+ if (!$sortBy) {
// CRM-5081 - added id to act like creation date
- $orderBy = " ORDER BY overdue_date ASC, display_date DESC, weight DESC";
+ $orderBy = "
+ ORDER BY overdue_date ASC, display_date DESC, weight DESC";
}
else {
- $sort = "{$sortname} {$sortorder}";
- $sort = CRM_Utils_Type::escape($sort, 'String');
- $orderBy = " ORDER BY $sort ";
- if ($sortname != 'display_date') {
- $orderBy .= ', display_date DESC';
- }
+ $sortBy = CRM_Utils_Type::escape($sortBy, 'String');
+ $orderBy = " ORDER BY $sortBy ";
}
$page = CRM_Utils_Array::value('page', $params);
if (!$rp) {
$rp = 10;
}
-
$start = (($page - 1) * $rp);
- $query = $select . $from . $where . $groupBy . $orderBy;
-
- $params = array(1 => array($caseID, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $params['total'] = $dao->N;
-
- //FIXME: need to optimize/cache these queries
$limit = " LIMIT $start, $rp";
- $query .= $limit;
- //EXIT;
- $dao = CRM_Core_DAO::executeQuery($query, $params);
+ $query = $select . $from . $where . $groupBy . $orderBy . $limit;
+ $queryParams = array(1 => array($caseID, 'Integer'));
+
+ $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
- $activityStatus = CRM_Core_PseudoConstant::activityStatus();
- $activityPriority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
+ $activityStatuses = CRM_Core_PseudoConstant::activityStatus();
$url = CRM_Utils_System::url("civicrm/case/activity",
"reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE
foreach ($compStatusNames as $name) {
$compStatusValues[] = CRM_Core_OptionGroup::getValue('activity_status', $name, 'name');
}
- $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view",
- "reset=1&cid=", FALSE, NULL, FALSE
- );
+
+ $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE);
$hasViewContact = CRM_Core_Permission::giveMeAllACLs();
$clientIds = self::retrieveContactIdsByCaseId($caseID);
$userID = $session->get('userID');
}
+ $caseActivities = array();
+ $caseCount = 0;
+
while ($dao->fetch()) {
+ $caseCount++;
+ $caseActivity = array();
+ $caseActivityId = $dao->id;
- $allowView = self::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID);
- $allowEdit = self::checkPermission($dao->id, 'edit', $dao->activity_type_id, $userID);
- $allowDelete = self::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID);
+ $allowView = self::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID);
+ $allowEdit = self::checkPermission($caseActivityId, 'edit', $dao->activity_type_id, $userID);
+ $allowDelete = self::checkPermission($caseActivityId, 'delete', $dao->activity_type_id, $userID);
//do not have sufficient permission
//to access given case activity record.
continue;
}
- $values[$dao->id]['id'] = $dao->id;
- $values[$dao->id]['type'] = $activityTypes[$dao->type]['label'];
+ //Add classes to the row, via DataTables syntax
+ $caseActivity['DT_RowClass'] = "crm-entity";
- $reporterName = $dao->reporter;
- if ($hasViewContact) {
- $reporterName = '<a href="' . $contactViewUrl . $dao->reporter_id . '">' . $dao->reporter . '</a>';
- }
- $values[$dao->id]['reporter'] = $reporterName;
- $targetNames = CRM_Activity_BAO_ActivityContact::getNames($dao->id, $targetID);
- $targetContactUrls = $withContacts = array();
- foreach ($targetNames as $targetId => $targetName) {
- if (!in_array($targetId, $clientIds)) {
- $withContacts[$targetId] = $targetName;
+ if (CRM_Utils_Array::crmInArray($dao->status, $compStatusValues)) {
+ $caseActivity['DT_RowClass'] .= " status-completed";
+ }
+ else {
+ if (CRM_Utils_Date::overdue($dao->display_date)) {
+ $caseActivity['DT_RowClass'] .= " status-overdue";
+ }
+ else {
+ $caseActivity['DT_RowClass'] .= " status-scheduled";
}
}
- foreach ($withContacts as $cid => $name) {
- if ($hasViewContact) {
- $name = '<a href="' . $contactViewUrl . $cid . '">' . $name . '</a>';
+
+ if (!empty($dao->priority)) {
+ if ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Urgent', 'name')) {
+ $caseActivity['DT_RowClass'] .= " priority-urgent ";
+ }
+ elseif ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Low', 'name')) {
+ $caseActivity['DT_RowClass'] .= " priority-low ";
}
- $targetContactUrls[] = $name;
}
- $values[$dao->id]['with_contacts'] = implode('; ', $targetContactUrls);
- $values[$dao->id]['display_date'] = CRM_Utils_Date::customFormat($dao->display_date);
- $values[$dao->id]['status'] = $activityStatus[$dao->status];
+ //Add data to the row for inline editing, via DataTable syntax
+ $caseActivity['DT_RowData'] = array();
+ $caseActivity['DT_RowData']['entity'] = 'activity';
+ $caseActivity['DT_RowData']['id'] = $caseActivityId;
- //check for view activity.
- $subject = (empty($dao->subject)) ? '(' . ts('no subject') . ')' : $dao->subject;
- if ($allowView) {
- $url = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $dao->id));
- $subject = '<a class="crm-popup medium-popup" href="' . $url . '" title="' . $viewTitle . '">' . $subject . '</a>';
- }
- $values[$dao->id]['subject'] = $subject;
+ //Activity Date and Time
+ $caseActivity['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date);
- // add activity assignee to activity selector. CRM-4485.
- if (isset($dao->assignee)) {
- if ($dao->ismultiple == 1) {
- if ($dao->reporter_id != $dao->assignee_id) {
- $values[$dao->id]['reporter'] .= ($hasViewContact) ? ' / ' . "<a href='{$contactViewUrl}{$dao->assignee_id}'>$dao->assignee</a>" : ' / ' . $dao->assignee;
- }
- $values[$dao->id]['assignee'] = $dao->assignee;
+ //Activity Subject
+ $caseActivity['subject'] = $dao->subject;
+
+ //Activity Type
+ $caseActivity['type'] = $activityTypes[$dao->type]['label'];
+
+ //Activity Target (With)
+ $targetContact = '';
+ if (isset($dao->target_contact_id)) {
+ $targetContact = $dao->target_contact_name;
+ if ($hasViewContact) {
+ $targetContact = '<a href="' . $contactViewUrl . $dao->target_contact_id . '">' . $dao->target_contact_name . '</a>';
}
- else {
- $values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)');
+ }
+ $caseActivity['target_contact_name'] = $targetContact;
+
+ //Activity Source Contact (Reporter)
+ $sourceContact = $dao->source_contact_name;
+ if ($hasViewContact) {
+ $sourceContact = '<a href="' . $contactViewUrl . $dao->source_contact_id . '">' . $dao->source_contact_name . '</a>';
+ }
+ $caseActivity['source_contact_name'] = $sourceContact;
+
+ //Activity Assignee. CRM-4485.
+ $assigneeContact = '';
+ if (isset($dao->assignee_contact_id)) {
+ $assigneeContact = $dao->assignee_contact_name;
+ if ($hasViewContact) {
+ $assigneeContact = '<a href="' . $contactViewUrl . $dao->assignee_contact_id . '">' . $dao->assignee_contact_name . '</a>';
}
}
+ $caseActivity['assignee_contact_name'] = $assigneeContact;
+
+ //Activity Status
+ $caseActivity['status_id'] = $activityStatuses[$dao->status];
+
// FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
$url = "";
$css = 'class="action-item crm-hover-button"';
- $additionalUrl = "&id={$dao->id}";
+ if ($allowView) {
+ $viewUrl = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $caseActivityId));
+ $url = '<a ' . str_replace('action-item', 'action-item medium-pop-up', $css) . 'href="' . $viewUrl . '" title="' . $viewTitle . '">' . ts('View') . '</a>';
+ }
+ $additionalUrl = "&id={$caseActivityId}";
if (!$dao->deleted) {
//hide edit link of activity type email.CRM-4530.
if (!in_array($dao->type, $emailActivityTypeIDs)) {
//hide Edit link if activity type is NOT editable (special case activities).CRM-5871
if ($allowEdit) {
- $url = '<a ' . $css . ' href="' . $editUrl . $additionalUrl . '">' . ts('Edit') . '</a> ';
+ $url .= '<a ' . $css . ' href="' . $editUrl . $additionalUrl . '">' . ts('Edit') . '</a> ';
}
}
if ($allowDelete) {
}
elseif (!$caseDeleted) {
$url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>';
- $values[$dao->id]['status'] = $values[$dao->id]['status'] . '<br /> (deleted)';
+ $caseActivity['status_id'] = $caseActivity['status_id'] . '<br /> (deleted)';
}
//check for operations.
- if (self::checkPermission($dao->id, 'Move To Case', $dao->activity_type_id)) {
- $url .= ' <a ' . $css . ' href="#" onClick="Javascript:fileOnCase( \'move\',' . $dao->id . ', ' . $caseID . ', this ); return false;">' . ts('Move To Case') . '</a> ';
+ if (self::checkPermission($caseActivityId, 'Move To Case', $dao->activity_type_id)) {
+ $url .= ' <a ' . $css . ' href="#" onClick="Javascript:fileOnCase( \'move\',' . $caseActivityId . ', ' . $caseID . ', this ); return false;">' . ts('Move To Case') . '</a> ';
}
- if (self::checkPermission($dao->id, 'Copy To Case', $dao->activity_type_id)) {
- $url .= ' <a ' . $css . ' href="#" onClick="Javascript:fileOnCase( \'copy\',' . $dao->id . ',' . $caseID . ', this ); return false;">' . ts('Copy To Case') . '</a> ';
+ if (self::checkPermission($caseActivityId, 'Copy To Case', $dao->activity_type_id)) {
+ $url .= ' <a ' . $css . ' href="#" onClick="Javascript:fileOnCase( \'copy\',' . $caseActivityId . ',' . $caseID . ', this ); return false;">' . ts('Copy To Case') . '</a> ';
}
// if there are file attachments we will return how many and, if only one, add a link to it
if (!empty($dao->attachment_ids)) {
$attachmentIDs = explode(',', $dao->attachment_ids);
- $values[$dao->id]['no_attachments'] = count($attachmentIDs);
- if ($values[$dao->id]['no_attachments'] == 1) {
+ $caseActivity['no_attachments'] = count($attachmentIDs);
+ if ($caseActivity['no_attachments'] == 1) {
// if there is only one it's easy to do a link - otherwise just flag it
$attachmentViewUrl = CRM_Utils_System::url(
"civicrm/file",
- "reset=1&eid=" . $dao->id . "&id=" . $dao->attachment_ids,
+ "reset=1&eid=" . $caseActivityId . "&id=" . $dao->attachment_ids,
FALSE,
NULL,
FALSE
}
}
- $values[$dao->id]['links'] = $url;
- $values[$dao->id]['class'] = "";
+ $caseActivity['links'] = $url;
- if (!empty($dao->priority)) {
- if ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Urgent', 'name')) {
- $values[$dao->id]['class'] = $values[$dao->id]['class'] . "priority-urgent ";
- }
- elseif ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Low', 'name')) {
- $values[$dao->id]['class'] = $values[$dao->id]['class'] . "priority-low ";
- }
- }
-
- if (CRM_Utils_Array::crmInArray($dao->status, $compStatusValues)) {
- $values[$dao->id]['class'] = $values[$dao->id]['class'] . " status-completed";
- }
- else {
- if (CRM_Utils_Date::overdue($dao->display_date)) {
- $values[$dao->id]['class'] = $values[$dao->id]['class'] . " status-overdue";
- }
- else {
- $values[$dao->id]['class'] = $values[$dao->id]['class'] . " status-scheduled";
- }
- }
-
- if ($allowEdit) {
- $values[$dao->id]['status'] = '<div class="crmf-status_id crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-editable" data-type="select" data-action="create" data-refresh="true">' . $values[$dao->id]['status'] . '</div>';
- }
+ array_push($caseActivities, $caseActivity);
}
$dao->free();
- return $values;
+ $caseActivitiesDT = array();
+ $caseActivitiesDT['data'] = $caseActivities;
+ $caseActivitiesDT['recordsTotal'] = $caseCount;
+ $caseActivitiesDT['recordsFiltered'] = $caseCount;
+
+ return $caseActivitiesDT;
}
/**
- * Get Case Related Contacts
+ * Get Case Related Contacts.
*
* @param int $caseID
* Case id.
}
/**
- * Create an activity for a case via email
+ * Create an activity for a case via email.
*
* @param int $file
* Email sent.
}
/**
- * Retrieve the scheduled activity type and date
+ * Retrieve the scheduled activity type and date.
*
* @param array $cases
* Array of contact and case id.
}
/**
- * Combine all the exportable fields from the lower levels object
+ * Combine all the exportable fields from the lower levels object.
*
* @return array
* array of exportable Fields
}
/**
- * Restore the record that are associated with this case
+ * Restore the record that are associated with this case.
*
* @param int $caseId
* Id of the case to restore.
}
/**
- * Convenience function to get both case contacts and global in one array
+ * Convenience function to get both case contacts and global in one array.
* @param int $caseId
*
* @return array
}
/**
- * Get all cases with no end dates
+ * Get all cases with no end dates.
*
* @param array $params
* @param array $excludeCaseIds
* @param bool $excludeDeleted
*
+ * @param bool $includeClosed
+ *
* @return array
- * case and related data keyed on case id
+ * Case and related data keyed on case id
*/
public static function getUnclosedCases($params = array(), $excludeCaseIds = array(), $excludeDeleted = TRUE, $includeClosed = FALSE) {
//params from ajax call.
* @see CRM_Dedupe_Merger::cpTables()
*
* TODO: use the 3rd $sqls param to append sql statements rather than executing them here
+ *
+ * @param int $mainContactId
+ * @param int $otherContactId
*/
public static function mergeContacts($mainContactId, $otherContactId) {
self::mergeCases($mainContactId, NULL, $otherContactId);
}
}
- //create merge activity record.
+ //Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
$activityParams = array(
'subject' => $mergeActSubject,
'details' => $mergeActSubjectDetails,
'status_id' => array_search('Completed', $activityStatuses),
'activity_type_id' => $mergeActType,
- 'source_contact_id' => $mainContactId,
+ 'source_contact_id' => $currentUserId,
'activity_date_time' => date('YmdHis'),
);
}
/**
- * Verify user has permission to access a case
+ * Verify user has permission to access a case.
*
* @param int $caseId
* @param bool $denyClosed
}
/**
- * Check whether activity is a case Activity
+ * Check whether activity is a case Activity.
*
* @param int $activityID
* Activity id.
}
/**
- * Get all the case type ids currently in use
+ * Get all the case type ids currently in use.
*
* @return array
*/
}
/**
- * Get all the case status ids currently in use
+ * Get all the case status ids currently in use.
*
* @return array
*/
}
/**
- * Get all the encounter medium ids currently in use
+ * Get all the encounter medium ids currently in use.
*
* @return array
*/
}
/**
- * Used during case component enablement and during ugprade
+ * Used during case component enablement and during ugprade.
*
* @return bool
*/
/**
* Helper function, also used by the upgrade in case of error
*
+ * @param string $section
+ *
* @return string
*/
public static function createCaseViewsQuery($section = 'upcoming') {
}
/**
- * Get the list of clients for a case
+ * Get the list of clients for a case.
*
* @param int $caseId
*