本文整理汇总了PHP中CRM_Case_XMLProcessor_Process类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_XMLProcessor_Process类的具体用法?PHP CRM_Case_XMLProcessor_Process怎么用?PHP CRM_Case_XMLProcessor_Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Case_XMLProcessor_Process类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param $caseType
* @param array $params
*
* @return bool
* @throws Exception
*/
public function run($caseType, &$params)
{
$xml = $this->retrieve($caseType);
if ($xml === FALSE) {
$docLink = CRM_Utils_System::docURL2("user/case-management/setup");
CRM_Core_Error::fatal(ts("Configuration file could not be retrieved for case type = '%1' %2.", array(1 => $caseType, 2 => $docLink)));
return FALSE;
}
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$this->_isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->process($xml, $params);
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:19,代码来源:Process.php
示例2: run
function run($caseType, &$params)
{
$xml = $this->retrieve($caseType);
if ($xml === false) {
require_once 'CRM/Utils/System.php';
$docLink = CRM_Utils_System::docURL2("CiviCase Configuration");
CRM_Core_Error::fatal(ts("Configuration file could not be retrieved for case type = '%1' %2.", array(1 => $caseType, 2 => $docLink)));
return false;
}
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$this->_isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->process($xml, $params);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:14,代码来源:Process.php
示例3: civicrm_api3_case_create
/**
* Open a new case, add client and manager roles, and add standard timeline
*
* @param array(
//REQUIRED:
* 'case_type_id' => int OR
* 'case_type' => str (provide one or the other)
* 'contact_id' => int // case client
* 'subject' => str
*
* //OPTIONAL
* 'medium_id' => int // see civicrm option values for possibilities
* 'creator_id' => int // case manager, default to the logged in user
* 'status_id' => int // defaults to 1 "ongoing"
* 'location' => str
* 'start_date' => str datestamp // defaults to: date('YmdHis')
* 'duration' => int // in minutes
* 'details' => str // html format
*
* @return sucessfully opened case
*
* @access public
* {@getfields case_create}
*/
function civicrm_api3_case_create($params)
{
if (!empty($params['id'])) {
return civicrm_api3_case_update($params);
}
civicrm_api3_verify_mandatory($params, NULL, array('contact_id', 'subject', array('case_type', 'case_type_id')));
_civicrm_api3_case_format_params($params);
// If format_params didn't find what it was looking for, return error
if (empty($params['case_type_id'])) {
return civicrm_api3_create_error('Invalid case_type. No such case type exists.');
}
if (empty($params['case_type'])) {
return civicrm_api3_create_error('Invalid case_type_id. No such case type exists.');
}
// Fixme: can we safely pass raw params to the BAO?
$newParams = array('case_type_id' => $params['case_type_id'], 'creator_id' => $params['creator_id'], 'status_id' => $params['status_id'], 'start_date' => $params['start_date'], 'end_date' => CRM_Utils_Array::value('end_date', $params), 'subject' => $params['subject']);
$caseBAO = CRM_Case_BAO_Case::create($newParams);
if (!$caseBAO) {
return civicrm_api3_create_error('Case not created. Please check input params.');
}
foreach ((array) $params['contact_id'] as $cid) {
$contactParams = array('case_id' => $caseBAO->id, 'contact_id' => $cid);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
// Initialize XML processor with $params
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $params['contact_id'], 'creatorID' => $params['creator_id'], 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $caseBAO->id, 'subject' => $params['subject'], 'location' => CRM_Utils_Array::value('location', $params), 'activity_date_time' => $params['start_date'], 'duration' => CRM_Utils_Array::value('duration', $params), 'medium_id' => CRM_Utils_Array::value('medium_id', $params), 'details' => CRM_Utils_Array::value('details', $params), 'custom' => array());
// Do it! :-D
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
// return case
$values = array();
_civicrm_api3_object_to_array($caseBAO, $values[$caseBAO->id]);
return civicrm_api3_create_success($values, $params, 'case', 'create', $caseBAO);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:58,代码来源:Case.php
示例4: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$buttonName = $this->controller->getButtonName();
// user context
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_contactID}&id={$this->_caseID}&show=1");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
if (!empty($params['timeline_id']) && !empty($_POST['_qf_CaseView_next'])) {
$session = CRM_Core_Session::singleton();
$this->_uid = $session->get('userID');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $this->_contactID, 'creatorID' => $this->_uid, 'standardTimeline' => 0, 'activity_date_time' => date('YmdHis'), 'caseID' => $this->_caseID, 'caseType' => $this->_caseType, 'activitySetName' => $params['timeline_id']);
$xmlProcessor->run($this->_caseType, $xmlProcessorParams);
$reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
CRM_Core_Session::setStatus(ts('Activities from the %1 activity set have been added to this case.', array(1 => $reports[$params['timeline_id']])), ts('Done'), 'success');
} elseif ($this->_mergeCases && $buttonName == '_qf_CaseView_next_merge_case') {
$mainCaseId = $params['merge_case_id'];
$otherCaseId = $this->_caseID;
//merge two cases.
CRM_Case_BAO_Case::mergeCases($this->_contactID, $mainCaseId, NULL, $otherCaseId);
//redirect user to main case view.
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_contactID}&id={$mainCaseId}&show=1");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:33,代码来源:CaseView.php
示例5: getCaseManagerContact
/**
* 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
*
* @return array $caseManagerContact array of contact on success otherwise empty
*
* @static
*/
static function getCaseManagerContact($caseType, $caseId)
{
if (!$caseType || !$caseId) {
return;
}
$caseManagerContact = array();
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseType);
if (!empty($managerRoleId)) {
$managerRoleQuery = "\nSELECT civicrm_contact.id as casemanager_id, \n civicrm_contact.sort_name as casemanager\nFROM civicrm_contact \nLEFT JOIN civicrm_relationship ON (civicrm_relationship.contact_id_b = civicrm_contact.id AND civicrm_relationship.relationship_type_id = %1)\nLEFT JOIN civicrm_case ON civicrm_case.id = civicrm_relationship.case_id\nWHERE civicrm_case.id = %2";
$managerRoleParams = array(1 => array($managerRoleId, 'Integer'), 2 => array($caseId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($managerRoleQuery, $managerRoleParams);
if ($dao->fetch()) {
$caseManagerContact['casemanager_id'] = $dao->casemanager_id;
$caseManagerContact['casemanager'] = $dao->casemanager;
}
}
return $caseManagerContact;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:31,代码来源:Case.php
示例6: endPostProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function endPostProcess(&$form, &$params, $activity)
{
if (CRM_Utils_Array::value('start_date', $params)) {
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
}
$caseType = $form->_caseType;
if (!$caseType && $form->_caseId) {
$query = "\nSELECT cov_type.label as case_type FROM civicrm_case \nLEFT JOIN civicrm_option_group cog_type ON cog_type.name = 'case_type'\nLEFT JOIN civicrm_option_value cov_type ON \n( civicrm_case.case_type_id = cov_type.value AND cog_type.id = cov_type.option_group_id ) \nWHERE civicrm_case.id= %1";
$queryParams = array(1 => array($form->_caseId, 'Integer'));
$caseType = CRM_Core_DAO::singleValueQuery($query, $queryParams);
}
if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$form->_caseId || !$caseType) {
CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
}
$config =& CRM_Core_Config::singleton();
// 1. save activity subject with new start date
$currentStartDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $form->_caseId, 'start_date'), $config->dateformatFull);
$newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']), $config->dateformatFull);
$subject = 'Change Case Start Date from ' . $currentStartDate . ' to ' . $newStartDate;
$activity->subject = $subject;
$activity->save();
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, 'activity_date_time' => $params['start_date'], 'caseID' => $form->_caseId, 'caseType' => $caseType, 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1);
$xmlProcessor->run($caseType, $xmlProcessorParams);
// 2.5 Update open case activity date
// Multiple steps since revisioned
if ($form->openCaseActivityId) {
require_once 'CRM/Activity/BAO/Activity.php';
$abao = new CRM_Activity_BAO_Activity();
$oldParams = array('id' => $form->openCaseActivityId);
$oldActivityDefaults = array();
$oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults);
// save the old values
require_once 'api/v2/utils.php';
$openCaseParams = array();
_civicrm_object_to_array($oldActivity, $openCaseParams);
// update existing revision
$oldParams = array('id' => $form->openCaseActivityId, 'is_current_revision' => 0);
require_once 'CRM/Activity/DAO/Activity.php';
$oldActivity = new CRM_Activity_DAO_Activity();
$oldActivity->copyValues($oldParams);
$oldActivity->save();
// change some params for the new one
unset($openCaseParams['id']);
$openCaseParams['activity_date_time'] = $params['start_date'];
$openCaseParams['target_contact_id'] = $oldActivityDefaults['target_contact'];
$openCaseParams['assignee_contact_id'] = $oldActivityDefaults['assignee_contact'];
$session =& CRM_Core_Session::singleton();
$openCaseParams['source_contact_id'] = $session->get('userID');
// original_id always refers to the first activity, so only update if null (i.e. this is the second revision)
$openCaseParams['original_id'] = $openCaseParams['original_id'] ? $openCaseParams['original_id'] : $form->openCaseActivityId;
$newActivity = CRM_Activity_BAO_Activity::create($openCaseParams);
if (is_a($newActivity, 'CRM_Core_Error')) {
CRM_Core_Error::fatal('Unable to update Open Case activity');
} else {
// Create linkage to case
$caseActivityParams = array('activity_id' => $newActivity->id, 'case_id' => $form->_caseId);
require_once "CRM/Case/BAO/Case.php";
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
}
// 3.status msg
$params['statusMsg'] = ts('Case Start Date changed successfully.');
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:71,代码来源:ChangeCaseStartDate.php
示例7: civicrm_case_create
/**
* Open a new case, add client and manager roles, and add standard timeline
*
* @param array( //REQUIRED:
* 'case_type_id' => int OR 'case_type' => str (provide one or the other)
* 'contact_id' => int // case client
* 'creator_id' => int // case manager
* 'subject' => str
* 'medium_id' => int // see civicrm option values for possibilities
*
* //OPTIONAL
* 'status_id' => int // defaults to 1 "ongoing"
* 'location' => str
* 'start_date' => str datestamp // defaults to: date('YmdHis')
* 'duration' => int // in minutes
* 'details' => str // html format
*
* @return sucessfully opened case
*
* @access public
*/
function civicrm_case_create(&$params)
{
_civicrm_initialize();
//check parameters
$errors = _civicrm_case_check_params($params, 'create');
if ($errors) {
return $errors;
}
_civicrm_case_format_params($params, 'create');
// If format_params didn't find what it was looking for, return error
if (!$params['case_type_id']) {
return civicrm_create_error(ts('Invalid case_type. No such case type exists.'));
}
if (!$params['case_type']) {
return civicrm_create_error(ts('Invalid case_type_id. No such case type exists.'));
}
// format input with value separators
$sep = CRM_Case_BAO_Case::VALUE_SEPERATOR;
$newParams = array('case_type_id' => $sep . $params['case_type_id'] . $sep, 'creator_id' => $params['creator_id'], 'status_id' => $params['status_id'], 'start_date' => $params['start_date'], 'subject' => $params['subject']);
$case =& CRM_Case_BAO_Case::create($newParams);
if (!$case) {
return civicrm_create_error(ts('Case not created. Please check your input params.'));
}
// Add client role
$contactParams = array('case_id' => $case->id, 'contact_id' => $params['contact_id']);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
// Initialize XML processor with $params
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $params['contact_id'], 'creatorID' => $params['creator_id'], 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $case->id, 'subject' => $params['subject'], 'location' => $params['location'], 'activity_date_time' => $params['start_date'], 'duration' => $params['duration'], 'medium_id' => $params['medium_id'], 'details' => $params['details'], 'custom' => array());
// Do it! :-D
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
// status msg
$params['statusMsg'] = ts('Case opened successfully.');
// return case
$details = _civicrm_case_read($case->id);
return civicrm_create_success($details);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:59,代码来源:Case.php
示例8: endPostProcess
/**
* Process the form submission.
*
*
* @param CRM_Core_Form $form
* @param array $params
* @param $activity
*/
public static function endPostProcess(&$form, &$params, $activity)
{
if (!empty($params['start_date'])) {
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
}
$caseType = CRM_Utils_Array::first($form->_caseType);
$caseId = CRM_Utils_Array::first($form->_caseId);
if (!$caseType && $caseId) {
$caseType = CRM_Case_BAO_Case::getCaseType($caseId, 'title');
}
if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$caseId || !$caseType) {
CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
}
$config = CRM_Core_Config::singleton();
$params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activity->status_id = $params['status_id'];
$params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name');
$activity->priority_id = $params['priority_id'];
// 1. save activity subject with new start date
$currentStartDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'start_date'), $config->dateformatFull);
$newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']), $config->dateformatFull);
$subject = 'Change Case Start Date from ' . $currentStartDate . ' to ' . $newStartDate;
$activity->subject = $subject;
$activity->save();
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, 'activity_date_time' => $params['start_date'], 'caseID' => $caseId, 'caseType' => $caseType, 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1);
$xmlProcessor->run($caseType, $xmlProcessorParams);
// 2.5 Update open case activity date
// Multiple steps since revisioned
if ($form->openCaseActivityId) {
$abao = new CRM_Activity_BAO_Activity();
$oldParams = array('id' => $form->openCaseActivityId);
$oldActivityDefaults = array();
$oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults);
// save the old values
require_once 'api/v3/utils.php';
$openCaseParams = array();
//@todo calling api functions directly is not supported
_civicrm_api3_object_to_array($oldActivity, $openCaseParams);
// update existing revision
$oldParams = array('id' => $form->openCaseActivityId, 'is_current_revision' => 0);
$oldActivity = new CRM_Activity_DAO_Activity();
$oldActivity->copyValues($oldParams);
$oldActivity->save();
// change some params for the new one
unset($openCaseParams['id']);
$openCaseParams['activity_date_time'] = $params['start_date'];
$openCaseParams['target_contact_id'] = $oldActivityDefaults['target_contact'];
$openCaseParams['assignee_contact_id'] = $oldActivityDefaults['assignee_contact'];
$session = CRM_Core_Session::singleton();
$openCaseParams['source_contact_id'] = $session->get('userID');
// original_id always refers to the first activity, so only update if null (i.e. this is the second revision)
$openCaseParams['original_id'] = $openCaseParams['original_id'] ? $openCaseParams['original_id'] : $form->openCaseActivityId;
$newActivity = CRM_Activity_BAO_Activity::create($openCaseParams);
if (is_a($newActivity, 'CRM_Core_Error')) {
CRM_Core_Error::fatal('Unable to update Open Case activity');
} else {
// Create linkage to case
$caseActivityParams = array('activity_id' => $newActivity->id, 'case_id' => $caseId);
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
$caseActivityParams = array('activityID' => $form->openCaseActivityId, 'mainActivityId' => $newActivity->id);
CRM_Activity_BAO_Activity::copyExtendedActivityData($caseActivityParams);
}
}
// 3.status msg
$params['statusMsg'] = ts('Case Start Date changed successfully.');
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:76,代码来源:ChangeCaseStartDate.php
示例9: getCaseRoles
public static function getCaseRoles()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
$hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
foreach ($caseRelationships as $key => $value) {
// This role has been filled
unset($caseRoles[$value['relation_type']]);
// mark original case relationships record to use on setting edit links below
$caseRelationships[$key]['source'] = 'caseRel';
}
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
// move/transform caseRoles array data to caseRelationships
// for sorting and display
// CRM-14466 added cid to the non-client array to avoid php notice
foreach ($caseRoles as $id => $value) {
if ($id != "client") {
$rel = array();
$rel['relation'] = $value;
$rel['relation_type'] = $id;
$rel['name'] = '(not assigned)';
$rel['phone'] = '';
$rel['email'] = '';
$rel['source'] = 'caseRoles';
$caseRelationships[] = $rel;
} else {
foreach ($value as $clientRole) {
$relClient = array();
$relClient['relation'] = 'Client';
$relClient['name'] = $clientRole['sort_name'];
$relClient['phone'] = $clientRole['phone'];
$relClient['email'] = $clientRole['email'];
$relClient['cid'] = $clientRole['contact_id'];
$relClient['source'] = 'contact';
$caseRelationships[] = $relClient;
}
}
}
// sort clientRelationships array using jquery call params
foreach ($caseRelationships as $key => $row) {
$sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
}
$sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
array_multisort($sortArray, constant($sort_type), $caseRelationships);
$relationships = array();
// set user name, email and edit columns links
foreach ($caseRelationships as $key => &$row) {
$typeLabel = $row['relation'];
// Add "<br />(Case Manager)" to label
if ($row['relation_type'] == $managerRoleId) {
$row['relation'] .= '<br />' . '(' . ts('Case Manager') . ')';
}
// view user links
if (!empty($row['cid'])) {
$row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
}
// email column links/icon
if ($row['email']) {
$row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope"></i></a>';
}
// edit links
$row['actions'] = '';
if ($hasAccessToAllCases) {
$contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
$contactType = $contactType == 'Contact' ? '' : $contactType;
switch ($row['source']) {
case 'caseRel':
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
break;
case 'caseRoles':
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_b_a" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>';
break;
}
}
unset($row['cid']);
unset($row['relation_type']);
unset($row['rel_id']);
unset($row['client_id']);
unset($row['source']);
array_push($relationships, $row);
}
$params['total'] = count($relationships);
$caseRelationshipsDT = array();
$caseRelationshipsDT['data'] = $relationships;
$caseRelationshipsDT['recordsTotal'] = $params['total'];
$caseRelationshipsDT['recordsFiltered'] = $params['total'];
CRM_Utils_JSON::output($caseRelationshipsDT);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:94,代码来源:AJAX.php
示例10: getCaseRoles
public static function getCaseRoles()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$sortMapper = array(0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$params = $_POST;
if ($sort && $sortOrder) {
$sortSQL = $sort . ' ' . $sortOrder;
}
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
$hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
if (!empty($managerRoleId)) {
$caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
}
foreach ($caseRelationships as $key => $value) {
//calculate roles that don't have relationships
if (!empty($caseRoles[$value['relation_type']])) {
//keep naming from careRoles array
$caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
unset($caseRoles[$value['relation_type']]);
}
// mark orginal case relationships record to use on setting edit links below
$caseRelationships[$key]['source'] = 'caseRel';
}
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
// move/transform caseRoles array data to caseRelationships
// for sorting and display
// CRM-14466 added cid to the non-client array to avoid php notice
foreach ($caseRoles as $id => $value) {
if ($id != "client") {
$rel = array();
$rel['relation'] = $value;
$rel['relation_type'] = $id;
$rel['name'] = '(not assigned)';
$rel['phone'] = '';
$rel['email'] = '';
$rel['source'] = 'caseRoles';
$caseRelationships[] = $rel;
} else {
foreach ($value as $clientRole) {
$relClient = array();
$relClient['relation'] = 'Client';
$relClient['name'] = $clientRole['sort_name'];
$relClient['phone'] = $clientRole['phone'];
$relClient['email'] = $clientRole['email'];
$relClient['cid'] = $clientRole['contact_id'];
$relClient['source'] = 'contact';
$caseRelationships[] = $relClient;
}
}
}
// sort clientRelationships array using jquery call params
foreach ($caseRelationships as $key => $row) {
$sortArray[$key] = $row[$sort];
}
$sort_type = "SORT_" . strtoupper($sortOrder);
array_multisort($sortArray, constant($sort_type), $caseRelationships);
//limit rows display
$allCaseRelationships = $caseRelationships;
$caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
// set user name, email and edit columns links
// idx will count number of current row / needed by edit links
$idx = 1;
foreach ($caseRelationships as &$row) {
// Get rid of the "<br />(Case Manager)" from label
list($typeLabel) = explode('<', $row['relation']);
// view user links
if (!empty($row['cid'])) {
$row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
}
// email column links/icon
if ($row['email']) {
$row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><span class="icon ui-icon-mail-closed"></span></a>';
}
// edit links
$row['actions'] = '';
if ($hasAccessToAllCases) {
$contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
$contactType = $contactType == 'Contact' ? '' : $contactType;
switch ($row['source']) {
case 'caseRel':
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
break;
case 'caseRoles':
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>';
break;
}
}
$idx++;
}
$iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:AJAX.php
示例11: delegateToXmlListeners
/**
* Find any extra listeners declared in XML and pass the event along to them.
*
* @param \Civi\CCase\Event\CaseChangeEvent $event
*/
public static function delegateToXmlListeners(\Civi\CCase\Event\CaseChangeEvent $event)
{
$p = new \CRM_Case_XMLProcessor_Process();
$listeners = $p->getListeners($event->analyzer->getCaseType());
foreach ($listeners as $listener) {
/** @var $listener \Civi\CCase\CaseChangeListener */
$listener->onCaseChange($event);
}
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:14,代码来源:Events.php
示例12: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
// user context
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_contactID}&id={$this->_caseID}&show=1");
$session =& CRM_Core_Session::singleton();
$session->pushUserContext($url);
if (CRM_Utils_Array::value('timeline_id', $params) && CRM_Utils_Array::value('_qf_CaseView_next', $_POST)) {
$session =& CRM_Core_Session::singleton();
$this->_uid = $session->get('userID');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $this->_contactID, 'creatorID' => $this->_uid, 'standardTimeline' => 0, 'activity_date_time' => date('YmdHis'), 'caseID' => $this->_caseID, 'caseType' => $this->_caseType, 'activitySetName' => $params['timeline_id']);
$xmlProcessor->run($this->_caseType, $xmlProcessorParams);
$reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
CRM_Core_Session::setStatus(ts('Activities from the %1 activity set have been added to this case.', array(1 => $reports[$params['timeline_id']])));
}
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:23,代码来源:CaseView.php
示例13: getCaseRoles
static function getCaseRoles()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$sortMapper = array(0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$params = $_POST;
if ($sort && $sortOrder) {
$sortSQL = $sort . ' ' . $sortOrder;
}
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
$hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
if (!empty($managerRoleId)) {
$caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
}
foreach ($caseRelationships as $key => $value) {
//calculate roles that don't have relationships
if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
//keep naming from careRoles array
$caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
unset($caseRoles[$value['relation_type']]);
}
// mark orginal case relationships record to use on setting edit links below
$caseRelationships[$key]['source'] = 'caseRel';
}
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
// move/transform caseRoles array data to caseRelationships
// for sorting and display
foreach ($caseRoles as $id => $value) {
if ($id != "client") {
$rel = array();
$rel['relation'] = $value;
$rel['relation_type'] = $id;
$rel['name'] = '(not assigned)';
$rel['phone'] = '';
$rel['email'] = '';
$rel['source'] = 'caseRoles';
$caseRelationships[] = $rel;
} else {
foreach ($value as $clientRole) {
$relClient = array();
$relClient['relation'] = 'Client';
$relClient['name'] = $clientRole['sort_name'];
$relClient['phone'] = $clientRole['phone'];
$relClient['email'] = $clientRole['email'];
$relClient['cid'] = $clientRole['contact_id'];
$relClient['source'] = 'contact';
$caseRelationships[] = $relClient;
}
}
}
// sort clientRelationships array using jquery call params
foreach ($caseRelationships as $key => $row) {
$sortArray[$key] = $row[$sort];
}
$sort_type = "SORT_" . strtoupper($sortOrder);
array_multisort($sortArray, constant($sort_type), $caseRelationships);
//limit rows display
$allCaseRelationships = $caseRelationships;
$caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
// set user name, email and edit columns links
// idx will count number of current row / needed by edit links
$idx = 1;
foreach ($caseRelationships as $key => $row) {
// view user links
if ($caseRelationships[$key]['cid']) {
$caseRelationships[$key]['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $caseRelationships[$key]['cid']) . '>' . $caseRelationships[$key]['name'] . '</a>';
}
// email column links/icon
if ($caseRelationships[$key]['email']) {
$caseRelationships[$key]['email'] = '<a href="' . CRM_Utils_System::url('civicrm/contact/view/activity', 'action=reset=1&action=add&atype=3&cid=' . $caseRelationships[$key]['cid']) . '&caseid=' . $caseID . '" title="compose and send an email"><div class="icon email-icon" title="compose and send an email"></div>
</a>';
}
// edit links
if ($hasAccessToAllCases) {
switch ($caseRelationships[$key]['source']) {
case 'caseRel':
$caseRelationships[$key]['actions'] = '<a href="#" title="edit case role" onclick="createRelationship( ' . $caseRelationships[$key]['relation_type'] . ', ' . $caseRelationships[$key]['cid'] . ', ' . $caseRelationships[$key]['rel_id'] . ', ' . $idx . ', \'' . $caseRelationships[$key]['relation'] . '\' );return false;"><div class="icon edit-icon" ></div></a> <a href="#" class="case-role-delete" case_id="' . $caseID . '" rel_type="' . $caseRelationships[$key]['relation_type'] . '"><div class="icon delete-icon" title="remove contact from case role"></div></a>';
break;
case 'caseRoles':
$caseRelationships[$key]['actions'] = '<a href="#" title="edit case role" onclick="createRelationship(' . $caseRelationships[$key]['relation_type'] . ', null, null, ' . $idx . ', \'' . $caseRelationships[$key]['relation'] . '\');return false;"><div class="icon edit-icon"></div></a>';
break;
}
} else {
$caseRelationships[$key]['actions'] = '';
}
$idx++;
}
$iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
$selectorElements = array('relation', 'name', 'phone', 'email', 'actions');
echo CRM_Utils_JSON::encodeDataTableSelector($caseRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:AJAX.php
示例14: civicrm_api3_case_create
/**
* Open a new case, add client and manager roles, and add standard timeline
*
* @param array(
//REQUIRED:
* 'case_type_id' => int OR
* 'case_type' => str (provide one or the other)
* 'contact_id' => int // case client
* 'subject' => str
*
* //OPTIONAL
* 'medium_id' => int // see civicrm option values for possibilities
* 'creator_id' => int // case manager, default to the logged in user
* 'status_id' => int // defaults to 1 "ongoing"
* 'location' => str
* 'start_date' => str datestamp // defaults to: date('YmdHis')
* 'duration' => int // in minutes
* 'details' => str // html format
*
* @return sucessfully opened case
*
* @access public
* {@getfields case_create}
*/
function civicrm_api3_case_create($params)
{
if (empty($params['contact_id']) && isset($params['client_id'])) {
$params['contact_id'] = $params['client_id'];
}
if (isset($params['id']) || isset($params['case_id'])) {
return _api_case_update($params);
}
// ongoing
if (!CRM_Utils_Array::value('status_id', $params)) {
$params['status_id'] = 1;
}
if (!array_key_exists('creator_id', $params)) {
$session = CRM_Core_Session::singleton();
$params['creator_id'] = $session->get('userID');
}
//check parameters
$errors = _civicrm_api3_case_check_params($params, 'create');
if ($errors) {
return $errors;
}
_civicrm_api3_case_format_params($params, 'create');
// If format_params didn't find what it was looking for, return error
if (empty($params['case_type_id'])) {
return civicrm_api3_create_error('Invalid case_type. No such case type exists.');
}
if (empty($params['case_type'])) {
return civicrm_api3_create_error('Invalid case_type_id. No such case type exists.');
}
// format input with value separators
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
$newParams = array('case_type_id' => $sep . $params['case_type_id'] . $sep, 'creator_id' => $params['creator_id'], 'status_id' => $params['status_id'], 'start_date' => $params['start_date'], 'subject' => $params['subject']);
$caseBAO = CRM_Case_BAO_Case::create($newParams);
if (!$caseBAO) {
return civicrm_api3_create_error('Case not created. Please check input params.');
}
foreach ((array) $params['contact_id'] as $cid) {
$contactParams = array('case_id' => $caseBAO->id, 'contact_id' => $cid);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
// Initialize XML processor with $params
require_once 'CRM/Case/XMLPr
|
请发表评论