Ejemplo n.º 1
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     parent::preProcess();
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     require_once 'CRM/Event/BAO/Participant.php';
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
     $this->_allowWaitlist = false;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = true;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     self::checkRegistration(null, $this);
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         require_once 'CRM/Event/Form/EventFees.php';
         CRM_Event_Form_EventFees::preProcess($this);
     }
     // Assign pageTitle
     $this->assign('pageTitle', ts('Event Registration'));
 }
Ejemplo n.º 2
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
     // Get payment processors if appropriate for this event
     // We hide the payment fields if the event is full or requires approval,
     // and the current user has not yet been approved CRM-12279
     $this->_noFees = ($eventFull || $this->_requireApproval) && !$this->_allowConfirmation;
     CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this, $this->_noFees);
     if ($this->_snippet) {
         return;
     }
     $this->_allowWaitlist = FALSE;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = TRUE;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     if (!$this->_skipDupeRegistrationCheck) {
         self::checkRegistration(NULL, $this);
     }
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         CRM_Event_Form_EventFees::preProcess($this);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param $event_id
  *
  * @return bool|int|null|string
  */
 function checkEventCapacity($event_id)
 {
     $empty_seats = CRM_Event_BAO_Participant::eventFull($event_id, TRUE);
     if (is_numeric($empty_seats)) {
         return $empty_seats;
     }
     if (is_string($empty_seats)) {
         return 0;
     } else {
         return NULL;
     }
 }
Ejemplo n.º 4
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     //CRM-4320
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     $this->_lineItem = $this->get('lineItem');
     $this->_isEventFull = $this->get('isEventFull');
     $this->_lineItemParticipantsCount = $this->get('lineItemParticipants');
     if (!is_array($this->_lineItem)) {
         $this->_lineItem = array();
     }
     if (!is_array($this->_lineItemParticipantsCount)) {
         $this->_lineItemParticipantsCount = array();
     }
     $this->_availableRegistrations = $this->get('availableRegistrations');
     $this->_participantIDS = $this->get('participantIDs');
     //check if participant allow to walk registration wizard.
     $this->_allowConfirmation = $this->get('allowConfirmation');
     // check for Approval
     $this->_requireApproval = $this->get('requireApproval');
     // check for waitlisting.
     $this->_allowWaitlist = $this->get('allowWaitlist');
     $this->_forcePayement = $this->get('forcePayement');
     //get the additional participant ids.
     $this->_additionalParticipantIds = $this->get('additionalParticipantIds');
     $config = CRM_Core_Config::singleton();
     if (!$this->_values) {
         // create redirect URL to send folks back to event info page is registration not available
         $infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", FALSE, NULL, FALSE, TRUE);
         // this is the first time we are hitting this, so check for permissions here
         if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId, 'register for events')) {
             CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
         }
         // get all the values from the dao object
         $this->_values = $this->_fields = array();
         $this->_forcePayement = FALSE;
         //retrieve event information
         $params = array('id' => $this->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
         // check for ability to add contributions of type
         if ($isMonetary && CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($this->_values['event']['financial_type_id']))) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
         $this->checkValidEvent($infoUrl);
         // get the participant values, CRM-4320
         $this->_allowConfirmation = FALSE;
         if ($this->_participantId) {
             $this->processFirstParticipant($this->_participantId);
         }
         //check for additional participants.
         if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
             $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
             $cnt = 1;
             foreach ($additionalParticipantIds as $additionalParticipantId) {
                 $this->_additionalParticipantIds[$cnt] = $additionalParticipantId;
                 $cnt++;
             }
             $this->set('additionalParticipantIds', $this->_additionalParticipantIds);
         }
         $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->_allowWaitlist = $this->_isEventFull = FALSE;
         if ($eventFull && !$this->_allowConfirmation) {
             $this->_isEventFull = TRUE;
             //lets redirecting to info only when to waiting list.
             $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
             if (!$this->_allowWaitlist) {
                 CRM_Utils_System::redirect($infoUrl);
             }
         }
         $this->set('isEventFull', $this->_isEventFull);
         $this->set('allowWaitlist', $this->_allowWaitlist);
         //check for require requires approval.
         $this->_requireApproval = FALSE;
         if (!empty($this->_values['event']['requires_approval']) && !$this->_allowConfirmation) {
             $this->_requireApproval = TRUE;
         }
         $this->set('requireApproval', $this->_requireApproval);
         if (isset($this->_values['event']['default_role_id'])) {
             $participant_role = CRM_Core_OptionGroup::values('participant_role');
             $this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
         }
         $isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
         //check for various combinations for paylater, payment
         //process with paid event.
         if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
             $this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values['event']));
             $this->assignPaymentProcessor($isPayLater);
         }
         //init event fee.
         self::initEventFee($this, $this->_eventId);
         // get the profile ids
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
         list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // set profiles for additional participants
         if ($this->_values['event']['is_multiple_registrations']) {
             // CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
             $ufJoinParams['module'] = 'CiviEvent_Additional';
             list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             // CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
             // set same profile for additional contacts.
             if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
                 $this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
             }
             if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
                 $this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
             }
             // now check for no profile condition, in that case is_active = 0
             if (isset($preActive) && !$preActive) {
                 unset($this->_values['additional_custom_pre_id']);
             }
             if (isset($postActive) && !$postActive) {
                 unset($this->_values['additional_custom_post_id']);
             }
         }
         $this->assignBillingType();
         if ($this->_values['event']['is_monetary']) {
             CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
         }
         $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
         $this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
         $this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->set('availableRegistrations', $this->_availableRegistrations);
     }
     $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
     // check if this is a paypal auto return and redirect accordingly
     if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
         $url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
         CRM_Utils_System::redirect($url);
     }
     // The concept of contributeMode is deprecated.
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     // setting CMS page title
     CRM_Utils_System::setTitle($this->_values['event']['title']);
     $this->assign('title', $this->_values['event']['title']);
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', FALSE);
     // Registration page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     // Handle PCP
     $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
     if ($pcpId) {
         $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
         $this->_pcpId = $pcp['pcpId'];
         $this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
     }
     // assign all event properties so wizard templates can display event info.
     $this->assign('event', $this->_values['event']);
     $this->assign('location', $this->_values['location']);
     $this->assign('bltID', $this->_bltID);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     //CRM-6907
     $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
     //lets allow user to override campaign.
     $campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
     if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
         $this->_values['event']['campaign_id'] = $campID;
     }
     // Set the same value for is_billing_required as contribution page so code can be shared.
     $this->_values['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
     // check if billing block is required for pay later
     // note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting
     // the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only
     // removing in very limited cases.
     if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
         $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
         $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
     }
 }
Ejemplo n.º 5
0
 /**
  * EventFull() method (checking the event for full )
  */
 public function testEventFull()
 {
     $eventParams = array('max_participants' => 1, 'id' => $this->_eventId);
     CRM_Event_BAO_Event::add($eventParams);
     $participantId = Participant::create($this->_contactId, $this->_eventId);
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
     $this->assertEquals($eventFull, 'This event is full.', 'Checking if Event is full.');
     Participant::delete($participantId);
     Contact::delete($this->_contactId);
     Event::delete($this->_eventId);
 }
 public function updateParticipantStatus()
 {
     require_once 'CRM/Event/PseudoConstant.php';
     $participantRole = CRM_Event_PseudoConstant::participantRole();
     $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
     $expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
     $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
     //build the required status ids.
     $statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')';
     $participantDetails = $fullEvents = array();
     $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
     //get all participant who's status in class pending and waiting
     $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
     $query = "\n   SELECT  participant.id,\n           participant.contact_id,\n           participant.status_id,\n           participant.register_date,\n           participant.registered_by_id,\n           participant.event_id,\n           event.title as eventTitle,\n           event.registration_start_date,\n           event.registration_end_date,\n           event.end_date,\n           event.expiration_time,\n           event.requires_approval\n     FROM  civicrm_participant participant\nLEFT JOIN  civicrm_event event ON ( event.id = participant.event_id )\n    WHERE  participant.status_id IN {$statusIds}\n     AND   (event.end_date > now() OR event.end_date IS NULL)\n     AND   event.is_active = 1 \n ORDER BY  participant.register_date, participant.id \n";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $participantDetails[$dao->id] = array('id' => $dao->id, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, 'eventTitle' => $dao->eventTitle, 'registration_start_date' => $dao->registration_start_date, 'registration_end_date' => $dao->registration_end_date, 'end_date' => $dao->end_date, 'expiration_time' => $dao->expiration_time, 'requires_approval' => $dao->requires_approval);
     }
     if (!empty($participantDetails)) {
         //cron 1. move participant from pending to expire if needed
         foreach ($participantDetails as $participantId => $values) {
             //process the additional participant at the time of
             //primary participant, don't process separately.
             if (CRM_Utils_Array::value('registered_by_id', $values)) {
                 continue;
             }
             $expirationTime = CRM_Utils_Array::value('expiration_time', $values);
             if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) {
                 //get the expiration and registration pending time.
                 $expirationSeconds = $expirationTime * 3600;
                 $registrationPendingSeconds = CRM_Utils_Date::unixTime($values['register_date']);
                 // expired registration since registration cross allow confirmation time.
                 if ($expirationSeconds + $registrationPendingSeconds < time()) {
                     //lets get the transaction mechanism.
                     require_once 'CRM/Core/Transaction.php';
                     $transaction = new CRM_Core_Transaction();
                     require_once 'CRM/Event/BAO/Participant.php';
                     $ids = array($participantId);
                     $expiredId = array_search('Expired', $expiredStatuses);
                     $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE);
                     $transaction->commit();
                     if (!empty($results)) {
                         //diaplay updated participants
                         if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
                             foreach ($results['updatedParticipantIds'] as $processedId) {
                                 $expiredParticipantCount += 1;
                                 echo "<br /><br />- status updated to: Expired";
                                 //mailed participants.
                                 if (is_array($results['mailedParticipants']) && array_key_exists($processedId, $results['mailedParticipants'])) {
                                     echo "<br />Expiration Mail sent to: {$results['mailedParticipants'][$processedId]}";
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //cron 1 end.
         //cron 2. lets move participants from waiting list to pending status
         foreach ($participantDetails as $participantId => $values) {
             //process the additional participant at the time of
             //primary participant, don't process separately.
             if (CRM_Utils_Array::value('registered_by_id', $values)) {
                 continue;
             }
             if (array_key_exists($values['status_id'], $waitingStatuses) && !array_key_exists($values['event_id'], $fullEvents)) {
                 if ($waitingStatuses[$values['status_id']] == 'On waitlist' && CRM_Event_BAO_Event::validRegistrationDate($values)) {
                     //check the target event having space.
                     require_once 'CRM/Event/BAO/Participant.php';
                     $eventOpenSpaces = CRM_Event_BAO_Participant::eventFull($values['event_id'], TRUE, FALSE);
                     if ($eventOpenSpaces && is_numeric($eventOpenSpaces) || $eventOpenSpaces === NULL) {
                         //get the additional participant if any.
                         $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
                         $allIds = array($participantId);
                         if (!empty($additionalIds)) {
                             $allIds = array_merge($allIds, $additionalIds);
                         }
                         $pClause = ' participant.id IN ( ' . implode(' , ', $allIds) . ' )';
                         $requiredSpaces = CRM_Event_BAO_Event::eventTotalSeats($values['event_id'], $pClause);
                         //need to check as to see if event has enough speces
                         if ($requiredSpaces <= $eventOpenSpaces || $eventOpenSpaces === NULL) {
                             require_once 'CRM/Core/Transaction.php';
                             $transaction = new CRM_Core_Transaction();
                             require_once 'CRM/Event/BAO/Participant.php';
                             $ids = array($participantId);
                             $updateStatusId = array_search('Pending from waitlist', $pendingStatuses);
                             //lets take a call to make pending or need approval
                             if ($values['requires_approval']) {
                                 $updateStatusId = array_search('Awaiting approval', $waitingStatuses);
                             }
                             $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $updateStatusId, $values['status_id'], TRUE, TRUE);
                             //commit the transaction.
                             $transaction->commit();
                             if (!empty($results)) {
                                 //diaplay updated participants
                                 if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
                                     foreach ($results['updatedParticipantIds'] as $processedId) {
                                         if ($values['requires_approval']) {
                                             $waitingApprovalCount += 1;
                                             echo "<br /><br />- status updated to: Awaiting approval";
                                             echo "<br />Will send you Confirmation Mail when registration get approved.";
                                         } else {
                                             $waitingConfirmCount += 1;
                                             echo "<br /><br />- status updated to: Pending from waitlist";
                                             if (is_array($results['mailedParticipants']) && array_key_exists($processedId, $results['mailedParticipants'])) {
                                                 echo "<br />Confirmation Mail sent to: {$results['mailedParticipants'][$processedId]}";
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             //target event is full.
                             $fullEvents[$values['event_id']] = $values['eventTitle'];
                         }
                     } else {
                         //target event is full.
                         $fullEvents[$values['event_id']] = $values['eventTitle'];
                     }
                 }
             }
         }
         //cron 2 ends.
     }
     echo "<br /><br />Number of Expired registration(s) = {$expiredParticipantCount}";
     echo "<br />Number of registration(s) require approval =  {$waitingApprovalCount}";
     echo "<br />Number of registration changed to Pending from waitlist = {$waitingConfirmCount}<br /><br />";
     if (!empty($fullEvents)) {
         foreach ($fullEvents as $eventId => $title) {
             echo "Full Event : {$title}<br />";
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * EventFull() method (checking the event for full )
  */
 public function testEventFull()
 {
     $eventParams = array('max_participants' => 1, 'id' => $this->_eventId);
     CRM_Event_BAO_Event::add($eventParams);
     $participantId = $this->participantCreate(array('contact_id' => $this->_contactId, 'event_id' => $this->_eventId));
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
     $this->assertEquals($eventFull, 'Sorry! We are already full', 'Checking if Event is full.');
     $this->participantDelete($participantId);
     $this->contactDelete($this->_contactId);
     $this->eventDelete($this->_eventId);
 }
Ejemplo n.º 8
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     //get the event id.
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $config =& CRM_Core_Config::singleton();
     require_once 'CRM/Event/BAO/Event.php';
     // ensure that the user has permission to see this page
     if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
         CRM_Core_Error::fatal(ts('You do not have permission to view this event'));
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'register');
     $this->assign('context', $context);
     // Sometimes we want to suppress the Event Full msg
     $noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, false, 'false');
     // set breadcrumb to append to 2nd layer pages
     $breadCrumbPath = CRM_Utils_System::url("civicrm/event/info", "id={$this->_id}&reset=1");
     $additionalBreadCrumb = "<a href=\"{$breadCrumbPath}\">" . ts('Events') . '</a>';
     //retrieve event information
     $params = array('id' => $this->_id);
     CRM_Event_BAO_Event::retrieve($params, $values['event']);
     if (!$values['event']['is_active']) {
         // form is inactive, die a fatal death
         CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
     }
     $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
     // show event fees.
     require_once 'CRM/Price/BAO/Set.php';
     if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
         // get price set options, - CRM-5209
         if ($priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $this->_id)) {
             $setDetails = CRM_Price_BAO_Set::getSetDetail($priceSetId);
             eval("\$priceSetFields = \$setDetails[{$priceSetId}][fields];");
             if (is_array($priceSetFields)) {
                 $fieldCnt = 1;
                 foreach ($priceSetFields as $fid => $fieldValues) {
                     if (!is_array($fieldValues['options']) || empty($fieldValues['options'])) {
                         continue;
                     }
                     foreach ($fieldValues['options'] as $optionId => $optionVal) {
                         $values['feeBlock']['value'][$fieldCnt] = $optionVal['value'];
                         $values['feeBlock']['label'][$fieldCnt] = $optionVal['description'];
                         $fieldCnt++;
                     }
                 }
             }
         } else {
             //retrieve event fee block.
             require_once 'CRM/Core/OptionGroup.php';
             require_once 'CRM/Core/BAO/Discount.php';
             $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
             if ($discountId) {
                 CRM_Core_OptionGroup::getAssoc(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id'), $values['feeBlock'], false, 'id');
             } else {
                 CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$this->_id}", $values['feeBlock']);
             }
         }
     }
     $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
     require_once 'CRM/Core/BAO/Location.php';
     $values['location'] = CRM_Core_BAO_Location::getValues($params, true);
     //retrieve custom field information
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Event", $this, $this->_id, 0, $values['event']['event_type_id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign('action', CRM_Core_Action::VIEW);
     //To show the event location on maps directly on event info page
     $locations =& CRM_Event_BAO_Event::getMapInfo($this->_id);
     if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
         $this->assign('locations', $locations);
         $this->assign('mapProvider', $config->mapProvider);
         $this->assign('mapKey', $config->mapAPIKey);
         $sumLat = $sumLng = 0;
         $maxLat = $maxLng = -400;
         $minLat = $minLng = +400;
         foreach ($locations as $location) {
             $sumLat += $location['lat'];
             $sumLng += $location['lng'];
             if ($location['lat'] > $maxLat) {
                 $maxLat = $location['lat'];
             }
             if ($location['lat'] < $minLat) {
                 $minLat = $location['lat'];
             }
             if ($location['lng'] > $maxLng) {
                 $maxLng = $location['lng'];
             }
             if ($location['lng'] < $minLng) {
                 $minLng = $location['lng'];
             }
         }
         $center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
         $span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
         $this->assign_by_ref('center', $center);
         $this->assign_by_ref('span', $span);
     }
     require_once 'CRM/Event/BAO/Participant.php';
     $eventFullMessage = CRM_Event_BAO_Participant::eventFull($this->_id);
     if ($eventFullMessage and $noFullMsg == 'false') {
         if (CRM_Utils_Array::value('has_waitlist', $values['event'])) {
             $eventFullMessage = null;
             $statusMessage = CRM_Utils_Array::value('waitlist_text', $values['event'], 'Event is currently full, but you can register and be a part of waiting list.');
         } else {
             $statusMessage = $eventFullMessage;
         }
         CRM_Core_Session::setStatus($statusMessage);
     }
     if (CRM_Utils_Array::value('is_online_registration', $values['event'])) {
         if (CRM_Event_BAO_Event::validRegistrationDate($values['event'], $this->_id)) {
             if (!$eventFullMessage) {
                 $registerText = ts('Register Now');
                 if (CRM_Utils_Array::value('registration_link_text', $values['event'])) {
                     $registerText = $values['event']['registration_link_text'];
                 }
                 //Fixed for CRM-4855
                 if (CRM_Event_BAO_Event::showHideRegistrationLink($values)) {
                     $this->assign('allowRegistration', true);
                 }
                 $this->assign('registerText', $registerText);
             }
             // we always generate urls for the front end in joomla
             if ($action == CRM_Core_Action::PREVIEW) {
                 $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1&action=preview", true, null, true, true);
             } else {
                 $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1", true, null, true, true);
             }
             if (!$eventFullMessage) {
                 $this->assign('registerURL', $url);
             }
         }
         if ($action == CRM_Core_Action::PREVIEW) {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1&action=preview", true, null, true, true);
         } else {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1", true, null, true, true);
         }
         $this->assign('mapURL', $mapURL);
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', false);
     // set page title = event title
     CRM_Utils_System::setTitle($values['event']['title']);
     $this->assign('event', $values['event']);
     if (isset($values['feeBlock'])) {
         $this->assign('feeBlock', $values['feeBlock']);
     }
     $this->assign('location', $values['location']);
     parent::run();
 }
Ejemplo n.º 9
0
function _civicrm_api3_event_getisfull(&$event, $event_id)
{
    $eventFullResult = CRM_Event_BAO_Participant::eventFull($event_id, 1);
    if (!empty($eventFullResult) && is_int($eventFullResult)) {
        $event[$event_id]['available_places'] = $eventFullResult;
    } else {
        $event[$event_id]['available_places'] = 0;
    }
    $event[$event_id]['is_full'] = $event[$event_id]['available_places'] == 0 ? 1 : 0;
}
Ejemplo n.º 10
0
 /**
  * Apply form rule.
  *
  * @param array $fields
  * @param array $files
  * @param CRM_Core_Form $self
  *
  * @return array|bool
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     $eventFull = CRM_Event_BAO_Participant::eventFull($self->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $self->_values['event']));
     if ($eventFull && empty($self->_allowConfirmation)) {
         if (empty($self->_allowWaitlist)) {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$self->_eventId}", FALSE, NULL, FALSE, TRUE));
         }
     }
     $self->_feeBlock = $self->_values['fee'];
     CRM_Event_Form_Registration_Register::formatFieldsForOptionFull($self);
     if (!empty($self->_priceSetId) && !$self->_requireApproval && !$self->_allowWaitlist) {
         $priceSetErrors = self::validatePriceSet($self, $self->_params);
         if (!empty($priceSetErrors)) {
             CRM_Core_Session::setStatus(ts('You have been returned to the start of the registration process and any sold out events have been removed from your selections. You will not be able to continue until you review your booking and select different events if you wish.'), ts('Unfortunately some of your options have now sold out for one or more participants.'), 'error');
             CRM_Core_Session::setStatus(ts('Please note that the options which are marked or selected are sold out for participant being viewed.'), ts('Sold out:'), 'error');
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "_qf_Register_display=true&qfKey={$fields['qfKey']}"));
         }
     }
     return empty($priceSetErrors) ? TRUE : $priceSetErrors;
 }
Ejemplo n.º 11
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  *
  * @return void
  */
 public function run()
 {
     //get the event id.
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $config = CRM_Core_Config::singleton();
     // ensure that the user has permission to see this page
     if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'view event info')) {
         CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event'));
         return CRM_Utils_System::permissionDenied();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'register');
     $this->assign('context', $context);
     // Sometimes we want to suppress the Event Full msg
     $noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
     // set breadcrumb to append to 2nd layer pages
     $breadCrumbPath = CRM_Utils_System::url('civicrm/event/info', "id={$this->_id}&reset=1");
     //retrieve event information
     $params = array('id' => $this->_id);
     CRM_Event_BAO_Event::retrieve($params, $values['event']);
     if (!$values['event']['is_active']) {
         // form is inactive, die a fatal death
         CRM_Utils_System::setUFMessage(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
         return CRM_Utils_System::permissionDenied();
     }
     if (!empty($values['event']['is_template'])) {
         // form is an Event Template
         CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
     }
     // Add Event Type to $values in case folks want to display it
     $values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType());
     $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
     // show event fees.
     if ($this->_id && !empty($values['event']['is_monetary'])) {
         //CRM-6907
         $config = CRM_Core_Config::singleton();
         $config->defaultCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency);
         //CRM-10434
         $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
         if ($discountId) {
             $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'price_set_id');
         } else {
             $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_id);
         }
         // get price set options, - CRM-5209
         if ($priceSetId) {
             $setDetails = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, TRUE);
             $priceSetFields = $setDetails[$priceSetId]['fields'];
             if (is_array($priceSetFields)) {
                 $fieldCnt = 1;
                 $visibility = CRM_Core_PseudoConstant::visibility('name');
                 // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
                 $adminFieldVisible = FALSE;
                 if (CRM_Core_Permission::check('administer CiviCRM')) {
                     $adminFieldVisible = TRUE;
                 }
                 foreach ($priceSetFields as $fid => $fieldValues) {
                     if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == FALSE) {
                         continue;
                     }
                     if (count($fieldValues['options']) > 1) {
                         $values['feeBlock']['value'][$fieldCnt] = '';
                         $values['feeBlock']['label'][$fieldCnt] = $fieldValues['label'];
                         $values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label';
                         $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
                         $fieldCnt++;
                         $labelClass = 'price_set_option-label';
                     } else {
                         $labelClass = 'price_set_field-label';
                     }
                     // show tax rate with amount
                     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
                     $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
                     $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings);
                     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
                     foreach ($fieldValues['options'] as $optionId => $optionVal) {
                         $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
                         if ($invoicing && isset($optionVal['tax_amount'])) {
                             $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
                             $values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount'];
                         } else {
                             $values['feeBlock']['value'][$fieldCnt] = $optionVal['amount'];
                         }
                         $values['feeBlock']['label'][$fieldCnt] = $optionVal['label'];
                         $values['feeBlock']['lClass'][$fieldCnt] = $labelClass;
                         $fieldCnt++;
                     }
                 }
             }
             // Tell tpl we have price set fee data and whether it's a quick_config price set
             $this->assign('isPriceSet', 1);
             $this->assign('isQuickConfig', $setDetails[$priceSetId]['is_quick_config']);
         }
     }
     $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
     $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
     // fix phone type labels
     if (!empty($values['location']['phone'])) {
         $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
         foreach ($values['location']['phone'] as &$val) {
             if (!empty($val['phone_type_id'])) {
                 $val['phone_type_display'] = $phoneTypes[$val['phone_type_id']];
             }
         }
     }
     //retrieve custom field information
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
     $this->assign('action', CRM_Core_Action::VIEW);
     //To show the event location on maps directly on event info page
     $locations = CRM_Event_BAO_Event::getMapInfo($this->_id);
     if (!empty($locations) && !empty($values['event']['is_map'])) {
         $this->assign('locations', $locations);
         $this->assign('mapProvider', $config->mapProvider);
         $this->assign('mapKey', $config->mapAPIKey);
         $sumLat = $sumLng = 0;
         $maxLat = $maxLng = -400;
         $minLat = $minLng = 400;
         foreach ($locations as $location) {
             $sumLat += $location['lat'];
             $sumLng += $location['lng'];
             if ($location['lat'] > $maxLat) {
                 $maxLat = $location['lat'];
             }
             if ($location['lat'] < $minLat) {
                 $minLat = $location['lat'];
             }
             if ($location['lng'] > $maxLng) {
                 $maxLng = $location['lng'];
             }
             if ($location['lng'] < $minLng) {
                 $minLng = $location['lng'];
             }
         }
         $center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
         $span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
         $this->assign_by_ref('center', $center);
         $this->assign_by_ref('span', $span);
         if ($action == CRM_Core_Action::PREVIEW) {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
         } else {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE);
         }
         $this->assign('skipLocationType', TRUE);
         $this->assign('mapURL', $mapURL);
     }
     if (CRM_Core_Permission::check('view event participants') && CRM_Core_Permission::check('view all contacts')) {
         $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1', 'label');
         $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0', 'label');
         $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes));
         $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending));
         $this->assign('findParticipants', $findParticipants);
     }
     $participantListingID = CRM_Utils_Array::value('participant_listing_id', $values['event']);
     if ($participantListingID) {
         $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', "reset=1&id={$this->_id}", TRUE, NULL, TRUE, TRUE);
         $this->assign('participantListingURL', $participantListingURL);
     }
     $hasWaitingList = CRM_Utils_Array::value('has_waitlist', $values['event']);
     $eventFullMessage = CRM_Event_BAO_Participant::eventFull($this->_id, FALSE, $hasWaitingList);
     $allowRegistration = FALSE;
     if (!empty($values['event']['is_online_registration'])) {
         if (CRM_Event_BAO_Event::validRegistrationRequest($values['event'], $this->_id)) {
             // we always generate urls for the front end in joomla
             $action_query = $action === CRM_Core_Action::PREVIEW ? "&action={$action}" : '';
             $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1{$action_query}", TRUE, NULL, TRUE, TRUE);
             if (!$eventFullMessage || $hasWaitingList) {
                 $registerText = ts('Register Now');
                 if (!empty($values['event']['registration_link_text'])) {
                     $registerText = $values['event']['registration_link_text'];
                 }
                 // check if we're in shopping cart mode for events
                 $enable_cart = Civi::settings()->get('enable_cart');
                 if ($enable_cart) {
                     $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($this->_id);
                     $registerText = $link['label'];
                     $url = CRM_Utils_System::url($link['path'], $link['query'] . $action_query, TRUE, NULL, TRUE, TRUE);
                 }
                 //Fixed for CRM-4855
                 $allowRegistration = CRM_Event_BAO_Event::showHideRegistrationLink($values);
                 $this->assign('registerText', $registerText);
                 $this->assign('registerURL', $url);
                 $this->assign('eventCartEnabled', $enable_cart);
             }
         } elseif (CRM_Core_Permission::check('register for events')) {
             $this->assign('registerClosed', TRUE);
         }
     }
     $this->assign('allowRegistration', $allowRegistration);
     $session = CRM_Core_Session::singleton();
     $params = array('contact_id' => $session->get('userID'), 'event_id' => CRM_Utils_Array::value('id', $values['event']), 'role_id' => CRM_Utils_Array::value('default_role_id', $values['event']));
     if ($eventFullMessage && $noFullMsg == 'false' || CRM_Event_BAO_Event::checkRegistration($params)) {
         $statusMessage = $eventFullMessage;
         if (CRM_Event_BAO_Event::checkRegistration($params)) {
             if ($noFullMsg == 'false') {
                 if ($values['event']['allow_same_participant_emails']) {
                     $statusMessage = ts('It looks like you are already registered for this event.  You may proceed if you want to create an additional registration.');
                 } else {
                     $registerUrl = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$values['event']['id']}&cid=0");
                     $statusMessage = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also <a href="%1">register another participant</a>.', array(1 => $registerUrl));
                 }
             }
         } elseif ($hasWaitingList) {
             $statusMessage = CRM_Utils_Array::value('waitlist_text', $values['event']);
             if (!$statusMessage) {
                 $statusMessage = ts('Event is currently full, but you can register and be a part of waiting list.');
             }
         }
         CRM_Core_Session::setStatus($statusMessage);
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     // set page title = event title
     CRM_Utils_System::setTitle($values['event']['title']);
     $this->assign('event', $values['event']);
     if (isset($values['feeBlock'])) {
         $this->assign('feeBlock', $values['feeBlock']);
     }
     $this->assign('location', $values['location']);
     if (CRM_Core_Permission::check('access CiviEvent')) {
         $enableCart = Civi::settings()->get('enable_cart');
         $this->assign('manageEventLinks', CRM_Event_Page_ManageEvent::tabs($enableCart));
     }
     return parent::run();
 }
Ejemplo n.º 12
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $config =& CRM_Core_Config::singleton();
     $button = substr($this->controller->getButtonName(), -4);
     $this->add('hidden', 'scriptFee', null);
     $this->add('hidden', 'scriptArray', null);
     if ($this->_values['event']['is_monetary']) {
         require_once 'CRM/Event/Form/Registration/Register.php';
         CRM_Event_Form_Registration_Register::buildAmount($this);
     }
     $first_name = $last_name = null;
     foreach (array('pre', 'post') as $keys) {
         if (isset($this->_values['additional_custom_' . $keys . '_id'])) {
             $this->buildCustom($this->_values['additional_custom_' . $keys . '_id'], 'additionalCustom' . ucfirst($keys), true);
             ${$keys} = CRM_Core_BAO_UFGroup::getFields($this->_values['additional_custom_' . $keys . '_id']);
         }
         foreach (array('first_name', 'last_name') as $name) {
             if (CRM_Utils_Array::value($name, ${$keys}) && CRM_Utils_Array::value('is_required', CRM_Utils_Array::value($name, ${$keys}))) {
                 ${$name} = 1;
             }
         }
     }
     $required = $button == 'skip' || $this->_values['event']['allow_same_participant_emails'] == 1 && ($first_name && $last_name) ? false : true;
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), $required);
     //add buttons
     $js = null;
     if ($this->isLastParticipant(true) && !CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
         $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
     }
     //handle case where user might sart with waiting by group
     //registration and skip some people and now group fit to
     //become registered so need to take payment from user.
     //this case only occurs at dynamic waiting status, CRM-4320
     $statusMessage = null;
     $allowToProceed = true;
     $includeSkipButton = true;
     $this->_resetAllowWaitlist = false;
     if ($this->_lastParticipant && !$this->_allowConfirmation && CRM_Utils_Array::value('bypass_payment', $this->_params[0])) {
         require_once 'CRM/Event/BAO/Participant.php';
         $spaces = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], true);
         $processedCnt = 0;
         //need to check current participant present in params.
         $currentParticipantNum = substr($this->_name, 12);
         foreach ($this->_params as $key => $value) {
             if ($value == 'skip' || $key == $currentParticipantNum) {
                 continue;
             }
             $processedCnt++;
         }
         //we might did reset allow waiting in case of dynamic calculation
         if (CRM_Utils_Array::value('bypass_payment', $this->_params[0]) && is_numeric($spaces) && CRM_Utils_Array::value('additional_participants', $this->_params[0]) >= $spaces) {
             $this->_allowWaitlist = true;
             $this->set('allowWaitlist', true);
         }
         //lets allow to become a part of runtime waiting list, if primary selected pay later.
         $realPayLater = false;
         if (CRM_Utils_Array::value('is_monetary', $this->_values['event']) && CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
             $realPayLater = CRM_Utils_Array::value('is_pay_later', $this->_params[0]);
         }
         //truly spaces are greater than required.
         if (is_numeric($spaces) && $spaces >= $processedCnt + 1) {
             if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0 || $this->_requireApproval) {
                 $this->_allowWaitlist = false;
                 $this->set('allowWaitlist', $this->_allowWaitlist);
                 if ($this->_requireApproval) {
                     $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.", array(1 => ++$processedCnt, 2 => $spaces));
                 } else {
                     $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed).", array(1 => ++$processedCnt, 2 => $spaces));
                 }
             } else {
                 $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.", array(1 => ++$processedCnt, 2 => $spaces));
                 $allowToProceed = false;
             }
             CRM_Core_Session::setstatus($status);
         } else {
             if ($processedCnt == $spaces) {
                 if (CRM_Utils_Array::value('amount', $this->_params[0], 0) == 0 || $realPayLater || $this->_requireApproval) {
                     $this->_resetAllowWaitlist = true;
                     if ($this->_requireApproval) {
                         $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.");
                     } else {
                         $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed).");
                     }
                 } else {
                     //hey there is enough space and we require payment.
                     $statusMessage = ts("If you skip this participant there will be enough spaces in the event for your group (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.");
                     $includeSkipButton = false;
                 }
             }
         }
     }
     $this->assign('statusMessage', $statusMessage);
     $buttons = array(array('type' => 'back', 'name' => ts('<< Go Back'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp'));
     //CRM-4320
     if ($allowToProceed) {
         $buttons = array_merge($buttons, array(array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true, 'js' => $js)));
         if ($includeSkipButton) {
             $buttons = array_merge($buttons, array(array('type' => 'next', 'name' => ts('Skip Participant >>|'), 'subName' => 'skip')));
         }
     }
     $this->addButtons($buttons);
     $this->addFormRule(array('CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'), $this);
 }
Ejemplo n.º 13
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     $this->_ppType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('ppType', FALSE);
     if ($this->_ppType) {
         $this->assign('ppType', TRUE);
         return CRM_Core_Payment_ProcessorForm::preProcess($this);
     }
     //get payPal express id and make it available to template
     $paymentProcessors = $this->get('paymentProcessors');
     $this->assign('payPalExpressId', 0);
     if (!empty($paymentProcessors)) {
         foreach ($paymentProcessors as $ppId => $values) {
             $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0;
             $this->assign('payPalExpressId', $payPalExpressId);
             if ($payPalExpressId) {
                 break;
             }
         }
     }
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
     $this->_allowWaitlist = FALSE;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = TRUE;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     if (!$this->_skipDupeRegistrationCheck) {
         self::checkRegistration(NULL, $this);
     }
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         CRM_Event_Form_EventFees::preProcess($this);
     }
     if (CRM_Utils_Array::value('hidden_processor', $_POST)) {
         $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST));
         $this->set('mode', $this->_mode);
         $this->set('paymentProcessor', $this->_paymentProcessor);
         CRM_Core_Payment_ProcessorForm::preProcess($this);
         CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
 }
Ejemplo n.º 14
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     //CRM-4320
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     $this->_lineItem = $this->get('lineItem');
     $this->_isEventFull = $this->get('isEventFull');
     $this->_lineItemParticipantsCount = $this->get('lineItemParticipants');
     if (!is_array($this->_lineItem)) {
         $this->_lineItem = array();
     }
     if (!is_array($this->_lineItemParticipantsCount)) {
         $this->_lineItemParticipantsCount = array();
     }
     $this->_availableRegistrations = $this->get('availableRegistrations');
     $this->_participantIDS = $this->get('participantIDs');
     //check if participant allow to walk registration wizard.
     $this->_allowConfirmation = $this->get('allowConfirmation');
     // check for Approval
     $this->_requireApproval = $this->get('requireApproval');
     // check for waitlisting.
     $this->_allowWaitlist = $this->get('allowWaitlist');
     $this->_forcePayement = $this->get('forcePayement');
     //get the additional participant ids.
     $this->_additionalParticipantIds = $this->get('additionalParticipantIds');
     $config = CRM_Core_Config::singleton();
     if (!$this->_values) {
         // create redirect URL to send folks back to event info page is registration not available
         $infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", FALSE, NULL, FALSE, TRUE);
         // this is the first time we are hitting this, so check for permissions here
         if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId, 'register for events')) {
             CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
         }
         // get all the values from the dao object
         $this->_values = $this->_fields = array();
         $this->_forcePayement = FALSE;
         //retrieve event information
         $params = array('id' => $this->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
         $this->checkValidEvent($infoUrl);
         // get the participant values, CRM-4320
         $this->_allowConfirmation = FALSE;
         if ($this->_participantId) {
             $this->processFirstParticipant($this->_participantId);
         }
         //check for additional participants.
         if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
             $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
             $cnt = 1;
             foreach ($additionalParticipantIds as $additionalParticipantId) {
                 $this->_additionalParticipantIds[$cnt] = $additionalParticipantId;
                 $cnt++;
             }
             $this->set('additionalParticipantIds', $this->_additionalParticipantIds);
         }
         $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->_allowWaitlist = $this->_isEventFull = FALSE;
         if ($eventFull && !$this->_allowConfirmation) {
             $this->_isEventFull = TRUE;
             //lets redirecting to info only when to waiting list.
             $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
             if (!$this->_allowWaitlist) {
                 CRM_Utils_System::redirect($infoUrl);
             }
         }
         $this->set('isEventFull', $this->_isEventFull);
         $this->set('allowWaitlist', $this->_allowWaitlist);
         //check for require requires approval.
         $this->_requireApproval = FALSE;
         if (!empty($this->_values['event']['requires_approval']) && !$this->_allowConfirmation) {
             $this->_requireApproval = TRUE;
         }
         $this->set('requireApproval', $this->_requireApproval);
         if (isset($this->_values['event']['default_role_id'])) {
             $participant_role = CRM_Core_OptionGroup::values('participant_role');
             $this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
         }
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
         $isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
         //check for variour combination for paylater, payment
         //process with paid event.
         if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
             $ppID = CRM_Utils_Array::value('payment_processor', $this->_values['event']);
             if (!$ppID) {
                 CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'), $infoUrl);
             }
             $ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
             $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPayments($ppIds, $this->_mode);
             $this->set('paymentProcessors', $this->_paymentProcessors);
             //set default payment processor
             if (!empty($this->_paymentProcessors) && empty($this->_paymentProcessor)) {
                 foreach ($this->_paymentProcessors as $ppId => $values) {
                     if ($values['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
                         $defaultProcessorId = $ppId;
                         break;
                     }
                 }
             }
             if (isset($defaultProcessorId)) {
                 $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
             }
             // make sure we have a valid payment class, else abort
             if ($this->_values['event']['is_monetary']) {
                 if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
                     foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
                         // check selected payment processor is active
                         if (!$eachPaymentProcessor) {
                             CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
                         }
                         // ensure that processor has a valid config
                         $payment = CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
                         $error = $payment->checkConfig();
                         if (!empty($error)) {
                             CRM_Core_Error::fatal($error);
                         }
                     }
                 }
             }
         }
         //init event fee.
         self::initEventFee($this, $this->_eventId);
         // get the profile ids
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
         list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // set profiles for additional participants
         if ($this->_values['event']['is_multiple_registrations']) {
             // CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
             $ufJoinParams['module'] = 'CiviEvent_Additional';
             list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             // CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
             // set same profile for additional contacts.
             if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
                 $this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
             }
             if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
                 $this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
             }
             // now check for no profile condition, in that case is_active = 0
             if (isset($preActive) && !$preActive) {
                 unset($this->_values['additional_custom_pre_id']);
             }
             if (isset($postActive) && !$postActive) {
                 unset($this->_values['additional_custom_post_id']);
             }
         }
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
         //$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);
         if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
             CRM_Core_Payment_Form::setCreditCardFields($this);
         }
         $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
         $this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
         $this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->set('availableRegistrations', $this->_availableRegistrations);
     }
     $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
     // check if this is a paypal auto return and redirect accordingly
     if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
         $url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
         CRM_Utils_System::redirect($url);
     }
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     // setting CMS page title
     CRM_Utils_System::setTitle($this->_values['event']['title']);
     $this->assign('title', $this->_values['event']['title']);
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', FALSE);
     // Registration page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     // Handle PCP
     $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
     if ($pcpId) {
         $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
         $this->_pcpId = $pcp['pcpId'];
         $this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
     }
     // assign all event properties so wizard templates can display event info.
     $this->assign('event', $this->_values['event']);
     $this->assign('location', $this->_values['location']);
     $this->assign('bltID', $this->_bltID);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     //CRM-6907
     $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
     //lets allow user to override campaign.
     $campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
     if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
         $this->_values['event']['campaign_id'] = $campID;
     }
 }
Ejemplo n.º 15
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
     //CRM-4320
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     //check if participant allow to walk registration wizard.
     $this->_allowConfirmation = $this->get('allowConfirmation');
     // check for Approval
     $this->_requireApproval = $this->get('requireApproval');
     // check for waitlisting.
     $this->_allowWaitlist = $this->get('allowWaitlist');
     //get the additional participant ids.
     $this->_additionalParticipantIds = $this->get('additionalParticipantIds');
     $config =& CRM_Core_Config::singleton();
     if (!$this->_values) {
         // create redirect URL to send folks back to event info page is registration not available
         $infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", false, null, false, true);
         // this is the first time we are hitting this, so check for permissions here
         if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId)) {
             CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
         }
         // get all the values from the dao object
         $this->_values = array();
         $this->_fields = array();
         // get the participant values, CRM-4320
         $this->_allowConfirmation = false;
         if ($this->_participantId) {
             require_once 'CRM/Event/BAO/Event.php';
             $ids = $participantValues = array();
             $participantParams = array('id' => $this->_participantId);
             require_once 'CRM/Event/BAO/Participant.php';
             CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
             $this->_values['participant'] = $participantValues[$this->_participantId];
             //allow pending status class walk registration wizard.
             require_once 'CRM/Core/PseudoConstant.php';
             if (array_key_exists($participantValues[$this->_participantId]['status_id'], CRM_Event_PseudoConstant::participantStatus(null, "class = 'Pending'"))) {
                 $this->_allowConfirmation = true;
                 $this->set('allowConfirmation', true);
             }
         }
         //retrieve event information
         require_once 'CRM/Event/BAO/Event.php';
         $params = array('id' => $this->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
         require_once 'CRM/Event/BAO/Participant.php';
         //check for additional participants.
         if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
             $this->_additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
             $this->set('additionalParticipantIds', $this->_additionalParticipantIds);
         }
         $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
         $this->_allowWaitlist = false;
         if ($eventFull && !$this->_allowConfirmation) {
             //lets redirecting to info only when to waiting list.
             $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
             if (!$this->_allowWaitlist) {
                 CRM_Utils_System::redirect($infoUrl);
             }
         }
         $this->set('allowWaitlist', $this->_allowWaitlist);
         //check for require requires approval.
         $this->_requireApproval = false;
         if (CRM_Utils_Array::value('requires_approval', $this->_values['event']) && !$this->_allowConfirmation) {
             $this->_requireApproval = true;
         }
         $this->set('requireApproval', $this->_requireApproval);
         // also get the accounting code
         if (CRM_Utils_Array::value('contribution_type_id', $this->_values['event'])) {
             $this->_values['event']['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $this->_values['event']['contribution_type_id'], 'accounting_code');
         }
         if (isset($this->_values['event']['default_role_id'])) {
             require_once 'CRM/Core/OptionGroup.php';
             $participant_role = CRM_Core_OptionGroup::values('participant_role');
             $this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
         }
         // is the event active (enabled)?
         if (!$this->_values['event']['is_active']) {
             // form is inactive, die a fatal death
             CRM_Core_Error::statusBounce(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
         }
         // is online registration is enabled?
         if (!$this->_values['event']['is_online_registration']) {
             CRM_Core_Error::statusBounce(ts('Online registration is not currently available for this event (contact the site administrator for assistance).'), $infoUrl);
         }
         // is this an event template ?
         if (CRM_Utils_Array::value('is_template', $this->_values['event'])) {
             CRM_Core_Error::statusBounce(ts('Event templates are not meant to be registered.'), $infoUrl);
         }
         $now = date('YmdHis');
         $startDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('registration_start_date', $this->_values['event']));
         if ($startDate && $startDate >= $now) {
             CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event'])))), $infoUrl);
         }
         $endDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('registration_end_date', $this->_values['event']));
         if ($endDate && $endDate < $now) {
             CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_end_date', $this->_values['event'])))), $infoUrl);
         }
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
         //retrieve custom information
         $eventID = $this->_eventId;
         $isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'is_pay_later');
         //check for variour combination for paylater, payment
         //process with paid event.
         if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor_id', $this->_values['event']))) {
             $ppID = CRM_Utils_Array::value('payment_processor_id', $this->_values['event']);
             if (!$ppID) {
                 CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'), $infoUrl);
             }
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             $this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             // make sure we have a valid payment class, else abort
             if ($this->_values['event']['is_monetary']) {
                 if (!$this->_paymentProcessor) {
                     CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
                 }
                 // ensure that processor has a valid config
                 $payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
                 $error = $payment->checkConfig();
                 if (!empty($error)) {
                     CRM_Core_Error::fatal($error);
                 }
             }
             $this->_paymentProcessor['processorName'] = $payment->_processorName;
             $this->set('paymentProcessor', $this->_paymentProcessor);
         }
         // get price info
         $price = self::initPriceSet($this, $eventID);
         if ($price == false) {
             if (!isset($this->_values['fee'])) {
                 $this->_values['fee'] = array();
             }
             require_once 'CRM/Core/OptionGroup.php';
             CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$eventID}", $this->_values['fee'], true);
             //fix for non-upgraded price sets.CRM-4256.
             if ($isMonetary && empty($this->_values['fee'])) {
                 CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage', 'reset=1&action=update&subPage=Fee&id=' . $this->_eventId))));
             }
         }
         // get the profile ids
         require_once 'CRM/Core/BAO/UFJoin.php';
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
         list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // set profiles for additional participants
         if ($this->_values['event']['is_multiple_registrations']) {
             require_once 'CRM/Core/BAO/UFJoin.php';
             $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent_Additional', 'entity_id' => $this->_eventId);
             list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             // CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
             // set same profile for additional contacts.
             if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
                 $this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
             }
             if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
                 $this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
             }
             // now check for no profile condition, in that case is_active = 0
             if (isset($preActive) && !$preActive) {
                 unset($this->_values['additional_custom_pre_id']);
             }
             if (isset($postActive) && !$postActive) {
                 unset($this->_values['additional_custom_post_id']);
             }
         }
         $params = array('id' => $this->_eventId);
         // 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);
         if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
             require_once 'CRM/Core/Payment/Form.php';
             CRM_Core_Payment_Form::setCreditCardFields($this);
         }
         $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
         require_once 'CRM/Core/BAO/Location.php';
         $this->_values['location'] = CRM_Core_BAO_Location::getValues($params, true);
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
     }
     $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
     // check if this is a paypal auto return and redirect accordingly
     if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
         $url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
         CRM_Utils_System::redirect($url);
     }
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     // setting CMS page title
     CRM_Utils_System::setTitle($this->_values['event']['title']);
     $this->assign('title', $this->_values['event']['title']);
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', false);
     // Registration page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', true);
     // assign all event properties so wizard templates can display event info.
     $this->assign('event', $this->_values['event']);
     $this->assign('location', $this->_values['location']);
     $this->assign('bltID', $this->_bltID);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
 }
Ejemplo n.º 16
0
 /**
  * eventFull() method (checking the event for full )
  */
 function testeventFull()
 {
     require_once 'CRM/Event/BAO/Event.php';
     CRM_Event_BAO_Event::add($eventParams = array('max_participants' => 1, 'id' => $this->_eventId));
     $participantId = Participant::create($this->_contactId, $this->_eventId);
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
     $this->assertEquals($eventFull, 'This event is full !!!', 'Checking if Event is full.');
     Participant::delete($participantId);
     Contact::delete($this->_contactId);
     Event::delete($this->_eventId);
 }