/**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', FALSE);
     $this->assign('feeBlockPaid', FALSE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->setPageTitle(ts('Event Registration for %1', array(1 => $displayName)));
     } else {
         $this->setPageTitle(ts('Event Registration'));
     }
     // check the current path, if search based, then dont get participantID
     // CRM-5792
     $path = CRM_Utils_System::currentPath();
     if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) {
         $this->_id = NULL;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     if ($this->_id) {
         $this->assign('participantId', $this->_id);
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
         $this->assign('hasPayment', $this->_paymentId);
         // CRM-12615 - Get payment information from the primary registration
         if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) {
             $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id');
             if ($registered_by_id) {
                 $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id');
                 $this->assign('registeredByParticipantId', $registered_by_id);
             }
         }
     }
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->assignPaymentRelatedVariables();
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', TRUE);
         $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary');
         if ($isMonetary) {
             $this->assign('feeBlockPaid', TRUE);
         }
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_id || $this->_contactId || $this->_context == 'standalone') {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_id && !$this->_contactId) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $context = $this->get('context');
         $urlString = 'civicrm/contact/search';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($context) {
             case 'advanced':
                 $urlString = 'civicrm/contact/search/advanced';
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $urlString = 'civicrm/contact/search/builder';
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'basic':
                 $urlString = 'civicrm/contact/search/basic';
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'custom':
                 $urlString = 'civicrm/contact/search/custom';
                 $this->_action = CRM_Core_Action::COPY;
                 break;
         }
         CRM_Contact_Form_Task::preProcessCommon($this);
         $this->_single = FALSE;
         $this->_contactId = NULL;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', $urlString);
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     if (!$this->_id) {
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     }
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         // check delete permission for contribution
         if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
         return;
     }
     if ($this->_id) {
         // assign participant id to the template
         $this->assign('participantId', $this->_id);
         $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id');
     }
     // when fee amount is included in form
     if (!empty($_POST['hidden_feeblock']) || !empty($_POST['send_receipt'])) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         // Custom data of type participant role
         // Note: Some earlier commits imply $_POST['role_id'] could be a comma separated string,
         //       not sure if that ever really happens
         if (!empty($_POST['role_id'])) {
             foreach ($_POST['role_id'] as $roleID) {
                 CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $roleID, 1, 'Participant', $this->_id);
                 CRM_Custom_Form_CustomData::buildQuickForm($this);
                 CRM_Custom_Form_CustomData::setDefaultValues($this);
             }
         }
         //custom data of type participant event
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         // custom data of type participant event type
         $eventTypeId = NULL;
         if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) {
             $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id');
         }
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Beispiel #2
0
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     parent::preProcess();
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
         // check delete permission for contribution
         if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) {
             // all possible statuses are disabled - redirect back to contact form
             CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured'));
         }
         if ($this->_contactID) {
             //check whether contact has a current membership so we can alert user that they may want to do a renewal instead
             $contactMemberships = array();
             $memParams = array('contact_id' => $this->_contactID);
             CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE);
             $cMemTypes = array();
             foreach ($contactMemberships as $mem) {
                 $cMemTypes[] = $mem['membership_type_id'];
             }
             if (count($cMemTypes) > 0) {
                 $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes);
                 $mems_by_org = array();
                 foreach ($contactMemberships as $memid => $mem) {
                     $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs);
                     if (!empty($mem['membership_end_date'])) {
                         $mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']);
                     }
                     $mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id');
                     $mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id');
                     $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member" . ($this->_mode ? '&mode=live' : ''));
                     $mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member");
                     $mems_by_org[$mem['member_of_contact_id']] = $mem;
                 }
                 $this->assign('existingContactMemberships', $mems_by_org);
             }
         } else {
             // In standalone mode we don't have a contact id yet so lookup will be done client-side with this script:
             $resources = CRM_Core_Resources::singleton();
             $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js');
             $passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id'));
             $resources->addSetting(array('existingMems' => $passthru));
         }
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $this->setPageTitle(ts('Membership'));
 }
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_processors = array();
     CRM_Core_Resources::singleton()->addSetting(array('ids' => array('contact' => $this->_contactID)));
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
         // check delete permission for contribution
         if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_id) {
         $this->_memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'membership_type_id');
         $this->_membershipIDs[] = $this->_id;
     }
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('membershipMode', $this->_mode);
     if ($this->_mode) {
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'billing_mode IN ( 1, 3 )');
         foreach ($processors as $ppID => $label) {
             $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                 continue;
             } else {
                 $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                 $error = $paymentObject->checkConfig();
                 if (empty($error)) {
                     $validProcessors[$ppID] = $label;
                 }
                 $paymentObject = NULL;
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', TRUE);
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) {
             // all possible statuses are disabled - redirect back to contact form
             CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured'));
         }
         if ($this->_contactID) {
             //check whether contact has a current membership so we can alert user that they may want to do a renewal instead
             $contactMemberships = array();
             $memParams = array('contact_id' => $this->_contactID);
             CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE);
             $cMemTypes = array();
             foreach ($contactMemberships as $mem) {
                 $cMemTypes[] = $mem['membership_type_id'];
             }
             if (count($cMemTypes) > 0) {
                 $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes);
                 $mems_by_org = array();
                 foreach ($contactMemberships as $memid => $mem) {
                     $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs);
                     if (CRM_Utils_Array::value('membership_end_date', $mem)) {
                         $mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']);
                     }
                     $mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id');
                     $mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id');
                     if ($this->_mode) {
                         $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member&mode=live");
                     } else {
                         $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member");
                     }
                     $mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member");
                     $mems_by_org[$mem['member_of_contact_id']] = $mem;
                 }
                 $resources = CRM_Core_Resources::singleton();
                 $resources->addSetting(array('existingMems' => array('memberorgs' => $mems_by_org)));
                 $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/Membership.js');
             }
         } else {
             $resources = CRM_Core_Resources::singleton();
             $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js');
             $statuses = array();
             $membershipStatus = new CRM_Member_DAO_MembershipStatus();
             $membershipStatus->is_current_member = 1;
             $membershipStatus->find();
             $membershipStatus->selectAdd();
             $membershipStatus->selectAdd('id');
             while ($membershipStatus->fetch()) {
                 $statuses[$membershipStatus->id] = $membershipStatus->label;
             }
             $membershipStatus->free();
             $passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE), 'statuses' => $statuses);
             $resources->addSetting(array('existingMems' => $passthru));
         }
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     // Set title
     if ($this->_contactID) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
         // Check if this is default domain contact CRM-10482
         if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactID)) {
             $displayName .= ' (' . ts('default organization') . ')';
         }
         // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
         CRM_Utils_System::setTitle(ts('Membership for') . ' ' . $displayName);
     }
     parent::preProcess();
 }
 static function updatePendingOnlineContribution($participantId, $statusId)
 {
     if (!$participantId || !$statusId) {
         return;
     }
     $contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId, 'Event');
     if (!$contributionId) {
         return;
     }
     //status rules.
     //1. participant - positive => contribution - completed.
     //2. participant - negative => contribution - cancelled.
     $positiveStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Positive'");
     $negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $contributionStatusId = NULL;
     if (array_key_exists($statusId, $positiveStatuses)) {
         $contributionStatusId = array_search('Completed', $contributionStatuses);
     }
     if (array_key_exists($statusId, $negativeStatuses)) {
         $contributionStatusId = array_search('Cancelled', $contributionStatuses);
     }
     if (!$contributionStatusId) {
         return;
     }
     $params = array('component_id' => $participantId, 'componentName' => 'Event', 'contribution_id' => $contributionId, 'contribution_status_id' => $contributionStatusId);
     //change related contribution status.
     $updatedStatusId = CRM_Core_Payment_BaseIPN::updateContributionStatus($params);
     return $updatedStatusId;
 }
Beispiel #5
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', false);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', true);
         $this->assign('paid', true);
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_participantId || $this->_contactID || $this->_context == 'standalone') {
         $this->_single = true;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_participantId && !$this->_contactID) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $advanced = null;
         $builder = null;
         $session =& CRM_Core_Session::singleton();
         $advanced = $session->get('isAdvanced');
         $builder = $session->get('isSearchBuilder');
         $searchType = "basic";
         if ($advanced == 1) {
             $this->_action = CRM_Core_Action::ADVANCED;
             $searchType = "advanced";
         } else {
             if ($advanced == 2 && ($builder = 1)) {
                 $this->_action = CRM_Core_Action::PROFILE;
                 $searchType = "builder";
             } else {
                 if ($advanced == 3) {
                     $searchType = "custom";
                 }
             }
         }
         parent::preProcess();
         $this->_single = false;
         $this->_contactID = null;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     if ($this->_participantId) {
         // assign participant id to the template
         $this->assign('participantId', $this->_participantId);
         $this->_roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $this->_participantId, 'role_id');
     }
     // when fee amount is included in form
     if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         //custom data of type participant role
         CRM_Custom_Form_Customdata::preProcess($this, $this->_roleCustomDataTypeID, $_POST['role_id'], 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
         //custom data of type participant event
         CRM_Custom_Form_Customdata::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_Customdata::preProcess($this, 'null', 'null', 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = null;
     if (!$this->_mode && $this->_participantId && $this->_action & CRM_Core_Action::UPDATE) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_participantId, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Beispiel #6
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', FALSE);
     $this->assign('feeBlockPaid', FALSE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
         CRM_Utils_System::setTitle(ts('Event Registration for') . ' ' . $displayName);
     }
     // check the current path, if search based, then dont get participantID
     // CRM-5792
     $path = CRM_Utils_System::currentPath();
     if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) {
         $this->_id = NULL;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     if ($this->_id) {
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
         // CRM-12615 - Get payment information from the primary registration
         if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) {
             $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id');
             if ($registered_by_id) {
                 $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id');
                 $this->assign('registeredByParticipantId', $registered_by_id);
             }
         }
     }
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                 continue;
             } else {
                 $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                 $error = $paymentObject->checkConfig();
                 if (empty($error)) {
                     $validProcessors[$ppID] = $label;
                 }
                 $paymentObject = NULL;
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', TRUE);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', TRUE);
         $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary');
         if ($isMonetary) {
             $this->assign('feeBlockPaid', TRUE);
         }
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, NULL, NULL, NULL, TRUE);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_id || $this->_contactId || $this->_context == 'standalone') {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_id && !$this->_contactId) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $context = $this->get('context');
         $urlString = 'civicrm/contact/search';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($context) {
             case 'advanced':
                 $urlString = 'civicrm/contact/search/advanced';
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $urlString = 'civicrm/contact/search/builder';
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'basic':
                 $urlString = 'civicrm/contact/search/basic';
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'custom':
                 $urlString = 'civicrm/contact/search/custom';
                 $this->_action = CRM_Core_Action::COPY;
                 break;
         }
         parent::preProcess();
         $this->_single = FALSE;
         $this->_contactId = NULL;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', $urlString);
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     if (!$this->_id) {
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     }
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         // check delete permission for contribution
         if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
         return;
     }
     if ($this->_id) {
         // assign participant id to the template
         $this->assign('participantId', $this->_id);
         $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id');
     }
     // when fee amount is included in form
     if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         //custom data of type participant role
         if (CRM_Utils_Array::value('role_id', $_POST)) {
             foreach ($_POST['role_id'] as $k => $val) {
                 $roleID = $val;
                 CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $k, 1, 'Participant', $this->_id);
                 CRM_Custom_Form_CustomData::buildQuickForm($this);
                 CRM_Custom_Form_CustomData::setDefaultValues($this);
             }
         }
         //custom data of type participant event
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         // custom data of type participant event type
         $eventTypeId = NULL;
         if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) {
             $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id');
         }
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $roleIds = CRM_Event_PseudoConstant::participantRole();
     if (!empty($roleIds)) {
         $query = "\nSELECT civicrm_custom_group.name as name,\n       civicrm_custom_group.id as id,\n       extends_entity_column_value as value\n  FROM civicrm_custom_group\n WHERE ( extends_entity_column_value REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', array_keys($roleIds)) . "[[:>:]]'\n    OR extends_entity_column_value IS NULL )\n   AND extends_entity_column_id = '{$this->_roleCustomDataTypeID}'\n   AND extends = 'Participant'\n   AND is_active = 1";
         $dao = CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             if ($dao->value) {
                 $getRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->value);
                 foreach ($getRole as $r) {
                     if (!$r) {
                         continue;
                     }
                     if (isset($this->_participantRoleIds[$r])) {
                         $this->_participantRoleIds[$r] .= ',' . $dao->name;
                     } else {
                         $this->_participantRoleIds[$r] = $dao->name;
                     }
                 }
             } else {
                 if (isset($this->_participantRoleIds[0])) {
                     $this->_participantRoleIds[0] .= ',' . $dao->name;
                 } else {
                     $this->_participantRoleIds[0] = $dao->name;
                 }
             }
         }
         $dao->free();
     }
     foreach ($roleIds as $k => $v) {
         if (!isset($this->_participantRoleIds[$k])) {
             $this->_participantRoleIds[$k] = '';
         }
     }
     $this->assign('participantRoleIds', $this->_participantRoleIds);
 }
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_processors = array();
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_id) {
         $this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id");
         $this->_membershipIDs[] = $this->_id;
     }
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('membershipMode', $this->_mode);
     if ($this->_mode) {
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                 continue;
             } else {
                 $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                 $error = $paymentObject->checkConfig();
                 if (empty($error)) {
                     $validProcessors[$ppID] = $label;
                 }
                 $paymentObject = NULL;
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::locationType();
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', TRUE);
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         //check whether any active membership statuses are available - redirects back to contact summary if not
         CRM_Member_BAO_Membership::statusAvilability($this->_contactID);
         if ($this->_contactID) {
             //check whether contact has a current membership so we can alert user that they may want to do a renewal instead
             $hasMembership = CRM_Member_BAO_Membership::getContactMembership($this->_contactID, NULL, 0);
             if (!empty($hasMembership)) {
                 $hasMembership['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $hasMembership['membership_type_id'], 'name', 'id');
                 $hasMembership['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $hasMembership['status_id'], 'label', 'id');
                 $membershipTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member");
                 if ($this->_mode) {
                     $renewUrl = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$hasMembership['id']}&context=membership&selectedChild=member&mode=live");
                 } else {
                     $renewUrl = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$hasMembership['id']}&context=membership&selectedChild=member");
                 }
                 if (CRM_Utils_Array::value('membership_end_date', $hasMembership)) {
                     CRM_Core_Session::setStatus(ts('This contact has an existing %1 membership record with %2 status and end date of %3. <a href="%4">Click here if you want to renew this membership</a> (rather than creating a new membership record). <a href="%5">Click here to view all existing and / or expired memberships for this contact.</a>', array(1 => $hasMembership['membership_type'], 2 => $hasMembership['membership_status'], 3 => CRM_Utils_Date::customformat($hasMembership['membership_end_date']), 4 => $renewUrl, 5 => $membershipTab)));
                 } else {
                     CRM_Core_Session::setStatus(ts('This contact has an existing %1 membership record with %2 status. <a href="%3">Click here if you want to renew this membership</a> (rather than creating a new membership record). <a href="%4">Click here to view all existing and / or expired memberships for this contact.</a>', array(1 => $hasMembership['membership_type'], 2 => $hasMembership['membership_status'], 3 => $renewUrl, 4 => $membershipTab)));
                 }
             }
         }
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     parent::preProcess();
 }
Beispiel #8
0
 /**
  * @param int $participantId
  * @param int $statusId
  *
  * @return Ambigous|void
  */
 public static function updatePendingOnlineContribution($participantId, $statusId)
 {
     if (!$participantId || !$statusId) {
         return NULL;
     }
     $contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId, 'Event');
     if (!$contributionId) {
         return;
     }
     //status rules.
     //1. participant - positive => contribution - completed.
     //2. participant - negative => contribution - cancelled.
     $positiveStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Positive'");
     $negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $contributionStatusId = NULL;
     if (array_key_exists($statusId, $positiveStatuses)) {
         $contributionStatusId = array_search('Completed', $contributionStatuses);
     }
     if (array_key_exists($statusId, $negativeStatuses)) {
         $contributionStatusId = array_search('Cancelled', $contributionStatuses);
     }
     if (!$contributionStatusId) {
         return;
     }
     $params = array('component_id' => $participantId, 'componentName' => 'Event', 'contribution_id' => $contributionId, 'contribution_status_id' => $contributionStatusId, 'IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved' => 1);
     //change related contribution status.
     $updatedStatusId = self::updateContributionStatus($params);
     return $updatedStatusId;
 }
Beispiel #9
0
 public function preProcess()
 {
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_id) {
         $this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id");
     }
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if ($this->_mode) {
         $this->assign('membershipMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     //check whether membership status present or not
     if ($this->_action & CRM_Core_Action::ADD) {
         CRM_Member_BAO_Membership::statusAvilability($this->_contactID);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         CRM_Custom_Form_Customdata::preProcess($this);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = null;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
     }
     $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
     parent::preProcess();
 }