Пример #1
0
 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
     $this->_view = CRM_Utils_Request::retrieve('view', 'String', $this, FALSE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $this->assign('component', $this->_component);
     $this->assign('id', $this->_id);
     $this->assign('suppressPaymentFormButtons', $this->isBeingCalledFromSelectorContext());
     if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
         $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE);
         $transactionRows = $paymentInfo['transaction'];
         $title = ts('View Payment');
         if ($this->_component == 'event') {
             $info = CRM_Event_BAO_Participant::participantDetails($this->_id);
             $title .= " - {$info['title']}";
         }
         CRM_Utils_System::setTitle($title);
         $this->assign('transaction', TRUE);
         $this->assign('rows', $transactionRows);
         return;
     }
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     $enitityType = NULL;
     if ($this->_component == 'event') {
         $enitityType = 'participant';
         $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
     }
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
     $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
     $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
     $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE);
     $this->_amtPaid = $paymentDetails['paid'];
     $this->_amtTotal = $paymentDetails['total'];
     if (!empty($paymentInfo['refund_due'])) {
         $paymentAmt = $this->_refund = $paymentInfo['refund_due'];
         $this->_paymentType = 'refund';
     } elseif (!empty($paymentInfo['amount_owed'])) {
         $paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
         $this->_paymentType = 'owed';
     } else {
         CRM_Core_Error::fatal(ts('No payment information found for this record'));
     }
     //set the payment mode - _mode property is defined in parent class
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if (!empty($this->_mode) && $this->_paymentType == 'refund') {
         CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
     }
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
     $this->assignPaymentRelatedVariables();
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
     $this->assign('paymentType', $this->_paymentType);
     $this->assign('paymentAmt', abs($paymentAmt));
     $this->setPageTitle($this->_refund ? ts('Refund') : ts('Payment'));
 }
Пример #2
0
 /**
  * ParticipantDetails() method ( Checking the Participant Details )
  */
 public function testparticipantDetails()
 {
     $participantId = Participant::create($this->_contactId, $this->_eventId);
     $params = array('name' => 'Doe, John', 'title' => 'Test Event');
     $participantDetails = CRM_Event_BAO_Participant::participantDetails($participantId);
     $this->assertEquals(count($participantDetails), 3, 'Equating the array contains.');
     $this->assertEquals($participantDetails['name'], $params['name'], 'Checking Name of Participant.');
     $this->assertEquals($participantDetails['title'], $params['title'], 'Checking Event Title in which participant is enroled.');
     Participant::delete($participantId);
     Contact::delete($this->_contactId);
     Event::delete($this->_eventId);
 }
Пример #3
0
 /**
  * This function sets the default values for the form.
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     if (empty($this->_fields)) {
         return;
     }
     $defaults = array();
     foreach ($this->_participantIds as $participantId) {
         $details[$participantId] = array();
         $details[$participantId] = CRM_Event_BAO_Participant::participantDetails($participantId);
         CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $participantId, 'Event');
         //get the from status ids, CRM-4323
         if (array_key_exists('participant_status', $this->_fields)) {
             $this->_fromStatusIds[$participantId] = CRM_Utils_Array::value("field[{$participantId}][participant_status]", $defaults);
         }
         if (array_key_exists('participant_role', $this->_fields)) {
             if ($defaults["field[{$participantId}][participant_role]"]) {
                 $roles = $defaults["field[{$participantId}][participant_role]"];
                 foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $roles) as $k => $v) {
                     $defaults["field[{$participantId}][participant_role][{$v}]"] = 1;
                 }
                 unset($defaults["field[{$participantId}][participant_role]"]);
             }
         }
     }
     $this->assign('details', $details);
     return $defaults;
 }
Пример #4
0
 /**
  * Set variables up before form is built based on participant ID from URL
  *
  * @return void
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     $participant = $values = array();
     $this->_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
     $params = array('id' => $this->_participant_id);
     $this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
     $this->_part_values = $values[$this->_participant_id];
     $this->set('values', $this->_part_values);
     //fetch Event by event_id, verify that this event can still be xferred/cancelled
     $this->_event_id = $this->_part_values['event_id'];
     $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
     $this->_contact_id = $this->_part_values['participant_contact_id'];
     $this->assign('action', $this->_action);
     if ($this->_participant_id) {
         $this->assign('participantId', $this->_participant_id);
     }
     $event = array();
     $daoName = 'title';
     $this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
     $daoName = 'start_date';
     $this->_event_start_date = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
     list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contact_id);
     $this->_contact_name = $displayName;
     $this->_contact_email = $email;
     $details = array();
     $details = CRM_Event_BAO_Participant::participantDetails($this->_participant_id);
     $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
     $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participant_id, 'contribution_id', 'participant_id');
     $this->assign('contributionId', $contributionId);
     $query = "\n      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, cp.status_id\n      FROM civicrm_participant cp\n      LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id\n      LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}\n      WHERE cp.id = {$this->_participant_id}";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         $details['status'] = $dao->status;
         $details['role'] = $dao->role;
         $details['fee_level'] = $dao->fee_level;
         $details['fee_amount'] = $dao->fee_amount;
         $details['register_date'] = $dao->register_date;
     }
     //verify participant status is still Registered
     if ($details['status'] != "Registered") {
         $status = "You are no longer registered for " . $this->_event_title;
         CRM_Core_Session::setStatus($status, ts('Event status error.'), 'alert');
         CRM_Utils_System::redirect($url);
     }
     $query = "select start_date as start, selfcancelxfer_time as time from civicrm_event where id = " . $this->_event_id;
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         $time_limit = $dao->time;
         $start_date = $dao->start;
     }
     $start_time = new Datetime($start_date);
     $timenow = new Datetime();
     if (!empty($start_time) && $start_time < $timenow) {
         $status = ts("The event has been started, cannot transfer or cancel this event");
         $session->setStatus($status, ts('Oops.'), 'alert');
         CRM_Utils_System::redirect($url);
     }
     if (!empty($time_limit) && $time_limit > 0) {
         $interval = $timenow->diff($start_time);
         $days = $interval->format('%d');
         $hours = $interval->format('%h');
         if ($hours <= $time_limit && $days < 1) {
             $status = ts("Less than %1 hours to start time, cannot transfer or cancel this event", array(1 => $time_limit));
             $session->setStatus($status, ts('Oops.'), 'alert');
             CRM_Utils_System::redirect($url);
         }
     }
     $this->assign('details', $details);
     $this->selfsvcupdateUrl = CRM_Utils_System::url('civicrm/event/selfsvcupdate', "reset=1&id={$this->_participant_id}&id=0");
     $this->selfsvcupdateText = ts('Update');
     $this->selfsvcupdateButtonText = ts('Update');
     // Based on those ids retrieve event and verify it is eligible
     // for self update (event.start_date > today, event can be 'self_updated'
     // retrieve contact name and email, and let user verify his/her identity
 }
Пример #5
0
 /**
  * ParticipantDetails() method ( Checking the Participant Details )
  */
 public function testparticipantDetails()
 {
     $participant = $this->callAPISuccess('Participant', 'create', array('contact_id' => $this->_contactId, 'event_id' => $this->_eventId));
     $params = array('name' => 'Anderson, Anthony', 'title' => 'Annual CiviCRM meet');
     $participantDetails = CRM_Event_BAO_Participant::participantDetails($participant['id']);
     $this->assertEquals(count($participantDetails), 3, 'Equating the array contains.');
     $this->assertEquals($participantDetails['name'], $params['name'], 'Checking Name of Participant.');
     $this->assertEquals($participantDetails['title'], $params['title'], 'Checking Event Title in which participant is enroled.');
     $this->participantDelete($participant['id']);
     $this->contactDelete($this->_contactId);
     $this->eventDelete($this->_eventId);
 }
Пример #6
0
 /**
  * This function sets the default values for the form.
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     if (empty($this->_fields)) {
         return;
     }
     $defaults = array();
     foreach ($this->_participantIds as $participantId) {
         $details[$participantId] = array();
         require_once 'CRM/Event/BAO/Participant.php';
         $details[$participantId] = CRM_Event_BAO_Participant::participantDetails($participantId);
         CRM_Core_BAO_UFGroup::setProfileDefaults(null, $this->_fields, $defaults, false, $participantId, 'Event');
         //get the from status ids, CRM-4323
         if (array_key_exists('participant_status_id', $this->_fields)) {
             $this->_fromStatusIds[$participantId] = CRM_Utils_Array::value("field[{$participantId}][participant_status_id]", $defaults);
         }
     }
     $this->assign('details', $details);
     return $defaults;
 }
Пример #7
0
 /**
  * Get source values for transfer based on participant id in URL. Line items will
  * be transferred to this participant - at this point no transaction changes processed
  *
  * return @void
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     $this->_userContext = $session->readUserContext();
     $this->_from_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST');
     $this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST');
     $params = array('id' => $this->_from_participant_id);
     $participant = $values = array();
     $this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant);
     $this->_part_values = $values[$this->_from_participant_id];
     $this->set('values', $this->_part_values);
     $this->_event_id = $this->_part_values['event_id'];
     $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}");
     $this->_from_contact_id = $this->_part_values['participant_contact_id'];
     $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($this->_from_contact_id, $this->_userChecksum);
     if (!$validUser && !CRM_Core_Permission::check('edit all events')) {
         CRM_Core_Error::statusBounce(ts('You do not have sufficient permission to transfer/cancel this participant.'), $url);
     }
     $this->assign('action', $this->_action);
     if ($this->_from_participant_id) {
         $this->assign('participantId', $this->_from_participant_id);
     }
     $event = array();
     $daoName = 'title';
     $this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
     $daoName = 'start_date';
     $this->_event_start_date = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName);
     list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_from_contact_id);
     $this->_contact_name = $displayName;
     $this->_contact_email = $email;
     $details = array();
     $details = CRM_Event_BAO_Participant::participantDetails($this->_from_participant_id);
     $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name');
     $query = "\n      SELECT cpst.name as status, cov.name as role, cp.fee_level, cp.fee_amount, cp.register_date, civicrm_event.start_date\n      FROM civicrm_participant cp\n      LEFT JOIN civicrm_participant_status_type cpst ON cpst.id = cp.status_id\n      LEFT JOIN civicrm_option_value cov ON cov.value = cp.role_id and cov.option_group_id = {$optionGroupId}\n      LEFT JOIN civicrm_event ON civicrm_event.id = cp.event_id\n      WHERE cp.id = {$this->_from_participant_id}";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $details['status'] = $dao->status;
         $details['role'] = $dao->role;
         $details['fee_level'] = $dao->fee_level;
         $details['fee_amount'] = $dao->fee_amount;
         $details['register_date'] = $dao->register_date;
         $details['event_start_date'] = $dao->start_date;
     }
     $this->assign('details', $details);
     //This participant row will be cancelled.  Get line item(s) to cancel
     $this->selfsvctransferUrl = CRM_Utils_System::url('civicrm/event/selfsvcupdate', "reset=1&id={$this->_from_participant_id}&id=0");
     $this->selfsvctransferText = ts('Update');
     $this->selfsvctransferButtonText = ts('Update');
 }