/**
  * 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);
     $errorRequired = FALSE;
     if ($this->_membershipTypeIndex < 0) {
         $errorRequired = TRUE;
     } else {
         $errorRequired = !CRM_Utils_Array::value($this->_membershipTypeIndex, $values);
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required fields'));
         return CRM_Import_Parser::ERROR;
     }
     $params =& $this->getActiveFieldParams();
     $errorMessage = NULL;
     //To check whether start date or join date is provided
     if (!CRM_Utils_Array::value('membership_start_date', $params) && !CRM_Utils_Array::value('join_date', $params)) {
         $errorMessage = 'Membership Start Date is required to create a memberships.';
         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
     }
     //end
     //for date-Formats
     $session = CRM_Core_Session::singleton();
     $dateType = $session->get('dateTypes');
     foreach ($params as $key => $val) {
         if ($val) {
             switch ($key) {
                 case 'join_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Member Since', $errorMessage);
                         }
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Member Since', $errorMessage);
                     }
                     break;
                 case 'membership_start_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
                         }
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
                     }
                     break;
                 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('End date', $errorMessage);
                         }
                     } else {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('End date', $errorMessage);
                     }
                     break;
                 case 'membership_type_id':
                     $membershipTypes = CRM_Member_PseudoConstant::membershipType();
                     if (!CRM_Utils_Array::crmInArray($val, $membershipTypes) && !array_key_exists($val, $membershipTypes)) {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Membership Type', $errorMessage);
                     }
                     break;
                 case 'status_id':
                     if (!CRM_Utils_Array::crmInArray($val, CRM_Member_PseudoConstant::membershipStatus())) {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Membership Status', $errorMessage);
                     }
                     break;
                 case 'email':
                     if (!CRM_Utils_Rule::email($val)) {
                         CRM_Contact_Import_Parser_Contact::addToErrorMsg('Email Address', $errorMessage);
                     }
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Membership';
     //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;
 }
Пример #2
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;
 }
Пример #3
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;
 }
Пример #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);
     $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;
 }
Пример #5
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;
 }