/** * Function to get Case Activities * * @param int $caseID case id * @param array $params posted params * @param int $contactID contact id * * @param null $context * @param null $userID * @param null $type * * @return returns case activities * * @static */ static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) { $values = array(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // 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,\n ca.activity_type_id as type,\n ca.activity_type_id as activity_type_id,\n cc.sort_name as reporter,\n cc.id as reporter_id,\n acc.sort_name AS assignee,\n acc.id AS assignee_id,\n DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') as overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,\n ca.status_id as status,\n ca.subject as subject,\n ca.is_deleted as deleted,\n ca.priority_id as priority,\n ca.weight as weight,\n GROUP_CONCAT(ef.file_id) as attachment_ids "; $from = "\n FROM civicrm_case_activity cca\n INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id\n INNER JOIN civicrm_activity_contact cac ON cac.activity_id = ca.id AND cac.record_type_id = {$sourceID}\n INNER JOIN civicrm_contact cc ON cc.id = cac.contact_id\n INNER JOIN civicrm_option_group cog ON cog.name = 'activity_type'\n INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id\n AND cov.value = ca.activity_type_id AND cov.is_active = 1\n LEFT JOIN civicrm_entity_file ef on ef.entity_table = 'civicrm_activity' AND ef.entity_id = ca.id\n LEFT OUTER JOIN civicrm_option_group og ON og.name = 'activity_status'\n LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name = 'Scheduled'\n LEFT JOIN civicrm_activity_contact caa\n ON caa.activity_id = ca.id AND caa.record_type_id = {$assigneeID}\n 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'); } if (!empty($params['status_id'])) { $where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer'); } if (!empty($params['activity_deleted'])) { $where .= " AND ca.is_deleted = 1"; } else { $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'); } if (!empty($params['activity_date_low'])) { $fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date'); } 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}'"; } // hack to handle to allow initial sorting to be done by query if (CRM_Utils_Array::value('sortname', $params) == 'undefined') { $params['sortname'] = NULL; } 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) { // CRM-5081 - added id to act like creation date $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'; } } $page = CRM_Utils_Array::value('page', $params); $rp = CRM_Utils_Array::value('rp', $params); if (!$page) { $page = 1; } 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); $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $activityPriority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE); $contextUrl = ''; if ($context == 'fulltext') { $contextUrl = "&context={$context}"; } $editUrl = "{$url}&action=update{$contextUrl}"; $deleteUrl = "{$url}&action=delete{$contextUrl}"; $restoreUrl = "{$url}&action=renew{$contextUrl}"; $viewTitle = ts('View this activity.'); $statusTitle = ts('Edit status'); $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted'); // define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status) $compStatusValues = array(); $compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required'); 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); $hasViewContact = CRM_Core_Permission::giveMeAllACLs(); $clientIds = self::retrieveContactIdsByCaseId($caseID); if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } while ($dao->fetch()) { $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); //do not have sufficient permission //to access given case activity record. if (!$allowView && !$allowEdit && !$allowDelete) { continue; } $values[$dao->id]['id'] = $dao->id; $values[$dao->id]['type'] = $activityTypes[$dao->type]['label']; $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; } } foreach ($withContacts as $cid => $name) { if ($hasViewContact) { $name = '<a href="' . $contactViewUrl . $cid . '">' . $name . '</a>'; } $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]; //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; // 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; } else { $values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)'); } } // 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 (!$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> '; } } if ($allowDelete) { $url .= ' <a ' . str_replace('action-item', 'action-item small-popup', $css) . ' href="' . $deleteUrl . $additionalUrl . '">' . ts('Delete') . '</a>'; } } elseif (!$caseDeleted) { $url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>'; $values[$dao->id]['status'] = $values[$dao->id]['status'] . '<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($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 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) { // 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, FALSE, NULL, FALSE); $url .= " <a href='{$attachmentViewUrl}' ><span class='icon paper-icon'></span></a>"; } } $values[$dao->id]['links'] = $url; $values[$dao->id]['class'] = ""; 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'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-activity-change-status crm-editable-enabled" activity_id=' . $dao->id . ' current_status=' . $dao->status . ' case_id=' . $caseID . ' href="#" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>'; } } $dao->free(); return $values; }
/** * handle the values in summary mode * * @param array $values the array of values belonging to this line * * @return boolean the result of this processing * @access public */ function summary(&$values) { $erroneousField = NULL; $response = $this->setActiveFieldValues($values, $erroneousField); $errorRequired = FALSE; if ($this->_membershipTypeIndex < 0) { $errorRequired = TRUE; } else { $errorRequired = !CRM_Utils_Array::value($this->_membershipTypeIndex, $values); } if ($errorRequired) { array_unshift($values, ts('Missing required fields')); return CRM_Import_Parser::ERROR; } $params =& $this->getActiveFieldParams(); $errorMessage = NULL; //To check whether start date or join date is provided if (!CRM_Utils_Array::value('membership_start_date', $params) && !CRM_Utils_Array::value('join_date', $params)) { $errorMessage = 'Membership Start Date is required to create a memberships.'; CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage); } //end //for date-Formats $session = CRM_Core_Session::singleton(); $dateType = $session->get('dateTypes'); foreach ($params as $key => $val) { if ($val) { switch ($key) { case 'join_date': if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) { if (!CRM_Utils_Rule::date($params[$key])) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Member Since', $errorMessage); } } else { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Member Since', $errorMessage); } break; case 'membership_start_date': if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) { if (!CRM_Utils_Rule::date($params[$key])) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage); } } else { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage); } break; case 'membership_end_date': if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) { if (!CRM_Utils_Rule::date($params[$key])) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('End date', $errorMessage); } } else { CRM_Contact_Import_Parser_Contact::addToErrorMsg('End date', $errorMessage); } break; case 'membership_type_id': $membershipTypes = CRM_Member_PseudoConstant::membershipType(); if (!CRM_Utils_Array::crmInArray($val, $membershipTypes) && !array_key_exists($val, $membershipTypes)) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Membership Type', $errorMessage); } break; case 'status_id': if (!CRM_Utils_Array::crmInArray($val, CRM_Member_PseudoConstant::membershipStatus())) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Membership Status', $errorMessage); } break; case 'email': if (!CRM_Utils_Rule::email($val)) { CRM_Contact_Import_Parser_Contact::addToErrorMsg('Email Address', $errorMessage); } } } } //date-Format part ends $params['contact_type'] = 'Membership'; //checking error in custom data CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage); if ($errorMessage) { $tempMsg = "Invalid value for field(s) : {$errorMessage}"; array_unshift($values, $tempMsg); $errorMessage = NULL; return CRM_Import_Parser::ERROR; } return CRM_Import_Parser::VALID; }
/** * Function to get Case Activities * * @param int $caseID case id * @param array $params posted params * @param int $contactID contact id * * @return returns case activities * * @static */ static function getCaseActivity($caseID, &$params, $contactID) { $values = array(); $select = 'SELECT count(ca.id) as ismultiple, ca.id as id, ca.activity_type_id as type, cc.sort_name as reporter, cc.id as reporter_id, acc.sort_name AS assignee, acc.id AS assignee_id, IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value, ca.activity_date_time, DATE_ADD(NOW(), INTERVAL 1 YEAR) ) as overdue_date, ca.activity_date_time as display_date, ca.status_id as status, ca.subject as subject, ca.is_deleted as deleted, ca.priority_id as priority '; $from = 'FROM civicrm_case_activity cca INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_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_assignment caa ON caa.activity_id = ca.id LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id '; $where = 'WHERE cca.case_id= %1 AND ca.is_current_revision = 1'; if (CRM_Utils_Array::value('reporter_id', $params)) { $where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer'); } if (CRM_Utils_Array::value('status_id', $params)) { $where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer'); } if (CRM_Utils_Array::value('activity_deleted', $params)) { $where .= " AND ca.is_deleted = 1"; } else { $where .= " AND ca.is_deleted = 0"; } if (CRM_Utils_Array::value('activity_type_id', $params)) { $where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'); } if (CRM_Utils_Array::value('activity_date_low', $params)) { $fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date'); } if (CRM_Utils_Array::value('activity_date_high', $params)) { $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}'"; } // hack to handle to allow initial sorting to be done by query if (CRM_Utils_Array::value('sortname', $params) == 'undefined') { $params['sortname'] = null; } 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) { $orderBy = " ORDER BY overdue_date ASC, display_date DESC"; } else { $orderBy = " ORDER BY {$sortname} {$sortorder}, display_date DESC"; } $page = CRM_Utils_Array::value('page', $params); $rp = CRM_Utils_Array::value('rp', $params); if (!$page) { $page = 1; } 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; $dao =& CRM_Core_DAO::executeQuery($query, $params); $activityTypes = CRM_Case_PseudoConstant::activityType(false, true); require_once "CRM/Utils/Date.php"; require_once "CRM/Core/PseudoConstant.php"; $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $activityPriority = CRM_Core_PseudoConstant::priority(); $url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", false, null, false); $editUrl = "{$url}&action=update"; $deleteUrl = "{$url}&action=delete"; $restoreUrl = "{$url}&action=renew"; $viewTitle = ts('View this activity.'); require_once 'CRM/Core/OptionGroup.php'; $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); $activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')"; $caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', false, false, false, $activityCondition); require_once 'CRM/Core/OptionGroup.php'; $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); require_once 'CRM/Case/BAO/Case.php'; $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted'); //check for delete activities CRM-4418 require_once 'CRM/Core/Permission.php'; $allowToDeleteActivities = CRM_Core_Permission::check('delete activities'); // define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status) $compStatusValues = array(); $compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required'); 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); while ($dao->fetch()) { $values[$dao->id]['id'] = $dao->id; $values[$dao->id]['type'] = $activityTypes[$dao->type]['label']; $values[$dao->id]['reporter'] = "<a href='{$contactViewUrl}{$dao->reporter_id}'>{$dao->reporter}</a>"; $values[$dao->id]['display_date'] = CRM_Utils_Date::customFormat($dao->display_date); $values[$dao->id]['status'] = $activityStatus[$dao->status]; $values[$dao->id]['subject'] = "<a href='javascript:viewActivity( {$dao->id}, {$contactID} );' title='{$viewTitle}'>{$dao->subject}</a>"; // add activity assignee to activity selector. CRM-4485. if (isset($dao->assignee)) { if ($dao->ismultiple == 1) { $values[$dao->id]['reporter'] .= ' / ' . "<a href='{$contactViewUrl}{$dao->assignee_id}'>{$dao->assignee}</a>"; $values[$dao->id]['assignee'] = $dao->assignee; } else { $values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)'); } } $url = ""; $additionalUrl = "&id={$dao->id}"; if (!$dao->deleted) { //hide edit link of activity type email.CRM-4530. if (!in_array($dao->type, $emailActivityTypeIDs)) { $url = "<a href='" . $editUrl . $additionalUrl . "'>" . ts('Edit') . "</a> "; } //block deleting activities which affects //case attributes.CRM-4543 if (!array_key_exists($dao->type, $caseAttributeActivities) && $allowToDeleteActivities) { if (!empty($url)) { $url .= " | "; } $url .= "<a href='" . $deleteUrl . $additionalUrl . "'>" . ts('Delete') . "</a>"; } } else { if (!$caseDeleted) { $url = "<a href='" . $restoreUrl . $additionalUrl . "'>" . ts('Restore') . "</a>"; $values[$dao->id]['status'] = $values[$dao->id]['status'] . '<br /> (deleted)'; } } $values[$dao->id]['links'] = $url; $values[$dao->id]['class'] = ""; 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"; } } } $dao->free(); return $values; }
/** * Get Case Activities. * * @param int $caseID * Case id. * @param array $params * Posted params. * @param int $contactID * Contact id. * * @param null $context * @param int $userID * @param null $type * * @return array * Array of case activities * */ public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) { $values = array(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // 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 = "\n SELECT COUNT(ca.id) AS ismultiple,\n ca.id AS id,\n ca.activity_type_id AS type,\n ca.activity_type_id AS activity_type_id,\n tcc.sort_name AS target_contact_name,\n tcc.id AS target_contact_id,\n scc.sort_name AS source_contact_name,\n scc.id AS source_contact_id,\n acc.sort_name AS assignee_contact_name,\n acc.id AS assignee_contact_id,\n DATE_FORMAT(\n IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') AS overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') AS display_date,\n ca.status_id AS status,\n ca.subject AS subject,\n ca.is_deleted AS deleted,\n ca.priority_id AS priority,\n ca.weight AS weight,\n GROUP_CONCAT(ef.file_id) AS attachment_ids "; $from = "\n FROM civicrm_case_activity cca\n INNER JOIN civicrm_activity ca\n ON ca.id = cca.activity_id\n INNER JOIN civicrm_activity_contact cas\n ON cas.activity_id = ca.id\n AND cas.record_type_id = {$sourceID}\n INNER JOIN civicrm_contact scc\n ON scc.id = cas.contact_id\n LEFT JOIN civicrm_activity_contact caa\n ON caa.activity_id = ca.id\n AND caa.record_type_id = {$assigneeID}\n LEFT JOIN civicrm_contact acc\n ON acc.id = caa.contact_id\n LEFT JOIN civicrm_activity_contact cat\n ON cat.activity_id = ca.id\n AND cat.record_type_id = {$targetID}\n LEFT JOIN civicrm_contact tcc\n ON tcc.id = cat.contact_id\n INNER JOIN civicrm_option_group cog\n ON cog.name = 'activity_type'\n INNER JOIN civicrm_option_value cov\n ON cov.option_group_id = cog.id\n AND cov.value = ca.activity_type_id\n AND cov.is_active = 1\n LEFT JOIN civicrm_entity_file ef\n ON ef.entity_table = 'civicrm_activity'\n AND ef.entity_id = ca.id\n LEFT OUTER JOIN civicrm_option_group og\n ON og.name = 'activity_status'\n LEFT OUTER JOIN civicrm_option_value ov\n ON ov.option_group_id=og.id\n AND ov.name = 'Scheduled'"; $where = ' WHERE cca.case_id= %1 AND ca.is_current_revision = 1'; if (!empty($params['source_contact_id'])) { $where .= "\n AND cas.contact_id = " . CRM_Utils_Type::escape($params['source_contact_id'], 'Integer'); } if (!empty($params['status_id'])) { $where .= "\n AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer'); } if (!empty($params['activity_deleted'])) { $where .= "\n AND ca.is_deleted = 1"; } else { $where .= "\n AND ca.is_deleted = 0"; } if (!empty($params['activity_type_id'])) { $where .= "\n 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 .= "\n 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($toActivityDate)) { $where .= "\n AND ca.activity_date_time <= '{$toActivityDate}'"; } $groupBy = "\n GROUP BY ca.id "; $sortBy = CRM_Utils_Array::value('sortBy', $params); if (!$sortBy) { // CRM-5081 - added id to act like creation date $orderBy = "\n ORDER BY overdue_date ASC, display_date DESC, weight DESC"; } else { $sortBy = CRM_Utils_Type::escape($sortBy, 'String'); $orderBy = " ORDER BY {$sortBy} "; } $page = CRM_Utils_Array::value('page', $params); $rp = CRM_Utils_Array::value('rp', $params); if (!$page) { $page = 1; } if (!$rp) { $rp = 10; } $start = ($page - 1) * $rp; $limit = " LIMIT {$start}, {$rp}"; $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); $activityStatuses = CRM_Core_PseudoConstant::activityStatus(); $url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE); $contextUrl = ''; if ($context == 'fulltext') { $contextUrl = "&context={$context}"; } $editUrl = "{$url}&action=update{$contextUrl}"; $deleteUrl = "{$url}&action=delete{$contextUrl}"; $restoreUrl = "{$url}&action=renew{$contextUrl}"; $viewTitle = ts('View activity'); $statusTitle = ts('Edit Status'); $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted'); // define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status) $compStatusValues = array(); $compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required'); 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); $hasViewContact = CRM_Core_Permission::giveMeAllACLs(); $clientIds = self::retrieveContactIdsByCaseId($caseID); if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } $caseActivities = array(); $caseCount = 0; while ($dao->fetch()) { $caseCount++; $caseActivity = array(); $caseActivityId = $dao->id; $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. if (!$allowView && !$allowEdit && !$allowDelete) { continue; } //Add classes to the row, via DataTables syntax $caseActivity['DT_RowClass'] = "crm-entity"; 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"; } } 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 "; } } //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; //Activity Date and Time $caseActivity['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date); //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>'; } } $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"'; 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> '; } } if ($allowDelete) { $url .= ' <a ' . str_replace('action-item', 'action-item small-popup', $css) . ' href="' . $deleteUrl . $additionalUrl . '">' . ts('Delete') . '</a>'; } } elseif (!$caseDeleted) { $url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>'; $caseActivity['status_id'] = $caseActivity['status_id'] . '<br /> (deleted)'; } //check for operations. 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($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); $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=" . $caseActivityId . "&id=" . $dao->attachment_ids, FALSE, NULL, FALSE); $url .= " <a href='{$attachmentViewUrl}' ><span class='icon paper-icon'></span></a>"; } } $caseActivity['links'] = $url; array_push($caseActivities, $caseActivity); } $dao->free(); $caseActivitiesDT = array(); $caseActivitiesDT['data'] = $caseActivities; $caseActivitiesDT['recordsTotal'] = $caseCount; $caseActivitiesDT['recordsFiltered'] = $caseCount; return $caseActivitiesDT; }
/** * Function to get Case Activities * * @param int $caseID case id * @param array $params posted params * @param int $contactID contact id * * @return returns case activities * * @static */ static function getCaseActivity($caseID, &$params, $contactID, $context = null, $userID = null, $type = null) { $values = array(); // 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, \n ca.activity_type_id as type,\n ca.activity_type_id as activity_type_id, \n cc.sort_name as reporter,\n cc.id as reporter_id,\n acc.sort_name AS assignee,\n acc.id AS assignee_id,\n DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') as overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,\n ca.status_id as status, \n ca.subject as subject, \n ca.is_deleted as deleted,\n ca.priority_id as priority "; $from = 'FROM civicrm_case_activity cca INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id INNER JOIN civicrm_contact cc ON cc.id = ca.source_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 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_assignment caa ON caa.activity_id = ca.id LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id '; $where = 'WHERE cca.case_id= %1 AND ca.is_current_revision = 1'; if (CRM_Utils_Array::value('reporter_id', $params)) { $where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer'); } if (CRM_Utils_Array::value('status_id', $params)) { $where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer'); } if (CRM_Utils_Array::value('activity_deleted', $params)) { $where .= " AND ca.is_deleted = 1"; } else { $where .= " AND ca.is_deleted = 0"; } if (CRM_Utils_Array::value('activity_type_id', $params)) { $where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'); } if (CRM_Utils_Array::value('activity_date_low', $params)) { $fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date'); } if (CRM_Utils_Array::value('activity_date_high', $params)) { $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}'"; } // hack to handle to allow initial sorting to be done by query if (CRM_Utils_Array::value('sortname', $params) == 'undefined') { $params['sortname'] = null; } 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) { // CRM-5081 - added id to act like creation date $orderBy = " ORDER BY overdue_date ASC, display_date DESC, ca.id DESC"; } else { $orderBy = " ORDER BY {$sortname} {$sortorder}"; if ($sortname != 'display_date') { $orderBy .= ', display_date DESC'; } } $page = CRM_Utils_Array::value('page', $params); $rp = CRM_Utils_Array::value('rp', $params); if (!$page) { $page = 1; } 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; $dao =& CRM_Core_DAO::executeQuery($query, $params); require_once "CRM/Utils/Date.php"; require_once "CRM/Core/PseudoConstant.php"; require_once 'CRM/Case/PseudoConstant.php'; $activityTypes = CRM_Case_PseudoConstant::activityType(false, true); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $activityPriority = CRM_Core_PseudoConstant::priority(); $url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", false, null, false); $contextUrl = ''; if ($context == 'fulltext') { $contextUrl = "&context={$context}"; } $editUrl = "{$url}&action=update{$contextUrl}"; $deleteUrl = "{$url}&action=delete{$contextUrl}"; $restoreUrl = "{$url}&action=renew{$contextUrl}"; $viewTitle = ts('View this activity.'); require_once 'CRM/Core/OptionGroup.php'; $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); require_once 'CRM/Core/OptionGroup.php'; $emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name')); require_once 'CRM/Case/BAO/Case.php'; $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted'); // define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status) $compStatusValues = array(); $compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required'); 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); require_once 'CRM/Activity/BAO/ActivityTarget.php'; $hasViewContact = CRM_Core_Permission::giveMeAllACLs(); $clientIds = self::retrieveContactIdsByCaseId($caseID); if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } while ($dao->fetch()) { $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); //do not have sufficient permission //to access given case activity record. if (!$allowView && !$allowEdit && !$allowDelete) { continue; } $values[$dao->id]['id'] = $dao->id; $values[$dao->id]['type'] = $activityTypes[$dao->type]['label']; $reporterName = $dao->reporter; if ($hasViewContact) { $reporterName = '<a href="' . $contactViewUrl . $dao->reporter_id . '">' . $dao->reporter . '</a>'; } $values[$dao->id]['reporter'] = $reporterName; $targetNames = CRM_Activity_BAO_ActivityTarget::getTargetNames($dao->id); $targetContactUrls = $withContacts = array(); foreach ($targetNames as $targetId => $targetName) { if (!in_array($targetId, $clientIds)) { $withContacts[$targetId] = $targetName; } } foreach ($withContacts as $cid => $name) { if ($hasViewContact) { $name = '<a href="' . $contactViewUrl . $cid . '">' . $name . '</a>'; } $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]; //check for view activity. $subject = empty($dao->subject) ? '(' . ts('no subject') . ')' : $dao->subject; if ($allowView) { $subject = '<a href="javascript:' . $type . 'viewActivity(' . $dao->id . ',' . $contactID . ',' . '\'' . $type . '\' );" title=' . $viewTitle . '>' . $subject . '</a>'; } $values[$dao->id]['subject'] = $subject; // 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; } else { $values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)'); } } $url = ""; $additionalUrl = "&id={$dao->id}"; 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 href="' . $editUrl . $additionalUrl . '">' . ts('Edit') . '</a> '; } } if ($allowDelete) { if (!empty($url)) { $url .= " | "; } $url .= '<a href="' . $deleteUrl . $additionalUrl . '">' . ts('Delete') . '</a>'; } } else { if (!$caseDeleted) { $url = '<a href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>'; $values[$dao->id]['status'] = $values[$dao->id]['status'] . '<br /> (deleted)'; } } //check for operations. if (self::checkPermission($dao->id, 'Move To Case', $dao->activity_type_id)) { $url .= " | " . '<a href="#" onClick="Javascript:fileOnCase( \'move\',' . $dao->id . ', ' . $caseID . ' ); return false;">' . ts('Move To Case') . '</a> '; } if (self::checkPermission($dao->id, 'Copy To Case', $dao->activity_type_id)) { $url .= " | " . '<a href="#" onClick="Javascript:fileOnCase( \'copy\',' . $dao->id . ',' . $caseID . ' ); return false;">' . ts('Copy To Case') . '</a> '; } $values[$dao->id]['links'] = $url; $values[$dao->id]['class'] = ""; 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"; } } } $dao->free(); return $values; }