*/
static $_exportableFields = NULL;
+ /**
+ *
+ */
function __construct() {
parent::__construct();
}
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
- * @param array $ids the array that holds all the db ids
+ *
+ * @internal param array $ids the array that holds all the db ids
*
* @return object CRM_Case_BAO_Case object
* @access public
* takes an associative array and creates a case object
*
* @param array $params (reference ) an assoc array of name/value pairs
- * @param array $ids the array that holds all the db ids
+ *
+ * @internal param array $ids the array that holds all the db ids
*
* @return object CRM_Case_BAO_Case object
* @access public
*
* @param int $caseId
*
+ * @param string $colName
+ *
* @return case type
* @access public
* @static
*
* @param int $caseId id of the case to delete
*
- * @return void
+ * @param bool $moveToTrash
+ *
+ * @return bool is successful
* @access public
* @static
*/
/**
* Retrieve contact_id by case_id
*
- * @param int $caseId ID of the case
+ * @param int $caseId ID of the case
+ *
+ * @param null $contactID
*
* @return array
* @access public
- *
*/
static function retrieveContactIdsByCaseId($caseId, $contactID = NULL) {
$caseContact = new CRM_Case_DAO_CaseContact();
/**
* Look up a case using an activity ID
*
- * @param $activity_id
+ * @param $activityId
+ *
+ * @internal param $activity_id
*
* @return int, case ID
*/
/**
* Retrieve case_id by contact_id
*
- * @param int $contactId ID of the contact
+ * @param $contactID
* @param boolean $includeDeleted include the deleted cases in result
*
+ * @param null $caseType
+ *
+ * @internal param int $contactId ID of the contact
* @return array
*
* @access public
- *
*/
static function retrieveCaseIdsByContactId($contactID, $includeDeleted = FALSE, $caseType = NULL) {
$query = "
return $caseArray;
}
+ /**
+ * @param string $type
+ * @param null $userID
+ * @param null $condition
+ * @param int $isDeleted
+ *
+ * @return string
+ */
static function getCaseActivityQuery($type = 'upcoming', $userID = NULL, $condition = NULL, $isDeleted = 0) {
if (!$userID) {
$session = CRM_Core_Session::singleton();
*
* @param String $type /upcoming,recent,all/
*
+ * @param string $context
+ *
* @return array Array of Cases
*
* @access public
- *
*/
static function getCases($allCases = TRUE, $userID = NULL, $type = 'upcoming', $context = 'dashboard') {
$condition = NULL;
}
}
//CRM-4510.
- $caseManagerContact = self::getCaseManagerContact($result->case_type_name, $result->case_id);
+ $caseTypes = CRM_Case_PseudoConstant::caseType('name');
+ $caseManagerContact = self::getCaseManagerContact($caseTypes[$result->case_type_id], $result->case_id);
if (!empty($caseManagerContact)) {
$casesList[$result->case_id]['casemanager_id'] = CRM_Utils_Array::value('casemanager_id', $caseManagerContact);
$casesList[$result->case_id]['casemanager'] = CRM_Utils_Array::value('casemanager', $caseManagerContact);
*
* @param int $contactID contact id
* @param int $caseID case id
+ * @param null $relationshipID
+ *
* @return returns case role / relationships
*
* @static
* @param array $params posted params
* @param int $contactID contact id
*
+ * @param null $context
+ * @param null $userID
+ * @param null $type
+ *
* @return returns case activities
*
* @static
//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 . ' ); return false;">' . ts('Move To Case') . '</a> ';
+ $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 . ' ); return false;">' . ts('Copy To Case') . '</a> ';
+ $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)) {
* @param int $caseID case id
* @param boolean $skipDetails if true include details of contacts
*
- * @return returns $searchRows array of returnproperties
+ * @return array $searchRows array of return properties
*
* @static
*/
static function getRelatedContacts($caseID, $skipDetails = FALSE) {
$values = array();
- $query = 'SELECT cc.display_name as name, cc.sort_name as sort_name, cc.id, crt.label_b_a as role, ce.email
- FROM civicrm_relationship cr
- LEFT JOIN civicrm_relationship_type crt ON crt.id = cr.relationship_type_id
- LEFT JOIN civicrm_contact cc ON cc.id = cr.contact_id_b
- LEFT JOIN civicrm_email ce ON ce.contact_id = cc.id
- WHERE cr.case_id = %1 AND ce.is_primary= 1
- GROUP BY cc.id';
+ $query = '
+ SELECT cc.display_name as name, cc.sort_name as sort_name, cc.id, crt.label_b_a as role, ce.email
+ FROM civicrm_relationship cr
+ LEFT JOIN civicrm_relationship_type crt
+ ON crt.id = cr.relationship_type_id
+ LEFT JOIN civicrm_contact cc
+ ON cc.id = cr.contact_id_b
+ LEFT JOIN civicrm_email ce
+ ON ce.contact_id = cc.id
+ AND ce.is_primary= 1
+ WHERE cr.case_id = %1
+ GROUP BY cc.id';
$params = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
/**
* Function that sends e-mail copy of activity
*
+ * @param $clientId
* @param int $activityId activity Id
* @param array $contacts array of related contact
*
+ * @param null $attachments
+ * @param $caseId
+ *
* @return void
* @access public
*/
/**
* Create an activity for a case via email
*
- * @param int $file email sent
- *
- * @return $activity object of newly creted activity via email
- *
- * @access public
+ * @param int $file email sent
*
+ * @return array|void $activity object of newly creted activity via email@access public
*/
static function recordActivityViaEmail($file) {
if (!file_exists($file) ||
/**
* Function to retrieve the scheduled activity type and date
*
- * @param array $cases Array of contact and case id
+ * @param array $cases Array of contact and case id
+ *
+ * @param string $type
*
* @return array $activityInfo Array of scheduled activity type and date
*
return TRUE;
}
+ /**
+ * @param $groupInfo
+ * @param null $sort
+ * @param null $showLinks
+ * @param bool $returnOnlyCount
+ * @param int $offset
+ * @param int $rowCount
+ *
+ * @return array
+ */
static function getGlobalContacts(&$groupInfo, $sort = NULL, $showLinks = NULL, $returnOnlyCount = FALSE, $offset = 0, $rowCount = 25) {
$globalContacts = array();
/*
* Convenience function to get both case contacts and global in one array
*/
+ /**
+ * @param $caseId
+ *
+ * @return array
+ */
static function getRelatedAndGlobalContacts($caseId) {
$relatedContacts = self::getRelatedContacts($caseId);
/**
* Function to create activities when Case or Other roles assigned/modified/deleted.
*
- * @param int $caseID case id
+ * @param $caseId
* @param int $relationshipId relationship id
* @param int $relContactId case role assignee contactId.
*
+ * @param null $contactId
+ *
+ * @internal param int $caseID case id
* @return void on success creates activity and case activity
*
* @static
/**
* Get all cases with no end dates
*
+ * @param array $params
+ * @param array $excludeCaseIds
+ * @param bool $excludeDeleted
+ *
* @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, $includeClosed = FALSE) {
//params from ajax call.
- $where = array('( ca.end_date is null )');
+ $where = array($includeClosed ? '(1)' : '(ca.end_date is null)');
if ($caseType = CRM_Utils_Array::value('case_type', $params)) {
$where[] = "( civicrm_case_type.title LIKE '%$caseType%' )";
}
$search = ($config->includeWildCardInName) ? "%$sortName%" : "$sortName%";
$where[] = "( sort_name LIKE '$search' )";
}
+ if ($cid = CRM_Utils_Array::value('contact_id', $params)) {
+ $where[] = " c.id = $cid ";
+ }
if (is_array($excludeCaseIds) &&
!CRM_Utils_System::isNull($excludeCaseIds)
) {
ca.id,
ca.subject as case_subject,
civicrm_case_type.title as case_type,
- ca.start_date as start_date
+ ca.start_date as start_date,
+ ca.end_date as end_date,
+ ca.status_id
FROM civicrm_case ca INNER JOIN civicrm_case_contact cc ON ca.id=cc.case_id
INNER JOIN civicrm_contact c ON cc.contact_id=c.id
INNER JOIN civicrm_case_type ON ca.case_type_id = civicrm_case_type.id
WHERE {$whereClause}
- ORDER BY c.sort_name
+ ORDER BY c.sort_name, ca.end_date
{$limitClause}
";
$dao = CRM_Core_DAO::executeQuery($query);
+ $statuses = CRM_Case_BAO_Case::buildOptions('status_id', 'create');
+
$unclosedCases = array();
while ($dao->fetch()) {
if ($doFilterCases && !array_key_exists($dao->id, $filterCases)) {
'case_type' => $dao->case_type,
'contact_id' => $dao->contact_id,
'start_date' => $dao->start_date,
+ 'end_date' => $dao->end_date,
'case_subject' => $dao->case_subject,
+ 'case_status' => $statuses[$dao->status_id],
);
}
$dao->free();
return $unclosedCases;
}
+ /**
+ * @param null $contactId
+ * @param bool $excludeDeleted
+ *
+ * @return null|string
+ */
static function caseCount($contactId = NULL, $excludeDeleted = TRUE) {
$whereConditions = array();
if ($excludeDeleted) {
* 1. Merge two duplicate contacts cases - follow CRM-5758 rules.
* 2. Merge two cases of same contact - follow CRM-5598 rules.
*
- * @param int $mainContactId contact id of main contact record.
- * @param int $mainCaseId case id of main case record.
- * @param int $otherContactId contact id of record which is going to merge.
- * @param int $otherCaseId case id of record which is going to merge.
+ * @param int $mainContactId contact id of main contact record.
+ * @param int $mainCaseId case id of main case record.
+ * @param int $otherContactId contact id of record which is going to merge.
+ * @param int $otherCaseId case id of record which is going to merge.
*
- * @return void.
+ * @param bool $changeClient
+ *
+ * @return integer|NULL
* @static
*/
static function mergeCases($mainContactId, $mainCaseId = NULL, $otherContactId = NULL,
/**
* Function to check case configuration.
*
+ * @param null $contactId
+ *
* @return array $configured
*/
static function isCaseConfigured($contactId = NULL) {
* @see CRM_Core_DAO::buildOptions
*
* @param String $fieldName
- * @param String $context: @see CRM_Core_DAO::buildOptionsContext
- * @param Array $props: whatever is known about this dao object
+ * @param String $context : @see CRM_Core_DAO::buildOptionsContext
+ * @param Array $props : whatever is known about this dao object
+ *
+ * @return Array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
$className = __CLASS__;