* @static
*/
static $_exportableFields = NULL;
+
function __construct() {
parent::__construct();
}
* case object. the params array could contain additional unused name/value
* pairs
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
*
* @return object CRM_Case_BAO_Case object
* Delete the record that are associated with this case
* record are deleted from case
*
- * @param int $caseId id of the case to delete
+ * @param int $caseId id of the case to delete
*
* @return void
* @access public
/**
* Function to enable disable case related relationships
*
- * @param int $caseId case id
- * @param boolean $enable action
+ * @param int $caseId case id
+ * @param boolean $enable action
*
- * @return void
- * @access public
- * @static
+ * @return void
+ * @access public
+ * @static
*/
static function enableDisableCaseRelationships($caseId, $enable) {
$contactIds = self::retrieveContactIdsByCaseId($caseId);
$roles = self::getCaseRoles($cid, $caseId);
if (!empty($roles)) {
$relationshipIds = implode(',', array_keys($roles));
- $enable = (int)$enable;
- $query = "UPDATE civicrm_relationship SET is_active = {$enable}
+ $enable = (int) $enable;
+ $query = "UPDATE civicrm_relationship SET is_active = {$enable}
WHERE id IN ( {$relationshipIds} )";
CRM_Core_DAO::executeQuery($query);
}
/**
* Delete the activities related to case
*
- * @param int $activityId id of the activity
+ * @param int $activityId id of the activity
*
* @return void
* @access public
/**
* Retrieve contact_id by case_id
*
- * @param int $caseId ID of the case
+ * @param int $caseId ID of the case
*
* @return array
* @access public
/**
* Retrieve contact names by caseId
*
- * @param int $caseId ID of the case
+ * @param int $caseId ID of the case
*
* @return array
*
/**
* Retrieve case_id by contact_id
*
- * @param int $contactId ID of the contact
+ * @param int $contactId ID of the contact
* @param boolean $includeDeleted include the deleted cases in result
*
* @return array
* Retrieve cases related to particular contact or whole contact
* used in Dashboad and Tab
*
- * @param boolean $allCases
+ * @param boolean $allCases
*
- * @param int $userID
+ * @param int $userID
*
- * @param String $type /upcoming,recent,all/
+ * @param String $type /upcoming,recent,all/
*
* @return array Array of Cases
*
$allCases = FALSE;
}
- $caseTypes = CRM_Case_PseudoConstant::caseType();
+ $caseTypes = CRM_Case_PseudoConstant::caseType();
$caseStatuses = CRM_Case_PseudoConstant::caseStatus();
- $caseTypes = array_flip($caseTypes);
+ $caseTypes = array_flip($caseTypes);
// get statuses as headers for the table
$url = CRM_Utils_System::url('civicrm/case/search', "reset=1&force=1&all=1&status=");
$case_owner = 1;
}
else {
- $all = 0;
+ $all = 0;
$case_owner = 2;
$myCaseWhereClause = " AND case_relationship.contact_id_b = {$userID}";
- $myGroupByClause = " GROUP BY CONCAT(case_relationship.case_id,'-',case_relationship.contact_id_b)";
+ $myGroupByClause = " GROUP BY CONCAT(case_relationship.case_id,'-',case_relationship.contact_id_b)";
}
$seperator = CRM_Core_DAO::VALUE_SEPARATOR;
/**
* Function to get Case roles
*
- * @param int $contactID contact id
- * @param int $caseID case id
+ * @param int $contactID contact id
+ * @param int $caseID case id
* @return returns case role / relationships
*
* @static
/**
* Function to get Case Activities
*
- * @param int $caseID case id
- * @param array $params posted params
- * @param int $contactID contact id
+ * @param int $caseID case id
+ * @param array $params posted params
+ * @param int $contactID contact id
*
* @return returns case activities
*
$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.
ca.weight as weight,
GROUP_CONCAT(ef.file_id) as attachment_ids ";
- $from = 'FROM civicrm_case_activity cca
+ $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
+ 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_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_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 ';
+ 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';
$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 = 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();
+ $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",
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.');
+ $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(
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);
+ $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
$url .= " | " . '<a href="#" onClick="Javascript:fileOnCase( \'copy\',' . $dao->id . ',' . $caseID . ' ); 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);
+ 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 ($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",
}
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>';
+ $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();
/**
* Function to get Case Related Contacts
*
- * @param int $caseID case id
+ * @param int $caseID case id
* @param boolean $skipDetails if true include details of contacts
*
* @return returns $searchRows array of returnproperties
/**
* Function that sends e-mail copy of activity
*
- * @param int $activityId activity Id
- * @param array $contacts array of related contact
+ * @param int $activityId activity Id
+ * @param array $contacts array of related contact
*
* @return void
* @access public
* Retrieve count of activities having a particular type, and
* associated with a particular case.
*
- * @param int $caseId ID of the case
- * @param int $activityTypeId ID of the activity type
+ * @param int $caseId ID of the case
+ * @param int $activityTypeId ID of the activity type
*
* @return array
*
*
*/
static function getCaseActivityCount($caseId, $activityTypeId) {
- $queryParam = array(1 => array($caseId, 'Integer'),
+ $queryParam = array(
+ 1 => array($caseId, 'Integer'),
2 => array($activityTypeId, 'Integer'),
);
$query = "SELECT count(ca.id) as countact
/**
* Create an activity for a case via email
*
- * @param int $file email sent
+ * @param int $file email sent
*
* @return $activity object of newly creted activity via email
*
/**
* Function to retrive the scheduled activity type and date
*
- * @param array $cases Array of contact and case id
+ * @param array $cases Array of contact and case id
*
* @return array $activityInfo Array of scheduled activity type and date
*
self::$_exportableFields = array();
}
- $fields = CRM_Case_DAO_Case::export();
+ $fields = CRM_Case_DAO_Case::export();
$fields['case_role'] = array('title' => ts('Role in Case'));
- $fields['case_type'] = array('title' => ts('Case Type'),
+ $fields['case_type'] = array(
+ 'title' => ts('Case Type'),
'name' => 'case_type',
);
- $fields['case_status'] = array('title' => ts('Case Status'),
+ $fields['case_status'] = array(
+ 'title' => ts('Case Status'),
'name' => 'case_status',
);
/**
* Restore the record that are associated with this case
*
- * @param int $caseId id of the case to restore
+ * @param int $caseId id of the case to restore
*
* @return true if success.
* @access public
}
}
//restore case
- $case = new CRM_Case_DAO_Case();
- $case->id = $caseId;
+ $case = new CRM_Case_DAO_Case();
+ $case->id = $caseId;
$case->is_deleted = 0;
$case->save();
$results = array();
CRM_Contact_BAO_Group::retrieve($searchParams, $results);
if ($results) {
- $groupInfo['id'] = $results['id'];
+ $groupInfo['id'] = $results['id'];
$groupInfo['title'] = $results['title'];
- $params = array(array('group', 'IN', array($groupInfo['id'] => 1), 0, 0));
- $return = array('sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
- $return = array('contact_id' => 1, 'sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
+ $params = array(array('group', 'IN', array($groupInfo['id'] => 1), 0, 0));
+ $return = array('sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
+ $return = array('contact_id' => 1, 'sort_name' => 1, 'display_name' => 1, 'email' => 1, 'phone' => 1);
list($globalContacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, $return, NULL, $sort, $offset, $rowCount, TRUE, $returnOnlyCount);
if ($returnOnlyCount) {
}
if ($showLinks) {
- foreach($globalContacts as $idx => $contact) {
+ foreach ($globalContacts as $idx => $contact) {
$globalContacts[$idx]['sort_name'] = '<a href="' . $contactViewUrl . $contact['contact_id'] . '">' . $contact['sort_name'] . '</a>';
}
}
/**
* Function to get Case ActivitiesDueDates with given criteria.
*
- * @param int $caseID case id
- * @param array $criteriaParams given criteria
- * @param boolean $latestDate if set newest or oldest date is selceted.
+ * @param int $caseID case id
+ * @param array $criteriaParams given criteria
+ * @param boolean $latestDate if set newest or oldest date is selceted.
*
* @return returns case activities due dates
*
* @static
*/
- static function getCaseActivityDates($caseID, $criteriaParams = array(
- ), $latestDate = FALSE) {
- $values = array();
+ static function getCaseActivityDates($caseID, $criteriaParams = array(), $latestDate = FALSE) {
+ $values = array();
$selectDate = " ca.activity_date_time";
- $where = $groupBy = ' ';
+ $where = $groupBy = ' ';
if (!$caseID) {
return;
/**
* Function to create activities when Case or Other roles assigned/modified/deleted.
*
- * @param int $caseID case id
- * @param int $relationshipId relationship id
- * @param int $relContactId case role assigne contactId.
+ * @param int $caseID case id
+ * @param int $relationshipId relationship id
+ * @param int $relContactId case role assigne contactId.
*
* @return void on success creates activity and case activity
*
* Function to get case manger
* contact which is assigned a case role of case manager.
*
- * @param int $caseType case type
- * @param int $caseId case id
+ * @param int $caseType case type
+ * @param int $caseId case id
*
* @return array $caseManagerContact array of contact on success otherwise empty
*
*
* @return array of case and related data keyed on case id
*/
- static function getUnclosedCases($params = array(
- ), $excludeCaseIds = array(), $excludeDeleted = TRUE) {
+ static function getUnclosedCases($params = array(), $excludeCaseIds = array(), $excludeDeleted = TRUE) {
//params from ajax call.
$where = array('( ca.end_date is null )');
if ($caseType = CRM_Utils_Array::value('case_type', $params)) {
$where[] = "( ov.label LIKE '%$caseType%' )";
}
if ($sortName = CRM_Utils_Array::value('sort_name', $params)) {
- $config = CRM_Core_Config::singleton();
- $search = ($config->includeWildCardInName) ? "%$sortName%" : "$sortName%";
+ $config = CRM_Core_Config::singleton();
+ $search = ($config->includeWildCardInName) ? "%$sortName%" : "$sortName%";
$where[] = "( sort_name LIKE '$search' )";
}
if (is_array($excludeCaseIds) &&
$doFilterCases = FALSE;
if (!CRM_Core_Permission::check('access all cases and activities')) {
$doFilterCases = TRUE;
- $session = CRM_Core_Session::singleton();
- $filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
+ $session = CRM_Core_Session::singleton();
+ $filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
}
$whereClause = implode(' AND ', $where);
/**
* Retrieve cases related to particular contact.
*
- * @param int $contactId contact id
+ * @param int $contactId contact id
* @param boolean $excludeDeleted do not include deleted cases.
*
* @return an array of cases.
/**
* Retrieve related cases for give case.
*
- * @param int $mainCaseId id of main case
- * @param int $contactId id of contact
+ * @param int $mainCaseId id of main case
+ * @param int $contactId id of contact
* @param boolean $excludeDeleted do not include deleted cases.
*
* @return an array of related cases.
$doFilterCases = FALSE;
if (!CRM_Core_Permission::check('access all cases and activities')) {
$doFilterCases = TRUE;
- $session = CRM_Core_Session::singleton();
- $filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
+ $session = CRM_Core_Session::singleton();
+ $filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
}
//2. fetch the details of related cases.
AND case_type_og.id = case_type_ov.option_group_id )
WHERE {$whereClause}";
- $dao = CRM_Core_DAO::executeQuery($query);
+ $dao = CRM_Core_DAO::executeQuery($query);
$contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=");
$hasViewContact = CRM_Core_Permission::giveMeAllACLs();
if (!$doFilterCases || array_key_exists($dao->id, $filterCases)) {
$caseViewStr = "reset=1&id={$dao->id}&cid={$dao->client_id}&action=view&context=case&selectedChild=case";
$caseViewUrl = CRM_Utils_System::url("civicrm/contact/view/case", $caseViewStr);
- $caseView = "<a href='{$caseViewUrl}'>" . ts('View Case') . "</a>";
+ $caseView = "<a href='{$caseViewUrl}'>" . ts('View Case') . "</a>";
}
$clientView = $dao->client_name;
if ($hasViewContact) {
* @static
*/
static function mergeCases($mainContactId, $mainCaseId = NULL, $otherContactId = NULL,
- $otherCaseId = NULL, $changeClient = FALSE ) {
+ $otherCaseId = NULL, $changeClient = FALSE) {
$moveToTrash = TRUE;
$duplicateContacts = FALSE;
}
foreach ($table as $tableName => $tableColumns) {
- $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
+ $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
$tableColumns[0] = $mainCaseId;
- $select = 'SELECT ' . implode(', ', $tableColumns);
- $from = ' FROM ' . $tableName;
- $where = " WHERE {$tableName}.entity_id = {$otherCaseId}";
- $query = $insert . $select . $from . $where;
- $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
+ $select = 'SELECT ' . implode(', ', $tableColumns);
+ $from = ' FROM ' . $tableName;
+ $where = " WHERE {$tableName}.entity_id = {$otherCaseId}";
+ $query = $insert . $select . $from . $where;
+ $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
}
-
+
$mainCase->free();
-
+
$mainCaseIds[] = $mainCaseId;
//insert record for case contact.
$otherCaseContact = new CRM_Case_DAO_CaseContact();
$mergeActType = array_search('Reassigned Case', $activityTypes);
$mergeActSubject = ts("Case %1 reassigned client from %2 to %3. New Case ID is %4.",
array(
- 1 => $otherCaseId, 2 => $otherContactDisplayName,
- 3 => $mainContactDisplayName, 4 => $mainCaseId
+ 1 => $otherCaseId,
+ 2 => $otherContactDisplayName,
+ 3 => $mainContactDisplayName,
+ 4 => $mainCaseId
)
);
}
$mergeActType = array_search('Merge Case', $activityTypes);
$mergeActSubject = ts("Case %1 copied from contact id %2 to contact id %3 via merge. New Case ID is %4.",
array(
- 1 => $otherCaseId, 2 => $otherContactId,
- 3 => $mainContactId, 4 => $mainCaseId
+ 1 => $otherCaseId,
+ 2 => $otherContactId,
+ 3 => $mainContactId,
+ 4 => $mainCaseId
)
);
}
* Validate contact permission for
* edit/view on activity record and build links.
*
- * @param array $tplParams params to be sent to template for sending email.
- * @param array $activityParams info of the activity.
+ * @param array $tplParams params to be sent to template for sending email.
+ * @param array $activityParams info of the activity.
*
* @return void
* @static
* Validate contact permission for
* given operation on activity record.
*
- * @param int $activityId activity record id.
- * @param string $operation user operation.
- * @param int $actTypeId activity type id.
- * @param int $contactId contact id/if not pass consider logged in
+ * @param int $activityId activity record id.
+ * @param string $operation user operation.
+ * @param int $actTypeId activity type id.
+ * @param int $contactId contact id/if not pass consider logged in
* @param boolean $checkComponent do we need to check component enabled.
*
* @return boolean $allow true/false
if (!empty($hasPermissions)) {
//need to check activity object specific.
if (in_array($operation, array(
- 'view', 'edit'))) {
+ 'view',
+ 'edit'
+ ))
+ ) {
//do we have supper permission.
if (in_array('access all cases and activities', $hasPermissions[$operation])) {
$allowOperations[$operation] = $allow = TRUE;
$actTypeName = CRM_Utils_Array::value($actTypeId, $activityTypes);
//do not allow multiple copy / edit action.
- $singletonNames = array('Open Case', 'Reassigned Case', 'Merge Case', 'Link Cases', 'Assign Case Role', 'Email', 'Inbound Email');
+ $singletonNames = array(
+ 'Open Case',
+ 'Reassigned Case',
+ 'Merge Case',
+ 'Link Cases',
+ 'Assign Case Role',
+ 'Email',
+ 'Inbound Email'
+ );
//do not allow to delete these activities, CRM-4543
$doNotDeleteNames = array('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date');
$allowEditNames = array('Open Case');
// do not allow File on Case
- $doNotFileNames = array('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date','Reassigned Case', 'Merge Case', 'Link Cases', 'Assign Case Role');
+ $doNotFileNames = array(
+ 'Open Case',
+ 'Change Case Type',
+ 'Change Case Status',
+ 'Change Case Start Date',
+ 'Reassigned Case',
+ 'Merge Case',
+ 'Link Cases',
+ 'Assign Case Role'
+ );
if (in_array($actTypeName, $singletonNames)) {
$allow = FALSE;
/**
* Function to check whether activity is a case Activity
*
- * @param int $activityID activity id
+ * @param int $activityID activity id
*
* @return boolean $isCaseActivity true/false
*/
break;
}
return $sql;
- }
-
- /**
- * Function to add/copy relationships, when new client is added for a case
- *
- * @param int $caseId case id
- * @param int $contactId contact id / new client id
- *
- * @return void
- */
+ }
+
+ /**
+ * Function to add/copy relationships, when new client is added for a case
+ *
+ * @param int $caseId case id
+ * @param int $contactId contact id / new client id
+ *
+ * @return void
+ */
static function addCaseRelationships($caseId, $contactId) {
// get the case role / relationships for the case
$caseRelationships = new CRM_Contact_DAO_Relationship();
$caseContact->case_id = $caseId;
$caseContact->find();
- while($caseContact->fetch()) {
+ while ($caseContact->fetch()) {
$clients[] = $caseContact->contact_id;
}