/** * Process the uploaded file. * * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $exportParams = $this->controller->exportValues('Select'); $currentPath = CRM_Utils_System::currentPath(); $urlParams = NULL; $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams = "&qfKey={$qfKey}"; } //get the button name $buttonName = $this->controller->getButtonName('done'); $buttonName1 = $this->controller->getButtonName('next'); if ($buttonName == '_qf_Map_done') { $this->set('exportColumnCount', NULL); $this->controller->resetPage($this->_name); return CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, 'force=1' . $urlParams)); } if ($this->controller->exportValue($this->_name, 'addMore')) { $this->set('exportColumnCount', $this->_exportColumnCount); return; } $mapperKeys = $params['mapper'][1]; $checkEmpty = 0; foreach ($mapperKeys as $value) { if ($value[0]) { $checkEmpty++; } } if (!$checkEmpty) { $this->set('mappingId', NULL); CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true' . $urlParams)); } if ($buttonName1 == '_qf_Map_next') { if (!empty($params['updateMapping'])) { //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($params, $params['mappingId']); } if (!empty($params['saveMapping'])) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($params, $saveMapping->id); } } //get the csv file CRM_Export_BAO_Export_Relationship::exportComponents($this->get('selectAll'), $this->get('componentIds'), $this->get('queryParams'), $this->get(CRM_Utils_Sort::SORT_ORDER), $mapperKeys, $this->get('returnProperties'), $this->get('exportMode'), $this->get('componentClause'), $this->get('componentTable'), $this->get('mergeSameAddress'), $this->get('mergeSameHousehold'), $exportParams); }
/** * Process the mapped fields and map it into the uploaded file * preview the file and extract some summary statistics * * @return void */ public function postProcess() { $params = $this->controller->exportValues('MapField'); //reload the mapfield if load mapping is pressed if (!empty($params['savedMapping'])) { $this->set('savedMapping', $params['savedMapping']); $this->controller->resetPage($this->_name); return; } $fileName = $this->controller->exportValue('DataSource', 'uploadFile'); $seperator = $this->controller->exportValue('DataSource', 'fieldSeparator'); $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); $mapperKeys = array(); $mapper = array(); $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $mapperKeysMain = array(); $mapperLocType = array(); $mapperPhoneType = array(); for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $mapperKeys[$i][0]; if (!empty($mapperKeys[$i][1]) && is_numeric($mapperKeys[$i][1])) { $mapperLocType[$i] = $mapperKeys[$i][1]; } else { $mapperLocType[$i] = NULL; } if (!empty($mapperKeys[$i][2]) && !is_numeric($mapperKeys[$i][2])) { $mapperPhoneType[$i] = $mapperKeys[$i][2]; } else { $mapperPhoneType[$i] = NULL; } } $this->set('mapper', $mapper); // store mapping Id to display it in the preview page if (!empty($params['mappingId'])) { $this->set('loadMappingId', $params['mappingId']); } //Updating Mapping Records if (!empty($params['updateMapping'])) { $mappingFields = new CRM_Core_DAO_MappingField(); $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); $mappingFieldsId = array(); while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; } } for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); $updateMappingFields->id = $mappingFieldsId[$i]; $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; $mapperKeyParts = explode('_', $mapperKeys[$i][0], 3); $id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL; $first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL; $second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL; $updateMappingFields->name = $mapper[$i]; $updateMappingFields->save(); } } //Saving Mapping Details and Records if (!empty($params['saveMapping'])) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Membership', 'name')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { $saveMappingFields = new CRM_Core_DAO_MappingField(); $saveMappingFields->mapping_id = $saveMapping->id; $saveMappingFields->column_number = $i; $mapperKeyParts = explode('_', $mapperKeys[$i][0], 3); $id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL; $first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL; $second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL; $saveMappingFields->name = $mapper[$i]; $saveMappingFields->save(); } $this->set('savedMapping', $saveMappingFields->mapping_id); } $parser = new CRM_Member_Import_Parser_Membership($mapperKeysMain, $mapperLocType, $mapperPhoneType); $parser->run($fileName, $seperator, $mapper, $skipColumnHeader, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType')); // add all the necessary variables to the form $parser->set($this); }
/** * Process the mapped fields and map it into the uploaded file * preview the file and extract some summary statistics * * @return void * @access public */ public function postProcess() { $params = $this->controller->exportValues('MapField'); //reload the mapfield if load mapping is pressed if (!empty($params['savedMapping'])) { $this->set('savedMapping', $params['savedMapping']); $this->controller->resetPage($this->_name); return; } $fileName = $this->controller->exportValue('DataSource', 'uploadFile'); $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); $config = CRM_Core_Config::singleton(); $seperator = $config->fieldSeparator; $mapperKeys = array(); $mapper = array(); $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $mapperKeysMain = array(); for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $mapperKeys[$i][0]; } $this->set('mapper', $mapper); // store mapping Id to display it in the preview page $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params)); //Updating Mapping Records if (CRM_Utils_Array::value('updateMapping', $params)) { $mappingFields = new CRM_Core_DAO_MappingField(); $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); $mappingFieldsId = array(); while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; } } for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); $updateMappingFields->id = $mappingFieldsId[$i]; $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); $id = CRM_Utils_Array::value(0, $explodedValues); $first = CRM_Utils_Array::value(1, $explodedValues); $second = CRM_Utils_Array::value(2, $explodedValues); $updateMappingFields->name = $mapper[$i]; $updateMappingFields->save(); } } //Saving Mapping Details and Records if (CRM_Utils_Array::value('saveMapping', $params)) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { $saveMappingFields = new CRM_Core_DAO_MappingField(); $saveMappingFields->mapping_id = $saveMapping->id; $saveMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); $id = CRM_Utils_Array::value(0, $explodedValues); $first = CRM_Utils_Array::value(1, $explodedValues); $second = CRM_Utils_Array::value(2, $explodedValues); $saveMappingFields->name = $mapper[$i]; $saveMappingFields->save(); } $this->set('savedMapping', $saveMappingFields->mapping_id); } $parser = new CRM_Event_Import_Parser_Participant($mapperKeysMain); $parser->run($fileName, $seperator, $mapper, $skipColumnHeader, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType')); // add all the necessary variables to the form $parser->set($this); }
/** * Process the mapped fields and map it into the uploaded file preview the file and extract some summary statistics. */ public function postProcess() { $params = $this->controller->exportValues('MapField'); //reload the mapfield if load mapping is pressed if (!empty($params['savedMapping'])) { $this->set('savedMapping', $params['savedMapping']); $this->controller->resetPage($this->_name); return; } $fileName = $this->controller->exportValue('DataSource', 'uploadFile'); $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); $config = CRM_Core_Config::singleton(); $seperator = $config->fieldSeparator; $mapper = $mapperKeys = $mapperKeysMain = $mapperSoftCredit = $softCreditFields = $mapperPhoneType = $mapperSoftCreditType = array(); $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type'); for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $mapperKeys[$i][0]; if (isset($mapperKeys[$i][0]) && $mapperKeys[$i][0] == 'soft_credit') { $mapperSoftCredit[$i] = $mapperKeys[$i][1]; if (strpos($mapperSoftCredit[$i], '_') !== FALSE) { list($first, $second) = explode('_', $mapperSoftCredit[$i]); $softCreditFields[$i] = ucwords($first . " " . $second); } else { $softCreditFields[$i] = $mapperSoftCredit[$i]; } $mapperSoftCreditType[$i] = array('value' => isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : '', 'label' => isset($softCreditTypes[$mapperKeys[$i][2]]) ? $softCreditTypes[$mapperKeys[$i][2]] : ''); } else { $mapperSoftCredit[$i] = $softCreditFields[$i] = $mapperSoftCreditType[$i] = NULL; } } $this->set('mapper', $mapper); $this->set('softCreditFields', $softCreditFields); $this->set('mapperSoftCreditType', $mapperSoftCreditType); // store mapping Id to display it in the preview page $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params)); //Updating Mapping Records if (!empty($params['updateMapping'])) { $mappingFields = new CRM_Core_DAO_MappingField(); $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); $mappingFieldsId = array(); while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; } } for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); $updateMappingFields->id = $mappingFieldsId[$i]; $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; $updateMappingFields->name = $mapper[$i]; //reuse contact_type field in db to store fields associated with soft credit $updateMappingFields->contact_type = isset($mapperSoftCredit[$i]) ? $mapperSoftCredit[$i] : NULL; $updateMappingFields->save(); } } //Saving Mapping Details and Records if (!empty($params['saveMapping'])) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { $saveMappingFields = new CRM_Core_DAO_MappingField(); $saveMappingFields->mapping_id = $saveMapping->id; $saveMappingFields->column_number = $i; $saveMappingFields->name = $mapper[$i]; //reuse contact_type field in db to store fields associated with soft credit $saveMappingFields->contact_type = isset($mapperSoftCredit[$i]) ? $mapperSoftCredit[$i] : NULL; $saveMappingFields->save(); } $this->set('savedMapping', $saveMappingFields->mapping_id); } $parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeysMain, $mapperSoftCredit, $mapperPhoneType); $parser->run($fileName, $seperator, $mapper, $skipColumnHeader, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType')); // add all the necessary variables to the form $parser->set($this); }
/** * Process the mapped fields and map it into the uploaded file. */ public function postProcess() { $params = $this->controller->exportValues('MapField'); //reload the mapfield if load mapping is pressed if (!empty($params['savedMapping'])) { $this->set('savedMapping', $params['savedMapping']); $this->controller->resetPage($this->_name); return; } $mapper = array(); $mapperKeys = array(); $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $mapperKeysMain = array(); $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); //these mapper params need to set key as array and val as null. $mapperParams = array('related' => 'relatedVal', 'locations' => 'locationsVal', 'mapperLocType' => 'mapperLocTypeVal', 'mapperPhoneType' => 'mapperPhoneTypeVal', 'mapperImProvider' => 'mapperImProviderVal', 'mapperWebsiteType' => 'mapperWebsiteTypeVal', 'relatedContactType' => 'relatedContactTypeVal', 'relatedContactDetails' => 'relatedContactDetailsVal', 'relatedContactLocType' => 'relatedContactLocTypeVal', 'relatedContactPhoneType' => 'relatedContactPhoneTypeVal', 'relatedContactImProvider' => 'relatedContactImProviderVal', 'relatedContactWebsiteType' => 'relatedContactWebsiteTypeVal'); //set respective mapper params to array. foreach (array_keys($mapperParams) as $mapperParam) { ${$mapperParam} = array(); } for ($i = 0; $i < $this->_columnCount; $i++) { //set respective mapper value to null foreach (array_values($mapperParams) as $mapperParam) { ${$mapperParam} = NULL; } $fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]); $selOne = CRM_Utils_Array::value(1, $mapperKeys[$i]); $selTwo = CRM_Utils_Array::value(2, $mapperKeys[$i]); $selThree = CRM_Utils_Array::value(3, $mapperKeys[$i]); $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $fldName; //need to differentiate non location elements. if ($selOne && is_numeric($selOne)) { if ($fldName == 'url') { $mapperWebsiteTypeVal = $websiteTypes[$selOne]; } else { $locationsVal = $locationTypes[$selOne]; $mapperLocTypeVal = $selOne; if ($selTwo && is_numeric($selTwo)) { if ($fldName == 'phone') { $mapperPhoneTypeVal = $phoneTypes[$selTwo]; } elseif ($fldName == 'im') { $mapperImProviderVal = $imProviders[$selTwo]; } } } } //relationship contact mapper info. list($id, $first, $second) = CRM_Utils_System::explode('_', $fldName, 3); if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $relatedVal = $this->_mapperFields[$fldName]; if ($selOne) { if ($selOne == 'url') { $relatedContactWebsiteTypeVal = $websiteTypes[$selTwo]; } else { $relatedContactLocTypeVal = CRM_Utils_Array::value($selTwo, $locationTypes); if ($selThree) { if ($selOne == 'phone') { $relatedContactPhoneTypeVal = $phoneTypes[$selThree]; } elseif ($selOne == 'im') { $relatedContactImProviderVal = $imProviders[$selThree]; } } } //get the related contact type. $relationType = new CRM_Contact_DAO_RelationshipType(); $relationType->id = $id; $relationType->find(TRUE); $relatedContactTypeVal = $relationType->{"contact_type_{$second}"}; $relatedContactDetailsVal = $this->_formattedFieldNames[$relatedContactTypeVal][$selOne]; } } //set the respective mapper param array values. foreach ($mapperParams as $mapperParamKey => $mapperParamVal) { ${$mapperParamKey}[$i] = ${$mapperParamVal}; } } $this->set('columnNames', $this->_columnNames); //set main contact properties. $properties = array('ims' => 'mapperImProvider', 'mapper' => 'mapper', 'phones' => 'mapperPhoneType', 'websites' => 'mapperWebsiteType', 'locations' => 'locations'); foreach ($properties as $propertyName => $propertyVal) { $this->set($propertyName, ${$propertyVal}); } //set related contact propeties. $relProperties = array('related', 'relatedContactType', 'relatedContactDetails', 'relatedContactLocType', 'relatedContactPhoneType', 'relatedContactImProvider', 'relatedContactWebsiteType'); foreach ($relProperties as $relProperty) { $this->set($relProperty, ${$relProperty}); } // store mapping Id to display it in the preview page $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params)); //Updating Mapping Records if (!empty($params['updateMapping'])) { $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $mappingFields = new CRM_Core_DAO_MappingField(); $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); $mappingFieldsId = array(); while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; } } for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); $updateMappingFields->id = CRM_Utils_Array::value($i, $mappingFieldsId); $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; $mapperKeyParts = explode('_', $mapperKeys[$i][0], 3); $id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL; $first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL; $second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL; if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $updateMappingFields->relationship_type_id = $id; $updateMappingFields->relationship_direction = "{$first}_{$second}"; $updateMappingFields->name = ucwords(str_replace("_", " ", $mapperKeys[$i][1])); // get phoneType id and provider id separately // before updating mappingFields of phone and IM for related contact, CRM-3140 if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'url') { $updateMappingFields->website_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } else { if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') { $updateMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL; } elseif (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') { $updateMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL; } $updateMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } } else { $updateMappingFields->name = $mapper[$i]; $updateMappingFields->relationship_type_id = 'NULL'; $updateMappingFields->relationship_type_direction = 'NULL'; // to store phoneType id and provider id separately // before updating mappingFields for phone and IM, CRM-3140 if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'url') { $updateMappingFields->website_type_id = isset($mapperKeys[$i][1]) ? $mapperKeys[$i][1] : NULL; } else { if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') { $updateMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } elseif (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') { $updateMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } $location = array_keys($locationTypes, $locations[$i]); $updateMappingFields->location_type_id = isset($location) && isset($location[0]) ? $location[0] : NULL; } } $updateMappingFields->save(); } } //Saving Mapping Details and Records if (!empty($params['saveMapping'])) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $contactType = $this->get('contactType'); switch ($contactType) { case CRM_Import_Parser::CONTACT_INDIVIDUAL: $cType = 'Individual'; break; case CRM_Import_Parser::CONTACT_HOUSEHOLD: $cType = 'Household'; break; case CRM_Import_Parser::CONTACT_ORGANIZATION: $cType = 'Organization'; } for ($i = 0; $i < $this->_columnCount; $i++) { $saveMappingFields = new CRM_Core_DAO_MappingField(); $saveMappingFields->mapping_id = $saveMapping->id; $saveMappingFields->contact_type = $cType; $saveMappingFields->column_number = $i; $mapperKeyParts = explode('_', $mapperKeys[$i][0], 3); $id = isset($mapperKeyParts[0]) ? $mapperKeyParts[0] : NULL; $first = isset($mapperKeyParts[1]) ? $mapperKeyParts[1] : NULL; $second = isset($mapperKeyParts[2]) ? $mapperKeyParts[2] : NULL; if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $saveMappingFields->name = ucwords(str_replace("_", " ", $mapperKeys[$i][1])); $saveMappingFields->relationship_type_id = $id; $saveMappingFields->relationship_direction = "{$first}_{$second}"; // to get phoneType id and provider id separately // before saving mappingFields of phone and IM for related contact, CRM-3140 if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'url') { $saveMappingFields->website_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } else { if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') { $saveMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL; } elseif (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') { $saveMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : NULL; } $saveMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } } else { $saveMappingFields->name = $mapper[$i]; $location_id = array_keys($locationTypes, $locations[$i]); // to get phoneType id and provider id separately // before saving mappingFields of phone and IM, CRM-3140 if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'url') { $saveMappingFields->website_type_id = isset($mapperKeys[$i][1]) ? $mapperKeys[$i][1] : NULL; } else { if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') { $saveMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } elseif (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') { $saveMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : NULL; } $saveMappingFields->location_type_id = isset($location_id[0]) ? $location_id[0] : NULL; } $saveMappingFields->relationship_type_id = NULL; } $saveMappingFields->save(); } $this->set('savedMapping', $saveMappingFields->mapping_id); } $parser = new CRM_Contact_Import_Parser_Contact($mapperKeysMain, $mapperLocType, $mapperPhoneType, $mapperImProvider, $related, $relatedContactType, $relatedContactDetails, $relatedContactLocType, $relatedContactPhoneType, $relatedContactImProvider, $mapperWebsiteType, $relatedContactWebsiteType); $primaryKeyName = $this->get('primaryKeyName'); $statusFieldName = $this->get('statusFieldName'); $parser->run($this->_importTableName, $mapper, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType'), $primaryKeyName, $statusFieldName, $this->_onDuplicate, NULL, NULL, FALSE, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType'), $this->get('dedupe')); // add all the necessary variables to the form $parser->set($this); }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { // store the submitted values in an array $params = $this->exportValues(); if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id) { CRM_Core_BAO_Mapping::del($this->_id); } } else { if ($this->_id) { $params['id'] = $this->_id; } CRM_Core_BAO_Mapping::add($params); } }
/** * This function create the hidden smart group when user perform * contact seach and want to send mailing to search contacts. * * @param array $params ( reference ) an assoc array of name/value pairs * @return array ( smartGroupId, ssId ) smart group id and saved search id * @access public * @static */ static function createHiddenSmartGroup($params) { $ssId = CRM_Utils_Array::value('saved_search_id', $params); //add mapping record only for search builder saved search $mappingId = null; if ($params['is_advanced'] == '2' && $params['is_searchBuilder'] == '1') { //save the mapping for search builder require_once "CRM/Core/BAO/Mapping.php"; if (!$ssId) { //save record in mapping table $temp = array(); $mappingParams = array('mapping_type' => 'Search Builder'); $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp); $mappingId = $mapping->id; } else { //get the mapping id from saved search require_once "CRM/Contact/BAO/SavedSearch.php"; $savedSearch =& new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $ssId; $savedSearch->find(true); $mappingId = $savedSearch->mapping_id; } //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($params['form_values'], $mappingId); } //create/update saved search record. $savedSearch =& new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $ssId; $savedSearch->form_values = serialize($params['form_values']); $savedSearch->mapping_id = $mappingId; $savedSearch->search_custom_id = CRM_Utils_Array::value('search_custom_id', $params); $savedSearch->save(); $ssId = $savedSearch->id; if (!$ssId) { return null; } $smartGroupId = null; if (CRM_Utils_Array::value('saved_search_id', $params)) { $smartGroupId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $ssId, 'id', 'saved_search_id'); } else { //create group only when new saved search. $groupParams = array('title' => "Hidden Smart Group {$ssId}", 'is_active' => CRM_Utils_Array::value('is_active', $params, 1), 'is_hidden' => CRM_Utils_Array::value('is_hidden', $params, 1), 'group_type' => CRM_Utils_Array::value('group_type', $params), 'visibility' => CRM_Utils_Array::value('visibility', $params), 'saved_search_id' => $ssId); require_once 'CRM/Contact/BAO/Group.php'; $smartGroup = self::create($groupParams); $smartGroupId = $smartGroup->id; } return array($smartGroupId, $ssId); }
/** * Process the mapped fields and map it into the uploaded file * preview the file and extract some summary statistics * * @return void * @access public */ public function postProcess() { $params = $this->controller->exportValues('MapField'); //reload the mapfield if load mapping is pressed if (!empty($params['savedMapping'])) { $this->set('savedMapping', $params['savedMapping']); $this->controller->resetPage($this->_name); return; } $mapperKeys = array(); $mapper = array(); $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $mapperKeysMain = array(); $mapperLocType = array(); $mapperPhoneType = array(); $mapperImProvider = array(); $locations = array(); $phoneTypes = CRM_Core_PseudoConstant::phoneType(); $imProviders = CRM_Core_PseudoConstant::IMProvider(); for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $mapperKeys[$i][0]; if (isset($mapperKeys[$i][1]) && is_numeric($mapperKeys[$i][1])) { $mapperLocType[$i] = $mapperKeys[$i][1]; } else { $mapperLocType[$i] = null; } $locations[$i] = isset($mapperLocType[$i]) ? $this->_location_types[$mapperLocType[$i]] : null; // to store phone_type id and provider id seperately, CRM-3140 if (CRM_Utils_Array::value($i, $mapperKeysMain) == 'phone') { $mapperPhoneType[$i] = $phoneTypes[$mapperKeys[$i][2]]; $mapperImProvider[$i] = null; } else { if (CRM_Utils_Array::value($i, $mapperKeysMain) == 'im') { $mapperImProvider[$i] = $imProviders[$mapperKeys[$i][2]]; $mapperPhoneType[$i] = null; } else { $mapperPhoneType[$i] = null; $mapperImProvider[$i] = null; } } //relationship info if (isset($mapperKeys[$i]) && isset($mapperKeys[$i][0])) { list($id, $first, $second) = CRM_Utils_System::explode('_', $mapperKeys[$i][0], 3); } else { list($id, $first, $second) = array(null, null, null); } if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $related[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $relatedContactLocType[$i] = isset($mapperKeys[$i][1]) ? $this->_location_types[$mapperKeys[$i][2]] : null; //$relatedContactPhoneType[$i] = !is_numeric($mapperKeys[$i][2]) ? $mapperKeys[$i][3] : null; // to store phoneType id and provider id seperately for ralated contact, CRM-3140 if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') { $relatedContactPhoneType[$i] = isset($mapperKeys[$i][3]) ? $phoneTypes[$mapperKeys[$i][3]] : null; $relatedContactImProvider[$i] = null; } else { if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') { $relatedContactImProvider[$i] = isset($mapperKeys[$i][3]) ? $imProviders[$mapperKeys[$i][3]] : null; $relatedContactPhoneType[$i] = null; } } $relationType =& new CRM_Contact_DAO_RelationshipType(); $relationType->id = $id; $relationType->find(true); eval('$relatedContactType[$i] = $relationType->contact_type_' . $second . ';'); $relatedContactDetails[$i] = $this->_formattedFieldNames[$relatedContactType[$i]][$mapperKeys[$i][1]]; } else { $related[$i] = null; $relatedContactType[$i] = null; $relatedContactDetails[$i] = null; $relatedContactLocType[$i] = null; $relatedContactPhoneType[$i] = null; $relatedContactImProvider[$i] = null; } } $this->set('mapper', $mapper); $this->set('locations', $locations); $this->set('phones', $mapperPhoneType); $this->set('ims', $mapperImProvider); $this->set('columnNames', $this->_columnNames); //relationship info $this->set('related', $related); $this->set('relatedContactType', $relatedContactType); $this->set('relatedContactDetails', $relatedContactDetails); $this->set('relatedContactLocType', $relatedContactLocType); $this->set('relatedContactPhoneType', $relatedContactPhoneType); $this->set('relatedContactImProvider', $relatedContactImProvider); // store mapping Id to display it in the preview page $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params)); //Updating Mapping Records if (CRM_Utils_Array::value('updateMapping', $params)) { $locationTypes =& CRM_Core_PseudoConstant::locationType(); $mappingFields =& new CRM_Core_DAO_MappingField(); $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); $mappingFieldsId = array(); while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; } } for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields =& new CRM_Core_DAO_MappingField(); $updateMappingFields->id = $mappingFieldsId[$i]; $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; list($id, $first, $second) = explode('_', $mapperKeys[$i][0]); if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $updateMappingFields->relationship_type_id = $id; $updateMappingFields->relationship_direction = "{$first}_{$second}"; $updateMappingFields->name = ucwords(str_replace("_", " ", $mapperKeys[$i][1])); $updateMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; // get phoneType id and provider id separately // before updating mappingFields of phone and IM for related contact, CRM-3140 if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') { $updateMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : null; } else { if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') { $updateMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : null; } } } else { $updateMappingFields->name = $mapper[$i]; $updateMappingFields->relationship_type_id = null; $location = array_keys($locationTypes, $locations[$i]); $updateMappingFields->location_type_id = isset($location) ? $location[0] : null; // to store phoneType id and provider id seperately // before updating mappingFields for phone and IM, CRM-3140 if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') { $updateMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; } else { if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') { $updateMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; } } } $updateMappingFields->save(); } } //Saving Mapping Details and Records if (CRM_Utils_Array::value('saveMapping', $params)) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); $locationTypes =& CRM_Core_PseudoConstant::locationType(); $contactType = $this->get('contactType'); switch ($contactType) { case CRM_Import_Parser::CONTACT_INDIVIDUAL: $cType = 'Individual'; break; case CRM_Import_Parser::CONTACT_HOUSEHOLD: $cType = 'Household'; break; case CRM_Import_Parser::CONTACT_ORGANIZATION: $cType = 'Organization'; } for ($i = 0; $i < $this->_columnCount; $i++) { $saveMappingFields =& new CRM_Core_DAO_MappingField(); $saveMappingFields->mapping_id = $saveMapping->id; $saveMappingFields->contact_type = $cType; $saveMappingFields->column_number = $i; list($id, $first, $second) = explode('_', $mapperKeys[$i][0]); if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') { $saveMappingFields->name = ucwords(str_replace("_", " ", $mapperKeys[$i][1])); $saveMappingFields->relationship_type_id = $id; $saveMappingFields->relationship_direction = "{$first}_{$second}"; // to get phoneType id and provider id seperately // before saving mappingFields of phone and IM for related contact, CRM-3140 if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'phone') { $saveMappingFields->phone_type_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : null; } else { if (CRM_Utils_Array::value('1', $mapperKeys[$i]) == 'im') { $saveMappingFields->im_provider_id = isset($mapperKeys[$i][3]) ? $mapperKeys[$i][3] : null; } } $saveMappingFields->location_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; } else { $saveMappingFields->name = $mapper[$i]; $location_id = array_keys($locationTypes, $locations[$i]); $saveMappingFields->location_type_id = isset($location_id[0]) ? $location_id[0] : null; // to get phoneType id and provider id seperately // before saving mappingFields of phone and IM, CRM-3140 if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'phone') { $saveMappingFields->phone_type_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; } else { if (CRM_Utils_Array::value('0', $mapperKeys[$i]) == 'im') { $saveMappingFields->im_provider_id = isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : null; } } $saveMappingFields->relationship_type_id = null; } $saveMappingFields->save(); } $this->set('savedMapping', $saveMappingFields->mapping_id); } $parser =& new CRM_Import_Parser_Contact($mapperKeysMain, $mapperLocType, $mapperPhoneType, $mapperImProvider, $related, $relatedContactType, $relatedContactDetails, $relatedContactLocType, $relatedContactPhoneType, $relatedContactImProvider); $primaryKeyName = $this->get('primaryKeyName'); $statusFieldName = $this->get('statusFieldName'); $parser->run($this->_importTableName, $mapper, CRM_Import_Parser::MODE_PREVIEW, $this->get('contactType'), $primaryKeyName, $statusFieldName, $this->_onDuplicate, null, null, false, CRM_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType')); // add all the necessary variables to the form $parser->set($this); }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { // saved search form values // get form values of all the forms in this controller $formValues = $this->controller->exportValues(); $isAdvanced = $this->get('isAdvanced'); $isSearchBuilder = $this->get('isSearchBuilder'); // add mapping record only for search builder saved search $mappingId = NULL; if ($isAdvanced == '2' && $isSearchBuilder == '1') { //save the mapping for search builder if (!$this->_id) { //save record in mapping table $mappingParams = array('mapping_type' => 'Search Builder'); $temp = array(); $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp); $mappingId = $mapping->id; } else { //get the mapping id from saved search $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; $savedSearch->find(TRUE); $mappingId = $savedSearch->mapping_id; } //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId); } //save the search $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; $savedSearch->form_values = serialize($this->get('formValues')); $savedSearch->mapping_id = $mappingId; $savedSearch->search_custom_id = $this->get('customSearchID'); $savedSearch->save(); $this->set('ssID', $savedSearch->id); CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success'); // also create a group that is associated with this saved search only if new saved search $params = array(); $params['title'] = $formValues['title']; $params['description'] = $formValues['description']; if (isset($formValues['group_type']) && is_array($formValues['group_type'])) { $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR; } else { $params['group_type'] = ''; } $params['visibility'] = 'User and User Admin Only'; $params['saved_search_id'] = $savedSearch->id; $params['is_active'] = 1; //CRM-14190 $params['parents'] = $formValues['parents']; if ($this->_id) { $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id'); } $group = CRM_Contact_BAO_Group::create($params); // CRM-9464 $this->_id = $savedSearch->id; //CRM-14190 if (!empty($formValues['parents'])) { CRM_Contact_BAO_GroupNestingCache::update(); } }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { // saved search form values // get form values of all the forms in this controller $formValues = $this->controller->exportValues(); $isAdvanced = $this->get('isAdvanced'); $isSearchBuilder = $this->get('isSearchBuilder'); // add mapping record only for search builder saved search $mappingId = NULL; if ($isAdvanced == '2' && $isSearchBuilder == '1') { //save the mapping for search builder if (!$this->_id) { //save record in mapping table $mappingParams = array('mapping_type' => 'Search Builder'); $temp = array(); $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp); $mappingId = $mapping->id; } else { //get the mapping id from saved search $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; $savedSearch->find(TRUE); $mappingId = $savedSearch->mapping_id; } //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId); } //save the search $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; // Use the query parameters rather than the form values - these have already been assessed / converted // with the extra knowledge that the form has. // Note that we want to move towards a standardised way of saving the query that is not // an exact match for the form requirements & task the form layer with converting backwards and forwards. // Ideally per CRM-17075 we will use entity reference fields heavily in the form layer & convert to the // sql operator syntax at the query layer. $savedSearch->form_values = serialize($this->get('queryParams')); $savedSearch->mapping_id = $mappingId; $savedSearch->search_custom_id = $this->get('customSearchID'); $savedSearch->save(); $this->set('ssID', $savedSearch->id); CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success'); // also create a group that is associated with this saved search only if new saved search $params = array(); $params['title'] = $formValues['title']; $params['description'] = $formValues['description']; if (isset($formValues['group_type']) && is_array($formValues['group_type'])) { $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR; } else { $params['group_type'] = ''; } $params['visibility'] = 'User and User Admin Only'; $params['saved_search_id'] = $savedSearch->id; $params['is_active'] = 1; //CRM-14190 $params['parents'] = $formValues['parents']; if ($this->_id) { $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id'); } $group = CRM_Contact_BAO_Group::create($params); // CRM-9464 $this->_id = $savedSearch->id; //CRM-14190 if (!empty($formValues['parents'])) { CRM_Contact_BAO_GroupNestingCache::update(); } }
/** * process the form after the input has been submitted and validated * * @access public * @return void */ public function postProcess() { // saved search form values // get form values of all the forms in this controller $formValues = $this->controller->exportValues(); $isAdvanced = $this->get('isAdvanced'); $isSearchBuilder = $this->get('isSearchBuilder'); // add mapping record only for search builder saved search $mappingId = null; if ($isAdvanced == '2' && $isSearchBuilder == '1') { //save the mapping for search builder require_once "CRM/Core/BAO/Mapping.php"; if (!$this->_id) { //save record in mapping table $mappingParams = array('mapping_type' => 'Search Builder'); $temp = array(); $mapping = CRM_Core_BAO_Mapping::add($mappingParams, $temp); $mappingId = $mapping->id; } else { //get the mapping id from saved search require_once "CRM/Contact/BAO/SavedSearch.php"; $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; $savedSearch->find(true); $mappingId = $savedSearch->mapping_id; } //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($formValues, $mappingId); } //save the search $savedSearch = new CRM_Contact_BAO_SavedSearch(); $savedSearch->id = $this->_id; $savedSearch->form_values = serialize($this->get('formValues')); $savedSearch->mapping_id = $mappingId; $savedSearch->search_custom_id = $this->get('customSearchID'); $savedSearch->save(); $this->set('ssID', $savedSearch->id); CRM_Core_Session::setStatus(ts('Your smart group has been saved as \'%1\'.', array(1 => $formValues['title']))); // also create a group that is associated with this saved search only if new saved search $params = array(); $params['title'] = $formValues['title']; $params['description'] = $formValues['description']; if (is_array($formValues['group_type'])) { $params['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($formValues['group_type'])) . CRM_Core_DAO::VALUE_SEPARATOR; } else { $params['group_type'] = ''; } $params['visibility'] = 'User and User Admin Only'; $params['saved_search_id'] = $savedSearch->id; $params['is_active'] = 1; if ($this->_id) { $params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id'); } require_once 'CRM/Contact/BAO/Group.php'; $group =& CRM_Contact_BAO_Group::create($params); }
/** * Process the form submission. */ public function postProcess() { // store the submitted values in an array $params = $this->exportValues(); if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id) { CRM_Core_BAO_Mapping::del($this->_id); CRM_Core_Session::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success'); } } else { if ($this->_id) { $params['id'] = $this->_id; } CRM_Core_BAO_Mapping::add($params); } }
/** * Process the uploaded file * * @return void * @access public */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $currentPath = CRM_Utils_System::currentPath(); //get the button name $buttonName = $this->controller->getButtonName('done'); $buttonName1 = $this->controller->getButtonName('next'); if ($buttonName == '_qf_Map_done') { $this->set('exportColumnCount', null); $this->controller->resetPage($this->_name); return CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, 'force=1')); } if ($this->controller->exportValue($this->_name, 'addMore')) { $this->set('exportColumnCount', $this->_exportColumnCount); return; } $mapperKeys = $params['mapper'][1]; $checkEmpty = 0; foreach ($mapperKeys as $value) { if ($value[0]) { $checkEmpty++; } } if (!$checkEmpty) { $this->set('mappingId', null); require_once 'CRM/Utils/System.php'; CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true')); } if ($buttonName1 == '_qf_Map_next') { if (CRM_Utils_Array::value('updateMapping', $params)) { //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($params, $params['mappingId']); } if (CRM_Utils_Array::value('saveMapping', $params)) { $mappingParams = array('name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId')); $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); //save mapping fields CRM_Core_BAO_Mapping::saveMappingFields($params, $saveMapping->id); } } //get the csv file require_once "CRM/Export/BAO/Export.php"; CRM_Export_BAO_Export::exportComponents($this->get('selectAll'), $this->get('componentIds'), $this->get('queryParams'), $this->get(CRM_Utils_Sort::SORT_ORDER), $mapperKeys, $this->get('returnProperties'), $this->get('exportMode'), $this->get('componentClause')); }