Exemple #1
0
 /**
  * Function to process the form
  *
  * @access public
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_HRAbsence_BAO_HRAbsenceType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected absence type has been deleted.'), 'Success', 'success');
     } else {
         $params = $ids = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         foreach (array('allow_debits', 'allow_credits', 'is_active') as $key => $index) {
             if (!array_key_exists($index, $params)) {
                 $params[$index] = 0;
             }
         }
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $params['id'] = $this->_id;
         }
         $absenceType = CRM_HRAbsence_BAO_HRAbsenceType::create($params);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Core_Session::setStatus(ts('The absence type \'%1\' has been updated.', array(1 => $absenceType->title)), 'Success', 'success');
         } else {
             CRM_Core_Session::setStatus(ts('The absence type \'%1\' has been added.', array(1 => $absenceType->title)), 'Success', 'success');
         }
         $url = CRM_Utils_System::url('civicrm/absence/type', 'reset=1&action=browse');
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
 }