Exemplo n.º 1
0
 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action == CRM_Core_Action::DELETE) {
         $fieldValues = array('price_field_id' => $this->_fid);
         $wt = CRM_Utils_Weight::delWeight('CRM_Price_DAO_PriceFieldValue', $this->_oid, $fieldValues);
         $label = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, 'label', 'id');
         if (CRM_Price_BAO_PriceFieldValue::del($this->_oid)) {
             CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label)), ts('Record Deleted'), 'success');
         }
         return NULL;
     } else {
         $params = $ids = array();
         $params = $this->controller->exportValues('Option');
         $fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'label');
         $params['amount'] = CRM_Utils_Rule::cleanMoney(trim($params['amount']));
         $params['price_field_id'] = $this->_fid;
         $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
         $ids = array();
         if ($this->_oid) {
             $ids['id'] = $this->_oid;
         }
         $optionValue = CRM_Price_BAO_PriceFieldValue::create($params, $ids);
         CRM_Core_Session::setStatus(ts("The option '%1' has been saved.", array(1 => $params['label'])), ts('Value Saved'), 'success');
     }
 }