<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
* Retrieve unclosed cases.
*/
static function unclosedCases() {
- $criteria = explode('-', CRM_Utils_Type::escape(CRM_Utils_Array::value('s', $_GET), 'String'));
-
- $limit = NULL;
- if ($limit = CRM_Utils_Array::value('limit', $_GET)) {
- $limit = CRM_Utils_Type::escape($limit, 'Integer');
- }
-
$params = array(
- 'limit' => $limit,
- 'case_type' => trim(CRM_Utils_Array::value(1, $criteria)),
- 'sort_name' => trim(CRM_Utils_Array::value(0, $criteria)),
+ 'limit' => CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10),
+ 'sort_name' => CRM_Utils_Type::escape(CRM_Utils_Array::value('term', $_GET, ''), 'String'),
);
$excludeCaseIds = array();
- if ($caseIdStr = CRM_Utils_Array::value('excludeCaseIds', $_GET)) {
- $excludeIdStr = CRM_Utils_Type::escape($caseIdStr, 'String');
- $excludeCaseIds = explode(',', $excludeIdStr);
+ if (!empty($_GET['excludeCaseIds'])) {
+ $excludeCaseIds = explode(',', CRM_Utils_Type::escape($_GET['excludeCaseIds'], 'String'));
}
$unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds);
-
+ $results = array();
foreach ($unclosedCases as $caseId => $details) {
- echo $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ') ' . "|$caseId|" . $details['contact_id'] . '|' . $details['case_type'] . '|' . $details['sort_name'] . "\n";
+ $results[] = array(
+ 'id' => $caseId,
+ 'text' => $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ')',
+ 'extra' => $details,
+ );
}
-
+ print json_encode($results);
CRM_Utils_System::civiExit();
}
$caseId = CRM_Utils_Type::escape($_POST['case_id'], 'Integer');
$tags = CRM_Utils_Type::escape($_POST['tag'], 'String');
+ $tagList = $_POST['taglist'];
if (empty($caseId)) {
echo 'false';
$tagIds = explode(',', $tags);
}
- $params = array(
- 'entity_id' => $caseId,
- 'entity_table' => 'civicrm_case',
- );
+ if (!empty($tagIds)) {
+ $params = array(
+ 'entity_id' => $caseId,
+ 'entity_table' => 'civicrm_case',
+ );
- CRM_Core_BAO_EntityTag::del($params);
+ CRM_Core_BAO_EntityTag::del($params);
- foreach ($tagIds as $tagid) {
- if (is_numeric($tagid)) {
- $params['tag_id'] = $tagid;
- CRM_Core_BAO_EntityTag::add($params);
+ foreach ($tagIds as $tagid) {
+ if (is_numeric($tagid)) {
+ $params['tag_id'] = $tagid;
+ CRM_Core_BAO_EntityTag::add($params);
+ }
}
}
+ if (!empty($tagList)) {
+ CRM_Core_Form_Tag::postProcess($tagList, $caseId, 'civicrm_case', CRM_Core_DAO::$_nullObject);
+ }
+
$session = CRM_Core_Session::singleton();
$activityParams = array();
$caseStatuses = CRM_Case_PseudoConstant::caseStatus();
$cs = $caseStatuses[$dao->status_id];
$caseDetails = "<table><tr><td>" . ts('Case Subject') . "</td><td>{$dao->subject}</td></tr>
- <tr><td>" . ts('Case Type') . "</td><td>{$caseType}</td></tr>
+ <tr><td>" . ts('Case Type') . "</td><td>{$caseType}</td></tr>
<tr><td>" . ts('Case Status') . "</td><td>{$cs}</td></tr>
<tr><td>" . ts('Case Start Date') . "</td><td>" . CRM_Utils_Date::customFormat($dao->start_date) . "</td></tr>
<tr><td>" . ts('Case End Date') . "</td><td></td></tr>" . CRM_Utils_Date::customFormat($dao->end_date) . "</table>";