예제 #1
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Contact Type'));
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'label', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'label'), TRUE);
     $contactType = $this->add('select', 'parent_id', ts('Basic Contact Type'), CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id'));
     $enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $contactType->freeze();
         // We'll display actual "name" for built-in types (for reference) when editing their label / image_URL
         $contactTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'name');
         $this->assign('contactTypeName', $contactTypeName);
         $this->_parentId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'parent_id');
         // Freeze Enabled field for built-in contact types (parent_id is NULL for these)
         if (is_null($this->_parentId)) {
             $enabled->freeze();
         }
     }
     $this->addElement('text', 'image_URL', ts('Image URL'));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'description'));
     $this->assign('cid', $this->_id);
     $this->addFormRule(array('CRM_Admin_Form_ContactType', 'formRule'), $this);
 }
예제 #2
0
 /**
  * Various pre defined contact super types.
  *
  * @return array
  */
 public static function contactType()
 {
     static $contactType = NULL;
     if (!$contactType) {
         $contactType = CRM_Contact_BAO_ContactType::basicTypePairs();
     }
     return $contactType;
 }
 /**
  * various pre defined contact super types
  * @static
  */
 static function &contactType()
 {
     static $contactType = NULL;
     if (!$contactType) {
         $contactType = array('' => ts('- any contact type -'));
         $contactType = $contactType + CRM_Contact_BAO_ContactType::basicTypePairs();
     }
     return $contactType;
 }
예제 #4
0
 /**
  * various pre defined contact super types
  * @static
  */
 static function &contactType()
 {
     static $contactType = null;
     if (!$contactType) {
         require_once 'CRM/Contact/BAO/ContactType.php';
         $contactType = array('' => ts('- any contact type -'));
         $contactType = $contactType + CRM_Contact_BAO_ContactType::basicTypePairs();
     }
     return $contactType;
 }
예제 #5
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();
}
예제 #6
0
파일: hrjob.php 프로젝트: JoeMurray/civihr
/**
 * 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();
}
예제 #7
0
 function __construct()
 {
     $this->_columns = array('civicrm_grant' => array('dao' => 'CRM_Grant_DAO_Grant', 'fields' => array('summary_statistics' => array('name' => 'id', 'title' => ts('Summary Statistics'), 'required' => TRUE), 'grant_type_id' => array('name' => 'grant_type_id', 'title' => ts('By Grant Type')), 'status_id' => array('no_display' => TRUE, 'required' => TRUE), 'amount_total' => array('no_display' => TRUE, 'required' => TRUE), 'grant_report_received' => array('no_display' => TRUE, 'required' => TRUE), 'currency' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('application_received_date' => array('name' => 'application_received_date', 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'decision_date' => array('name' => 'decision_date', 'title' => ts('Grant Decision'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'money_transfer_date' => array('name' => 'money_transfer_date', 'title' => ts('Money Transferred'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'grant_due_date' => array('name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'grant_type' => array('name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id')), 'status_id' => array('name' => 'status_id', 'title' => ts('Grant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id')), 'amount_requested' => array('name' => 'amount_requested', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY), 'amount_granted' => array('name' => 'amount_granted', 'title' => ts('Amount Granted')), 'grant_report_received' => array('name' => 'grant_report_received', 'title' => ts('Report Received'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'))))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('required' => TRUE, 'no_display' => TRUE), 'gender_id' => array('name' => 'gender_id', 'title' => ts('By Gender')), 'contact_type' => array('name' => 'contact_type', 'title' => ts('By Contact Type'))), 'filters' => array('gender_id' => array('name' => 'gender_id', 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'contact_type' => array('name' => 'contact_type', 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_ContactType::basicTypePairs())), 'grouping' => 'contact-fields'), 'civicrm_world_region' => array('dao' => 'CRM_Core_DAO_Worldregion', 'fields' => array('id' => array('no_display' => TRUE), 'name' => array('name' => 'name', 'title' => ts('By World Region'))), 'filters' => array('region_id' => array('name' => 'id', 'title' => ts('World Region'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion()))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('country_id' => array('name' => 'country_id', 'title' => ts('By Country'))), 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()))));
     parent::__construct();
 }
 public static function &contactType($column = 'label')
 {
     if (!self::$contactType) {
         self::$contactType = CRM_Contact_BAO_ContactType::basicTypePairs(TRUE);
     }
     return self::$contactType;
 }
예제 #9
0
 public function upgrade_1108()
 {
     $this->ctx->log->info('Applying update 1108');
     if (CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider') && CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider_life_insurance')) {
         $opt_grp_name = array('hrjob_health_provider' => array('name' => 'Health_Insurance_Provider', 'label' => ts('Health Insurance Provider'), 'column' => 'provider'), 'hrjob_life_provider' => array('name' => 'Life_Insurance_Provider', 'label' => ts('Life Insurance Provider'), 'column' => 'provider_life_insurance'));
         $org_id = array_search('Organization', CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id'));
         $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
         foreach ($opt_grp_name as $oKey => $oValue) {
             $subID = array_key_exists($oValue['name'], $orgSubType);
             if (!$subID) {
                 CRM_Contact_BAO_ContactType::add(array('parent_id' => $org_id, 'is_active' => 1, 'name' => $oValue['name'], 'label' => $oValue['label']));
             }
             $options = CRM_Core_OptionGroup::values($oKey, TRUE, FALSE);
             foreach ($options as $orgKey => $orgValue) {
                 $params = array('organization_name' => $orgValue, 'sort_name' => $orgValue, 'display_name' => $orgValue, 'legal_name' => $orgValue, 'contact_type' => 'Organization', 'contact_sub_type' => $oValue['name']);
                 $result = civicrm_api3('contact', 'create', $params);
                 if ($result['id']) {
                     CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = {$result['id']} WHERE {$oValue['column']} LIKE '{$orgValue}'");
                     CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = NULL WHERE {$oValue['column']} = ''");
                 }
             }
             CRM_Core_OptionGroup::deleteAssoc($oKey);
         }
         CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjob_health`\n        MODIFY COLUMN `provider` int(10) unsigned DEFAULT NULL,\n        MODIFY COLUMN `provider_life_insurance` int(10) unsigned DEFAULT NULL,\n        ADD CONSTRAINT `FK_civicrm_hrjob_health_provider` FOREIGN KEY (`provider`)  REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL,\n        ADD CONSTRAINT `FK_civicrm_hrjob_health_provider_life_insurance` FOREIGN KEY (`provider_life_insurance`)  REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL");
     }
     return TRUE;
 }