_action = CRM_Utils_Request::retrieve('action', 'String',$this, FALSE, 'add'); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->assign('context', $this->_context); $this->assign('membershipMode', $this->_mode); $this->assign('contactID', $this->_contactID); if ($this->_mode) { $this->assignPaymentRelatedVariables(); } if ($this->_id) { $this->_memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'membership_type_id'); $this->_membershipIDs[] = $this->_id; } $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); } /** * Set default values for the form. MobileProvider that in edit/view mode * the default values are retrieved from the database * * @access public * * @return array defaults */ function setDefaultValues() { $defaults = array(); if (isset($this->_id)) { $params = array('id' => $this->_id); CRM_Member_BAO_Membership::retrieve($params, $defaults); } if (isset($defaults['minimum_fee'])) { $defaults['minimum_fee'] = CRM_Utils_Money::format($defaults['minimum_fee'], NULL, '%a'); } if (isset($defaults['status'])) { $this->assign('membershipStatus', $defaults['status']); } if ($this->_action & CRM_Core_Action::ADD) { $defaults['is_active'] = 1; } if (isset($defaults['member_of_contact_id']) && $defaults['member_of_contact_id'] ) { $defaults['member_org'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $defaults['member_of_contact_id'], 'display_name' ); } return $defaults; } /** * Build the form object * * @return void * @access public */ public function buildQuickForm() { if ($this->_mode) { $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE, array('onChange' => "buildAutoRenew( null, this.value );") ); CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, TRUE); } if ($this->_action & CRM_Core_Action::RENEW) { $this->addButtons(array( array( 'type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE ), array( 'type' => 'cancel', 'name' => ts('Cancel') ) ) ); } elseif ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array( array( 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE ), array( 'type' => 'cancel', 'name' => ts('Cancel') ) ) ); } else { $this->addButtons(array( array( 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE ), array( 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new' ), array( 'type' => 'cancel', 'name' => ts('Cancel') ) ) ); } } /** * Extract values from the contact create boxes on the form and assign appropriately to * * - $this->_contributorEmail, * - $this->_memberEmail & * - $this->_contributionName * - $this->_memberName * - $this->_contactID (effectively memberContactId but changing might have spin-off effects) * - $this->_contributorContactId - id of the contributor * - $this->_receiptContactId * * If the member & contributor are the same then the values will be the same. But if different people paid * then they weill differ * * @param $formValues array values from form. The important values we are looking for are * - contact_id * - soft_credit_contact_id */ function storeContactFields($formValues){ // in a 'standalone form' (contact id not in the url) the contact will be in the form values if (!empty($formValues['contact_id'])) { $this->_contactID = $formValues['contact_id']; } list($this->_memberDisplayName, $this->_memberEmail ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); //CRM-10375 Where the payer differs to the member the payer should get the email. // here we store details in order to do that if (!empty($formValues['soft_credit_contact_id'])) { $this->_receiptContactId = $this->_contributorContactID = $formValues['soft_credit_contact_id']; list( $this->_contributorDisplayName, $this->_contributorEmail ) = CRM_Contact_BAO_Contact_Location::getEmailDetails( $this->_contributorContactID ); } else { $this->_receiptContactId = $this->_contributorContactID = $this->_contactID; $this->_contributorDisplayName = $this->_memberDisplayName; $this->_contributorEmail = $this->_memberEmail; } } }