/** * Build the form object. * * @return void */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->setMaxFileSize($uploadFileSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL); $this->addGroup($duplicateOptions, 'onDuplicate', ts('On duplicate entries')); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Common form elements. */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE); $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator)); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadedMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadedMapping); $this->setDefaults(array('savedMapping' => $loadedMapping)); } //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to actually build the form * * @return None * @access public */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); if ($config->maxImportFileSize >= 8388608) { $uploadFileSize = 8388608; } else { $uploadFileSize = $config->maxImportFileSize; } $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=60', true); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Insert new contributions'), CRM_Contribute_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Update existing contributions'), CRM_Contribute_Import_Parser::DUPLICATE_UPDATE); $this->addGroup($duplicateOptions, 'onDuplicate', ts('Import mode')); //get the saved mapping details require_once "CRM/Core/BAO/Mapping.php"; require_once "CRM/Core/OptionGroup.php"; $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); $this->addElement('submit', 'loadMapping', ts('Load Mapping'), null, array('onclick' => 'checkSelect()')); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Contribute_Import_Parser::DUPLICATE_SKIP)); //contact types option require_once 'CRM/Contact/BAO/ContactType.php'; $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Individual'), CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Household'), CRM_Contribute_Import_Parser::CONTACT_HOUSEHOLD); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Organization'), CRM_Contribute_Import_Parser::CONTACT_ORGANIZATION); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array('contactType' => CRM_Contribute_Import_Parser::CONTACT_INDIVIDUAL)); //build date formats require_once 'CRM/Core/Form/Date.php'; CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { //Setting Upload File Size $config = CRM_Core_Config::singleton(); if ($config->maxImportFileSize >= 8388608) { $uploadFileSize = 8388608; } else { $uploadFileSize = $config->maxImportFileSize; } $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); // for contributions NOCHECK == SKIP // $duplicateOptions[] = $this->createElement('radio', // null, null, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); $this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries')); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); //contact types option $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to build mapping form element * */ function buildMapping() { switch ($this->_exportMode) { case CRM_Export_Form_Select::CONTACT_EXPORT: $exportType = 'Export Contact'; break; case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: $exportType = 'Export Contribution'; break; case CRM_Export_Form_Select::MEMBER_EXPORT: $exportType = 'Export Membership'; break; case CRM_Export_Form_Select::EVENT_EXPORT: $exportType = 'Export Participant'; break; case CRM_Export_Form_Select::PLEDGE_EXPORT: $exportType = 'Export Pledge'; break; case CRM_Export_Form_Select::CASE_EXPORT: $exportType = 'Export Case'; break; case CRM_Export_Form_Select::GRANT_EXPORT: $exportType = 'Export Grant'; break; case CRM_Export_Form_Select::ACTIVITY_EXPORT: $exportType = 'Export Activity'; break; } $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name'); $this->set('mappingTypeId', $mappingTypeId); $mappings = CRM_Core_BAO_Mapping::getMappings($mappingTypeId); // Remove the mappings to which a user has no permission to use. foreach ($mappings as $mapping_id => $mapping) { if (!CRM_Mappingacl_Acl::hasAccessToMapping($mapping_id)) { unset($mappings[$mapping_id]); } } if (!empty($mappings)) { $this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings); } }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { // If there's a dataSource in the query string, we need to load // the form from the chosen DataSource class if ($this->_dataSourceIsValid) { $this->_dataSourceClassFile = str_replace('_', '/', $this->_dataSource) . ".php"; require_once $this->_dataSourceClassFile; $this->_dataSourceClass = new $this->_dataSource(); $this->_dataSourceClass->buildQuickForm($this); } // Get list of data sources and display them as options $dataSources = $this->_getDataSources(); $this->assign('urlPath', "civicrm/import"); $this->assign('urlPathVar', 'snippet=4'); $this->add('select', 'dataSource', ts('Data Source'), $dataSources, TRUE, array('onchange' => 'buildDataSourceFormBlock(this.value);')); // duplicate handling options $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); $this->addGroup($duplicateOptions, 'onDuplicate', ts('For Duplicate Contacts')); $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name')); $this->assign('savedMapping', $mappingArray); $this->addElement('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); $js = array('onClick' => "buildSubTypes();buildDedupeRules();"); // contact types option $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL, $js); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD, $js); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION, $js); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->addElement('select', 'subType', ts('Subtype')); $this->addElement('select', 'dedupe', ts('Dedupe Rule')); CRM_Core_Form_Date::buildAllowedDateFormats($this); $config = CRM_Core_Config::singleton(); $geoCode = FALSE; if (!empty($config->geocodeMethod)) { $geoCode = TRUE; $this->addElement('checkbox', 'doGeocodeAddress', ts('Lookup mapping info during import?')); } $this->assign('geoCode', $geoCode); $this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2)); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to build mapping form element * */ function buildMapping() { switch ($this->_exportMode) { case CRM_Export_Form_Select::CONTACT_EXPORT: $exportType = 'Export Contact'; break; case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: $exportType = 'Export Contribution'; break; case CRM_Export_Form_Select::MEMBER_EXPORT: $exportType = 'Export Membership'; break; case CRM_Export_Form_Select::EVENT_EXPORT: $exportType = 'Export Participant'; break; case CRM_Export_Form_Select::PLEDGE_EXPORT: $exportType = 'Export Pledge'; break; case CRM_Export_Form_Select::CASE_EXPORT: $exportType = 'Export Case'; break; case CRM_Export_Form_Select::GRANT_EXPORT: $exportType = 'Export Grant'; break; case CRM_Export_Form_Select::ACTIVITY_EXPORT: $exportType = 'Export Activity'; break; } require_once "CRM/Core/BAO/Mapping.php"; $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name'); $this->set('mappingTypeId', $mappingTypeId); $mappings = CRM_Core_BAO_Mapping::getMappings($mappingTypeId); if (!empty($mappings)) { $this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings); } }
/** * Build the form object. * * @return void */ public function buildQuickForm() { $multipleCustomData = CRM_Core_BAO_CustomGroup::getMultipleFieldGroup(); $this->add('select', 'multipleCustomData', ts('Multi-value Custom Data'), array('' => ts('- select -')) + $multipleCustomData, TRUE); //Setting Upload File Size $config = CRM_Core_Config::singleton(); $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE); $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Multi value custom data', 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); $this->setDefaults(array('savedMapping' => $loadeMapping)); } //contact types option $contactOptions = array(); if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Household'), CRM_Import_Parser::CONTACT_HOUSEHOLD); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Organization'), CRM_Import_Parser::CONTACT_ORGANIZATION); } $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to actually build the form - this appears to be entirely code that should be in a shared base class in core * * @return None * @access public */ public function buildQuickForm() { // Setting Upload File Size. $config = CRM_Core_Config::singleton(); // This conditional block is important as the "maxImportFileSize" has been changed to "maxFileSize" // in the newer versions. In order to remove version support, remove this block and // replace by $uploadFileSize = $config->maxFileSize. if (!empty($config->maxImportFileSize)) { $uploadFileSize = $config->maxImportFileSize; } else { $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE); } if ($uploadFileSize >= 8388608) { $uploadFileSize = 8388608; } $uploadSize = round($uploadFileSize / (1024 * 1024), 2); $this->assign('uploadSize', $uploadSize); $this->add('file', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize); $this->setMaxFileSize($uploadFileSize); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); if ($this->isDuplicateOptions) { $duplicateOptions = array(); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE); $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('No Duplicate Checking'), CRM_Import_Parser::DUPLICATE_NOCHECK); $this->addGroup($duplicateOptions, 'onDuplicate', ts('On Duplicate Entries')); } //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', $this->_mappingType, 'name')); $this->assign('savedMapping', $mappingArray); $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); if ($loadedMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadedMapping); $this->setDefaults(array('savedMapping' => $loadedMapping)); } $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); if ($this->_enableContactOptions) { $this->addContactOptions(); } $this->setDefaults(array('contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL)); $this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2)); //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Build mapping form element. */ public function buildMapping() { $exportType = 'Export Relations'; $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name'); $this->set('mappingTypeId', $mappingTypeId); $mappings = CRM_Core_BAO_Mapping::getMappings($mappingTypeId); if (!empty($mappings)) { $this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings); } }