Пример #1
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);
     $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_Member_Import_Parser::ERROR;
     }
     $params =& $this->getActiveFieldParams();
     require_once 'CRM/Import/Parser/Contact.php';
     $errorMessage = null;
     //To check whether start date or join date is provided
     if (!$params['membership_start_date'] && !$params['join_date']) {
         $errorMessage = "Membership Start Date is required to create a memberships.";
         CRM_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_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
                     }
                     break;
                 case 'membership_start_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
                         }
                     } else {
                         CRM_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_Import_Parser_Contact::addToErrorMsg('End date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('End date', $errorMessage);
                     }
                     break;
                 case 'membership_type_id':
                     if (!CRM_Utils_Array::crmInArray($val, CRM_Member_PseudoConstant::membershipType())) {
                         CRM_Import_Parser_Contact::addToErrorMsg('Membership Type', $errorMessage);
                     }
                     break;
                 case 'status_id':
                     if (!CRM_Utils_Array::crmInArray($val, CRM_Member_PseudoConstant::membershipStatus())) {
                         CRM_Import_Parser_Contact::addToErrorMsg('Membership Status', $errorMessage);
                     }
                     break;
                 case 'email':
                     if (!CRM_Utils_Rule::email($val)) {
                         CRM_Import_Parser_Contact::addToErrorMsg('Email Address', $errorMessage);
                     }
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Membership';
     //checking error in custom data
     CRM_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_Member_Import_Parser::VALID;
 }
Пример #2
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);
     $errorRequired = false;
     $index = -1;
     if ($this->_eventIndex > -1 && $this->_eventTitleIndex > -1) {
         array_unshift($values, ts('Select either EventID OR Event Title'));
         return CRM_Event_Import_Parser::ERROR;
     } elseif ($this->_eventTitleIndex > -1) {
         $index = $this->_eventTitleIndex;
     } elseif ($this->_eventIndex > -1) {
         $index = $this->_eventIndex;
     }
     $params =& $this->getActiveFieldParams();
     require_once 'CRM/Import/Parser/Contact.php';
     if (!($index < 0 || $this->_participantStatusIndex < 0)) {
         $errorRequired = !CRM_Utils_Array::value($this->_participantStatusIndex, $values);
         if (!$params['event_id'] && !$params['event_title']) {
             CRM_Import_Parser_Contact::addToErrorMsg('Event', $missingField);
         }
         if (!$params['participant_status_id']) {
             CRM_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField);
         }
     } else {
         $errorRequired = true;
         $missingField = null;
         if ($index < 0) {
             CRM_Import_Parser_Contact::addToErrorMsg('Event', $missingField);
         }
         if ($this->_participantStatusIndex < 0) {
             CRM_Import_Parser_Contact::addToErrorMsg('Participant Status', $missingField);
         }
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required field(s) :') . $missingField);
         return CRM_Event_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 (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                 if (!CRM_Utils_Rule::date($params[$key])) {
                     CRM_Import_Parser_Contact::addToErrorMsg('Register Date', $errorMessage);
                 }
             } else {
                 CRM_Import_Parser_Contact::addToErrorMsg('Register Date', $errorMessage);
             }
         } else {
             if ($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_Import_Parser_Contact::addToErrorMsg('Participant Role Id', $errorMessage);
                             break;
                         }
                     }
                 } else {
                     foreach ($val as $role) {
                         if (!CRM_Import_Parser_Contact::in_value(trim($role), $roleIDs)) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Participant Role', $errorMessage);
                             break;
                         }
                     }
                 }
             } else {
                 if ($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_Import_Parser_Contact::addToErrorMsg('Participant Status Id', $errorMessage);
                             break;
                         }
                     } else {
                         if (!CRM_Import_Parser_Contact::in_value($val, $statusIDs)) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Participant Status', $errorMessage);
                             break;
                         }
                     }
                 }
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Participant';
     //checking error in custom data
     CRM_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_Event_Import_Parser::VALID;
 }
 /**
  * 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_Activity_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_Activity_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 = self::formatDate($val, $dateType);
                 if ($dateValue) {
                     $params[$key] = $dateValue;
                 } else {
                     CRM_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
                 }
             }
         } elseif ($key == 'activity_engagement_level' && $val && !CRM_Utils_Rule::positiveInteger($val)) {
             CRM_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_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_Activity_Import_Parser::VALID;
 }
Пример #4
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->_activityNameIndex > -1) {
         array_unshift($values, ts('Please select either Activity Type ID OR Activity Type Label.'));
         return CRM_Activity_Import_Parser::ERROR;
     } elseif ($this->_activityNameIndex > -1) {
         $index = $this->_activityNameIndex;
     } 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_Activity_Import_Parser::ERROR;
     }
     $params =& $this->getActiveFieldParams();
     require_once 'CRM/Import/Parser/Contact.php';
     $errorMessage = null;
     //for date-Formats
     $session =& CRM_Core_Session::singleton();
     $dateType = $session->get("dateTypes");
     $params['source_contact_id'] = $session->get('userID');
     foreach ($params as $key => $val) {
         if ($key == 'activity_date_time') {
             if ($val) {
                 if ($dateType == 1) {
                     if (CRM_Utils_Rule::date($params[$key])) {
                         $params[$key] = CRM_Utils_Date::customFormat($val, '%Y%m%d%H%i');
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
                     }
                 } else {
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
                     }
                 }
             }
         }
     }
     //date-Format part ends
     //checking error in custom data
     $params['contact_type'] = $this->_contactType;
     CRM_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_Activity_Import_Parser::VALID;
 }
 /**
  * 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);
     $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 (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Receive Date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Receive Date', $errorMessage);
                     }
                     break;
                 case 'cancel_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Cancel Date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Cancel Date', $errorMessage);
                     }
                     break;
                 case 'receipt_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Receipt date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Receipt date', $errorMessage);
                     }
                     break;
                 case 'thankyou_date':
                     if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
                         if (!CRM_Utils_Rule::date($params[$key])) {
                             CRM_Import_Parser_Contact::addToErrorMsg('Thankyou Date', $errorMessage);
                         }
                     } else {
                         CRM_Import_Parser_Contact::addToErrorMsg('Thankyou Date', $errorMessage);
                     }
                     break;
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = 'Contribution';
     //checking error in custom data
     CRM_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
     if ($errorMessage) {
         $tempMsg = "Invalid value for field(s) : {$errorMessage}";
         array_unshift($values, $tempMsg);
         $errorMessage = NULL;
         return CRM_Contribute_Import_Parser::ERROR;
     }
     return CRM_Contribute_Import_Parser::VALID;
 }
Пример #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);
     /*if ($response != CRM_Contribute_Import_Parser::VALID) {
           array_unshift($values, ts('Invalid field value: %1', array(1 => $this->_activeFields[$erroneousField]->_title)));
           return CRM_Contribute_Import_Parser::ERROR;
       }*/
     $errorRequired = false;
     if ($this->_totalAmountIndex < 0 or $this->_contributionTypeIndex < 0) {
         $errorRequired = true;
     } else {
         $errorRequired = !CRM_Utils_Array::value($this->_totalAmountIndex, $values) || !CRM_Utils_Array::value($this->_contributionTypeIndex, $values);
     }
     if ($errorRequired) {
         array_unshift($values, ts('Missing required fields'));
         return CRM_CONTRIBUTE_IMPORT_PARSER_ERROR;
     }
     $params =& $this->getActiveFieldParams();
     require_once 'CRM/Import/Parser/Contact.php';
     $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':
                     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
                     if (!CRM_Utils_Rule::date($params[$key])) {
                         //return _crm_error('Invalid value for field  : Receive Date');
                         CRM_Import_Parser_Contact::addToErrorMsg('Receive Date', $errorMessage);
                     }
                     break;
                 case 'cancel_date':
                     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
                     if (!CRM_Utils_Rule::date($params[$key])) {
                         //return _crm_error('Invalid value for field  : Cancel Date');
                         CRM_Import_Parser_Contact::addToErrorMsg('Cancel Date', $errorMessage);
                     }
                     break;
                 case 'receipt_date':
                     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
                     if (!CRM_Utils_Rule::date($params[$key])) {
                         //return _crm_error('Invalid value for field  : Activity Date');
                         CRM_Import_Parser_Contact::addToErrorMsg('Receipt date', $errorMessage);
                     }
                     break;
                 case 'thankyou_date':
                     CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
                     if (!CRM_Utils_Rule::date($params[$key])) {
                         //return _crm_error('Invalid value for field  : Thankyou Date');
                         CRM_Import_Parser_Contact::addToErrorMsg('Thankyou Date', $errorMessage);
                     }
                     break;
             }
         }
     }
     //date-Format part ends
     $params['contact_type'] = $this->_contactType;
     //checking error in custom data
     CRM_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_CONTRIBUTE_IMPORT_PARSER_VALID;
 }