Ejemplo n.º 1
0
 /**
  * The summary function is a magic & mystical function I have only partially made sense of but note that
  * it makes a call to setActiveFieldValues - without which import won't work - so it's more than just a presentation
  * function
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * It is called from both the preview & the import actions
  * (non-PHP doc)
  * @see CRM_Csvimport_Import_Parser_BaseClass::summary()
  */
 function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $errorRequired = FALSE;
     $missingField = '';
     $this->_params =& $this->getActiveFieldParams();
     foreach ($this->_requiredFields as $requiredField) {
         if (empty($this->_params[$requiredField])) {
             $errorRequired = TRUE;
             $missingField .= ' ' . $requiredField;
             CRM_Contact_Import_Parser_Contact::addToErrorMsg($this->_entity, $requiredField);
         }
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required field(s) :') . $missingField);
         return CRM_Import_Parser::ERROR;
     }
     $errorMessage = NULL;
     //@todo add a validate fn to the apis so that we can dry run against them to check
     // pseudoconstants
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }
Ejemplo n.º 2
0
 /**
  * The summary function is a magic & mystical function
  * it makes a call to setActiveFieldValues - without which import won't work
  * function
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * It is called from both the preview & the import actions
  * (non-PHPdoc)
  * @see CRM_Hrjobcontract_Import_Parser_BaseClass::summary()
  */
 function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $errorRequired = FALSE;
     $missingField = '';
     $errorMessage = NULL;
     $errorMessages = array();
     return CRM_Import_Parser::VALID;
     ///TODO!
     foreach ($this->_entity as $entity) {
         $this->_params = $this->getActiveFieldParams();
         foreach ($this->_requiredFields as $requiredFieldKey => $requiredFieldVal) {
             // TODO: code below is TEMPORARY!
             if ($requiredFieldVal === 'jobcontract_id') {
                 continue;
             }
             if (empty($this->_params[$requiredFieldVal])) {
                 $errorRequired = TRUE;
                 $missingField .= ' ' . $requiredFieldVal;
                 //// TODO: BUG? previously: $requiredField;
                 CRM_Contact_Import_Parser_Contact::addToErrorMsg($entity, $requiredFieldVal);
             }
         }
         //checking error in core data
         $this->isErrorInCoreData($this->_params, $errorMessage);
         if ($errorMessage) {
             $errorMessages[] = $errorMessage;
             $tempMsg = "Invalid value for field(s) : {$errorMessage}";
             CRM_Contact_Import_Parser_Contact::addToErrorMsg($entity, $errorMessage);
         }
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required field(s) :') . $missingField);
         return CRM_Import_Parser::ERROR;
     }
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }
Ejemplo n.º 3
0
 /**
  * handle the values in import mode
  *
  * @param int $onDuplicate the code for what action to take on duplicates
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function import($onDuplicate, &$values)
 {
     try {
         // first make sure this is a valid line
         $response = $this->summary($values);
         if ($response != CRM_Import_Parser::VALID) {
             return $response;
         }
         $params =& $this->getActiveFieldParams();
         //assign join date equal to start date if join date is not provided
         if (!CRM_Utils_Array::value('join_date', $params) && CRM_Utils_Array::value('membership_start_date', $params)) {
             $params['join_date'] = $params['membership_start_date'];
         }
         $session = CRM_Core_Session::singleton();
         $dateType = $session->get('dateTypes');
         $formatted = array();
         $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
         // don't add to recent items, CRM-4399
         $formatted['skipRecentView'] = TRUE;
         $dateLabels = array('join_date' => ts('Member Since'), 'membership_start_date' => ts('Start Date'), 'membership_end_date' => ts('End Date'));
         foreach ($params as $key => $val) {
             if ($val) {
                 switch ($key) {
                     case 'join_date':
                     case 'membership_start_date':
                     case 'membership_end_date':
                         if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                             if (!CRM_Utils_Rule::date($params[$key])) {
                                 CRM_Contact_Import_Parser_Contact::addToErrorMsg($dateLabels[$key], $errorMessage);
                             }
                         } else {
                             CRM_Contact_Import_Parser_Contact::addToErrorMsg($dateLabels[$key], $errorMessage);
                         }
                         break;
                     case 'membership_type_id':
                         if (!is_numeric($val)) {
                             unset($params['membership_type_id']);
                             $params['membership_type'] = $val;
                         }
                         break;
                     case 'status_id':
                         if (!is_numeric($val)) {
                             unset($params['status_id']);
                             $params['membership_status'] = $val;
                         }
                         break;
                     case 'is_override':
                         $params[$key] = CRM_Utils_String::strtobool($val);
                         break;
                 }
                 if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
                     if ($customFields[$customFieldID]['data_type'] == 'Date') {
                         CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
                         unset($params[$key]);
                     } else {
                         if ($customFields[$customFieldID]['data_type'] == 'Boolean') {
                             $params[$key] = CRM_Utils_String::strtoboolstr($val);
                         }
                     }
                 }
             }
         }
         //date-Format part ends
         static $indieFields = NULL;
         if ($indieFields == NULL) {
             $tempIndieFields = CRM_Member_DAO_Membership::import();
             $indieFields = $tempIndieFields;
         }
         $formatValues = array();
         foreach ($params as $key => $field) {
             if ($field == NULL || $field === '') {
                 continue;
             }
             $formatValues[$key] = $field;
         }
         //format params to meet api v2 requirements.
         //@todo find a way to test removing this formatting
         $formatError = $this->membership_format_params($formatValues, $formatted, TRUE);
         if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
             $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, NULL, 'Membership');
         } else {
             //fix for CRM-2219 Update Membership
             // onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
             if (CRM_Utils_Array::value('is_override', $formatted) && !CRM_Utils_Array::value('status_id', $formatted)) {
                 array_unshift($values, 'Required parameter missing: Status');
                 return CRM_Import_Parser::ERROR;
             }
             if (!empty($formatValues['membership_id'])) {
                 $dao = new CRM_Member_BAO_Membership();
                 $dao->id = $formatValues['membership_id'];
                 $dates = array('join_date', 'start_date', 'end_date');
                 foreach ($dates as $v) {
                     if (!CRM_Utils_Array::value($v, $formatted)) {
                         $formatted[$v] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $formatValues['membership_id'], $v);
                     }
                 }
                 $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, $formatValues['membership_id'], 'Membership');
                 if ($dao->find(TRUE)) {
                     $ids = array('membership' => $formatValues['membership_id'], 'userId' => $session->get('userID'));
                     $newMembership = CRM_Member_BAO_Membership::create($formatted, $ids, TRUE);
                     if (civicrm_error($newMembership)) {
                         array_unshift($values, $newMembership['is_error'] . ' for Membership ID ' . $formatValues['membership_id'] . '. Row was skipped.');
                         return CRM_Import_Parser::ERROR;
                     } else {
                         $this->_newMemberships[] = $newMembership->id;
                         return CRM_Import_Parser::VALID;
                     }
                 } else {
                     array_unshift($values, 'Matching Membership record not found for Membership ID ' . $formatValues['membership_id'] . '. Row was skipped.');
                     return CRM_Import_Parser::ERROR;
                 }
             }
         }
         //Format dates
         $startDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $formatted), '%Y-%m-%d');
         $endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $formatted), '%Y-%m-%d');
         $joinDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $formatted), '%Y-%m-%d');
         if ($this->_contactIdIndex < 0) {
             //retrieve contact id using contact dedupe rule
             $formatValues['contact_type'] = $this->_contactType;
             $formatValues['version'] = 3;
             require_once 'CRM/Utils/DeprecatedUtils.php';
             $error = _civicrm_api3_deprecated_check_contact_dedupe($formatValues);
             if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
                 $matchedIDs = explode(',', $error['error_message']['params'][0]);
                 if (count($matchedIDs) > 1) {
                     array_unshift($values, 'Multiple matching contact records detected for this row. The membership was not imported');
                     return CRM_Import_Parser::ERROR;
                 } else {
                     $cid = $matchedIDs[0];
                     $formatted['contact_id'] = $cid;
                     //fix for CRM-1924
                     $calcDates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($formatted['membership_type_id'], $joinDate, $startDate, $endDate);
                     self::formattedDates($calcDates, $formatted);
                     //fix for CRM-3570, exclude the statuses those having is_admin = 1
                     //now user can import is_admin if is override is true.
                     $excludeIsAdmin = FALSE;
                     if (!CRM_Utils_Array::value('is_override', $formatted)) {
                         $formatted['exclude_is_admin'] = $excludeIsAdmin = TRUE;
                     }
                     $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', $excludeIsAdmin, $formatted['membership_type_id'], $formatted);
                     if (!CRM_Utils_Array::value('status_id', $formatted)) {
                         $formatted['status_id'] = $calcStatus['id'];
                     } elseif (!CRM_Utils_Array::value('is_override', $formatted)) {
                         if (empty($calcStatus)) {
                             array_unshift($values, 'Status in import row (' . $formatValues['status_id'] . ') does not match calculated status based on your configured Membership Status Rules. Record was not imported.');
                             return CRM_Import_Parser::ERROR;
                         } elseif ($formatted['status_id'] != $calcStatus['id']) {
                             //Status Hold" is either NOT mapped or is FALSE
                             array_unshift($values, 'Status in import row (' . $formatValues['status_id'] . ') does not match calculated status based on your configured Membership Status Rules (' . $calcStatus['name'] . '). Record was not imported.');
                             return CRM_Import_Parser::ERROR;
                         }
                     }
                     $newMembership = civicrm_api3('membership', 'create', $formatted);
                     $this->_newMemberships[] = $newMembership['id'];
                     return CRM_Import_Parser::VALID;
                 }
             } else {
                 // Using new Dedupe rule.
                 $ruleParams = array('contact_type' => $this->_contactType, 'used' => 'Unsupervised');
                 $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
                 $disp = '';
                 foreach ($fieldsArray as $value) {
                     if (array_key_exists(trim($value), $params)) {
                         $paramValue = $params[trim($value)];
                         if (is_array($paramValue)) {
                             $disp .= $params[trim($value)][0][trim($value)] . " ";
                         } else {
                             $disp .= $params[trim($value)] . " ";
                         }
                     }
                 }
                 if (CRM_Utils_Array::value('external_identifier', $params)) {
                     if ($disp) {
                         $disp .= "AND {$params['external_identifier']}";
                     } else {
                         $disp = $params['external_identifier'];
                     }
                 }
                 array_unshift($values, 'No matching Contact found for (' . $disp . ')');
                 return CRM_Import_Parser::ERROR;
             }
         } else {
             if (CRM_Utils_Array::value('external_identifier', $formatValues)) {
                 $checkCid = new CRM_Contact_DAO_Contact();
                 $checkCid->external_identifier = $formatValues['external_identifier'];
                 $checkCid->find(TRUE);
                 if ($checkCid->id != $formatted['contact_id']) {
                     array_unshift($values, 'Mismatch of External identifier :' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
                     return CRM_Import_Parser::ERROR;
                 }
             }
             //to calculate dates
             $calcDates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($formatted['membership_type_id'], $joinDate, $startDate, $endDate);
             self::formattedDates($calcDates, $formatted);
             //end of date calculation part
             //fix for CRM-3570, exclude the statuses those having is_admin = 1
             //now user can import is_admin if is override is true.
             $excludeIsAdmin = FALSE;
             if (!CRM_Utils_Array::value('is_override', $formatted)) {
                 $formatted['exclude_is_admin'] = $excludeIsAdmin = TRUE;
             }
             $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($startDate, $endDate, $joinDate, 'today', $excludeIsAdmin, $formatted['membership_type_id'], $formatted);
             if (!CRM_Utils_Array::value('status_id', $formatted)) {
                 $formatted['status_id'] = CRM_Utils_Array::value('id', $calcStatus);
             } elseif (!CRM_Utils_Array::value('is_override', $formatted)) {
                 if (empty($calcStatus)) {
                     array_unshift($values, 'Status in import row (' . CRM_Utils_Array::value('status_id', $formatValues) . ') does not match calculated status based on your configured Membership Status Rules. Record was not imported.');
                     return CRM_Import_Parser::ERROR;
                 } elseif ($formatted['status_id'] != $calcStatus['id']) {
                     //Status Hold" is either NOT mapped or is FALSE
                     array_unshift($values, 'Status in import row (' . CRM_Utils_Array::value('status_id', $formatValues) . ') does not match calculated status based on your configured Membership Status Rules (' . $calcStatus['name'] . '). Record was not imported.');
                     return CRM_Import_Parser::ERROR;
                 }
             }
             $newMembership = civicrm_api3('membership', 'create', $formatted);
             $this->_newMemberships[] = $newMembership['id'];
             return CRM_Import_Parser::VALID;
         }
     } catch (Exception $e) {
         array_unshift($values, $e->getMessage());
         return CRM_Import_Parser::ERROR;
     }
 }
Ejemplo n.º 4
0
 /**
  * Handle the values in summary mode.
  *
  * @param array $values
  *   The array of values belonging to this line.
  *
  * @return bool
  *   the result of this processing
  */
 public function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $errorRequired = FALSE;
     $index = -1;
     if ($this->_eventIndex > -1 && $this->_eventTitleIndex > -1) {
         array_unshift($values, ts('Select either EventID OR Event Title'));
         return CRM_Import_Parser::ERROR;
     } elseif ($this->_eventTitleIndex > -1) {
         $index = $this->_eventTitleIndex;
     } elseif ($this->_eventIndex > -1) {
         $index = $this->_eventIndex;
     }
     $params =& $this->getActiveFieldParams();
     if (!($index < 0 || $this->_participantStatusIndex < 0)) {
         $errorRequired = !CRM_Utils_Array::value($this->_participantStatusIndex, $values);
         if (empty($params['event_id']) && empty($params['event_title'])) {
             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Event', $missingField);
         }
         if (empty($params['participant_status_id'])) {
             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField);
         }
     } else {
         $errorRequired = TRUE;
         $missingField = NULL;
         if ($index < 0) {
             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Event', $missingField);
         }
         if ($this->_participantStatusIndex < 0) {
             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField);
         }
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required field(s) :') . $missingField);
         return CRM_Import_Parser::ERROR;
     }
     $errorMessage = NULL;
     //for date-Formats
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get('dateTypes');
     foreach ($params as $key => $val) {
         if ($val && $key == 'participant_register_date') {
             if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) {
                 $params[$key] = $dateValue;
             } else {
                 CRM_Contact_Import_Parser_Contact::addToErrorMsg('Register Date', $errorMessage);
             }
         } elseif ($val && ($key == 'participant_role_id' || $key == 'participant_role')) {
             $roleIDs = CRM_Event_PseudoConstant::participantRole();
             $val = explode(',', $val);
             if ($key == 'participant_role_id') {
                 foreach ($val as $role) {
                     if (!in_array(trim($role), array_keys($roleIDs))) {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Role Id', $errorMessage);
                         break;
                     }
                 }
             } else {
                 foreach ($val as $role) {
                     if (!CRM_Contact_Import_Parser_Contact::in_value(trim($role), $roleIDs)) {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Role', $errorMessage);
                         break;
                     }
                 }
             }
         } elseif ($val && ($key == 'participant_status_id' || $key == 'participant_status')) {
             $statusIDs = CRM_Event_PseudoConstant::participantStatus();
             if ($key == 'participant_status_id') {
                 if (!in_array(trim($val), array_keys($statusIDs))) {
                     CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status Id', $errorMessage);
                     break;
                 }
             } elseif (!CRM_Contact_Import_Parser_Contact::in_value($val, $statusIDs)) {
                 CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status', $errorMessage);
                 break;
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Participant';
     //checking error in custom data
     CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }
Ejemplo n.º 5
0
 /**
  * Handle the values in summary mode.
  *
  * @param array $values
  *   The array of values belonging to this line.
  *
  * @return bool
  *   the result of this processing
  */
 public function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $params =& $this->getActiveFieldParams();
     $errorMessage = NULL;
     //for date-Formats
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get('dateTypes');
     foreach ($params as $key => $val) {
         if ($val) {
             switch ($key) {
                 case 'receive_date':
                     if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) {
                         $params[$key] = $dateValue;
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Receive Date', $errorMessage);
                     }
                     break;
                 case 'cancel_date':
                     if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) {
                         $params[$key] = $dateValue;
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Cancel Date', $errorMessage);
                     }
                     break;
                 case 'receipt_date':
                     if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) {
                         $params[$key] = $dateValue;
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Receipt date', $errorMessage);
                     }
                     break;
                 case 'thankyou_date':
                     if ($dateValue = CRM_Utils_Date::formatDate($params[$key], $dateType)) {
                         $params[$key] = $dateValue;
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Thankyou Date', $errorMessage);
                     }
                     break;
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Contribution';
     //checking error in custom data
     CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }
Ejemplo n.º 6
0
 /**
  * handle the values in summary mode
  *
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $index = -1;
     $errorRequired = FALSE;
     if ($this->_activityTypeIndex > -1 && $this->_activityLabelIndex > -1) {
         array_unshift($values, ts('Please select either Activity Type ID OR Activity Type Label.'));
         return CRM_Import_Parser::ERROR;
     } elseif ($this->_activityLabelIndex > -1) {
         $index = $this->_activityLabelIndex;
     } elseif ($this->_activityTypeIndex > -1) {
         $index = $this->_activityTypeIndex;
     }
     if ($index < 0 or $this->_activityDateIndex < 0) {
         $errorRequired = TRUE;
     } else {
         $errorRequired = !CRM_Utils_Array::value($index, $values) || !CRM_Utils_Array::value($this->_activityDateIndex, $values);
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required fields'));
         return CRM_Import_Parser::ERROR;
     }
     $params =& $this->getActiveFieldParams();
     $errorMessage = NULL;
     //for date-Formats
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get('dateTypes');
     if (!isset($params['source_contact_id'])) {
         $params['source_contact_id'] = $session->get('userID');
     }
     foreach ($params as $key => $val) {
         if ($key == 'activity_date_time') {
             if ($val) {
                 $dateValue = CRM_Utils_Date::formatDate($val, $dateType);
                 if ($dateValue) {
                     $params[$key] = $dateValue;
                 } else {
                     CRM_Contact_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
                 }
             }
         } elseif ($key == 'activity_engagement_level' && $val && !CRM_Utils_Rule::positiveInteger($val)) {
             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Activity Engagement Index', $errorMessage);
         }
     }
     //date-Format part ends
     //checking error in custom data
     $params['contact_type'] = isset($this->_contactType) ? $this->_contactType : 'Activity';
     CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }
Ejemplo n.º 7
0
 /**
  * @param array $values
  *   The array of values belonging to this line.
  *
  * @return bool
  *   the result of this processing
  *   It is called from both the preview & the import actions
  *
  * @see CRM_Custom_Import_Parser_BaseClass::summary()
  */
 public function summary(&$values)
 {
     $erroneousField = NULL;
     $response = $this->setActiveFieldValues($values, $erroneousField);
     $errorRequired = FALSE;
     $missingField = '';
     $this->_params =& $this->getActiveFieldParams();
     $formatted = $this->_params;
     $this->_updateWithId = FALSE;
     $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE);
     $this->_params = $this->getActiveFieldParams();
     foreach ($this->_requiredFields as $requiredField) {
         if (empty($this->_params[$requiredField])) {
             $errorRequired = TRUE;
             $missingField .= ' ' . $requiredField;
             CRM_Contact_Import_Parser_Contact::addToErrorMsg($this->_entity, $requiredField);
         }
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required field(s) :') . $missingField);
         return CRM_Import_Parser::ERROR;
     }
     $errorMessage = NULL;
     $contactType = $this->_contactType ? $this->_contactType : 'Organization';
     CRM_Contact_Import_Parser_Contact::isErrorInCustomData($this->_params, $errorMessage, $contactType, NULL);
     // pseudoconstants
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Import_Parser::ERROR;
     }
     return CRM_Import_Parser::VALID;
 }