当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Case_XMLProcessor_Process::run方法代码示例

本文整理汇总了PHP中CRM_Case_XMLProcessor_Process::run方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_XMLProcessor_Process::run方法的具体用法?PHP CRM_Case_XMLProcessor_Process::run怎么用?PHP CRM_Case_XMLProcessor_Process::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Case_XMLProcessor_Process的用法示例。


在下文中一共展示了CRM_Case_XMLProcessor_Process::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
//.........这里部分代码省略.........
开发者ID:JoeMurray,项目名称:civihr,代码行数:101,代码来源:GenerateHRData.php

示例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);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:58,代码来源:Case.php

示例3: 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']);
     }
     $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');
     }
     // 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'));
     $newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']));
     $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);
     // 3.status msg
     $params['statusMsg'] = ts('Case Start Date changed successfully.');
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:33,代码来源:ChangeCaseStartDate.php

示例4: endPostProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 static function endPostProcess(&$form, &$params, $activity)
 {
     if (!$form->_caseId) {
         // always expecting a change, so case-id is a must.
         return;
     }
     $caseTypes = CRM_Case_PseudoConstant::caseType('name');
     $allCaseTypes = CRM_Case_PseudoConstant::caseType('label', FALSE);
     if (CRM_Utils_Array::value($params['case_type_id'], $caseTypes)) {
         $caseType = $caseTypes[$params['case_type_id']];
     }
     if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$params['case_type_id'] || !$caseType) {
         CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
     }
     $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'];
     if ($activity->subject == 'null') {
         $activity->subject = ts('Case type changed from %1 to %2', array(1 => CRM_Utils_Array::value($form->_defaults['case_type_id'], $allCaseTypes), 2 => CRM_Utils_Array::value($params['case_type_id'], $allCaseTypes)));
         $activity->save();
     }
     // 1. initiate xml processor
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, 'activityTypeName' => 'Change Case Type', 'activity_date_time' => CRM_Utils_Array::value('reset_date_time', $params), 'caseID' => $form->_caseId, 'resetTimeline' => CRM_Utils_Array::value('is_reset_timeline', $params));
     $xmlProcessor->run($caseType, $xmlProcessorParams);
     // status msg
     $params['statusMsg'] = ts('Case Type changed successfully.');
 }
开发者ID:hguru,项目名称:224Civi,代码行数:36,代码来源:ChangeCaseType.php

示例5: endPostProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function endPostProcess(&$form, &$params)
 {
     if (!$form->_caseId) {
         // always expecting a change, so case-id is a must.
         return;
     }
     $caseTypes = CRM_Case_PseudoConstant::caseType('name');
     if (CRM_Utils_Array::value($params['case_type_id'], $caseTypes)) {
         $caseType = $caseTypes[$params['case_type_id']];
     }
     if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$params['case_type_id'] || !$caseType) {
         CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
     }
     // 1. initiate xml processor
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, 'activityTypeName' => 'Change Case Type', 'activity_date_time' => CRM_Utils_Array::value('reset_date_time', $params), 'caseID' => $form->_caseId, 'resetTimeline' => CRM_Utils_Array::value('is_reset_timeline', $params));
     $xmlProcessor->run($caseType, $xmlProcessorParams);
     // status msg
     $params['statusMsg'] = ts('Case Type changed successfully.');
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:26,代码来源:ChangeCaseType.php

示例6: 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

示例7: 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

示例8: 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}"));
         }
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:62,代码来源:OpenCase.php

示例9: 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

示例10: array

<?php

require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/Error.php';
$config = CRM_Core_Config::singleton();
require_once 'CRM/Case/XMLProcessor/Report.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Report();
$report = $xmlProcessor->getActivityInfo(102, 552);
CRM_Core_Error::debug($report);
exit;
$xmlProcessor->run(104, 1, 'Substance Abuse', '15 Day Review');
$params = array('clientID' => 104, 'creatorID' => 108, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'dueDateTime' => time(), 'caseID' => 1);
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$result = $xmlProcessor->get('Substance Abuse', 'CaseRoles');
CRM_Core_Error::debug('Case Roles', $result);
$result = $xmlProcessor->get('Substance Abuse', 'ActivityTypes');
CRM_Core_Error::debug('Activity Types', $result);
$result = $xmlProcessor->get('Substance Abuse', 'ActivitySets');
CRM_Core_Error::debug('Activity Sets', $result);
$xmlProcessor->run('Substance Abuse', $params);
exit;
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:23,代码来源:testProcess.php

示例11: 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);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:75,代码来源:Case.php

示例12: 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}"));
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:36,代码来源:OpenCase.php

示例13: 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

示例14: 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'));
     }
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:59,代码来源:Application.php

示例15: 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


注:本文中的CRM_Case_XMLProcessor_Process::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。