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


PHP CRM_Case_BAO_Case::create方法代码示例

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


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

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

示例2: testPipeline

 public function testPipeline()
 {
     $contact = $this->callAPISuccess('contact', 'create', array('first_name' => 'JohnHR', 'contact_type' => 'Individual', 'last_name' => 'Smith', 'email' => 'johnhrsmith@hrtest.com'));
     // create case
     $newParams = array('case_type_id' => $this->casetype_id, 'creator_id' => $contact['id'], 'status_id' => 1, 'subject' => 'Case for HR Unit Test', 'contact_id' => $contact['id'], 'version' => 3, 'label' => 'test', 'name' => 'test');
     // assign case to contact
     $caseBAO = CRM_Case_BAO_Case::create($newParams);
     $newParams['id'] = $caseBAO->id;
     $caseContact = new CRM_Case_DAO_CaseContact();
     $caseContact->case_id = $caseBAO->id;
     $caseContact->contact_id = $contact['id'];
     $caseContact->find(TRUE);
     $caseContact->save();
     // create activity
     $paramsActivity = array('source_contact_id' => $contact['id'], 'activity_type_id' => $this->opencase_activityId, 'subject' => 'Open Case', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 1, 'priority_id' => 2, 'duration' => 120, 'location' => 'Pensulvania', 'details' => 'A test activity', 'case_id' => $caseBAO->id, 'is_current_revision' => 1);
     $resultActivity = civicrm_api3('activity', 'create', $paramsActivity);
     $opencase_activityIds = $resultActivity['id'];
     $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivity['id']);
     $analyzer->case_id = $caseBAO->id;
     $caseStatus = $caseBAO->status_id;
     $activityStatus = $resultActivity['values'][$resultActivity['id']]['status_id'];
     $activityTypeId = $resultActivity['values'][$resultActivity['id']]['activity_type_id'];
     $this->assertEquals('1', $caseStatus);
     // Check case stauts id
     $activityCheck = $analyzer->getSingleActivity($activityTypeId);
     $this->assertEquals('1', $activityCheck[1]['status_id']);
     // Check activity stauts id
     $this->assertFalse($analyzer->hasActivity('Interview Prospect'));
     $this->assertFalse($analyzer->hasActivity('Background Check'));
     $paramsActivity = array('id' => $opencase_activityIds, 'source_contact_id' => $contact['id'], 'activity_type_id' => $this->opencase_activityId, 'subject' => 'Open Case', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, 'priority_id' => 2, 'duration' => 120, 'location' => 'Pensulvania', 'details' => 'A test activity', 'case_id' => $caseBAO->id, 'is_current_revision' => 1, 'original_id' => $opencase_activityIds);
     $resultActivity = civicrm_api3('activity', 'create', $paramsActivity);
     $paramsActivityGet = array('activity_type_id' => $this->activityIds['Interview Prospect'], 'version' => 3);
     $resultActivityGet = civicrm_api3('activity', 'get', $paramsActivityGet);
     $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivityGet['values'][$resultActivityGet['id']]['id']);
     $ActivityIP = $analyzer->getSingleActivity($this->activityIds['Interview Prospect']);
     $this->assertEquals('2', $resultActivity['values'][$resultActivity['id']]['status_id']);
     $this->assertEquals('1', $ActivityIP[1]['status_id']);
     $this->assertFalse($analyzer->hasActivity('Background Check'));
     // get second activity
     $params = array('activity_type_id' => $this->activityIds['Interview Prospect'], 'sequential' => 1, 'version' => 3);
     $result = civicrm_api3('activity', 'get', $params);
     $paramsActivity2 = array('id' => $result['id'], 'status_id' => 'Completed', 'version' => 3, 'case_id' => $caseBAO->id, 'activity_type_id' => $this->activityIds['Interview Prospect'], 'original_id' => $result['id']);
     $resultActivity2 = civicrm_api3('activity', 'create', $paramsActivity2);
     $paramsActivityGet1 = array('activity_type_id' => $this->activityIds['Background Check'], 'version' => 3);
     $resultActivityGet1 = civicrm_api3('activity', 'get', $paramsActivityGet1);
     $analyzer = new CRM_HRCaseUtils_Analyzer($caseBAO->id, $resultActivityGet1['values'][$resultActivityGet1['id']]['id']);
     $ActivityIP1 = $analyzer->getSingleActivity($this->activityIds['Background Check']);
     $this->assertEquals('2', $resultActivity2['values'][$resultActivity2['id']]['status_id']);
     $this->assertEquals('1', $ActivityIP1[1]['status_id']);
     // get second activity
     $params = array('activity_type_id' => $this->activityIds['Background Check'], 'sequential' => 1, 'version' => 3);
     $result = civicrm_api3('activity', 'get', $params);
     $paramsActivity3 = array('id' => $result['id'], 'status_id' => 'Completed', 'version' => 3, 'case_id' => $caseBAO->id, 'activity_type_id' => $this->activityIds['Background Check'], 'original_id' => $result['id']);
     $resultActivity3 = civicrm_api3('activity', 'create', $paramsActivity3);
     $this->assertEquals('2', $resultActivity3['values'][$resultActivity3['id']]['status_id']);
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:56,代码来源:HRCaseUtilsPipelineTest.php

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

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

示例5: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $tx = new CRM_Core_Transaction();
     // check if dedupe button, if so return.
     $buttonName = $this->controller->getButtonName();
     if (isset($this->_dedupeButtonName) && $buttonName == $this->_dedupeButtonName) {
         return;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $statusMsg = NULL;
         $caseDelete = CRM_Case_BAO_Case::deleteCase($this->_caseId, TRUE);
         if ($caseDelete) {
             $statusMsg = ts('The selected case has been moved to the Trash. You can view and / or restore deleted cases by checking the "Deleted Cases" option under Find Cases.<br />');
         }
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
         $statusMsg = NULL;
         $caseRestore = CRM_Case_BAO_Case::restoreCase($this->_caseId);
         if ($caseRestore) {
             $statusMsg = ts('The selected case has been restored.<br />');
         }
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $params['now'] = date("Ymd");
     // 1. call begin post process
     if ($this->_activityTypeFile) {
         eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::beginPostProcess( \$this, \$params );");
     }
     if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
         $customFields = array();
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, NULL, 'Case');
     }
     // 2. create/edit case
     if (CRM_Utils_Array::value('case_type_id', $params)) {
         $caseType = CRM_Case_PseudoConstant::caseType('name');
         $params['case_type'] = $caseType[$params['case_type_id']];
         $params['subject'] = $params['activity_subject'];
         $params['case_type_id'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['case_type_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
     }
     $caseObj = CRM_Case_BAO_Case::create($params);
     $params['case_id'] = $caseObj->id;
     // unset any ids, custom data
     unset($params['id'], $params['custom']);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         $tagParams = array();
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_case', $caseObj->id);
     //save free tags
     if (isset($params['case_taglist']) && !empty($params['case_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['case_taglist'], $caseObj->id, 'civicrm_case', $this);
     }
     // user context
     $url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseObj->id}");
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
     // 3. format activity custom data
     if (CRM_Utils_Array::value('hidden_custom', $params)) {
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
     }
     // 4. call end post process
     if ($this->_activityTypeFile) {
         eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::endPostProcess( \$this, \$params );");
     }
     // 5. auto populate activites
     // 6. set status
     CRM_Core_Session::setStatus("{$params['statusMsg']}");
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:86,代码来源:Case.php

示例6: postProcess


//.........这里部分代码省略.........
             }
         }
         // build custom data getFields array
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_activityId, 'Activity');
     }
     // assigning formatted value
     if (!empty($params['assignee_contact_id'])) {
         $params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
     } else {
         $params['assignee_contact_id'] = array();
     }
     if (isset($this->_activityId)) {
         // activity which hasn't been modified by a user yet
         if ($this->_defaults['is_auto'] == 1) {
             $params['is_auto'] = 0;
         }
         // always create a revision of an case activity. CRM-4533
         $newActParams = $params;
         // add target contact values in update mode
         if (empty($params['target_contact_id']) && !empty($this->_defaults['target_contact'])) {
             $newActParams['target_contact_id'] = $this->_defaults['target_contact'];
         }
     }
     if (!isset($newActParams)) {
         // add more attachments if needed for old activity
         CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($params);
         foreach ($this->_caseId as $key => $val) {
             $params['case_id'] = $val;
             // activity create/update
             $activity = CRM_Activity_BAO_Activity::create($params);
             $vvalue[] = array('case_id' => $val, 'actId' => $activity->id);
             // call end post process, after the activity has been created/updated.
             $this->endPostProcess($params, $activity);
         }
     } else {
         // since the params we need to set are very few, and we don't want rest of the
         // work done by bao create method , lets use dao object to make the changes
         $params = array('id' => $this->_activityId);
         $params['is_current_revision'] = 0;
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->save();
     }
     // create a new version of activity if activity was found to
     // have been modified/created by user
     if (isset($newActParams)) {
         // set proper original_id
         if (!empty($this->_defaults['original_id'])) {
             $newActParams['original_id'] = $this->_defaults['original_id'];
         } else {
             $newActParams['original_id'] = $activity->id;
         }
         //is_current_revision will be set to 1 by default.
         // add attachments if any
         CRM_Core_BAO_File::formatAttachment($newActParams, $newActParams, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($newActParams);
         foreach ($this->_caseId as $key => $val) {
             $newActParams['case_id'] = $val;
             $activity = CRM_Activity_BAO_Activity::create($newActParams);
             $vvalue[] = array('case_id' => $val, 'actId' => $activity->id);
             // call end post process, after the activity has been created/updated.
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:67,代码来源:Activity.php

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

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

示例9: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // check if dedupe button, if so return.
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_dedupeButtonName) {
         return;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $statusMsg = null;
         require_once 'CRM/Case/BAO/Case.php';
         $caseDelete = CRM_Case_BAO_Case::deleteCase($this->_caseId, true);
         if ($caseDelete) {
             $statusMsg = ts('The selected case has been moved to the Trash. You can view and / or restore deleted cases by checking the "Deleted Cases" option under Find Cases.<br />');
         }
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
         $statusMsg = null;
         require_once 'CRM/Case/BAO/Case.php';
         $caseRestore = CRM_Case_BAO_Case::restoreCase($this->_caseId);
         if ($caseRestore) {
             $statusMsg = ts('The selected case has been restored.<br />');
         }
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     $params['now'] = date("Ymd");
     require_once 'CRM/Case/XMLProcessor/Process.php';
     // 1. call begin post process
     if ($this->_activityTypeFile) {
         eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::beginPostProcess( \$this, \$params );");
     }
     // 2. create/edit case
     require_once 'CRM/Case/BAO/Case.php';
     if (CRM_Utils_Array::value('case_type_id', $params)) {
         $caseType = CRM_Core_OptionGroup::values('case_type', false, false, false, null, 'name');
         $params['case_type'] = $caseType[$params['case_type_id']];
         $params['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . $params['case_type_id'] . CRM_Case_BAO_Case::VALUE_SEPERATOR;
     }
     $caseObj = CRM_Case_BAO_Case::create($params);
     $params['case_id'] = $caseObj->id;
     // unset any ids, custom data
     unset($params['id'], $params['custom']);
     // user context
     $url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseObj->id}");
     $session =& CRM_Core_Session::singleton();
     $session->pushUserContext($url);
     // 3. format activity custom data
     if (CRM_Utils_Array::value('hidden_custom', $params)) {
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
     }
     // 4. call end post process
     if ($this->_activityTypeFile) {
         eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::endPostProcess( \$this, \$params );");
     }
     // 5. auto populate activites
     // 6. set status
     CRM_Core_Session::setStatus("{$params['statusMsg']}");
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:70,代码来源:Case.php

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

示例11: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $statusMsg = null;
         //block deleting activities which affects
         //case attributes.CRM-4543
         $activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')";
         $caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', false, false, false, $activityCondition);
         if (!array_key_exists($this->_activityTypeId, $caseAttributeActivities)) {
             $params = array('id' => $this->_activityId);
             $activityDelete = CRM_Activity_BAO_Activity::deleteActivity($params, true);
             if ($activityDelete) {
                 $statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).<br />');
             }
         } else {
             $statusMsg = ts("Selected Activity cannot be deleted.");
         }
         require_once 'CRM/Core/BAO/EntityTag.php';
         $tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
         CRM_Core_BAO_EntityTag::del($tagParams);
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
         $statusMsg = null;
         $params = array('id' => $this->_activityId);
         $activityRestore = CRM_Activity_BAO_Activity::restoreActivity($params);
         if ($activityRestore) {
             $statusMsg = ts('The selected activity has been restored.<br />');
         }
         CRM_Core_Session::setStatus($statusMsg);
         return;
     }
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if ($params['source_contact_id']) {
         $params['source_contact_id'] = $params['source_contact_qid'];
     }
     //set parent id if its edit mode
     if ($parentId = CRM_Utils_Array::value('parent_id', $this->_defaults)) {
         $params['parent_id'] = $parentId;
     }
     // required for status msg
     $recordStatus = 'created';
     // store the dates with proper format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     $params['activity_type_id'] = $this->_activityTypeId;
     require_once 'CRM/Case/XMLProcessor/Process.php';
     $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
     $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
     $this->assign('multiClient', $isMultiClient);
     $targetContacts = array($this->_currentlyViewedContactId);
     if (CRM_Utils_Array::value('hidden_target_contact', $params) && CRM_Utils_Array::value('target_contact_id', $params)) {
         $targetContacts = array_unique(explode(',', $params['target_contact_id']));
     }
     $params['target_contact_id'] = $targetContacts;
     // format activity custom data
     if (CRM_Utils_Array::value('hidden_custom', $params)) {
         if ($this->_activityId) {
             // unset custom fields-id from params since we want custom
             // fields to be saved for new activity.
             foreach ($params as $key => $value) {
                 $match = array();
                 if (preg_match('/^(custom_\\d+_)(\\d+)$/', $key, $match)) {
                     $params[$match[1] . '-1'] = $params[$key];
                     // for autocomplete transfer hidden value instead of label
                     if ($params[$key] && isset($params[$key . '_id'])) {
                         $params[$match[1] . '-1_id'] = $params[$key . '_id'];
                         unset($params[$key . '_id']);
                     }
                     unset($params[$key]);
                 }
             }
         }
         // build custom data getFields array
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
     }
     if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
         $assineeContacts = explode(',', $params['assignee_contact_id']);
         $assineeContacts = array_unique($assineeContacts);
         unset($params['assignee_contact_id']);
     } else {
         $params['assignee_contact_id'] = $assineeContacts = array();
     }
     if (isset($this->_activityId)) {
         // activity which hasn't been modified by a user yet
         if ($this->_defaults['is_auto'] == 1) {
             $params['is_auto'] = 0;
         }
         // always create a revision of an case activity. CRM-4533
         $newActParams = $params;
         // add target contact values in update mode
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Activity.php


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