<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
$priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1);
foreach ($options as $k => $v) {
$newMembershipType[$v['membership_type_id']] = 1;
- if ( !empty($defaults['auto_renew']) ) {
+ if (!empty($defaults['auto_renew'])) {
$defaults["auto_renew_".$v['membership_type_id']] = $defaults['auto_renew'][$v['membership_type_id']];
}
}
}
}
- $membership = $membershipDefault = array();
+ $membership = $membershipDefault = $params = array();
foreach ($membershipTypes as $k => $v) {
$membership[] = $this->createElement('advcheckbox', $k, NULL, $v);
$membershipDefault[] = $this->createElement('radio', NULL, NULL, NULL, $k);
+ $membershipRequired[$k] = NULL;
if ($isRecur) {
$autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
+ $membershipRequired[$k] = $autoRenew;
$autoRenewOptions = array();
if ($autoRenew) {
$autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required'));
$this->addElement('select', "auto_renew_$k", ts('Auto-renew'), $autoRenewOptions);
+ //CRM-15573
+ if($autoRenew == 2) {
+ $this->freeze("auto_renew_$k");
+ $params['id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipBlock', $this->_id , 'id', 'entity_id');
+ }
$this->_renewOption[$k] = $autoRenew;
}
}
}
+ //CRM-15573
+ if (!empty($params['id'])) {
+ $params['membership_types'] = serialize($membershipRequired);
+ CRM_Member_BAO_MembershipBlock::create($params);
+ }
$this->add('hidden', "mem_price_field_id", '', array('id' => "mem_price_field_id"));
$this->assign('is_recur', $isRecur);
if (isset($this->_renewOption)) {
$this->assign('auto_renew', $this->_renewOption);
}
$this->addGroup($membership, 'membership_type', ts('Membership Types'));
- $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'))->setAttribute('unselectable', TRUE);
+ $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'))->setAttribute('allowClear', TRUE);
$this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id);
}
*
* @param array $params (ref.) an assoc array of name/value pairs
*
+ * @param $files
+ * @param null $contributionPageId
+ *
* @return mixed true or array of errors
* @access public
* @static