Exemplo n.º 1
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache();
     $params = $this->exportValues();
     // delete action
     // TODO::Make sure we cannot delete if the entity is linked to bookings
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Booking_BAO_AdhocChargesItem::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected additional charges item has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $params = $this->exportValues();
         if ($this->_id) {
             $params['id'] = $this->_id;
             if (!isset($params['is_active'])) {
                 $params['is_active'] = 0;
             }
         }
         $set = CRM_Booking_BAO_AdhocChargesItem::create($params);
         // udpate action
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Core_Session::setStatus(ts('The Record \'%1\' has been saved.', array(1 => $set->label)), ts('Saved'), 'success');
         } else {
             $url = CRM_Utils_System::url('civicrm/admin/adhoc_charges_item', 'reset=1&action=browse&sid=' . $set->id);
             CRM_Core_Session::setStatus(ts("Your additional charges item '%1' has been added.", array(1 => $set->label)), ts('Saved'), 'success');
             $session = CRM_Core_Session::singleton();
             $session->replaceUserContext($url);
         }
     }
 }