Example #1
0
 /**
  * Migratie voor issue 3498
  * 
  * @param $caseId
  */
 public function setCaseRelations($caseId)
 {
     $query = 'SELECT contact_id_b FROM civicrm_relationship WHERE case_id = %1 AND relationship_type_id = %2 
   AND is_active = %3 LIMIT 1';
     $params[1] = array($caseId, 'Integer');
     $params[2] = array($this->_anaRelTypeId, 'Integer');
     $params[3] = array(1, 'Integer');
     $index = 1;
     $clauses = array();
     $clauseParams = array();
     $clauseParams[1] = array($caseId, 'Integer');
     $anamonId = CRM_Core_DAO::singleValueQuery($query, $params);
     if (!empty($anamonId)) {
         $index++;
         $clauses[] = "anamon_id = %" . $index;
         $clauseParams[$index] = array($anamonId, 'Integer');
     }
     $params[2] = array($this->_ccRelTypeId, 'Integer');
     $countryCoordinatorId = CRM_Core_DAO::singleValueQuery($query, $params);
     if (!empty($countryCoordinatorId)) {
         $index++;
         $clauses[] = "country_coordinator_id = %" . $index;
         $clauseParams[$index] = array($countryCoordinatorId, 'Integer');
     }
     $params[2] = array($this->_scRelTypeId, 'Integer');
     $sectorCoordinatorId = CRM_Core_DAO::singleValueQuery($query, $params);
     if (!empty($sectorCoordinatorId)) {
         $index++;
         $clauses[] = "sector_coordinator_id = %" . $index;
         $clauseParams[$index] = array($sectorCoordinatorId, 'Integer');
     }
     $params[2] = array($this->_poRelTypeId, 'Integer');
     $projectOfficerId = CRM_Core_DAO::singleValueQuery($query, $params);
     if (!empty($projectOfficerId)) {
         $index++;
         $clauses[] = "project_officer_id = %" . $index;
         $clauseParams[$index] = array($projectOfficerId, 'Integer');
     }
     if (CRM_Casereports_Activity::caseExists($caseId)) {
         if (!empty($clauses)) {
             $update = "UPDATE civicrm_pum_case_reports SET " . implode(', ', $clauses) . " WHERE case_id = %1";
             CRM_Core_DAO::executeQuery($update, $clauseParams);
         }
     } else {
         if (!empty($clauses)) {
             $insert = "INSERT INTO civicrm_pum_case_reports SET case_id = %1, " . implode(', ', $clauses);
             CRM_Core_DAO::executeQuery($insert, $clauseParams);
         } else {
             $insert = "INSERT INTO civicrm_pum_case_reports SET case_id = %1";
             CRM_Core_DAO::executeQuery($insert, $clauseParams);
         }
     }
 }
Example #2
0
/**
 * Implements hook civicrm_custom()
 * Process custom groups
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_custom
 */
function casereports_civicrm_custom($op, $groupId, $entityId, &$params)
{
    CRM_Casereports_Activity::custom($op, $groupId, $entityId, $params);
}