* Build the form object.
*/
public function buildQuickForm() {
+
if ($this->_mode) {
$this->add('select', 'payment_processor_id',
ts('Payment Processor'),
);
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE);
}
+ // Build the form for auto renew. This is displayed when in credit card mode or update mode.
+ // The reason for showing it in update mode is not that clear.
+ $autoRenew = array();
+ $recurProcessor = array();
+ if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) {
+ if (!empty($recurProcessor)) {
+ $autoRenew = array();
+ if (!empty($membershipType)) {
+ $sql = '
+SELECT id,
+ auto_renew,
+ duration_unit,
+ duration_interval
+ FROM civicrm_membership_type
+WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
+ $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql);
+ while ($recurMembershipTypes->fetch()) {
+ $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew;
+ foreach (array(
+ 'id',
+ 'auto_renew',
+ 'duration_unit',
+ 'duration_interval',
+ ) as $fld) {
+ $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->$fld;
+ }
+ }
+ }
+
+ if ($this->_mode) {
+ if (!empty($this->_recurPaymentProcessors)) {
+ $this->assign('allowAutoRenew', TRUE);
+ }
+ }
+
+ $this->assign('autoRenew', json_encode($autoRenew));
+ $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'),
+ NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );")
+ );
+ if ($this->_action & CRM_Core_Action::UPDATE) {
+ $autoRenewElement->freeze();
+ }
+ }
+
+ }
+ $this->assign('recurProcessor', json_encode($recurProcessor));
+
+ if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) {
+ $this->addElement('checkbox',
+ 'auto_renew',
+ ts('Membership renewed automatically'),
+ NULL,
+ array('onclick' => "buildReceiptANDNotice( );")
+ );
+
+ $this->assignPaymentRelatedVariables();
+ }
+ $this->assign('autoRenewOptions', json_encode($autoRenew));
+
if ($this->_action & CRM_Core_Action::RENEW) {
$this->addButtons(array(
array(
protected $_receiptContactId = NULL;
/**
- * Keep a class variable for ALL membeshipID's so
+ * Keep a class variable for ALL membership IDs so
* postProcess hook function can do something with it
*
* @var array
protected $_membershipIDs = array();
/**
- * An array to hold a list of datefields on the form
+ * An array to hold a list of date fields on the form
* so that they can be converted to ISO in a consistent manner
*
* @var array
$memTypeJs = array('onChange' => "CRM.buildCustomData( 'Membership', this.value );");
- //build the form for auto renew.
- $autoRenew = array();
- if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) {
- $this->addElement('checkbox',
- 'auto_renew',
- ts('Membership renewed automatically'),
- NULL,
- array('onclick' => "buildReceiptANDNotice( );")
- );
-
- $this->assignPaymentRelatedVariables();
-
- if ($this->_mode) {
- if (!empty($this->_recurPaymentProcessors)) {
- if (!empty($membershipType)) {
- $sql = '
-SELECT id,
- auto_renew,
- duration_unit,
- duration_interval
- FROM civicrm_membership_type
-WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
- $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql);
- while ($recurMembershipTypes->fetch()) {
- $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew;
- foreach (array(
- 'id',
- 'auto_renew',
- 'duration_unit',
- 'duration_interval',
- ) as $fld) {
- $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->$fld;
- }
- }
- }
- $memTypeJs = array(
- 'onChange' =>
- "CRM.buildCustomData( 'Membership', this.value ); buildAutoRenew(this.value, null );",
- );
- $this->assign('allowAutoRenew', TRUE);
- }
- }
- }
-
- $this->assign('autoRenewOptions', json_encode($autoRenew));
-
// for max_related: a little JS to show/hide & set default value
$memTypeJs['onChange'] = "buildMaxRelated(this.value,true); " . $memTypeJs['onChange'];
$this->add('text', 'max_related', ts('Max related'),
$lineItems = CRM_Price_BAO_LineItem::getLineItems($params['contribution_id'], 'contribution', NULL, TRUE, TRUE);
$itemId = key($lineItems);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
- $fieldType = NULL;
- if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
- $fieldType = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'html_type');
- }
+
$lineItems[$itemId]['unit_price'] = $params['total_amount'];
$lineItems[$itemId]['line_total'] = $params['total_amount'];
$lineItems[$itemId]['id'] = $itemId;
}
$js = array('onChange' => "setPaymentBlock( ); CRM.buildCustomData( 'Membership', this.value );");
-
- //build the form for auto renew.
- $recurProcessor = array();
- if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) {
- //get the valid recurring processors.
- $test = strtolower($this->_mode) == 'test' ? TRUE : FALSE;
- $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, $test, 'is_recur = 1');
- $recurProcessor = array_intersect_key($this->_processors, $recurring);
- if (!empty($recurProcessor)) {
- $autoRenew = array();
- if (!empty($membershipType)) {
- $sql = '
-SELECT id,
- auto_renew,
- duration_unit,
- duration_interval
- FROM civicrm_membership_type
-WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )';
- $recurMembershipTypes = CRM_Core_DAO::executeQuery($sql);
- while ($recurMembershipTypes->fetch()) {
- $autoRenew[$recurMembershipTypes->id] = $recurMembershipTypes->auto_renew;
- foreach (array(
- 'id',
- 'auto_renew',
- 'duration_unit',
- 'duration_interval',
- ) as $fld) {
- $this->_recurMembershipTypes[$recurMembershipTypes->id][$fld] = $recurMembershipTypes->$fld;
- }
- }
- }
- $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData( 'Membership', this.value );");
- $this->assign('autoRenew', json_encode($autoRenew));
- }
- $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'),
- NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );")
- );
- if ($this->_action & CRM_Core_Action::UPDATE) {
- $autoRenewElement->freeze();
- }
- }
- $this->assign('recurProcessor', json_encode($recurProcessor));
-
$sel = &$this->addElement('hierselect',
'membership_type_id',
ts('Renewal Membership Organization and Type'), $js