本文整理汇总了PHP中CRM_Case_BAO_Case::addCaseToContact方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::addCaseToContact方法的具体用法?PHP CRM_Case_BAO_Case::addCaseToContact怎么用?PHP CRM_Case_BAO_Case::addCaseToContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_BAO_Case
的用法示例。
在下文中一共展示了CRM_Case_BAO_Case::addCaseToContact方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddCaseToContact
public function testAddCaseToContact()
{
$params = array('case_id' => 1, 'contact_id' => 17);
CRM_Case_BAO_Case::addCaseToContact($params);
$recent = CRM_Utils_Recent::get();
$this->assertEquals('Test Contact - Housing Support', $recent[0]['title']);
}
示例2: 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);
}
示例3: 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);
}
示例4: addClient
public function addClient()
{
$caseId = CRM_Utils_Type::escape($_POST['caseID'], 'Positive');
$contactId = CRM_Utils_Type::escape($_POST['contactID'], 'Positive');
if (!$contactId || !CRM_Case_BAO_Case::accessCase($caseId)) {
CRM_Utils_System::permissionDenied();
}
$params = array('case_id' => $caseId, 'contact_id' => $contactId);
CRM_Case_BAO_Case::addCaseToContact($params);
// add case relationships
CRM_Case_BAO_Case::addCaseRelationships($caseId, $contactId);
$session = CRM_Core_Session::singleton();
$activityParams = array();
$activityParams['source_contact_id'] = $session->get('userID');
$activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Add Client To Case', 'name');
$activityParams['activity_date_time'] = date('YmdHis');
$activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activityParams['case_id'] = $caseId;
$activityParams['is_auto'] = 0;
$activityParams['subject'] = 'Client Added To Case';
$activity = CRM_Activity_BAO_Activity::create($activityParams);
$caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
CRM_Utils_JSON::output(TRUE);
}
示例5: addVacancies
function addVacancies($cid)
{
//sample data for HRRecruitment table
$grpParams['name'] = 'vacancy_status';
$optionValues = $vacancyPermissionContactIds = array();
$caseStatuses = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND grouping = 'Vacancy'");
$vacancyStatuses = CRM_Core_OptionGroup::values('vacancy_status');
//Filterout Rejected and Cancelled status while creating vacancy
foreach (array('Cancelled', 'Rejected') as $status) {
$key = array_search($status, $vacancyStatuses);
unset($vacancyStatuses[$key]);
}
$totalcount = 6;
$setNewVacancy = FALSE;
$templatePosition = array();
$randomVacancies = $this->randomVacancy();
for ($i = 1; $i <= $totalcount; $i++) {
$jobCount = mt_rand(0, 2);
$position = $randomVacancies[$jobCount]['position'];
$vacanciesValues = array('salary' => $randomVacancies[$jobCount]['salary'], 'position' => $position, 'description' => $this->randomItem('vacancydescription'), 'benefits' => $randomVacancies[$jobCount]['benefits'], 'requirements' => $randomVacancies[$jobCount]['requirements'], 'location' => $this->randomItem('location'), 'is_template' => mt_rand(0, 1), 'status_id' => array_rand($vacancyStatuses, 1), 'start_date' => $this->randomDate('20130701', '20140101', 'YmdHis'), 'end_date' => $this->randomDate('20140102', '20151231', 'YmdHis'), 'created_id' => $cid, 'created_date' => $this->randomDate());
if ($vacanciesValues['is_template'] == 1) {
unset($vacanciesValues['status_id']);
if (array_key_exists($position, $templatePosition)) {
//always create distict template
continue;
}
$templatePosition[$position] = NULL;
} else {
$setNewVacancy = TRUE;
}
//ensure that atleast there is one vacancy not all template
if (!$setNewVacancy && $i == $totalcount) {
$totalcount++;
}
$hrVacancies[] = $this->insertVacancyData('CRM_HRRecruitment_DAO_HRVacancy', $vacanciesValues);
}
//There are 6 sample Vacancies created, next is to create Entities - VacancyStage, VacancyPermission, Cases
foreach ($hrVacancies as $key => $hrVacanciesObj) {
$selectedCaseStatuses = array();
$lastSelectedCaseStatus = NULL;
$randCaseStatus = $caseStatuses;
//Igonre Apply and Hired statuses while removing random status
$ignoreCaseStatus = array(array_search('Apply', $randCaseStatus), array_search('Hired', $randCaseStatus));
for ($i = 1; $i <= mt_rand(1, 6); $i++) {
$randomValue = array_rand($randCaseStatus, 1);
if (in_array($randomValue, $ignoreCaseStatus)) {
continue;
}
unset($randCaseStatus[$randomValue]);
}
$count = 1;
foreach ($randCaseStatus as $caseStatus => $dontCare) {
$vacancyStagesValues = array('case_status_id' => $caseStatus, 'vacancy_id' => $hrVacanciesObj->id, 'weight' => $count);
$count++;
$this->insertVacancyData('CRM_HRRecruitment_DAO_HRVacancyStage', $vacancyStagesValues);
}
//sample data for HRPermission table
$vacancyPermissionContactIds[$hrVacanciesObj->id][] = $hrVacanciesObj->created_id;
for ($i = 1; $i <= mt_rand(1, 4); $i++) {
$vacancyPermissionValues = array('contact_id' => $this->randomContact(), 'vacancy_id' => $hrVacanciesObj->id, 'permission' => $this->randomItem('permission'));
if ($vacancyPermissionValues['permission'] == 'manage Applicants' || $vacancyPermissionValues['permission'] == 'administer Vacancy') {
$vacancyPermissionContactIds[$hrVacanciesObj->id][] = $vacancyPermissionValues['contact_id'];
}
$this->insertVacancyData('CRM_HRRecruitment_DAO_HRVacancyPermission', $vacancyPermissionValues);
}
foreach (array('application_profile', 'evaluation_profile') as $profileName) {
$ufgID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileName, 'id', 'name');
$vacancyUFJoinValues = array('module' => 'Vacancy', 'entity_id' => $hrVacanciesObj->id, 'entity_table' => 'civicrm_hrvacancy', 'uf_group_id' => $ufgID, 'module_data' => $profileName);
$this->insertVacancyData('CRM_Core_DAO_UFJoin', $vacancyUFJoinValues);
$caseTypes = CRM_Case_PseudoConstant::caseType('name', 1, 'AND filter = 1');
if (!$hrVacanciesObj->is_template) {
for ($i = 1; $i <= mt_rand(1, 4); $i++) {
$applicantID = $this->randomContact();
$caseParams['case_type_id'] = CRM_Utils_Array::key('Application', $caseTypes);
$caseParams['start_date'] = $this->randomDate($hrVacanciesObj->start_date, $hrVacanciesObj->end_date);
$caseParams['status_id'] = array_rand($randCaseStatus, 1);
$caseObj = CRM_Case_BAO_Case::create($caseParams);
$contactParams = array('case_id' => $caseObj->id, 'contact_id' => $applicantID);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $applicantID, 'creatorID' => $cid, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $caseObj->id, 'activity_date_time' => $caseParams['start_date']);
$xmlProcessor->run('Application', $xmlProcessorParams);
$aTypes = $xmlProcessor->get('Application', 'ActivityTypes');
$aTypes = array_rand(array_flip($aTypes), mt_rand(2, 5));
foreach ($aTypes as $aType) {
if (in_array($aType, array('Open Case', 'Assign Case Role', 'Link Cases'))) {
continue;
}
$index = array_rand($vacancyPermissionContactIds[$hrVacanciesObj->id], 1);
$aParam = array('source_contact_id' => $vacancyPermissionContactIds[$hrVacanciesObj->id][$index], 'activity_date_time' => $this->randomDate($hrVacanciesObj->start_date, $hrVacanciesObj->end_date, 'YmdHis'), 'activity_type_id' => $aType, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
if ($aType == 'Change Case Status') {
$aParam['last_status'] = $caseStatuses[$caseObj->status_id];
$caseObj->status_id = array_rand($caseStatuses, 1);
$caseObj->save();
$aParam['new_status'] = $caseStatuses[$caseObj->status_id];
}
$this->addActivityParamByType($aType, $aParam);
$result = civicrm_api3('Activity', 'create', $aParam);
$caseActivityParams = array('case_id' => $caseObj->id, 'activity_id' => $result['id']);
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
//.........这里部分代码省略.........
示例6: endPostProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
static function endPostProcess(&$form, &$params)
{
if ($form->_context == 'caseActivity') {
return;
}
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
if (!$isMultiClient && !$form->_currentlyViewedContactId) {
CRM_Core_Error::fatal('Required parameter missing for OpenCase - end post processing');
}
if (!$form->_currentUserId || !$params['case_id'] || !$params['case_type']) {
CRM_Core_Error::fatal('Required parameter missing for OpenCase - end post processing');
}
// 1. create case-contact
if ($isMultiClient && $form->_context != 'case') {
$client = explode(',', $params['contact'][1]);
foreach ($client as $key => $cliId) {
if (empty($cliId)) {
CRM_Core_Error::fatal('contact_id cannot be empty');
}
$contactParams = array('case_id' => $params['case_id'], 'contact_id' => $cliId);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
} else {
$contactParams = array('case_id' => $params['case_id'], 'contact_id' => $form->_currentlyViewedContactId);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
$client = $form->_currentlyViewedContactId;
}
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $client, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $params['case_id'], 'subject' => $params['activity_subject'], 'location' => $params['location'], 'activity_date_time' => $params['start_date'], 'duration' => CRM_Utils_Array::value('duration', $params), 'medium_id' => $params['medium_id'], 'details' => $params['activity_details']);
if (array_key_exists('custom', $params) && is_array($params['custom'])) {
$xmlProcessorParams['custom'] = $params['custom'];
}
// Add parameters for attachments
$numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
for ($i = 1; $i <= $numAttachments; $i++) {
$attachName = "attachFile_{$i}";
if (isset($params[$attachName]) && !empty($params[$attachName])) {
$xmlProcessorParams[$attachName] = $params[$attachName];
}
}
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
// status msg
$params['statusMsg'] = ts('Case opened successfully.');
$buttonName = $form->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($buttonName == $form->getButtonName('upload', 'new')) {
if ($form->_context == 'standalone') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=add&context=case&cid={$form->_contactID}"));
}
}
}
示例7: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once 'CRM/Case/BAO/Case.php';
CRM_Case_BAO_Case::deleteCase($this->_id);
CRM_Core_Session::setStatus(ts("Selected Case has been deleted."));
return;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$params['contact_id'] = $this->_contactID;
$params['start_date'] = CRM_Utils_Date::format($params['start_date']);
$params['end_date'] = CRM_Utils_Date::format($params['end_date']);
$params['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['case_type_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR;
$config =& CRM_Core_Config::singleton();
if ($config->civiHRD) {
$params['casetag2_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['casetag2_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR;
$params['casetag3_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['casetag3_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR;
}
require_once 'CRM/Case/BAO/Case.php';
$case = CRM_Case_BAO_Case::create($params);
CRM_Case_BAO_Case::deleteCaseContact($case->id);
if (!empty($this->_contactIds) && is_array($this->_contactIds)) {
foreach ($this->_contactIds as $key => $id) {
if ($id) {
$contactParams = array('case_id' => $case->id, 'contact_id' => $id);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
}
} else {
$contactParams = array('case_id' => $case->id, 'contact_id' => $this->_contactID);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
foreach ($params['case_contact'] as $key => $id) {
if ($id) {
$contactParams = array('case_id' => $case->id, 'contact_id' => $id);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
}
}
// set status message
CRM_Core_Session::setStatus(ts('Case \'%1\' has been saved.', array(1 => $params['subject'])));
}
示例8: 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/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' => $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);
}
示例9: addClient
function addClient()
{
$caseId = CRM_Utils_Type::escape($_POST['caseID'], 'Integer');
$contactId = CRM_Utils_Type::escape($_POST['contactID'], 'Integer');
$params = array('case_id' => $caseId, 'contact_id' => $contactId);
$result = CRM_Case_BAO_Case::addCaseToContact($params);
$session = CRM_Core_Session::singleton();
$activityParams = array();
$activityParams['source_contact_id'] = $session->get('userID');
$activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Add Client To Case', 'name');
$activityParams['activity_date_time'] = date('YmdHis');
$activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activityParams['case_id'] = $caseId;
$activityParams['is_auto'] = 0;
$activityParams['subject'] = 'Client Added To Case';
$activity = CRM_Activity_BAO_Activity::create($activityParams);
$caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
echo json_encode(TRUE);
CRM_Utils_System::civiExit();
}
示例10: endPostProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function endPostProcess(&$form, &$params)
{
if ($form->_context == 'caseActivity') {
return;
}
if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$params['case_id'] || !$params['case_type']) {
CRM_Core_Error::fatal('Required parameter missing for OpenCase - end post processing');
}
// 1. create case-contact
$contactParams = array('case_id' => $params['case_id'], 'contact_id' => $form->_currentlyViewedContactId);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $params['case_id'], 'subject' => $params['activity_subject'], 'location' => $params['location'], 'activity_date_time' => $params['start_date'], 'duration' => $params['duration'], 'medium_id' => $params['medium_id'], 'details' => $params['activity_details']);
if (array_key_exists('custom', $params) && is_array($params['custom'])) {
$xmlProcessorParams['custom'] = $params['custom'];
}
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
// status msg
$params['statusMsg'] = ts('Case opened successfully.');
$buttonName = $this->controller->getButtonName();
$session =& CRM_Core_Session::singleton();
if ($buttonName == $this->getButtonName('upload', 'new')) {
if ($this->_context == 'standalone') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=add&context=case&cid={$form->_contactID}"));
}
}
}
示例11: postProcess
/**
* Function to process the form
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//Check the contact provided in Application form is existing or new
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($this->_profileID);
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, $profileContactType);
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
$applicantID = $this->_contactID;
if (count($ids) && !$applicantID) {
$applicantID = CRM_Utils_Array::value(0, $ids);
}
$applicantID = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray, $applicantID, NULL, $this->_profileID);
if ($applicantID) {
$params['start_date'] = date("YmdHis");
$dao = new CRM_HRRecruitment_DAO_HRVacancyStage();
$dao->vacancy_id = $this->_id;
$dao->find();
while ($dao->fetch()) {
$params['case_status_id'] = $dao->case_status_id;
break;
}
//Create case of type Application against creator applicant and assignee as Vacancy creator
$caseTypes = array_flip(CRM_Case_PseudoConstant::caseType('name', TRUE, 'AND filter = 1'));
$cases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($applicantID, FALSE, 'Application');
foreach ($cases as $case) {
$oldAppl = CRM_HRRecruitment_BAO_HRVacancy::getVacancyIDByCase($case);
if ($oldAppl == $this->_id) {
$params['id'] = $case;
break;
}
}
$params['case_type_id'] = $caseTypes['Application'];
$caseObj = CRM_Case_BAO_Case::create($params);
if (empty($params['id'])) {
$contactParams = array('case_id' => $caseObj->id, 'contact_id' => $applicantID);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $applicantID, 'creatorID' => $this->_creatorID, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $caseObj->id, 'activity_date_time' => $params['start_date']);
$xmlProcessor->run('Application', $xmlProcessorParams);
}
//process Custom data
CRM_Core_BAO_CustomValueTable::postprocess($params, CRM_Core_DAO::$_nullArray, 'civicrm_case', $caseObj->id, 'Case');
//Process case to vacancy one-to-one mapping in custom table 'application_case'
$cgID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'application_case', 'id', 'name');
$result = civicrm_api3('CustomField', 'get', array('custom_group_id' => $cgID, 'name' => 'vacancy_id'));
civicrm_api3('custom_value', 'create', array("custom_{$result['id']}" => $this->_id, 'entity_id' => $caseObj->id));
}
if ($this->controller->getButtonName('submit') == "_qf_Application_upload") {
CRM_Core_Session::setStatus(ts("Application has been successfully submitted."));
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/vacancy/publiclisting', 'reset=1'));
}
}