public function upgrade_1400() { $this->ctx->log->info('Applying update 1400'); $i = 3; foreach (array('Joining', 'Probation') as $caseName) { CRM_Core_DAO::executeQuery("UPDATE civicrm_case_type SET weight = {$i} WHERE name = '{$caseName}'"); $i++; } CRM_Core_DAO::executeQuery("UPDATE civicrm_case_type SET weight = 6 WHERE name = 'Exiting'"); $this->executeSqlFile('sql/activities_install.sql'); require_once 'hrcase.php'; $scheduleActions = hrcase_getActionsSchedule(); foreach ($scheduleActions as $actionName => $scheduleAction) { $result = civicrm_api3('action_schedule', 'get', array('name' => $actionName)); if (empty($result['id'])) { $result = civicrm_api3('action_schedule', 'create', $scheduleAction); } } $existingCaseType = array('Appraisal'); $this->manageCaseTypes($existingCaseType); CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); //update query to replace Case with Assignment $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name'); $sql = "UPDATE civicrm_option_value SET label= replace(label,'Case','Assignment') WHERE label like '%Case%' and option_group_id={$optionGroupID} and label <> 'Open Case'"; CRM_Core_DAO::executeQuery($sql); $sql = "UPDATE civicrm_option_value SET label= replace(label,'Open Case','Created New Assignment') WHERE label like '%Case%' and option_group_id={$optionGroupID}"; CRM_Core_DAO::executeQuery($sql); return TRUE; }
function _hrcase_setActiveFields($setActive) { //disable/enable all custom group and fields $sql = "UPDATE civicrm_custom_field JOIN civicrm_custom_group\nON civicrm_custom_group.id = civicrm_custom_field.custom_group_id\nSET civicrm_custom_field.is_active = {$setActive}\nWHERE civicrm_custom_group.name IN ('Joining_Data', 'Exiting_Data')"; CRM_Core_DAO::executeQuery($sql); CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET is_active = {$setActive} WHERE name IN ('Joining_Data', 'Exiting_Data')"); //disable/enable activity type $query = "UPDATE civicrm_option_value\nSET is_active = {$setActive}\nWHERE name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date', 'Assign Case Role', 'Remove Case Role', 'Merge Case', 'Reassigned Case', 'Link Cases', 'Change Case Tags', 'Add Client To Case','Issue appointment letter','Fill Employee Details Form','Submission of ID/Residence proofs and photos','Program and work induction by program supervisor','Enter employee data in CiviHR','Group Orientation to organization values policies','Probation appraisal','Conduct appraisal','Collection of appraisal paperwork','Issue confirmation/warning letter','Get \"No Dues\" certification','Conduct Exit interview','Revoke access to databases','Block work email ID','Follow up on progress','Collection of Appraisal forms','Issue extension letter','Schedule joining date','Group Orientation to organization, values, policies','Probation appraisal (start probation workflow)','Schedule Exit Interview','Prepare formats','Print formats','Collate and print goals','References Check','Prepare and email schedule')"; CRM_Core_DAO::executeQuery($query); //disable/enable action schedule $scheduleActions = hrcase_getActionsSchedule(TRUE); $scheduleAction = implode("','", $scheduleActions); $query = "UPDATE civicrm_action_schedule SET is_active = {$setActive} WHERE name IN ('{$scheduleAction}')"; CRM_Core_DAO::executeQuery($query); $sqlrel = "UPDATE `civicrm_relationship_type` SET is_active={$setActive} WHERE name_b_a IN ('HR Manager','Line Manager')"; CRM_Core_DAO::executeQuery($sqlrel); $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrrecruitment', 'is_active', 'full_name'); if (!$isEnabled) { CRM_Core_DAO::executeQuery("UPDATE `civicrm_relationship_type` SET is_active={$setActive} WHERE name_b_a IN ('Recruiting Manager')"); } }