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


PHP CRM_Case_BAO_Case::getCaseRoles方法代码示例

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


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

示例1: relationship

 static function relationship(&$config)
 {
     // CRM_Core_Error::debug_var( 'GET' , $_GET , true, true );
     // CRM_Core_Error::debug_var( 'POST', $_POST, true, true );
     $relType = CRM_Utils_Array::value('rel_type', $_POST);
     $relContactID = CRM_Utils_Array::value('rel_contact', $_POST);
     $sourceContactID = CRM_Utils_Array::value('contact_id', $_POST);
     $relationshipID = CRM_Utils_Array::value('rel_id', $_POST);
     $caseID = CRM_Utils_Array::value('case_id', $_POST);
     $relationParams = array('relationship_type_id' => $relType . '_a_b', 'contact_check' => array($relContactID => 1), 'is_active' => 1, 'case_id' => $caseID, 'start_date' => date("Ymd"));
     if ($relationshipID == 'null') {
         $relationIds = array('contact' => $sourceContactID);
     } else {
         $relationIds = array('contact' => $sourceContactID, 'relationship' => $relationshipID, 'contactTarget' => $relContactID);
     }
     require_once "CRM/Contact/BAO/Relationship.php";
     $return = CRM_Contact_BAO_Relationship::create($relationParams, $relationIds);
     $relationshipID = $return[4][0];
     // we should return phone and email
     require_once "CRM/Case/BAO/Case.php";
     $caseRelationship = CRM_Case_BAO_Case::getCaseRoles($sourceContactID, $caseID, $relationshipID);
     //create an activity for case role assignment.CRM-4480
     CRM_Case_BAO_Case::createCaseRoleActivity($caseID, $relationshipID, $relContactID);
     $relation = $caseRelationship[$relationshipID];
     $relation['rel_id'] = $relationshipID;
     echo json_encode($relation);
     exit;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:28,代码来源:AJAX.php

示例2: getCaseRoles

 public static function getCaseRoles()
 {
     $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
     $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
     $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
     foreach ($caseRelationships as $key => $value) {
         // This role has been filled
         unset($caseRoles[$value['relation_type']]);
         // mark original case relationships record to use on setting edit links below
         $caseRelationships[$key]['source'] = 'caseRel';
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     // move/transform caseRoles array data to caseRelationships
     // for sorting and display
     // CRM-14466 added cid to the non-client array to avoid php notice
     foreach ($caseRoles as $id => $value) {
         if ($id != "client") {
             $rel = array();
             $rel['relation'] = $value;
             $rel['relation_type'] = $id;
             $rel['name'] = '(not assigned)';
             $rel['phone'] = '';
             $rel['email'] = '';
             $rel['source'] = 'caseRoles';
             $caseRelationships[] = $rel;
         } else {
             foreach ($value as $clientRole) {
                 $relClient = array();
                 $relClient['relation'] = 'Client';
                 $relClient['name'] = $clientRole['sort_name'];
                 $relClient['phone'] = $clientRole['phone'];
                 $relClient['email'] = $clientRole['email'];
                 $relClient['cid'] = $clientRole['contact_id'];
                 $relClient['source'] = 'contact';
                 $caseRelationships[] = $relClient;
             }
         }
     }
     // sort clientRelationships array using jquery call params
     foreach ($caseRelationships as $key => $row) {
         $sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
     }
     $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
     array_multisort($sortArray, constant($sort_type), $caseRelationships);
     $relationships = array();
     // set user name, email and edit columns links
     foreach ($caseRelationships as $key => &$row) {
         $typeLabel = $row['relation'];
         // Add "<br />(Case Manager)" to label
         if ($row['relation_type'] == $managerRoleId) {
             $row['relation'] .= '<br />' . '(' . ts('Case Manager') . ')';
         }
         // view user links
         if (!empty($row['cid'])) {
             $row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
         }
         // email column links/icon
         if ($row['email']) {
             $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope"></i></a>';
         }
         // edit links
         $row['actions'] = '';
         if ($hasAccessToAllCases) {
             $contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
             $contactType = $contactType == 'Contact' ? '' : $contactType;
             switch ($row['source']) {
                 case 'caseRel':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
                     break;
                 case 'caseRoles':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_b_a" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>';
                     break;
             }
         }
         unset($row['cid']);
         unset($row['relation_type']);
         unset($row['rel_id']);
         unset($row['client_id']);
         unset($row['source']);
         array_push($relationships, $row);
     }
     $params['total'] = count($relationships);
     $caseRelationshipsDT = array();
     $caseRelationshipsDT['data'] = $relationships;
     $caseRelationshipsDT['recordsTotal'] = $params['total'];
     $caseRelationshipsDT['recordsFiltered'] = $params['total'];
     CRM_Utils_JSON::output($caseRelationshipsDT);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:94,代码来源:AJAX.php

示例3: printCaseReport

 function printCaseReport()
 {
     $caseID = CRM_Utils_Request::retrieve('caseID', 'Positive', CRM_Core_DAO::$_nullObject);
     $clientID = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject);
     $activitySetName = CRM_Utils_Request::retrieve('asn', 'String', CRM_Core_DAO::$_nullObject);
     $isRedact = CRM_Utils_Request::retrieve('redact', 'Boolean', CRM_Core_DAO::$_nullObject);
     $includeActivities = CRM_Utils_Request::retrieve('all', 'Positive', CRM_Core_DAO::$_nullObject);
     $params = $otherRelationships = $globalGroupInfo = array();
     $report = new CRM_Case_XMLProcessor_Report($isRedact);
     if ($includeActivities) {
         $params['include_activities'] = 1;
     }
     if ($isRedact) {
         $params['is_redact'] = 1;
         $report->_redactionStringRules = array();
     }
     $template = CRM_Core_Smarty::singleton();
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($clientID, $caseID);
     $caseType = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseType, 'CaseRoles');
     foreach ($caseRelationships as $key => &$value) {
         if (!empty($caseRoles[$value['relation_type']])) {
             unset($caseRoles[$value['relation_type']]);
         }
         if ($isRedact) {
             if (!array_key_exists($value['name'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['name'] => 'name_' . rand(10000, 100000)));
             }
             $value['name'] = self::redact($value['name'], TRUE, $report->_redactionStringRules);
             if (!empty($value['email']) && !array_key_exists($value['email'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['email'] => 'email_' . rand(10000, 100000)));
             }
             $value['email'] = self::redact($value['email'], TRUE, $report->_redactionStringRules);
             if (!empty($value['phone']) && !array_key_exists($value['phone'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['phone'] => 'phone_' . rand(10000, 100000)));
             }
             $value['phone'] = self::redact($value['phone'], TRUE, $report->_redactionStringRules);
         }
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     if ($isRedact) {
         if (!array_key_exists($caseRoles['client']['sort_name'], $report->_redactionStringRules)) {
             $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['sort_name'] => 'name_' . rand(10000, 100000)));
         }
         if (!array_key_exists($caseRoles['client']['display_name'], $report->_redactionStringRules)) {
             $report->_redactionStringRules[$caseRoles['client']['display_name']] = $report->_redactionStringRules[$caseRoles['client']['sort_name']];
         }
         $caseRoles['client']['sort_name'] = self::redact($caseRoles['client']['sort_name'], TRUE, $report->_redactionStringRules);
         if (!empty($caseRoles['client']['email']) && !array_key_exists($caseRoles['client']['email'], $report->_redactionStringRules)) {
             $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['email'] => 'email_' . rand(10000, 100000)));
         }
         $caseRoles['client']['email'] = self::redact($caseRoles['client']['email'], TRUE, $report->_redactionStringRules);
         if (!empty($caseRoles['client']['phone']) && !array_key_exists($caseRoles['client']['phone'], $report->_redactionStringRules)) {
             $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['phone'] => 'phone_' . rand(10000, 100000)));
         }
         $caseRoles['client']['phone'] = self::redact($caseRoles['client']['phone'], TRUE, $report->_redactionStringRules);
     }
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($clientID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE);
     foreach ($relClient as $r) {
         if ($isRedact) {
             if (!array_key_exists($r['name'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['name'] => 'name_' . rand(10000, 100000)));
             }
             if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['name']];
             }
             $r['name'] = self::redact($r['name'], TRUE, $report->_redactionStringRules);
             if (!empty($r['phone']) && !array_key_exists($r['phone'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['phone'] => 'phone_' . rand(10000, 100000)));
             }
             $r['phone'] = self::redact($r['phone'], TRUE, $report->_redactionStringRules);
             if (!empty($r['email']) && !array_key_exists($r['email'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['email'] => 'email_' . rand(10000, 100000)));
             }
             $r['email'] = self::redact($r['email'], TRUE, $report->_redactionStringRules);
         }
         if (!array_key_exists($r['id'], $caseRelationships)) {
             $otherRelationships[] = $r;
         }
     }
     // Now global contact list that appears on all cases.
     $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
     foreach ($relGlobal as &$r) {
         if ($isRedact) {
             if (!array_key_exists($r['sort_name'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['sort_name'] => 'name_' . rand(10000, 100000)));
             }
             if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['sort_name']];
             }
             $r['sort_name'] = self::redact($r['sort_name'], TRUE, $report->_redactionStringRules);
             if (!empty($r['phone']) && !array_key_exists($r['phone'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['phone'] => 'phone_' . rand(10000, 100000)));
             }
             $r['phone'] = self::redact($r['phone'], TRUE, $report->_redactionStringRules);
             if (!empty($r['email']) && !array_key_exists($r['email'], $report->_redactionStringRules)) {
                 $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['email'] => 'email_' . rand(10000, 100000)));
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Report.php

示例4: endPostProcess

 /**
  * Process the form submission.
  *
  *
  * @param CRM_Core_Form $form
  * @param array $params
  * @param CRM_Activity_BAO_Activity $activity
  */
 public static function endPostProcess(&$form, &$params, $activity)
 {
     $groupingValues = CRM_Core_OptionGroup::values('case_status', FALSE, TRUE, FALSE, NULL, 'value');
     // Set case end_date if we're closing the case. Clear end_date if we're (re)opening it.
     if (CRM_Utils_Array::value($params['case_status_id'], $groupingValues) == 'Closed' && !empty($params['activity_date_time'])) {
         $params['end_date'] = $params['activity_date_time'];
         // End case-specific relationships (roles)
         foreach ($params['target_contact_id'] as $cid) {
             $rels = CRM_Case_BAO_Case::getCaseRoles($cid, $params['case_id']);
             // FIXME: Is there an existing function to close a relationship?
             $query = 'UPDATE civicrm_relationship SET end_date=%2 WHERE id=%1';
             foreach ($rels as $relId => $relData) {
                 $relParams = array(1 => array($relId, 'Integer'), 2 => array($params['end_date'], 'Timestamp'));
                 CRM_Core_DAO::executeQuery($query, $relParams);
             }
         }
     } elseif (CRM_Utils_Array::value($params['case_status_id'], $groupingValues) == 'Opened') {
         $params['end_date'] = "null";
         // Reopen case-specific relationships (roles)
         foreach ($params['target_contact_id'] as $cid) {
             $rels = CRM_Case_BAO_Case::getCaseRoles($cid, $params['case_id']);
             // FIXME: Is there an existing function?
             $query = 'UPDATE civicrm_relationship SET end_date=NULL WHERE id=%1';
             foreach ($rels as $relId => $relData) {
                 $relParams = array(1 => array($relId, 'Integer'));
                 CRM_Core_DAO::executeQuery($query, $relParams);
             }
         }
     }
     $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'];
     foreach ($form->_oldCaseStatus as $statuskey => $statusval) {
         if ($activity->subject == 'null') {
             $activity->subject = ts('Case status changed from %1 to %2', array(1 => CRM_Utils_Array::value($statusval, $form->_caseStatus), 2 => CRM_Utils_Array::value($params['case_status_id'], $form->_caseStatus)));
             $activity->save();
         }
     }
     // FIXME: does this do anything ?
     $params['statusMsg'] = ts('Case Status changed successfully.');
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:50,代码来源:ChangeCaseStatus.php

示例5: relationship

 static function relationship()
 {
     $relType = CRM_Utils_Array::value('rel_type', $_POST);
     $relContactID = CRM_Utils_Array::value('rel_contact', $_POST);
     $sourceContactID = CRM_Utils_Array::value('contact_id', $_POST);
     $relationshipID = CRM_Utils_Array::value('rel_id', $_POST);
     $caseID = CRM_Utils_Array::value('case_id', $_POST);
     $relationParams = array('relationship_type_id' => $relType . '_a_b', 'contact_check' => array($relContactID => 1), 'is_active' => 1, 'case_id' => $caseID, 'start_date' => date("Ymd"));
     $relationIds = array('contact' => $sourceContactID);
     if ($relationshipID && $relationshipID != 'null') {
         $relationIds['relationship'] = $relationshipID;
         $relationIds['contactTarget'] = $relContactID;
     }
     $return = CRM_Contact_BAO_Relationship::create($relationParams, $relationIds);
     $status = 'process-relationship-fail';
     if (CRM_Utils_Array::value(0, $return[4])) {
         $relationshipID = $return[4][0];
         $status = 'process-relationship-success';
     }
     $caseRelationship = array();
     if ($relationshipID && $relationshipID != 'null') {
         // we should return phone and email
         $caseRelationship = CRM_Case_BAO_Case::getCaseRoles($sourceContactID, $caseID, $relationshipID);
         //create an activity for case role assignment.CRM-4480
         CRM_Case_BAO_Case::createCaseRoleActivity($caseID, $relationshipID, $relContactID);
     }
     $relation = CRM_Utils_Array::value($relationshipID, $caseRelationship, array());
     $relation['rel_id'] = $relationshipID;
     $relation['status'] = $status;
     echo json_encode($relation);
     CRM_Utils_System::civiExit();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:32,代码来源:AJAX.php

示例6: activityForm

 /**
  * Build the activity selector/datatable
  * @param CRM_Core_Form $form
  */
 static function activityForm($form)
 {
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($form->_contactID, $form->_caseID);
     //build reporter select
     $reporters = array("" => ts(' - any reporter - '));
     foreach ($caseRelationships as $key => &$value) {
         $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
     }
     $form->add('select', 'reporter_id', ts('Reporter/Role'), $reporters, FALSE, array('id' => 'reporter_id_' . $form->_caseID));
     // take all case activity types for search filter, CRM-7187
     $aTypesFilter = array();
     $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType();
     foreach ($allCaseActTypes as $typeDetails) {
         if (!in_array($typeDetails['name'], array('Open Case'))) {
             $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
         }
     }
     asort($aTypesFilter);
     $form->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter, FALSE, array('id' => 'activity_type_filter_id_' . $form->_caseID));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     $form->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus, FALSE, array('id' => 'status_id_' . $form->_caseID));
     // activity dates
     $form->addDate('activity_date_low_' . $form->_caseID, ts('Activity Dates - From'), FALSE, array('formatType' => 'searchDate'));
     $form->addDate('activity_date_high_' . $form->_caseID, ts('To'), FALSE, array('formatType' => 'searchDate'));
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $form->add('checkbox', 'activity_deleted', ts('Deleted Activities'), '', FALSE, array('id' => 'activity_deleted_' . $form->_caseID));
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:32,代码来源:CaseView.php

示例7: getCaseRoles

 public static function getCaseRoles()
 {
     $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $sortMapper = array(0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions');
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $params = $_POST;
     if ($sort && $sortOrder) {
         $sortSQL = $sort . ' ' . $sortOrder;
     }
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
     $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
     $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     foreach ($caseRelationships as $key => $value) {
         //calculate roles that don't have relationships
         if (!empty($caseRoles[$value['relation_type']])) {
             //keep naming from careRoles array
             $caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
             unset($caseRoles[$value['relation_type']]);
         }
         // mark orginal case relationships record to use on setting edit links below
         $caseRelationships[$key]['source'] = 'caseRel';
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     // move/transform caseRoles array data to caseRelationships
     // for sorting and display
     // CRM-14466 added cid to the non-client array to avoid php notice
     foreach ($caseRoles as $id => $value) {
         if ($id != "client") {
             $rel = array();
             $rel['relation'] = $value;
             $rel['relation_type'] = $id;
             $rel['name'] = '(not assigned)';
             $rel['phone'] = '';
             $rel['email'] = '';
             $rel['source'] = 'caseRoles';
             $caseRelationships[] = $rel;
         } else {
             foreach ($value as $clientRole) {
                 $relClient = array();
                 $relClient['relation'] = 'Client';
                 $relClient['name'] = $clientRole['sort_name'];
                 $relClient['phone'] = $clientRole['phone'];
                 $relClient['email'] = $clientRole['email'];
                 $relClient['cid'] = $clientRole['contact_id'];
                 $relClient['source'] = 'contact';
                 $caseRelationships[] = $relClient;
             }
         }
     }
     // sort clientRelationships array using jquery call params
     foreach ($caseRelationships as $key => $row) {
         $sortArray[$key] = $row[$sort];
     }
     $sort_type = "SORT_" . strtoupper($sortOrder);
     array_multisort($sortArray, constant($sort_type), $caseRelationships);
     //limit rows display
     $allCaseRelationships = $caseRelationships;
     $caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
     // set user name, email and edit columns links
     // idx will count number of current row / needed by edit links
     $idx = 1;
     foreach ($caseRelationships as &$row) {
         // Get rid of the "<br />(Case Manager)" from label
         list($typeLabel) = explode('<', $row['relation']);
         // view user links
         if (!empty($row['cid'])) {
             $row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
         }
         // email column links/icon
         if ($row['email']) {
             $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><span class="icon ui-icon-mail-closed"></span></a>';
         }
         // edit links
         $row['actions'] = '';
         if ($hasAccessToAllCases) {
             $contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
             $contactType = $contactType == 'Contact' ? '' : $contactType;
             switch ($row['source']) {
                 case 'caseRel':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
                     break;
                 case 'caseRoles':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>';
                     break;
             }
         }
         $idx++;
     }
     $iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:AJAX.php

示例8: getCaseRoles

 static function getCaseRoles()
 {
     $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $sortMapper = array(0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions');
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $params = $_POST;
     if ($sort && $sortOrder) {
         $sortSQL = $sort . ' ' . $sortOrder;
     }
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
     $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
     $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     foreach ($caseRelationships as $key => $value) {
         //calculate roles that don't have relationships
         if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
             //keep naming from careRoles array
             $caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
             unset($caseRoles[$value['relation_type']]);
         }
         // mark orginal case relationships record to use on setting edit links below
         $caseRelationships[$key]['source'] = 'caseRel';
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     // move/transform caseRoles array data to caseRelationships
     // for sorting and display
     foreach ($caseRoles as $id => $value) {
         if ($id != "client") {
             $rel = array();
             $rel['relation'] = $value;
             $rel['relation_type'] = $id;
             $rel['name'] = '(not assigned)';
             $rel['phone'] = '';
             $rel['email'] = '';
             $rel['source'] = 'caseRoles';
             $caseRelationships[] = $rel;
         } else {
             foreach ($value as $clientRole) {
                 $relClient = array();
                 $relClient['relation'] = 'Client';
                 $relClient['name'] = $clientRole['sort_name'];
                 $relClient['phone'] = $clientRole['phone'];
                 $relClient['email'] = $clientRole['email'];
                 $relClient['cid'] = $clientRole['contact_id'];
                 $relClient['source'] = 'contact';
                 $caseRelationships[] = $relClient;
             }
         }
     }
     // sort clientRelationships array using jquery call params
     foreach ($caseRelationships as $key => $row) {
         $sortArray[$key] = $row[$sort];
     }
     $sort_type = "SORT_" . strtoupper($sortOrder);
     array_multisort($sortArray, constant($sort_type), $caseRelationships);
     //limit rows display
     $allCaseRelationships = $caseRelationships;
     $caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
     // set user name, email and edit columns links
     // idx will count number of current row / needed by edit links
     $idx = 1;
     foreach ($caseRelationships as $key => $row) {
         // view user links
         if ($caseRelationships[$key]['cid']) {
             $caseRelationships[$key]['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $caseRelationships[$key]['cid']) . '>' . $caseRelationships[$key]['name'] . '</a>';
         }
         // email column links/icon
         if ($caseRelationships[$key]['email']) {
             $caseRelationships[$key]['email'] = '<a href="' . CRM_Utils_System::url('civicrm/contact/view/activity', 'action=reset=1&action=add&atype=3&cid=' . $caseRelationships[$key]['cid']) . '&caseid=' . $caseID . '" title="compose and send an email"><div class="icon email-icon" title="compose and send an email"></div>
          </a>';
         }
         // edit links
         if ($hasAccessToAllCases) {
             switch ($caseRelationships[$key]['source']) {
                 case 'caseRel':
                     $caseRelationships[$key]['actions'] = '<a href="#" title="edit case role" onclick="createRelationship( ' . $caseRelationships[$key]['relation_type'] . ', ' . $caseRelationships[$key]['cid'] . ', ' . $caseRelationships[$key]['rel_id'] . ', ' . $idx . ', \'' . $caseRelationships[$key]['relation'] . '\' );return false;"><div class="icon edit-icon" ></div></a>&nbsp;&nbsp;<a href="#" class="case-role-delete" case_id="' . $caseID . '" rel_type="' . $caseRelationships[$key]['relation_type'] . '"><div class="icon delete-icon" title="remove contact from case role"></div></a>';
                     break;
                 case 'caseRoles':
                     $caseRelationships[$key]['actions'] = '<a href="#" title="edit case role" onclick="createRelationship(' . $caseRelationships[$key]['relation_type'] . ', null, null, ' . $idx . ',  \'' . $caseRelationships[$key]['relation'] . '\');return false;"><div class="icon edit-icon"></div></a>';
                     break;
             }
         } else {
             $caseRelationships[$key]['actions'] = '';
         }
         $idx++;
     }
     $iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
     $selectorElements = array('relation', 'name', 'phone', 'email', 'actions');
     echo CRM_Utils_JSON::encodeDataTableSelector($caseRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:AJAX.php

示例9: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     //this call is for show related cases.
     if ($this->_showRelatedCases) {
         return;
     }
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
     $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
     //adding case manager.CRM-4510.
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', true);
     require_once 'CRM/Core/PseudoConstant.php';
     $allActTypes = CRM_Core_PseudoConstant::activityType(true, true, false, 'name');
     // remove Open Case activity type since we're inside an existing case
     if (($openActTypeId = array_search('Open Case', $allActTypes)) && array_key_exists($openActTypeId, $aTypes)) {
         unset($aTypes[$openActTypeId]);
     }
     //check for link cases.
     $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(null, array($this->_caseID));
     if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes)) && array_key_exists($linkActTypeId, $aTypes)) {
         unset($aTypes[$linkActTypeId]);
     }
     asort($aTypes);
     $this->add('select', 'activity_type_id', ts('New Activity'), array('' => ts('- select activity type -')) + $aTypes);
     if ($this->_hasAccessToAllCases) {
         $this->add('select', 'report_id', ts('Run QA Audit / Redact'), array('' => ts('- select activity set -')) + $reports);
         $this->add('select', 'timeline_id', ts('Add Timeline'), array('' => ts('- select activity set -')) + $reports);
     }
     $this->addElement('submit', $this->getButtonName('next'), ts('Go'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
     if ($this->_mergeCases) {
         $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID);
         $otherCases = array();
         foreach ($allCases as $caseId => $details) {
             //filter current and own cases.
             if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) {
                 continue;
             }
             $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date'];
         }
         if (empty($otherCases)) {
             $this->_mergeCases = false;
             $this->assign('mergeCases', $this->_mergeCases);
         } else {
             $this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases);
             $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
         }
     }
     $this->add('text', 'change_client_id', ts('Assign to another Client'));
     $this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
     $this->addElement('submit', $this->getButtonName('next', 'edit_client'), ts('Reassign Case'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     $this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus);
     // activity dates
     $this->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate'));
     $this->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate'));
     require_once "CRM/Core/Permission.php";
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
     }
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
     //build reporter select
     $reporters = array("" => ts(' - any reporter - '));
     foreach ($caseRelationships as $key => &$value) {
         $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
         if ($managerRoleId == $value['relation_type']) {
             $value['relation'] = $caseRoles[$managerRoleId];
         }
         //calculate roles that don't have relationships
         if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
             unset($caseRoles[$value['relation_type']]);
         }
     }
     // take all case activity types for search filter, CRM-7187
     $aTypesFilter = array();
     $allCaseActTypes = CRM_Case_PseudoConstant::activityType();
     foreach ($allCaseActTypes as $typeDetails) {
         if (!in_array($typeDetails['name'], array('Open Case'))) {
             $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
         }
     }
     asort($aTypesFilter);
     $this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
     $this->assign('caseRelationships', $caseRelationships);
     //also add client as role. CRM-4438
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID);
     $this->assign('caseRoles', $caseRoles);
     $this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, null, null, false);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:CaseView.php

示例10: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
     $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
     //adding case manager.CRM-4510.
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', true);
     // remove Open Case activity type since we're inside an existing case
     $openCaseID = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
     unset($aTypes[$openCaseID]);
     asort($aTypes);
     $this->add('select', 'activity_type_id', ts('New Activity'), array('' => ts('- select activity type -')) + $aTypes);
     $this->add('select', 'report_id', ts('Run QA Audit / Redact'), array('' => ts('- select activity set -')) + $reports);
     $this->add('select', 'timeline_id', ts('Add Timeline'), array('' => ts('- select activity set -')) + $reports);
     $this->addElement('submit', $this->getButtonName('next'), ts('Go'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     $this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus);
     // activity dates
     $this->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate'));
     $this->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate'));
     require_once "CRM/Core/Permission.php";
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
     }
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
     //build reporter select
     $reporters = array("" => ts(' - any reporter - '));
     foreach ($caseRelationships as $key => &$value) {
         $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
         if ($managerRoleId == $value['relation_type']) {
             $value['relation'] = $caseRoles[$managerRoleId];
         }
         //calculate roles that don't have relationships
         if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
             unset($caseRoles[$value['relation_type']]);
         }
     }
     // activity type filter for case activity search, need to add Email Sent activity type
     $emailSentID = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
     $aTypesFilter = array($emailSentID => 'Email') + $aTypes;
     asort($aTypesFilter);
     $this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
     $this->assign('caseRelationships', $caseRelationships);
     //also add client as role. CRM-4438
     $caseRoles['client'] = CRM_Case_BAO_Case::getcontactNames($this->_caseID);
     $this->assign('caseRoles', $caseRoles);
     $this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, null, null, false);
     // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
     // so they don't show up twice.
     $clientRelationships = array();
     foreach ($relClient as $r) {
         if (!array_key_exists($r['id'], $caseRelationships)) {
             $clientRelationships[] = $r;
         }
     }
     $this->assign('clientRelationships', $clientRelationships);
     // Now global contact list that appears on all cases.
     $globalGroupInfo = array();
     $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
     $this->assign('globalRelationships', $relGlobal);
     $this->assign('globalGroupInfo', $globalGroupInfo);
     // List of relationship types
     require_once 'CRM/Contact/BAO/Relationship.php';
     $baoRel =& new CRM_Contact_BAO_Relationship();
     $relType = $baoRel->getRelationType('Individual');
     $roleTypes = array();
     foreach ($relType as $k => $v) {
         $roleTypes[substr($k, 0, strpos($k, '_'))] = $v;
     }
     $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes);
     $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true)));
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:85,代码来源:CaseView.php


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