<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig {
/**
- * max number of contacts we will display for membership-organisation
+ * Max number of contacts we will display for membership-organisation
*/
- CONST MAX_CONTACTS = 50;
+ const MAX_CONTACTS = 50;
- function preProcess() {
- $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0 );
+ public function preProcess() {
+ $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$this->_BAOName = 'CRM_Member_BAO_MembershipType';
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
$this->assign('action', $this->_action);
* Set default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
- * @access public
*
* @return void
*/
$periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
foreach ($periods as $per) {
if (isset($defaults[$per])) {
- $date = $defaults[$per];
+ $date = $defaults[$per];
$defaults[$per] = array();
if ($date > 31) {
- $date = ($date < 999) ? '0' . $date : $date;
+ $date = ($date < 999) ? '0' . $date : $date;
$defaults[$per]['M'] = substr($date, 0, 2);
$defaults[$per]['d'] = substr($date, 2, 3);
}
* Build the form object
*
* @return void
- * @access public
*/
public function buildQuickForm() {
parent::buildQuickForm();
);
//Auto-renew Option
- $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
- $isAuthorize = FALSE;
- $options = array();
+ $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
+ $isAuthorize = FALSE;
+ $options = array();
if (is_array($paymentProcessor) && !empty($paymentProcessor)) {
$isAuthorize = TRUE;
- $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
+ $options = CRM_Core_SelectValues::memberAutoRenew();
}
$this->addRadio('auto_renew', ts('Auto-renew Option'), $options);
CRM_Core_SelectValues::date(NULL, 'd'), FALSE
);
- $this->add('select', 'financial_type_id', ts( 'Financial Type' ),
+ $this->add('select', 'financial_type_id', ts('Financial Type'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE, array('class' => 'crm-select2')
);
$this->assign('membershipRecordsExists', $membershipRecords);
$this->add('text', 'max_related', ts('Max related'),
- CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'max_related')
+ CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'max_related')
);
$this->addFormRule(array('CRM_Member_Form_MembershipType', 'formRule'));
}
/**
- * validation
+ * Validation
*
- * @param array $params (ref.) an assoc array of name/value pairs
+ * @param array $params
+ * (ref.) an assoc array of name/value pairs.
*
- * @return mixed true or array of errors
- * @access public
- * @static
+ * @return bool|array
+ * mixed true or array of errors
*/
- static function formRule($params) {
+ public static function formRule($params) {
$errors = array();
if (!$params['name']) {
$errors['name'] = ts('Please enter a membership type name.');
}
- if (($params['minimum_fee'] > 0 ) && !$params['financial_type_id'] ) {
+ if (($params['minimum_fee'] > 0) && !$params['financial_type_id']) {
$errors['financial_type_id'] = ts('Please enter the financial Type.');
}
}
if (in_array(CRM_Utils_Array::value('auto_renew', $params), array(
- 1, 2))) {
+ 1,
+ 2
+ ))) {
if (($params['duration_interval'] > 1 && $params['duration_unit'] == 'year') ||
($params['duration_interval'] > 12 && $params['duration_unit'] == 'month')
) {
/**
* Process the form submission
*
- * @access public
*
* @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
- try{
- CRM_Member_BAO_MembershipType::del($this->_id);
+ try {
+ CRM_Member_BAO_MembershipType::del($this->_id);
}
- catch(CRM_Core_Exception $e) {
+ catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce($e->getMessage(), NULL, ts('Membership Type Not Deleted'));
}
CRM_Core_Session::setStatus(ts('Selected membership type has been deleted.'), ts('Record Deleted'), 'success');
'fixed_period_start_day',
'fixed_period_rollover_day',
'month_fixed_period_rollover_day',
- 'max_related'
+ 'max_related',
);
$params = $ids = array();
$periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
foreach ($periods as $per) {
if (!empty($params[$per]['M']) && !empty($params[$per]['d'])) {
- $mon = $params[$per]['M'];
- $dat = $params[$per]['d'];
- $mon = ($mon < 10) ? '0' . $mon : $mon;
- $dat = ($dat < 10) ? '0' . $dat : $dat;
+ $mon = $params[$per]['M'];
+ $dat = $params[$per]['d'];
+ $mon = ($mon < 10) ? '0' . $mon : $mon;
+ $dat = ($dat < 10) ? '0' . $dat : $dat;
$params[$per] = $mon . $dat;
}
- else if($per == 'fixed_period_rollover_day' && !empty($params['month_fixed_period_rollover_day'])){
+ elseif ($per == 'fixed_period_rollover_day' && !empty($params['month_fixed_period_rollover_day'])) {
$params['fixed_period_rollover_day'] = $params['month_fixed_period_rollover_day']['d'];
unset($params['month_fixed_period_rollover_day']);
}
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
CRM_Core_Session::setStatus(ts('The membership type \'%1\' has been saved.',
- array(1 => $membershipType->name)
- ), ts('Saved'), 'success');
+ array(1 => $membershipType->name)
+ ), ts('Saved'), 'success');
$session = CRM_Core_Session::singleton();
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(
}
/**
- * @param $previousID
- * @param $priceSetId
- * @param $membershipTypeId
+ * @param int $previousID
+ * @param int $priceSetId
+ * @param int $membershipTypeId
* @param $optionsIds
*/
public static function checkPreviousPriceField($previousID, $priceSetId, $membershipTypeId, &$optionsIds) {
}
}
}
-