Example #1
0
 /**
  * CRM_Casereports_Import constructor.
  */
 function __construct()
 {
     $config = CRM_Casereports_Config::singleton();
     $this->_acceptActivityTypeId = $config->getMaAcceptActivityTypeId();
     $this->_rejectActivityTypeId = $config->getMaRejectActivityTypeId();
     $this->_briefingActivityTypeId = $config->getBriefingActivityTypeId();
     $customGroup = $config->getMaAcceptCustomGroup();
     $this->_acceptTableName = $customGroup['table_name'];
     foreach ($customGroup['custom_fields'] as $customFieldId => $customField) {
         if ($customField['name'] == 'Assessment_SC') {
             $this->_scColumn = $customField['column_name'];
         }
         if ($customField['name'] == 'Assessment_CC') {
             $this->_ccColumn = $customField['column_name'];
         }
     }
     $this->_assessRepActivityTypeId = $config->getAssessRepActivityTypeId();
     $this->_assessSCActivityTypeId = $config->getAssessSCActivityTypeId();
     $this->_assessCCActivityTypeId = $config->getAssessCCActivityTypeId();
     $this->_assessAnamonActivityTypeId = $config->getAssessAnamonActivityTypeId();
     $this->_assessRepCustomTable = $config->getAssessRepCustomTable();
     $this->_assessSCCustomTable = $config->getAssessSCCustomTable();
     $this->_assessCCCustomTable = $config->getAssessCCCustomTable();
     $this->_assessAnamonCustomTable = $config->getAssessAnamonCustomTable();
     $this->_assessRepCustomColumn = $config->getAssessRepCustomColumn();
     $this->_assessSCCustomColumn = $config->getAssessSCCustomColumn();
     $this->_assessCCCustomColumn = $config->getAssessCCCustomColumn();
     $this->_assessAnamonCustomColumn = $config->getAssessAnamonCustomColumn();
     $this->_anaRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Anamon', 'return' => 'id'));
     $this->_ccRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Country Coordinator is', 'return' => 'id'));
     $this->_scRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Sector Coordinator', 'return' => 'id'));
     $this->_poRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Project Officer for', 'return' => 'id'));
 }
Example #2
0
 /**
  * Method to set columns when activity is deleted
  *
  * @param $activityId
  * @param $caseId
  * @access private
  * @static
  */
 private static function processDelete($activityId, $caseId)
 {
     try {
         $activity = civicrm_api3('Activity', 'Getsingle', array('id' => $activityId));
         $config = CRM_Casereports_Config::singleton();
         switch ($activity['activity_type_id']) {
             case $config->getMaAcceptActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET ma_expert_approval = %1, pq_approved_cc = NULL,\n          pq_approved_sc = NULL WHERE case_id = %2";
                 CRM_Core_DAO::executeQuery($update, array(1 => array('n/a', 'String'), 2 => array($caseId, 'Integer')));
                 break;
             case $config->getBriefingActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET briefing_status = NULL, briefing_date = NULL WHERE case_id = %1";
                 CRM_Core_DAO::executeQuery($update, array(1 => array($caseId, 'Integer')));
                 break;
             case $config->getAssessRepActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET assess_rep_date = NULL , assess_rep_customer = NULL WHERE case_id = %1";
                 CRM_Core_DAO::executeQuery($update, array(1 => array($caseId, 'Integer')));
                 break;
             case $config->getAssessCCActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET assess_cc_date = NULL, assess_cc_customer = NULL WHERE case_id = %1";
                 CRM_Core_DAO::executeQuery($update, array(1 => array($caseId, 'Integer')));
                 break;
             case $config->getAssessSCActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET assess_sc_date = NULL, assess_sc_customer = NULL WHERE case_id = %1";
                 CRM_Core_DAO::executeQuery($update, array(1 => array($caseId, 'Integer')));
                 break;
             case $config->getAssessAnamonActivityTypeId():
                 $update = "UPDATE civicrm_pum_case_reports SET assess_anamon_date = NULL, assess_anamon_customer = NULL WHERE case_id = %1";
                 CRM_Core_DAO::executeQuery($update, array(1 => array($caseId, 'Integer')));
                 break;
         }
     } catch (CiviCRM_API3_Exception $ex) {
     }
 }
Example #3
0
 /**
  * Function to return singleton object
  *
  * @return object $_singleton
  * @access public
  * @static
  */
 public static function &singleton()
 {
     if (self::$_singleton === NULL) {
         self::$_singleton = new CRM_Casereports_Config();
     }
     return self::$_singleton;
 }
Example #4
0
 /**
  * Upgrade 1001 change column ma_expert_approval for n/a value
  *
  * @return bool
  */
 public function upgrade_1001()
 {
     $this->ctx->log->info('Applying update 1001 alter table ma_expert_approval in civicrm_pum_case_reports');
     $config = CRM_Casereports_Config::singleton();
     if (CRM_Core_DAO::checkTableExists('civicrm_pum_case_reports')) {
         CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_pum_case_reports CHANGE COLUMN ma_expert_approval
     ma_expert_approval VARCHAR(15) NULL DEFAULT NULL');
         // set values 'n/a'
         $naQuery = 'UPDATE civicrm_pum_case_reports SET ma_expert_approval = %1 WHERE case_id NOT IN(
     SELECT DISTINCT(case_id) FROM civicrm_case_activity cact JOIN civicrm_activity act ON cact.activity_id = act.id
     WHERE activity_type_id IN(%2, %3) AND is_current_revision = %4)';
         $naParams = array(1 => array('n/a', 'String'), 2 => array($config->getMaAcceptActivityTypeId(), 'Integer'), 3 => array($config->getMaRejectActivityTypeId(), 'Integer'), 4 => array(1, 'Integer'));
         CRM_Core_DAO::executeQuery($naQuery, $naParams);
         // now set all remaining 1's to yes and 0's to no
         $yesQuery = 'UPDATE civicrm_pum_case_reports SET ma_expert_approval = %1 WHERE ma_expert_approval = %2';
         $yesParams = array(1 => array('Yes', 'String'), 2 => array('1', 'String'));
         CRM_Core_DAO::executeQuery($yesQuery, $yesParams);
         $noQuery = 'UPDATE civicrm_pum_case_reports SET ma_expert_approval = %1 WHERE ma_expert_approval = %2';
         $noParams = array(1 => array('No', 'String'), 2 => array('0', 'String'));
         CRM_Core_DAO::executeQuery($noQuery, $noParams);
     }
     return true;
 }