/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { CRM_CiviDiscount_BAO_Item::del($this->_id); CRM_Core_Session::setStatus(ts('Selected Discount has been deleted.'), ts('Deleted'), 'success'); return; } if ($this->_action & CRM_Core_Action::COPY) { $params = $this->exportValues(); $newCode = CRM_CiviDiscount_Utils::randomString('abcdefghjklmnpqrstwxyz23456789', 8); CRM_CiviDiscount_BAO_Item::copy($this->_cloneID, $params, $newCode); CRM_Core_Session::setStatus(ts('Selected Discount has been duplicated.'), ts('Copied'), 'success'); return; } $params = $this->exportValues(); $params['count_max'] = (int) $params['count_max']; if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } $params['multi_valued'] = $this->_multiValued; if (isset($params['events']) && in_array(0, $params['events']) && count($params['events']) > 1) { CRM_Core_Session::setStatus(ts('You selected `any event` and specific events, specific events have been unset')); $params['events'] = array(0); } if (!empty($params['autodiscount_membership_type_id']) && count($params['autodiscount_membership_status_id']) == 0) { $params['autodiscount_membership_status_id'] = array(''); } $params['filters'] = $this->getFiltersFromParams($params); $params['autodiscount'] = $this->getAutoDiscountFromParams($params); if (!empty($params['advanced_autodiscount_filter_entity'])) { $this->addAdvancedFilterToAutodiscount($params, $params['advanced_autodiscount_filter_entity'], CRM_Utils_Array::value('advanced_autodiscount_filter_string', $params)); } $item = CRM_CiviDiscount_BAO_Item::add($params); CRM_Core_Session::setStatus(ts('The discount \'%1\' has been saved.', array(1 => $item->description ? $item->description : $item->code)), ts('Saved'), 'success'); }