Beispiel #1
0
/**
 * Implementation of hook_civicrm_install
 */
function hrprofile_civicrm_install()
{
    $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
    $profileId = array_search('hrstaffdir_listing', $groups);
    $path = array('url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($profileId && $navigationPath) {
        $originalUrl = "civicrm/profile?reset=1&gid={$profileId}&force=1";
        $updatedUrl = "civicrm/profile/table?reset=1&gid={$profileId}&force=1";
        hrprofile_updateNavigation($originalUrl, $updatedUrl);
    } elseif ($profileId && !$navigationPath) {
        // add to navigation
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile/table?reset=1&gid={$profileId}&force=1", 'is_active' => 1);
        $navigation = CRM_Core_BAO_Navigation::add($navigationParams);
        CRM_Core_BAO_Navigation::resetNavigation();
        // set the profile as search view
        $params = array();
        CRM_Core_BAO_ConfigSetting::retrieve($params);
        if (!empty($params)) {
            $params['defaultSearchProfileID'] = $profileId;
            CRM_Core_BAO_ConfigSetting::create($params);
        }
    }
    return _hrprofile_civix_civicrm_install();
}
 /**
  * Test that a navigation item can be retrieved by it's url.
  */
 public function testGetNavItemByUrl()
 {
     $random_string = substr(sha1(rand()), 0, 7);
     $name = "Test Menu Link {$random_string}";
     $url = "civicrm/test/{$random_string}";
     $url_params = "reset=1";
     $params = array('name' => $name, 'label' => ts($name), 'url' => "{$url}?{$url_params}", 'parent_id' => NULL, 'is_active' => TRUE, 'permission' => array('access CiviCRM'));
     CRM_Core_BAO_Navigation::add($params);
     $new_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $url_params);
     $this->assertObjectHasAttribute('id', $new_nav);
     $this->assertNotNull($new_nav->id);
     $new_nav->delete();
 }
function mailchimpsync_civicrm_navigationMenu(&$params)
{
    // get the id of Administer Menu
    $administerMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Navigation', 'Administer', 'id', 'name');
    CRM_Core_Error::debug_var('$administerMenuId', $administerMenuId);
    // skip adding menu if there is no administer menu
    if ($administerMenuId) {
        // get the maximum key under adminster menu
        $maxKey = max(array_keys($params[$administerMenuId]['child']));
        $params[$administerMenuId]['child'][$maxKey + 1] = array('attributes' => array('label' => 'MailChimp Settings', 'name' => 'MailChimp Settings', 'url' => 'civicrm/mailchimp/apikeyregister', 'permission' => 'administer CiviCRM', 'operator' => NULL, 'separator' => TRUE, 'parentID' => $administerMenuId, 'navID' => $maxKey + 1, 'active' => 1));
        CRM_Core_BAO_Navigation::add($params);
    }
}
/**
 * Implementation of hook_civicrm_install
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function maxadditionalparticipants_civicrm_install()
{
    $parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
    $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'CiviReport', 'weight', 'name');
    if ($parentId) {
        $maxparticipantMenuTree = array(array('label' => ts('Max Participant'), 'name' => 'Participant_Settings', 'url' => 'civicrm/participant/config?reset=1'));
        foreach ($maxparticipantMenuTree as $key => $menuItems) {
            $menuItems['is_active'] = 1;
            $menuItems['parent_id'] = $parentId;
            $menuItems['weight'] = ++$weight;
            $menuItems['permission'] = 'administer CiviCRM';
            CRM_Core_BAO_Navigation::add($menuItems);
        }
        CRM_Core_BAO_Navigation::resetNavigation();
    }
    return _maxadditionalparticipants_civix_civicrm_install();
}
Beispiel #5
0
/**
 * Implementation of hook_civicrm_install
 */
function hrrecruitment_civicrm_install()
{
    $activityTypesResult = civicrm_api3('activity_type', 'get', array());
    $weight = count($activityTypesResult["values"]);
    foreach (array('Evaluation', 'Comment') as $activityType) {
        if (!in_array($activityType, $activityTypesResult["values"])) {
            civicrm_api3('activity_type', 'create', array('weight' => $weight++, 'name' => $activityType, 'label' => $activityType, 'is_active' => 1));
        }
    }
    $result = civicrm_api3('OptionGroup', 'create', array('name' => 'vacancy_status', 'title' => ts('Vacancy Status'), 'is_reserved' => 1, 'is_active' => 1));
    $vacancyStatus = array('Draft' => ts('Draft'), 'Open' => ts('Open'), 'Closed' => ts('Closed'), 'Cancelled' => ts('Cancelled'), 'Rejected' => ts('Rejected'));
    $weight = 1;
    foreach ($vacancyStatus as $name => $label) {
        $statusParam = array('option_group_id' => $result['id'], 'label' => $label, 'name' => $name, 'value' => $weight++, 'is_active' => 1);
        if ($name == 'Draft') {
            $statusParam['is_default'] = 1;
        } elseif ($name == 'Open') {
            $statusParam['is_reserved'] = 1;
        }
        civicrm_api3('OptionValue', 'create', $statusParam);
    }
    $stages = array('Apply' => ts('Apply'), 'Ongoing_Vacancy' => ts('Ongoing'), 'Phone_Interview' => ts('Phone Interview'), 'Manager_Interview' => ts('Manager Interview'), 'Board_Interview' => ts('Board Interview'), 'Group_Interview' => ts('Group Interview'), 'Psych_Exam' => ts('Psych Exam'), 'Offer' => ts('Offer'), 'Hired' => ts('Hired'));
    $count = count(CRM_Core_OptionGroup::values('case_status'));
    foreach ($stages as $name => $label) {
        $count++;
        $caseStatusParam = array('option_group_id' => 'case_status', 'label' => $label, 'name' => $name, 'value' => $count, 'grouping' => 'Vacancy', 'filter' => 1);
        civicrm_api3('OptionValue', 'create', $caseStatusParam);
    }
    $reportWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'weight', 'name');
    $vacancyNavigation = new CRM_Core_DAO_Navigation();
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Vacancies'), 'name' => 'Vacancies', 'url' => null, 'operator' => null, 'weight' => $reportWeight - 1, 'is_active' => 1);
    $vacancyNavigation->copyValues($params);
    $vacancyNavigation->save();
    $evalID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation');
    $vacancyMenuTree = array(array('label' => ts('Dashboard'), 'name' => 'dashboard', 'url' => 'civicrm/vacancy/dashboard?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Public Vacancy List'), 'name' => 'public_list', 'url' => 'civicrm/vacancy/publiclisting?reset=1', 'permission' => NULL, 'has_separator' => 1), array('label' => ts('New Vacancy'), 'name' => 'new_vacancy', 'url' => 'civicrm/vacancy/add?reset=1', 'permission' => 'administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('New Template'), 'name' => 'new_template', 'url' => 'civicrm/vacancy/add?reset=1&template=1', 'permission' => 'administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('New Applicant'), 'name' => 'new_applicant', 'has_separator' => 1), array('label' => ts('Find Vacancies'), 'name' => 'find_vacancies', 'url' => 'civicrm/vacancy/find?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Find Templates'), 'name' => 'find_templates', 'url' => 'civicrm/vacancy/find?reset=1&template=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Search by Application Form Fields'), 'name' => 'find_application', 'url' => 'civicrm/case/search?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Search by Evaluation Criteria'), 'name' => 'find_evaluation', 'url' => "civicrm/activity/search?force=1&type={$evalID}&reset=1", 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'));
    foreach ($vacancyMenuTree as $key => $menuItems) {
        $menuItems['is_active'] = 1;
        $menuItems['parent_id'] = $vacancyNavigation->id;
        $menuItems['weight'] = $key;
        CRM_Core_BAO_Navigation::add($menuItems);
    }
    CRM_Core_BAO_Navigation::resetNavigation();
    return _hrrecruitment_civix_civicrm_install();
}
Beispiel #6
0
/**
 * Implementation of hook_civicrm_install
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function hrjobcontract_civicrm_install()
{
    $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id');
    $org_id = array_search('Organization', $cType);
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true);
    $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $params['parent_id'] = $org_id;
    $params['is_active'] = 1;
    if ($org_id) {
        foreach ($sub_type_name as $sub_type_name) {
            $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
            $subID = array_key_exists($subTypeName, $orgSubType);
            if (!$subID) {
                $params['name'] = $subTypeName;
                $params['label'] = $sub_type_name;
                CRM_Contact_BAO_ContactType::add($params);
            } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) {
                CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1);
            }
        }
    }
    // Add Job Contract top menu
    $jobContractNavigation = new CRM_Core_DAO_Navigation();
    $jobContractNavigation->name = 'job_contracts';
    $jobContractNavigationResult = $jobContractNavigation->find();
    if (!$jobContractNavigationResult) {
        $contactsWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'weight', 'name');
        $jobContractNavigation = new CRM_Core_DAO_Navigation();
        $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Job Contracts'), 'name' => 'job_contracts', 'url' => null, 'operator' => null, 'weight' => $contactsWeight + 1, 'is_active' => 1);
        $jobContractNavigation->copyValues($params);
        $jobContractNavigation->save();
        $jobContractMenuTree = array(array('label' => ts('Import / Export'), 'name' => 'import_export_job_contracts'));
        foreach ($jobContractMenuTree as $key => $menuItems) {
            $menuItems['is_active'] = 1;
            $menuItems['parent_id'] = $jobContractNavigation->id;
            $menuItems['weight'] = $key;
            CRM_Core_BAO_Navigation::add($menuItems);
        }
    }
    return _hrjobcontract_civix_civicrm_install();
}
/**
 * Implementation of hook_civicrm_install
 */
function simpledonate_civicrm_install()
{
    //Add menu for donation page link under Contribution parent navigation
    //And Configuration link under Admin navigation
    $civiContributeParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'CiviContribute', 'id', 'name');
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate Configuration', 'name' => 'Simple Donate Configuration', 'url' => 'civicrm/simple/donation/configuration?reset=1', 'permission' => 'access CiviContribute', 'parent_id' => $civiContributeParentId, 'has_separator' => 1, 'is_active' => 1);
    CRM_Core_BAO_Navigation::add($params);
    $contributionsParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contributions', 'id', 'name');
    $donationNavigation = new CRM_Core_DAO_Navigation();
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate', 'name' => 'Simple Donate', 'url' => NULL, 'permission' => 'access CiviContribute', 'parent_id' => $contributionsParentId, 'has_separator' => 1, 'is_active' => 1, 'weight' => 100);
    $donationNavigation->copyValues($params);
    $donationNavigation->save();
    $donationMenuTree = array(array('label' => ts('Test mode'), 'name' => 'Test Donation', 'url' => 'civicrm/simple?test=1#/donation', 'permission' => 'access CiviContribute'), array('label' => ts('Live mode'), 'name' => 'Live Donation', 'url' => 'civicrm/simple/#/donation', 'permission' => 'access CiviContribute'));
    foreach ($donationMenuTree as $key => $menuItems) {
        $menuItems['is_active'] = 1;
        $menuItems['parent_id'] = $donationNavigation->id;
        $menuItems['weight'] = $key;
        CRM_Core_BAO_Navigation::add($menuItems);
    }
    return _simpledonate_civix_civicrm_install();
}
Beispiel #8
0
/**
 * Implementation of hook_civicrm_install
 */
function hrreport_civicrm_install()
{
    $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrabsence', 'is_active', 'full_name');
    $absenceReport = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'absenceReport', 'id', 'name');
    if ($isEnabled && !$absenceReport) {
        $reportParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
        $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absenceReport', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $reportParentId, 'is_active' => 1);
        CRM_Core_BAO_Navigation::add($params);
        $absenceParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Absences', 'id', 'name');
        $calendarId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'calendar', 'id', 'name');
        if (empty($calendarId)) {
            $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Calendar', 'name' => 'calendar', 'url' => null, 'permission' => 'access HRReport', 'parent_id' => $absenceParentId, 'is_active' => 1, 'weight' => 2);
            CRM_Core_BAO_Navigation::add($params);
        }
        $absenceReportId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'absence_report', 'id', 'name');
        if (empty($absenceReportId)) {
            $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absence_report', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $absenceParentId, 'is_active' => 1, 'weight' => 7);
            CRM_Core_BAO_Navigation::add($params);
        }
    }
    return _hrreport_civix_civicrm_install();
}
Beispiel #9
0
/**
 * Implementation of hook_civicrm_install
 */
function hrjob_civicrm_install()
{
    $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id');
    $org_id = array_search('Organization', $cType);
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true);
    $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $params['parent_id'] = $org_id;
    $params['is_active'] = 1;
    if ($org_id) {
        foreach ($sub_type_name as $sub_type_name) {
            $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
            $subID = array_key_exists($subTypeName, $orgSubType);
            if (!$subID) {
                $params['name'] = $subTypeName;
                $params['label'] = $sub_type_name;
                CRM_Contact_BAO_ContactType::add($params);
            } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) {
                CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1);
            }
        }
    }
    //Add job import navigation menu
    $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Import Contacts', 'weight', 'name');
    $contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name');
    $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name');
    $importJobNavigation = new CRM_Core_DAO_Navigation();
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Import Jobs'), 'name' => 'jobImport', 'url' => null, 'parent_id' => $contactNavId, 'weight' => $weight + 1, 'permission' => 'access HRJobs', 'separator' => 1, 'is_active' => 1);
    $importJobNavigation->copyValues($params);
    $importJobNavigation->save();
    $importJobMenuTree = array(array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId));
    foreach ($importJobMenuTree as $key => $menuItems) {
        $menuItems['is_active'] = 1;
        CRM_Core_BAO_Navigation::add($menuItems);
    }
    CRM_Core_BAO_Navigation::resetNavigation();
    return _hrjob_civix_civicrm_install();
}
Beispiel #10
0
 /**
  * Install Appraisals top navigation
  * 
  * @return boolean
  */
 public function upgrade_0007()
 {
     // Add Appraisals to the Top Navigation menu
     CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name = 'appraisals' and parent_id IS NULL");
     $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'weight', 'name');
     //$contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name');
     $appraisalsNavigation = new CRM_Core_DAO_Navigation();
     $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Appraisals'), 'name' => 'appraisals', 'url' => null, 'parent_id' => null, 'weight' => $weight + 1, 'separator' => 1, 'is_active' => 1);
     $appraisalsNavigation->copyValues($params);
     $appraisalsNavigation->save();
     if ($appraisalsNavigation->id) {
         $submenu = array(array('label' => ts('Appraisals Dashboard'), 'name' => 'appraisals_dashboard', 'url' => 'civicrm/appraisals/dashboard'), array('label' => ts('Search Appraisals'), 'name' => 'search_appraisals', 'url' => 'civicrm/appraisals/search'), array('label' => ts('Import Appraisals'), 'name' => 'import_appraisals', 'url' => 'civicrm/appraisals/import'));
         foreach ($submenu as $key => $item) {
             $item['parent_id'] = $appraisalsNavigation->id;
             $item['weight'] = $key;
             $item['is_active'] = 1;
             CRM_Core_BAO_Navigation::add($item);
         }
     }
     $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
     $aministerAppraisalMenu = array('label' => ts('Appraisal grade labels'), 'name' => 'appraisal_grade_labels', 'url' => 'civicrm/appraisal_criteria', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId, 'is_active' => 1);
     CRM_Core_BAO_Navigation::add($aministerAppraisalMenu);
     CRM_Core_BAO_Navigation::resetNavigation();
     return TRUE;
 }
 /**
  * Add or update Contact SubTypes.
  *
  * @param array $params
  *   An assoc array of name/value pairs.
  *
  * @return object|void
  */
 public static function add(&$params)
 {
     // label or name
     if (empty($params['id']) && empty($params['label'])) {
         return NULL;
     }
     if (!empty($params['parent_id']) && !CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])) {
         return NULL;
     }
     $contactType = new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     $contactType->save();
     if ($contactType->find(TRUE)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (!empty($params['id'])) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         $name = self::getBasicType($contactName);
         if (!$name) {
             return;
         }
         $value = array('name' => "New {$name}");
         CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
         $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add?ct={$name}&cst={$contactName}&reset=1", 'permission' => 'add contacts', 'parent_id' => $navinfo['id'], 'is_active' => $active);
         CRM_Core_BAO_Navigation::add($navigation);
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     // reset the cache after adding
     self::subTypeInfo(NULL, FALSE, FALSE, TRUE);
     return $contactType;
 }
Beispiel #12
0
 /**
  * Create a navigation item for a report instance.
  *
  * @param string $name
  * @param string $url
  * @param string $url_params
  * @param int $parent_id
  * @param string $permission
  * @param int $id
  * @param int $domain_id
  *   ID of domain to create item in.
  *
  * @return \CRM_Core_DAO_Navigation
  */
 public static function createReportNavItem($name, $url, $url_params, $parent_id, $permission, $id, $domain_id)
 {
     if ($url !== NULL) {
         $url = "{$url}?{$url_params}";
     }
     $params = array('name' => $name, 'label' => ts($name), 'url' => $url, 'parent_id' => $parent_id, 'is_active' => TRUE, 'permission' => array($permission), 'domain_id' => $domain_id);
     if ($id) {
         $params['id'] = $id;
     }
     return CRM_Core_BAO_Navigation::add($params);
 }
Beispiel #13
0
 /**
  * Function to add or update Contact SubTypes 
  * 
  * @param  array $params  an assoc array of name/value pairs
  * @return object  
  * @access public
  * @static
  */
 static function add($params)
 {
     $contactType =& new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     if (CRM_Utils_Array::value('parent_id', $params)) {
         $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     }
     $contactType->save();
     if ($contactType->find(true)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (CRM_Utils_Array::value('id', $params)) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         if (CRM_Utils_Array::value('parent_id', $params)) {
             $name = self::getBasicType($contactName);
             $value = array('name' => "New {$name}");
             CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
             $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add&ct={$name}&cst={$contactName}&reset=1", 'permission' => "add contacts", 'parent_id' => $navinfo['id'], 'is_active' => $active);
             CRM_Core_BAO_Navigation::add($navigation);
         }
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     return $contactType;
 }
Beispiel #14
0
 public function upgrade_1401()
 {
     $this->ctx->log->info('Applying update 1401');
     $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name');
     $params = array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId, 'is_active' => 1);
     CRM_Core_BAO_Navigation::add($params);
     CRM_Core_BAO_Navigation::resetNavigation();
     return TRUE;
 }
Beispiel #15
0
/**
 * Implementation of hook_civicrm_install
 */
function hrabsence_civicrm_install()
{
    $reportWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'weight', 'name');
    $absenceNavigation = new CRM_Core_DAO_Navigation();
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absences', 'name' => 'Absences', 'url' => null, 'operator' => null, 'weight' => $reportWeight - 1, 'is_active' => 1);
    $absenceNavigation->copyValues($params);
    $absenceNavigation->save();
    $absenceMenuTree = array(array('label' => ts('My Absences'), 'name' => 'my_absences', 'url' => 'civicrm/absences', 'permission' => 'view HRAbsences, edit HRAbsences, administer CiviCRM, manage own HRAbsences'), array('label' => ts('Calendar'), 'name' => 'calendar', 'url' => null, 'permission' => 'access HRReport'), array('label' => ts('New Absence'), 'name' => 'new_absence', 'url' => null, 'permission' => 'edit HRAbsences,administer CiviCRM,manage own HRAbsences', 'permission_operator' => 'OR', 'has_separator' => 1), array('label' => ts('Public Holidays'), 'name' => 'publicHolidays', 'url' => 'civicrm/absence/holidays?reset=1', 'permission' => 'administer CiviCRM'), array('label' => ts('Absence Periods'), 'name' => 'absencePeriods', 'url' => 'civicrm/absence/period?reset=1', 'permission' => 'administer CiviCRM'), array('label' => ts('Absence Types'), 'name' => 'absenceTypes', 'url' => 'civicrm/absence/type?reset=1', 'permission' => 'administer CiviCRM', 'has_separator' => 1), array('label' => ts('Absence Report'), 'name' => 'absence_report', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport'));
    foreach ($absenceMenuTree as $key => $menuItems) {
        $menuItems['is_active'] = 1;
        $menuItems['parent_id'] = $absenceNavigation->id;
        $menuItems['weight'] = $key;
        CRM_Core_BAO_Navigation::add($menuItems);
    }
    $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrreport', 'is_active', 'full_name');
    $reportParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absenceReport', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $reportParentId, 'is_active' => $isEnabled);
    CRM_Core_BAO_Navigation::add($params);
    CRM_Core_BAO_Navigation::resetNavigation();
    $params = array('sequential' => 1, 'option_group_id' => 'activity_status', 'name' => 'Rejected', 'is_reserved' => 1, 'is_active' => 1);
    civicrm_api3('OptionValue', 'create', $params);
    /* Create message template for absence leave application */
    $msg_text = '{ts}Dear{/ts} {$displayName},
    {ts}Employee:{/ts} {$empName}
    {ts}Position:{/ts} {$empPosition}
    {ts}Absence Type:{/ts} {$absenceType}
    {ts}Dates:{/ts} {$startDate} - {$endDate}

      {if $cancel}
        {ts}Leave has been cancelled.{/ts}
      {elseif $reject}
        {ts}Leave has been rejected.{/ts}
      {elseif $approval}
        Leave has been approved for {$appDays}.
      {/if}

      {ts}Date{/ts} | {ts}Absence{/ts} | {if $approval and $totDays neq $appDays} {ts}Approve{/ts} {/if}
      {foreach from=$absentDateDurations item=value key=label}
        {if $value.duration != 0}
          {$label|date_format} | {if $value.duration == $jobHoursTime.Full_Time*60} {ts}Full Day{/ts} {elseif $value.duration == $jobHoursTime.Part_Time*60} {ts}Half Day{/ts} {/if} | {if $approval and $totDays neq $appDays} {if $value.approval == 2}{ts}Approved{/ts} {elseif $value.approval == 9} {ts}Unapproved{/ts} {/if} {/if}
        {/if}
      {/foreach}
      {ts}Total{/ts} | {$totDays}
    {if $customGroup}
      {foreach from=$customGroup item=value key=customName}
        {foreach from=$value item=v key=n}
          {$customName} : {$v}
        {/foreach}
      {/foreach}
    {/if}';
    $msg_html = '<p>{ts}Dear{/ts} {$displayName},</p>
    <table>
      <tbody>
        <tr>
          <td>{ts}Employee:{/ts}</td>
          <td>{$empName}</td>
        </tr>
		    <tr>
          <td>{ts}Position:{/ts}</td>
          <td>{$empPosition}</td>
        </tr>
        <tr>
          <td>{ts}Absence Type:{/ts}</td>
          <td>{$absenceType}</td>
        </tr>
        <tr>
          <td>{ts}Dates:{/ts}</td>
          <td>{$startDate|date_format} - {$endDate|date_format}</td>
        </tr>
      </tbody>
    </table>
      {if $cancel}
        <p> {ts}Leave has been cancelled.{/ts} </p>
      {elseif $reject}
        <p> {ts}Leave has been rejected.{/ts} </p>
      {elseif $approval}
        <p> Leave has been approved for {$appDays}.</p>
      {/if}
      <br/>
      <table border="1" border-spacing="0">
        <tbody>
          <tr>
            <th> {ts}Date{/ts} </th>
            <th> {ts}Absence{/ts} </th>
            {if $approval and $totDays neq $appDays}
              <th> {ts}Status{/ts} </th>
            {/if}
          </tr>
          {foreach from=$absentDateDurations item=value key=label}
          {if $value.duration != 0}
            <tr>
              <td>{$label|date_format}</td>
              <td>{if $value.duration == $jobHoursTime.Full_Time*60} {ts}Full Day{/ts} {elseif $value.duration == $jobHoursTime.Part_Time*60} {ts}Half Day{/ts} {else} &nbsp;{/if}</td>
              {if $approval and $totDays neq $appDays}
                <td>{if $value.approval == 2} {ts}Approved{/ts} {elseif $value.approval == 9} {ts}Unapproved{/ts} {else}{/if}</td>
              {/if}
            </tr>
          {/if}
          {/foreach}
          <tr>
            <td>{ts}Total{/ts}</td>
            <td>{$totDays}</td>
            {if $approval and $totDays neq $appDays}
              <td> &nbsp; </td>
            {/if}
          </tr>
        </tbody>
      </table>
    <br/>
    {if $customGroup}
      <table>
        <tbody>
          {foreach from=$customGroup item=value key=customName}
            {foreach from=$value item=v key=n}
              <tr>
                <td>
                  {$customName} :
                </td>
                <td>
                  {$v}
                </td>
              </tr>
            {/foreach}
          {/foreach}
        </tbody>
      </table>
    {/if}';
    $subject = '{if $approval}Absences Approved{elseif $cancel}Absences Cancelled{elseif $reject}Absences Rejected{else}Absences Application{/if}';
    $msg_params = array('msg_title' => 'Absence Email', 'msg_subject' => $subject, 'msg_text' => $msg_text, 'msg_html' => $msg_html, 'workflow_id' => NULL, 'is_default' => '1', 'is_reserved' => '0');
    civicrm_api3('message_template', 'create', $msg_params);
    return _hrabsence_civix_civicrm_install();
}
Beispiel #16
0
 static function postProcess(&$form)
 {
     $params = $form->getVar('_params');
     $config = CRM_Core_Config::singleton();
     $params['header'] = $params['report_header'];
     $params['footer'] = $params['report_footer'];
     $params['domain_id'] = CRM_Core_Config::domainID();
     //navigation parameters
     if (CRM_Utils_Array::value('is_navigation', $params)) {
         $form->_navigation['permission'] = array();
         $permission = CRM_Utils_Array::value('permission', $params);
         $form->_navigation['current_parent_id'] = CRM_Utils_Array::value('parent_id', $form->_navigation);
         $form->_navigation['parent_id'] = CRM_Utils_Array::value('parent_id', $params);
         $form->_navigation['label'] = $params['title'];
         $form->_navigation['name'] = $params['title'];
         $form->_navigation['is_active'] = 1;
         if ($permission) {
             $form->_navigation['permission'][] = $permission;
         }
         //unset the navigation related element,
         //not used in report form values
         unset($params['parent_id']);
         unset($params['is_navigation']);
     }
     // add to dashboard
     $dashletParams = array();
     if (CRM_Utils_Array::value('addToDashboard', $params)) {
         $dashletParams = array('label' => $params['title'], 'is_active' => 1, 'content' => 'NULL');
         $permission = CRM_Utils_Array::value('permission', $params);
         if ($permission) {
             $dashletParams['permission'][] = $permission;
         }
         unset($params['addToDashboard']);
     }
     require_once 'CRM/Report/DAO/Instance.php';
     $dao = new CRM_Report_DAO_Instance();
     $dao->copyValues($params);
     if ($config->userFramework == 'Joomla') {
         $dao->permission = NULL;
     }
     // unset all the params that we use
     $fields = array('title', 'to_emails', 'cc_emails', 'header', 'footer', 'qfKey', '_qf_default', 'report_header', 'report_footer');
     foreach ($fields as $field) {
         unset($params[$field]);
     }
     $dao->form_values = serialize($params);
     $instanceID = $form->getVar('_id');
     if ($instanceID) {
         $dao->id = $instanceID;
     }
     require_once 'CRM/Report/Utils/Report.php';
     $dao->report_id = CRM_Report_Utils_Report::getValueFromUrl($instanceID);
     $dao->save();
     $form->set('id', $dao->id);
     $reloadTemplate = false;
     if ($dao->id) {
         if (!empty($form->_navigation)) {
             $form->_navigation['url'] = "civicrm/report/instance/{$dao->id}&reset=1";
             $navigation = CRM_Core_BAO_Navigation::add($form->_navigation);
             //set the navigation id in report instance table
             CRM_Core_DAO::setFieldValue('CRM_Report_DAO_Instance', $dao->id, 'navigation_id', $navigation->id);
             //reset navigation
             CRM_Core_BAO_Navigation::resetNavigation();
             // in order to reflect change in navigation, template needs to be reloaded
             $reloadTemplate = true;
         }
         // add to dashlet
         if (!empty($dashletParams)) {
             $section = 2;
             $chart = '';
             if (CRM_Utils_Array::value('charts', $params)) {
                 $section = 1;
                 $chart = "&charts=" . $params['charts'];
                 $dashletParams['is_fullscreen'] = 0;
             }
             $dashletParams['url'] = "civicrm/report/instance/{$dao->id}&reset=1&section={$section}&snippet=4{$chart}";
             $dashletParams['instanceURL'] = "civicrm/report/instance/{$dao->id}";
             require_once 'CRM/Core/BAO/Dashboard.php';
             CRM_Core_BAO_Dashboard::addDashlet($dashletParams);
         }
         $instanceParams = array('value' => $dao->report_id);
         $instanceDefaults = array();
         $cmpName = "Contact";
         $statusMsg = "null";
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $instanceParams, $instanceDefaults);
         if ($cmpID = CRM_Utils_Array::value('component_id', $instanceDefaults)) {
             $cmpName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Component', $cmpID, 'name', 'id');
             $cmpName = substr($cmpName, 4);
         }
         // Url to view this report and others created FROM this template
         $instanceUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$instanceDefaults['id']}");
         $statusMsg = ts('Report "%1" has been created and is now available in the <a href="%3">report listings under "%2" Reports</a>.', array(1 => $dao->title, 2 => $cmpName, 3 => $instanceUrl));
         if ($instanceID) {
             $statusMsg = ts('Report "%1" has been updated.', array(1 => $dao->title));
         }
         CRM_Core_Session::setStatus($statusMsg);
     }
     if ($reloadTemplate) {
         // as there's been change in navigation, reload the template
         return CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'force=1'));
     }
 }
Beispiel #17
0
/**
 * Implementation of hook_civicrm_install
 */
function hrstaffdir_civicrm_install()
{
    _hrstaffdir_civix_civicrm_install();
    $profileId = hrstaffdir_getUFGroupID();
    $path = array('url' => "civicrm/profile/table?reset=1?gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($profileId && !$navigationPath) {
        // add to navigation
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile?reset=1&gid={$profileId}&force=1", 'is_active' => 1);
        $navigation = CRM_Core_BAO_Navigation::add($navigationParams);
        CRM_Core_BAO_Navigation::resetNavigation();
        // set the profile as search view
        $params = array();
        CRM_Core_BAO_ConfigSetting::retrieve($params);
        if (!empty($params)) {
            $params['defaultSearchProfileID'] = $profileId;
            CRM_Core_BAO_ConfigSetting::create($params);
        }
    }
}
Beispiel #18
0
 public function upgradeBundle()
 {
     //$this->ctx->log->info('Applying update 0999');
     $this->executeCustomDataFile('xml/option_group_install.xml');
     //$this->ctx->log->info('Applying update 1101');
     $this->executeCustomDataFile('xml/1101_departments.xml');
     //$this->ctx->log->info('Applying update 1105');
     if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_pension_type', 'name')) {
         $this->executeCustomDataFile('xml/1105_pension_type.xml');
     }
     /* DEPRECATED:
        //$this->ctx->log->info('Applying update 1201');
        //get all fields of Custom Group "HRJobContract_Summary"
        $params = array(
          'custom_group_id' => 'HRJobContract_Summary',
        );
        $results = civicrm_api3('CustomField', 'get', $params);
        foreach ($results['values'] as $result) {
          $result['is_view'] = 0; // make the field editable
          civicrm_api3('CustomField', 'create', $result);
        }
        //disable trigger
        CRM_Core_DAO::triggerRebuild();*/
     //$this->ctx->log->info('Applying update 1202');
     //Add job import navigation menu
     $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Import Contacts', 'weight', 'name');
     $contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name');
     $importJobNavigation = new CRM_Core_DAO_Navigation();
     $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Import Jobs'), 'name' => 'jobImport', 'url' => null, 'parent_id' => $contactNavId, 'weight' => $weight + 1, 'permission' => 'access HRJobs', 'separator' => 1, 'is_active' => 1);
     $importJobNavigation->copyValues($params);
     $importJobNavigation->save();
     //$this->ctx->log->info('Applying update 1400');
     $i = 4;
     $params = array('option_group_id' => 'hrjc_contract_type', 'name' => 'Employee_Permanent', 'weight' => $i, 'label' => 'Employee - Permanent', 'value' => 'Employee - Permanent');
     civicrm_api3('OptionValue', 'create', $params);
     /* DEPRECATED:
        $empoption_id = civicrm_api3('OptionValue', 'getsingle', array('return' => "id",'option_group_id' => 'hrjc_contract_type', 'name' => "Employee"));
        civicrm_api3('OptionValue', 'create',array('id' => $empoption_id['id'],'name' => "Employee_Temporary",'label' => 'Employee - Temporary', 'value' => 'Employee - Temporary'));
        */
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_contract_type', 'id', 'name');
     foreach (array('Intern', 'Trustee', 'Volunteer') as $opName) {
         $i++;
         CRM_Core_DAO::executeQuery("UPDATE civicrm_option_value SET weight = {$i} WHERE name = '{$opName}' and option_group_id = {$optionGroupID}");
     }
     $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_hours_type', 'id', 'name');
     //change value of stored hours type
     CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjobcontract_hour SET hours_type = CASE hours_type WHEN 'full' THEN 8 WHEN 'part' THEN 4 WHEN 'casual' THEN 0 ELSE hours_type END");
     //$this->ctx->log->info('Applying update 1402');
     //Upgrade for HR-394 and HR-395
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_region', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_region', 'title' => 'Region', 'is_active' => 1);
         $newRegionGroupResult = civicrm_api3('OptionGroup', 'create', $params);
     }
     // Migrate old 'hrjob_region' option values into new 'hrjc_region':
     if (!empty($newRegionGroupResult['id'])) {
         $oldRegionGroup = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjob_region"));
         if (!empty($oldRegionGroup['id'])) {
             $oldRegionsResult = civicrm_api3('OptionValue', 'get', array('sequential' => 1, 'option_group_id' => $oldRegionGroup['id']));
             foreach ($oldRegionsResult['values'] as $oldRegion) {
                 $newRegion = $oldRegion;
                 unset($newRegion['id']);
                 $newRegion['option_group_id'] = $newRegionGroupResult['id'];
                 civicrm_api3('OptionValue', 'create', $newRegion);
             }
         }
     }
     $result = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_hrjobcontract_hour ORDER BY id ASC');
     while ($result->fetch()) {
         $fteFraction = CRM_Hrjobcontract_Upgrader::decToFraction($result->hours_fte);
         CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjobcontract_hour SET fte_num={$fteFraction[0]} , fte_denom={$fteFraction[1]} WHERE id = {$result->id}");
     }
     //$this->ctx->log->info('Applying update 1404');
     $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_pay_grade', 'id', 'name');
     $sql = "UPDATE civicrm_option_value SET civicrm_option_value.value = CASE civicrm_option_value.label WHEN 'Paid' THEN 1 WHEN 'Unpaid' THEN 0 END WHERE option_group_id = {$optionGroupId}";
     CRM_Core_DAO::executeQuery($sql);
     CRM_Core_DAO::triggerRebuild();
     $reportTemplateOptionGroup = CRM_Core_DAO::executeQuery("SELECT * FROM civicrm_option_group WHERE name='report_template' AND is_active = 1 LIMIT 1");
     if ($reportTemplateOptionGroup->fetch()) {
         $hrjobcontractReportTemplateQuery = "INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `domain_id`, `visibility_id`) VALUES\n        (%1, 'JobContract Revision Report', 'hrjobcontract/summary', 'CRM_Hrjobcontract_Report_Form_Summary', NULL, 0, 0, 54, 'JobContract Revision Report', 0, 0, 1, NULL, NULL, NULL)";
         $hrjobcontractReportTemplateParams = array(1 => array($reportTemplateOptionGroup->id, 'Integer'));
         CRM_Core_DAO::executeQuery($hrjobcontractReportTemplateQuery, $hrjobcontractReportTemplateParams);
     }
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract_hour` ADD `location_type` INT(3) NULL DEFAULT NULL AFTER `id`");
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract_hour` CHANGE `location_type` `location_standard_hours` INT(3) NULL DEFAULT NULL");
     CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_hrhours_location");
     CRM_Core_DAO::executeQuery("\n        CREATE TABLE IF NOT EXISTS `civicrm_hrhours_location` (\n        `id` int(10) unsigned NOT NULL,\n          `location` varchar(63) DEFAULT NULL,\n          `standard_hours` int(4) DEFAULT NULL,\n          `periodicity` varchar(63) DEFAULT NULL,\n          `is_active` tinyint(4) DEFAULT '1'\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1\n      ");
     CRM_Core_DAO::executeQuery("\n        INSERT INTO `civicrm_hrhours_location` (`id`, `location`, `standard_hours`, `periodicity`, `is_active`) VALUES\n        (1, 'Head office', 40, 'Week', 1),\n        (2, 'Other office', 8, 'Day', 1),\n        (3, 'Small office', 36, 'Week', 1)\n      ");
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_revision_change_reason', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_revision_change_reason', 'title' => 'Job Contract Revision Change Reason', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Reason 1', 2 => 'Reason 2', 3 => 'Reason 3');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_revision_change_reason', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     CRM_Core_DAO::executeQuery("\n        ALTER TABLE `civicrm_hrjobcontract_pay` ADD `annual_benefits` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `pay_is_auto_est`, ADD `annual_deductions` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `annual_benefits`\n    ");
     CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_hrhours_location");
     CRM_Core_DAO::executeQuery("\n        CREATE TABLE IF NOT EXISTS `civicrm_hrhours_location` (\n        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `location` varchar(63) DEFAULT NULL,\n          `standard_hours` int(4) DEFAULT NULL,\n          `periodicity` varchar(63) DEFAULT NULL,\n          `is_active` tinyint(4) DEFAULT '1',\n          PRIMARY KEY(id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1\n      ");
     CRM_Core_DAO::executeQuery("\n        INSERT INTO `civicrm_hrhours_location` (`id`, `location`, `standard_hours`, `periodicity`, `is_active`) VALUES\n        (1, 'Head office', 40, 'Week', 1),\n        (2, 'Other office', 8, 'Day', 1),\n        (3, 'Small office', 36, 'Week', 1)\n      ");
     // pay_cycle:
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_pay_cycle', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_pay_cycle', 'title' => 'Job Contract Pay Cycle', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Weekly', 2 => 'Monthly');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_pay_cycle', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     // benefit_name:
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_benefit_name', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_benefit_name', 'title' => 'Job Contract Benefit Name', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Bike', 2 => 'Medical');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_benefit_name', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     // benefit_type:
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_benefit_type', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_benefit_type', 'title' => 'Job Contract Benefit Type', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Fixed', 2 => '%');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_benefit_type', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     // deduction_name:
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_deduction_name', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_deduction_name', 'title' => 'Job Contract Deduction Name', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Bike', 2 => 'Medical');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_deduction_name', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     // deduction_type:
     $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_deduction_type', 'id', 'name');
     if (!$optionGroupID) {
         $params = array('name' => 'hrjc_deduction_type', 'title' => 'Job Contract Deduction Type', 'is_active' => 1, 'is_reserved' => 1);
         civicrm_api3('OptionGroup', 'create', $params);
         $optionsValue = array(1 => 'Fixed', 2 => '%');
         foreach ($optionsValue as $key => $value) {
             $opValueParams = array('option_group_id' => 'hrjc_deduction_type', 'name' => $value, 'label' => $value, 'value' => $key);
             civicrm_api3('OptionValue', 'create', $opValueParams);
         }
     }
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract_pay`  ADD `pay_cycle` INT(4) DEFAULT NULL  AFTER `annual_deductions`,  ADD `pay_per_cycle_gross` DECIMAL(10,2)  DEFAULT NULL  AFTER `pay_cycle`,  ADD `pay_per_cycle_net` DECIMAL(10,2)  DEFAULT NULL  AFTER `pay_per_cycle_gross`");
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract_revision` ADD `editor_uid` INT(10) NULL DEFAULT NULL AFTER `jobcontract_id`");
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract` ADD `deleted` INT(2) UNSIGNED NOT NULL DEFAULT '0'");
     CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjobcontract_revision` ADD `deleted` INT(2) UNSIGNED NOT NULL DEFAULT '0'");
     // Navigation items:
     CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name IN ('hoursType', 'pay_scale', 'hours_location', 'hrjc_contract_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')");
     // Add administer options
     $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name');
     $jobContractOptionsMenuTree = array(array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId), array('label' => ts('Job Contract Pay Scale'), 'name' => 'pay_scale', 'url' => 'civicrm/pay_scale', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId), array('label' => ts('Job Contract Hours/Location'), 'name' => 'hours_location', 'url' => 'civicrm/hours_location', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId));
     // hrjc_contract_type:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_contract_type"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Contract Type'), 'name' => 'hrjc_contract_type', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_location:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_location"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Normal place of work'), 'name' => 'hrjc_location', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
         // Migrating old 'hrjob_location' option values into new 'hrjc_location':
         $oldLocationGroup = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjob_location"));
         if (!empty($oldLocationGroup['id'])) {
             $oldLocationsResult = civicrm_api3('OptionValue', 'get', array('sequential' => 1, 'option_group_id' => $oldLocationGroup['id']));
             foreach ($oldLocationsResult['values'] as $oldLocation) {
                 $newLocationResult = civicrm_api3('OptionValue', 'get', array('sequential' => 1, 'option_group_id' => $result['id'], 'value' => $oldLocation['value']));
                 if (!empty($newLocationResult['id'])) {
                     continue;
                 }
                 $newLocation = $oldLocation;
                 unset($newLocation['id']);
                 $newLocation['option_group_id'] = $result['id'];
                 civicrm_api3('OptionValue', 'create', $newLocation);
             }
         }
     }
     // hrjc_pay_cycle:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_pay_cycle"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Pay cycle'), 'name' => 'hrjc_pay_cycle', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_benefit_name:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_benefit_name"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Benefits'), 'name' => 'hrjc_benefit_name', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_benefit_type:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_benefit_type"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Benefit type'), 'name' => 'hrjc_benefit_type', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_deduction_name:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_deduction_name"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Deductions'), 'name' => 'hrjc_deduction_name', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_deduction_type:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_deduction_type"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Deduction type'), 'name' => 'hrjc_deduction_type', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_pension_type:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_pension_type"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Pension provider type'), 'name' => 'hrjc_pension_type', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     // hrjc_revision_change_reason:
     $result = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'name' => "hrjc_revision_change_reason"));
     if (!empty($result['id'])) {
         $jobContractOptionsMenuTree[] = array('label' => ts('Reason for change'), 'name' => 'hrjc_revision_change_reason', 'url' => 'civicrm/admin/options?gid=' . $result['id'], 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId);
     }
     foreach ($jobContractOptionsMenuTree as $key => $menuItems) {
         $menuItems['is_active'] = 1;
         CRM_Core_BAO_Navigation::add($menuItems);
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     // Delete old HRJob Option Groups:
     CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('hrjob_contract_type',\n    'hrjob_department',\n    'hrjob_health_provider',\n    'hrjob_hours_type',\n    'hrjob_level_type',\n    'hrjob_life_provider',\n    'hrjob_pay_grade',\n    'hrjob_pay_scale',\n    'hrjob_pension_type',\n    'hrjob_region',\n    'hrjob_location')");
     $this->upgrade_1001();
     $this->upgrade_1002();
     $this->upgrade_1003();
     $this->upgrade_1004();
     $this->upgrade_1005();
     $this->upgrade_1006();
     $this->upgrade_1008();
     $this->upgrade_1009();
 }
Beispiel #19
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if (isset($this->_id)) {
         $params['id'] = $this->_id;
         $params['current_parent_id'] = $this->_currentParentID;
     }
     $navigation = CRM_Core_BAO_Navigation::add($params);
     // also reset navigation
     require_once 'CRM/Core/BAO/Navigation.php';
     CRM_Core_BAO_Navigation::resetNavigation();
     CRM_Core_Session::setStatus(ts('Menu \'%1\' has been saved.', array(1 => $navigation->label)));
 }
 /**
  * Function to add or update Contact SubTypes 
  * 
  * @param  array $params  an assoc array of name/value pairs
  * @return object  
  * @access public
  * @static
  */
 static function add($params)
 {
     // null if empty params or doesn't contain parent_id
     if (!CRM_Utils_Array::value('parent_id', $params)) {
         return;
     }
     // label or name
     if (!CRM_Utils_Array::value('label', $params)) {
         return;
     }
     // parent_id
     if (!CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])) {
         return;
     }
     $contactType = new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     $contactType->save();
     if ($contactType->find(true)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (CRM_Utils_Array::value('id', $params)) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         if (CRM_Utils_Array::value('parent_id', $params)) {
             $name = self::getBasicType($contactName);
             $value = array('name' => "New {$name}");
             CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
             $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add&ct={$name}&cst={$contactName}&reset=1", 'permission' => "add contacts", 'parent_id' => $navinfo['id'], 'is_active' => $active);
             CRM_Core_BAO_Navigation::add($navigation);
         }
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     // reset the cache after adding
     self::subTypeInfo(null, false, false, true);
     return $contactType;
 }
 /**
  * Create instance.
  * takes an associative array and creates a instance object and does any related work like permissioning, adding to dashboard etc.
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Report_BAO_ReportInstance
  */
 public static function &create(&$params)
 {
     if (isset($params['report_header'])) {
         $params['header'] = CRM_Utils_Array::value('report_header', $params);
     }
     if (isset($params['report_footer'])) {
         $params['footer'] = CRM_Utils_Array::value('report_footer', $params);
     }
     // build navigation parameters
     if (!empty($params['is_navigation'])) {
         if (!array_key_exists('navigation', $params)) {
             $params['navigation'] = array();
         }
         $navigationParams =& $params['navigation'];
         $navigationParams['permission'] = array();
         $navigationParams['label'] = $params['title'];
         $navigationParams['name'] = $params['title'];
         $navigationParams['current_parent_id'] = CRM_Utils_Array::value('parent_id', $navigationParams);
         $navigationParams['parent_id'] = CRM_Utils_Array::value('parent_id', $params);
         $navigationParams['is_active'] = 1;
         if ($permission = CRM_Utils_Array::value('permission', $params)) {
             $navigationParams['permission'][] = $permission;
         }
         // unset the navigation related elements, not used in report form values
         unset($params['parent_id']);
         unset($params['is_navigation']);
     }
     // add to dashboard
     $dashletParams = array();
     if (!empty($params['addToDashboard'])) {
         $dashletParams = array('label' => $params['title'], 'is_active' => 1);
         if ($permission = CRM_Utils_Array::value('permission', $params)) {
             $dashletParams['permission'][] = $permission;
         }
     }
     $transaction = new CRM_Core_Transaction();
     $instance = self::add($params);
     if (is_a($instance, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $instance;
     }
     // add / update navigation as required
     if (!empty($navigationParams)) {
         if (empty($params['id']) && empty($params['instance_id']) && !empty($navigationParams['id'])) {
             unset($navigationParams['id']);
         }
         $navigationParams['url'] = "civicrm/report/instance/{$instance->id}?reset=1";
         $navigation = CRM_Core_BAO_Navigation::add($navigationParams);
         if (!empty($navigationParams['is_active'])) {
             //set the navigation id in report instance table
             CRM_Core_DAO::setFieldValue('CRM_Report_DAO_ReportInstance', $instance->id, 'navigation_id', $navigation->id);
         } else {
             // has been removed from the navigation bar
             CRM_Core_DAO::setFieldValue('CRM_Report_DAO_ReportInstance', $instance->id, 'navigation_id', 'NULL');
         }
         //reset navigation
         CRM_Core_BAO_Navigation::resetNavigation();
     }
     // add to dashlet
     if (!empty($dashletParams)) {
         $section = 2;
         $chart = '';
         if (!empty($params['charts'])) {
             $section = 1;
             $chart = "&charts=" . $params['charts'];
         }
         $limitResult = NULL;
         if (!empty($params['row_count'])) {
             $limitResult = '&rowCount=' . $params['row_count'];
         }
         $dashletParams['name'] = "report/{$instance->id}";
         $dashletParams['url'] = "civicrm/report/instance/{$instance->id}?reset=1&section={$section}&snippet=5{$chart}&context=dashlet" . $limitResult;
         $dashletParams['fullscreen_url'] = "civicrm/report/instance/{$instance->id}?reset=1&section={$section}&snippet=5{$chart}&context=dashletFullscreen" . $limitResult;
         $dashletParams['instanceURL'] = "civicrm/report/instance/{$instance->id}";
         CRM_Core_BAO_Dashboard::addDashlet($dashletParams);
     }
     $transaction->commit();
     return $instance;
 }
 static function postProcess(&$form)
 {
     $params = $form->getVar('_params');
     $config = CRM_Core_Config::singleton();
     $params['header'] = $params['report_header'];
     $params['footer'] = $params['report_footer'];
     $params['domain_id'] = CRM_Core_Config::domainID();
     $form->_navigation['permission'] = array();
     $form->_navigation['label'] = $params['title'];
     $form->_navigation['name'] = $params['title'];
     //navigation parameters
     if (CRM_Utils_Array::value('is_navigation', $params)) {
         $permission = CRM_Utils_Array::value('permission', $params);
         $form->_navigation['current_parent_id'] = CRM_Utils_Array::value('parent_id', $form->_navigation);
         $form->_navigation['parent_id'] = CRM_Utils_Array::value('parent_id', $params);
         $form->_navigation['is_active'] = 1;
         if ($permission) {
             $form->_navigation['permission'][] = $permission;
         }
         //unset the navigation related element,
         //not used in report form values
         unset($params['parent_id']);
         unset($params['is_navigation']);
     }
     // convert roles array to string
     if (isset($params['grouprole']) && is_array($params['grouprole'])) {
         $grouprole_array = array();
         foreach ($params['grouprole'] as $key => $value) {
             $grouprole_array[$value] = $value;
         }
         $params['grouprole'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($grouprole_array));
     }
     // add to dashboard
     $dashletParams = array();
     if (CRM_Utils_Array::value('addToDashboard', $params)) {
         $dashletParams = array('label' => $params['title'], 'is_active' => 1);
         $permission = CRM_Utils_Array::value('permission', $params);
         if ($permission) {
             $dashletParams['permission'][] = $permission;
         }
     }
     $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
     $dao = new CRM_Report_DAO_Instance();
     $dao->copyValues($params);
     if ($config->userFramework == 'Joomla') {
         $dao->permission = 'null';
     }
     // explicitly set to null if params value is empty
     if (empty($params['grouprole'])) {
         $dao->grouprole = 'null';
     }
     // unset all the params that we use
     $fields = array('title', 'to_emails', 'cc_emails', 'header', 'footer', 'qfKey', '_qf_default', 'report_header', 'report_footer', 'grouprole');
     foreach ($fields as $field) {
         unset($params[$field]);
     }
     $dao->form_values = serialize($params);
     $instanceID = $form->getVar('_id');
     $isNew = $form->getVar('_createNew');
     if ($instanceID && !$isNew) {
         $dao->id = $instanceID;
     }
     $dao->report_id = CRM_Report_Utils_Report::getValueFromUrl($instanceID);
     $dao->save();
     $form->set('id', $dao->id);
     $reloadTemplate = FALSE;
     if ($dao->id) {
         if (!empty($form->_navigation)) {
             if ($isNew && CRM_Utils_Array::value('id', $form->_navigation)) {
                 unset($form->_navigation['id']);
             }
             $form->_navigation['url'] = "civicrm/report/instance/{$dao->id}&reset=1";
             $navigation = CRM_Core_BAO_Navigation::add($form->_navigation);
             if (CRM_Utils_Array::value('is_active', $form->_navigation)) {
                 //set the navigation id in report instance table
                 CRM_Core_DAO::setFieldValue('CRM_Report_DAO_Instance', $dao->id, 'navigation_id', $navigation->id);
             } else {
                 // has been removed from the navigation bar
                 CRM_Core_DAO::setFieldValue('CRM_Report_DAO_Instance', $dao->id, 'navigation_id', 'NULL');
             }
             //reset navigation
             CRM_Core_BAO_Navigation::resetNavigation();
             // in order to reflect change in navigation, template needs to be reloaded
             $reloadTemplate = TRUE;
         }
         // add to dashlet
         if (!empty($dashletParams)) {
             $section = 2;
             $chart = '';
             if (CRM_Utils_Array::value('charts', $params)) {
                 $section = 1;
                 $chart = "&charts=" . $params['charts'];
             }
             $dashletParams['url'] = "civicrm/report/instance/{$dao->id}&reset=1&section={$section}&snippet=5{$chart}&context=dashlet";
             $dashletParams['fullscreen_url'] = "civicrm/report/instance/{$dao->id}&reset=1&section={$section}&snippet=5{$chart}&context=dashletFullscreen";
             $dashletParams['instanceURL'] = "civicrm/report/instance/{$dao->id}";
             CRM_Core_BAO_Dashboard::addDashlet($dashletParams);
         }
         $instanceParams = array('value' => $dao->report_id);
         $instanceDefaults = array();
         $cmpName = "Contact";
         $statusMsg = "null";
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $instanceParams, $instanceDefaults);
         if ($cmpID = CRM_Utils_Array::value('component_id', $instanceDefaults)) {
             $cmpName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Component', $cmpID, 'name', 'id');
             $cmpName = substr($cmpName, 4);
         }
         // Url to view this report and others created FROM this template
         $instanceUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$instanceDefaults['id']}");
         $statusMsg = ts('Report "%1" has been created and is now available in the <a href="%3">report listings under "%2" Reports</a>.', array(1 => $dao->title, 2 => $cmpName, 3 => $instanceUrl));
         if ($instanceID && !$isNew) {
             $statusMsg = ts('Report "%1" has been updated.', array(1 => $dao->title));
         }
         CRM_Core_Session::setStatus($statusMsg);
     }
     if ($reloadTemplate) {
         // as there's been change in navigation, reload the template
         return CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'force=1'));
     }
 }